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.webauthn;
018
019import org.jspecify.annotations.NonNull;
020
021import javax.annotation.concurrent.Immutable;
022
023/** App-authorized account fence transition that stops future passkey acceptance.
024 * @since 1.0.0 */
025@Immutable
026public abstract sealed class WebAuthnAccountDisableResult permits
027        WebAuthnAccountDisableResult.Disabled,
028        WebAuthnAccountDisableResult.Unavailable, WebAuthnAccountDisableResult.Indeterminate, WebAuthnAccountDisableResult.ReconciliationRequired {
029    private static final @NonNull Disabled DISABLED = new Disabled();
030    private static final @NonNull Unavailable UNAVAILABLE = new Unavailable();
031    private static final @NonNull Indeterminate INDETERMINATE = new Indeterminate();
032    private static final @NonNull ReconciliationRequired RECONCILIATION_REQUIRED = new ReconciliationRequired();
033    WebAuthnAccountDisableResult() { }
034    static @NonNull WebAuthnAccountDisableResult disabled() { return DISABLED; }
035    static @NonNull WebAuthnAccountDisableResult unavailable() { return UNAVAILABLE; }
036    static @NonNull WebAuthnAccountDisableResult indeterminate() { return INDETERMINATE; }
037    static @NonNull WebAuthnAccountDisableResult reconciliationRequired() { return RECONCILIATION_REQUIRED; }
038    /** Redacts account identity.
039     * @return fixed description
040     * @since 1.0.0 */
041    @Override public final @NonNull String toString() { return "WebAuthnAccountDisableResult{<redacted>}"; }
042    /** The fence is confirmed permanently disabled for this namespace/RP/account handle.
043     * New enrollment and account-pinned reauthentication reject; authentication and registration
044     * completions enforce the disabled fence. Reopening traffic admission does not enable it.
045     * @since 1.0.0 */
046    @Immutable public static final class Disabled extends WebAuthnAccountDisableResult {
047        private Disabled() { }
048    }
049    /** Storage, recovery admission or a concurrent change prevented a confirmed result.
050     * @since 1.0.0 */
051    @Immutable public static final class Unavailable extends WebAuthnAccountDisableResult {
052        private Unavailable() { }
053    }
054    /** A write may have occurred; reconcile its actual effect through authorized fresh operations
055     * before resuming dependent application actions. This result does not authorize automatic
056     * retry, account reenabling, or deletion of the permanent fence.
057     * @since 1.0.0 */
058    @Immutable public static final class Indeterminate extends WebAuthnAccountDisableResult {
059        private Indeterminate() { }
060    }
061    /** The requested transition committed, but normal output could not be admitted.
062     * The disable effect remains committed and terminal. Reconcile through an authorized fresh
063     * operation before resuming dependent actions; reopening traffic admission does not undo it.
064     * @since 1.0.0 */
065    @Immutable public static final class ReconciliationRequired extends WebAuthnAccountDisableResult {
066        private ReconciliationRequired() { }
067    }
068
069}