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 */
016
017package com.revetsec.oidc;
018
019import org.jspecify.annotations.NonNull;
020import javax.annotation.concurrent.Immutable;
021import static java.util.Objects.requireNonNull;
022
023/**
024 * Structure-only restoration of a logout credential from trusted or typed sealed storage. A parsed hint creates
025 * no authenticated identity. Invalid stored forms release no credential or value-dependent details.
026 * Future releases may add variants; consuming switches should include a rejecting default branch.
027 * @author <a href="https://www.revetkn.com">Mark Allen</a>
028 * @since 1.0.0
029 */
030@Immutable
031public abstract sealed class OidcLogoutHintParseResult permits OidcLogoutHintParseResult.Parsed, OidcLogoutHintParseResult.Rejected {
032        private OidcLogoutHintParseResult() { }
033        static @NonNull OidcLogoutHintParseResult fromHint(@NonNull OidcLogoutHint hint) { return new Parsed(requireNonNull(hint)); }
034        static @NonNull OidcLogoutHintParseResult fromRejection() { return new Rejected(); }
035        /** Redacts the credential.
036         * @return redacted description
037         * @since 1.0.0
038         */
039        @Override public final @NonNull String toString() { return "OidcLogoutHintParseResult{credential=<redacted>}"; }
040        /**
041         * A structurally consistent hint, not an authentication proof.
042         * @author <a href="https://www.revetkn.com">Mark Allen</a>
043         * @since 1.0.0
044         */
045        @Immutable
046        public static final class Parsed extends OidcLogoutHintParseResult {
047                private final @NonNull OidcLogoutHint hint;
048                private Parsed(@NonNull OidcLogoutHint hint) { this.hint = hint; }
049                /** Returns the restored credential for explicit logout preparation.
050                 * @return hint, not authenticated identity
051                 * @since 1.0.0
052                 */
053                public @NonNull OidcLogoutHint getHint() { return this.hint; }
054        }
055        /**
056         * A stored form could not be opened or structurally restored. No credential is released.
057         * @author <a href="https://www.revetkn.com">Mark Allen</a>
058         * @since 1.0.0
059         */
060        @Immutable
061        public static final class Rejected extends OidcLogoutHintParseResult { private Rejected() { } }
062}