001/*
002 * Copyright 2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package com.revetsec.saml;
017
018import org.jspecify.annotations.NonNull;
019import javax.annotation.concurrent.Immutable;
020
021/**
022 * Result of a signed, pending-bound IdP LogoutResponse. Success means the IdP reported success;
023 * it does not claim that application sessions were terminated. Partial propagation is a
024 * {@link StatusReceived#PARTIAL_LOGOUT} outcome, never complete success.
025 *
026 * @since 1.0.0
027 */
028@Immutable
029public sealed interface SamlLogoutResult permits SamlLogoutResult.Succeeded,
030        SamlLogoutResult.StatusReceived, SamlLogoutResult.Rejected,
031        SamlLogoutResult.Unavailable, SamlLogoutResult.Indeterminate {
032    /**
033     * The IdP returned a verified flat Success status, with no subordinate code.
034     *
035     * @since 1.0.0
036     */
037    @Immutable
038    enum Succeeded implements SamlLogoutResult {
039        /** Verified IdP completion. */ INSTANCE
040    }
041    /**
042     * The IdP returned a verified failure or incomplete logout status. Consumers should
043     * treat any unknown value as lacking complete success.
044     *
045     * @since 1.0.0
046     */
047    @Immutable
048    enum StatusReceived implements SamlLogoutResult {
049        /** The provider did not report successful completion at the top level. */ NON_SUCCESS,
050        /**
051         * The provider reported Success with second-level PartialLogout: its own logout
052         * completed, but not all other participants confirmed logout. This is the provider's
053         * authenticated report, not proof that application sessions were terminated.
054         */
055        PARTIAL_LOGOUT
056    }
057    /**
058     * The response was invalid, expired, unbound or replayed.
059     *
060     * @since 1.0.0
061     */
062    @Immutable
063    enum Rejected implements SamlLogoutResult {
064        /** No provider outcome was established. */ INSTANCE
065    }
066    /**
067     * A required local capability or replay store was unavailable.
068     *
069     * @since 1.0.0
070     */
071    @Immutable
072    enum Unavailable implements SamlLogoutResult {
073        /** No provider outcome was established. */ INSTANCE
074    }
075    /**
076     * A pending or replay consume may have occurred. This also covers failure after a
077     * pending store has confirmed removal, including expiry or replay-admission failure.
078     *
079     * @since 1.0.0
080     */
081    @Immutable
082    enum Indeterminate implements SamlLogoutResult {
083        /** Reconciliation is required. */ INSTANCE
084    }
085}