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 credential removal; the app supplies session, CSRF and policy checks. 024 * @since 1.0.0 */ 025@Immutable 026public abstract sealed class WebAuthnCredentialRemovalResult permits 027 WebAuthnCredentialRemovalResult.Removed, WebAuthnCredentialRemovalResult.Absent, 028 WebAuthnCredentialRemovalResult.Unavailable, WebAuthnCredentialRemovalResult.Indeterminate, WebAuthnCredentialRemovalResult.ReconciliationRequired { 029 private static final @NonNull Removed REMOVED = new Removed(); 030 private static final @NonNull Absent ABSENT = new Absent(); 031 private static final @NonNull Unavailable UNAVAILABLE = new Unavailable(); 032 private static final @NonNull Indeterminate INDETERMINATE = new Indeterminate(); 033 private static final @NonNull ReconciliationRequired RECONCILIATION_REQUIRED = new ReconciliationRequired(); 034 WebAuthnCredentialRemovalResult() { } 035 static @NonNull WebAuthnCredentialRemovalResult removed() { return REMOVED; } 036 static @NonNull WebAuthnCredentialRemovalResult absent() { return ABSENT; } 037 static @NonNull WebAuthnCredentialRemovalResult unavailable() { return UNAVAILABLE; } 038 static @NonNull WebAuthnCredentialRemovalResult indeterminate() { return INDETERMINATE; } 039 static @NonNull WebAuthnCredentialRemovalResult reconciliationRequired() { return RECONCILIATION_REQUIRED; } 040 /** Redacts account and credential identifiers. 041 * @return fixed description 042 * @since 1.0.0 */ 043 @Override public final @NonNull String toString() { return "WebAuthnCredentialRemovalResult{<redacted>}"; } 044 /** The credential was atomically revoked and removed from the active index. 045 * @since 1.0.0 */ 046 @Immutable public static final class Removed extends WebAuthnCredentialRemovalResult { 047 private Removed() { } 048 } 049 /** No active credential with this ID belongs to the approved account. 050 * @since 1.0.0 */ 051 @Immutable public static final class Absent extends WebAuthnCredentialRemovalResult { 052 private Absent() { } 053 } 054 /** Storage, recovery admission or a concurrent change prevented a confirmed result. 055 * @since 1.0.0 */ 056 @Immutable public static final class Unavailable extends WebAuthnCredentialRemovalResult { 057 private Unavailable() { } 058 } 059 /** A write may have occurred; reconcile authoritative state before another action. 060 * @since 1.0.0 */ 061 @Immutable public static final class Indeterminate extends WebAuthnCredentialRemovalResult { 062 private Indeterminate() { } 063 } 064 /** The requested transition committed, but normal output could not be admitted. 065 * Reconcile through an authorized fresh operation before deciding what to do next. 066 * @since 1.0.0 */ 067 @Immutable public static final class ReconciliationRequired extends WebAuthnCredentialRemovalResult { 068 private ReconciliationRequired() { } 069 } 070 071}