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;
018
019import org.jspecify.annotations.NonNull;
020import javax.annotation.concurrent.Immutable;
021
022/** Fixed, value-free codes for a builder's configuration shape. A diagnostic does not establish
023 * runtime readiness, provider health, storage durability or deployment trust.
024 * @since 1.0.0
025 */
026@Immutable
027public enum ConfigurationDiagnostic {
028    /** TOTP credential namespace is absent. */ TOTP_CREDENTIAL_NAMESPACE_REQUIRED("credentialNamespace", "com.revetsec.totp.TotpAuthenticator.Builder#credentialNamespace"),
029    /** TOTP recovery epoch is absent. */ TOTP_RECOVERY_EPOCH_REQUIRED("recoveryEpoch", "com.revetsec.totp.TotpAuthenticator.Builder#recoveryEpoch"),
030    /** TOTP authoritative store is absent. */ TOTP_STORE_REQUIRED("store", "com.revetsec.totp.TotpAuthenticator.Builder#store"),
031    /** TOTP state sealer is absent. */ TOTP_STATE_SEALER_REQUIRED("stateSealer", "com.revetsec.totp.TotpAuthenticator.Builder#stateSealer"),
032    /** TOTP recovery gate is absent. */ TOTP_RECOVERY_GATE_REQUIRED("recoveryGate", "com.revetsec.totp.TotpAuthenticator.Builder#recoveryGate"),
033    /** WebAuthn relying-party name is absent. */ WEBAUTHN_RELYING_PARTY_NAME_REQUIRED("relyingPartyName", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#relyingPartyName"),
034    /** WebAuthn credential namespace is absent. */ WEBAUTHN_CREDENTIAL_NAMESPACE_REQUIRED("credentialNamespace", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#credentialNamespace"),
035    /** WebAuthn allowed origins are absent. */ WEBAUTHN_ALLOWED_ORIGINS_REQUIRED("allowedOrigins", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#allowedOrigins"),
036    /** WebAuthn authoritative store is absent. */ WEBAUTHN_STORE_REQUIRED("store", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#store"),
037    /** WebAuthn state sealer is absent. */ WEBAUTHN_STATE_SEALER_REQUIRED("stateSealer", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#stateSealer"),
038    /** WebAuthn recovery gate is absent. */ WEBAUTHN_RECOVERY_GATE_REQUIRED("recoveryGate", "com.revetsec.webauthn.WebAuthnRelyingParty.Builder#recoveryGate"),
039
040    /** Authorization endpoint required. */ OAUTH_AUTHORIZATION_ENDPOINT_REQUIRED("authorizationEndpoint", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#authorizationEndpoint"),
041    /** Token endpoint required. */ OAUTH_TOKEN_ENDPOINT_REQUIRED("tokenEndpoint", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#tokenEndpoint"),
042    /** Jwks endpoint required. */ OAUTH_JWKS_ENDPOINT_REQUIRED("jwksEndpoint", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#jwksEndpoint"),
043    /** Client repository required. */ OAUTH_CLIENT_REPOSITORY_REQUIRED("clientRepository", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#clientRepository"),
044    /** Store required. */ OAUTH_STORE_REQUIRED("store", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#store"),
045    /** Signing keys required. */ OAUTH_SIGNING_KEYS_REQUIRED("signingKeys", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#signingKeys"),
046    /** State sealer required. */ OAUTH_STATE_SEALER_REQUIRED("stateSealer", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#stateSealer"),
047    /** Grant policy required. */ OAUTH_GRANT_POLICY_REQUIRED("grantPolicy", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#grantPolicy"),
048    /** Resources required. */ OAUTH_RESOURCES_REQUIRED("resources", "REQUIRED", "Required configuration is missing.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#resources"),
049    /** Authorization endpoint invalid. */ OAUTH_AUTHORIZATION_ENDPOINT_INVALID("authorizationEndpoint", "INVALID", "Configured route is invalid or conflicts with another route.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#authorizationEndpoint"),
050    /** Token endpoint invalid. */ OAUTH_TOKEN_ENDPOINT_INVALID("tokenEndpoint", "INVALID", "Configured route is invalid or conflicts with another route.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#tokenEndpoint"),
051    /** Jwks endpoint invalid. */ OAUTH_JWKS_ENDPOINT_INVALID("jwksEndpoint", "INVALID", "Configured route is invalid or conflicts with another route.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#jwksEndpoint"),
052    /** Revocation endpoint invalid. */ OAUTH_REVOCATION_ENDPOINT_INVALID("revocationEndpoint", "INVALID", "Configured route is invalid or conflicts with another route.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#revocationEndpoint"),
053    /** Introspection endpoint invalid. */ OAUTH_INTROSPECTION_ENDPOINT_INVALID("introspectionEndpoint", "INVALID", "Configured route is invalid or conflicts with another route.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#introspectionEndpoint"),
054    /** Authorization interaction lifetime invalid. */ OAUTH_AUTHORIZATION_INTERACTION_LIFETIME_INVALID("authorizationInteractionLifetime", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#authorizationInteractionLifetime"),
055    /** Authorization code lifetime invalid. */ OAUTH_AUTHORIZATION_CODE_LIFETIME_INVALID("authorizationCodeLifetime", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#authorizationCodeLifetime"),
056    /** Access token lifetime invalid. */ OAUTH_ACCESS_TOKEN_LIFETIME_INVALID("accessTokenLifetime", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#accessTokenLifetime"),
057    /** Refresh token idle lifetime invalid. */ OAUTH_REFRESH_TOKEN_IDLE_LIFETIME_INVALID("refreshTokenIdleLifetime", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#refreshTokenIdleLifetime"),
058    /** Refresh token absolute lifetime invalid. */ OAUTH_REFRESH_TOKEN_ABSOLUTE_LIFETIME_INVALID("refreshTokenAbsoluteLifetime", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#refreshTokenAbsoluteLifetime"),
059    /** Clock skew invalid. */ OAUTH_CLOCK_SKEW_INVALID("clockSkew", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#clockSkew"),
060    /** Total deadline invalid. */ OAUTH_TOTAL_DEADLINE_INVALID("totalDeadline", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#totalDeadline"),
061    /** Request timeout invalid. */ OAUTH_REQUEST_TIMEOUT_INVALID("requestTimeout", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#requestTimeout"),
062    /** Public metadata http cache max age invalid. */ OAUTH_PUBLIC_METADATA_HTTP_CACHE_MAX_AGE_INVALID("publicMetadataHttpCacheMaxAge", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#publicMetadataHttpCacheMaxAge"),
063    /** Maximum request body bytes invalid. */ OAUTH_MAXIMUM_REQUEST_BODY_BYTES_INVALID("maximumRequestBodyBytes", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumRequestBodyBytes"),
064    /** Maximum raw query length invalid. */ OAUTH_MAXIMUM_RAW_QUERY_LENGTH_INVALID("maximumRawQueryLength", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumRawQueryLength"),
065    /** Maximum header bytes invalid. */ OAUTH_MAXIMUM_HEADER_BYTES_INVALID("maximumHeaderBytes", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumHeaderBytes"),
066    /** Maximum response body bytes invalid. */ OAUTH_MAXIMUM_RESPONSE_BODY_BYTES_INVALID("maximumResponseBodyBytes", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumResponseBodyBytes"),
067    /** Maximum store record bytes invalid. */ OAUTH_MAXIMUM_STORE_RECORD_BYTES_INVALID("maximumStoreRecordBytes", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumStoreRecordBytes"),
068    /** Maximum store commit attempts invalid. */ OAUTH_MAXIMUM_STORE_COMMIT_ATTEMPTS_INVALID("maximumStoreCommitAttempts", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumStoreCommitAttempts"),
069    /** Maximum resources invalid. */ OAUTH_MAXIMUM_RESOURCES_INVALID("maximumResources", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumResources"),
070    /** Maximum redirect uris invalid. */ OAUTH_MAXIMUM_REDIRECT_URIS_INVALID("maximumRedirectUris", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumRedirectUris"),
071    /** Maximum scopes per resource invalid. */ OAUTH_MAXIMUM_SCOPES_PER_RESOURCE_INVALID("maximumScopesPerResource", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumScopesPerResource"),
072    /** Maximum scope length invalid. */ OAUTH_MAXIMUM_SCOPE_LENGTH_INVALID("maximumScopeLength", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumScopeLength"),
073    /** Maximum state length invalid. */ OAUTH_MAXIMUM_STATE_LENGTH_INVALID("maximumStateLength", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumStateLength"),
074    /** Maximum client id length invalid. */ OAUTH_MAXIMUM_CLIENT_ID_LENGTH_INVALID("maximumClientIdLength", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumClientIdLength"),
075    /** Maximum subject length invalid. */ OAUTH_MAXIMUM_SUBJECT_LENGTH_INVALID("maximumSubjectLength", "INVALID", "Configuration value is outside its supported range.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumSubjectLength"),
076    /** Resources invalid. */ OAUTH_RESOURCES_INVALID("resources", "INVALID", "Configured resources are invalid.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#resources"),
077    /** Refresh requires revocation endpoint. */ OAUTH_REFRESH_REQUIRES_REVOCATION_ENDPOINT("revocationEndpoint", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#revocationEndpoint"),
078    /** Issuer scheme incompatible. */ OAUTH_ISSUER_SCHEME_INCOMPATIBLE("issuer", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#allowInsecureLoopback"),
079    /** Request timeout exceeds deadline. */ OAUTH_REQUEST_TIMEOUT_EXCEEDS_DEADLINE("requestTimeout", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#requestTimeout"),
080    /** Code lifetime exceeds interaction. */ OAUTH_CODE_LIFETIME_EXCEEDS_INTERACTION("authorizationCodeLifetime", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#authorizationCodeLifetime"),
081    /** Access lifetime exceeds idle. */ OAUTH_ACCESS_LIFETIME_EXCEEDS_IDLE("accessTokenLifetime", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#accessTokenLifetime"),
082    /** Idle lifetime exceeds absolute. */ OAUTH_IDLE_LIFETIME_EXCEEDS_ABSOLUTE("refreshTokenIdleLifetime", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#refreshTokenIdleLifetime"),
083    /** Clock skew exceeds half access. */ OAUTH_CLOCK_SKEW_EXCEEDS_HALF_ACCESS("clockSkew", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#clockSkew"),
084    /** Store record exceeds sealer. */ OAUTH_STORE_RECORD_EXCEEDS_SEALER("maximumStoreRecordBytes", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#maximumStoreRecordBytes"),
085    /** Client metadata runtime incompatible. */ OAUTH_CLIENT_METADATA_RUNTIME_INCOMPATIBLE("clientMetadataPolicy", "INCOMPATIBLE", "Configuration settings are incompatible.", "com.revetsec.oauth.server.OAuthAuthorizationServer.Builder#clientMetadataPolicy");
086
087    private final @NonNull String fieldCode;
088    private final @NonNull String reasonCode;
089    private final @NonNull String message;
090    private final @NonNull String documentationReference;
091
092    ConfigurationDiagnostic(@NonNull String fieldCode, @NonNull String documentationReference) {
093        this(fieldCode, "REQUIRED", "Required configuration is missing.", documentationReference);
094    }
095
096    ConfigurationDiagnostic(@NonNull String fieldCode, @NonNull String reasonCode,
097            @NonNull String message, @NonNull String documentationReference) {
098        this.fieldCode = fieldCode;
099        this.reasonCode = reasonCode;
100        this.message = message;
101        this.documentationReference = documentationReference;
102    }
103
104    /** Returns a fixed field identifier, never a supplied value.
105     * @return field identifier
106     * @since 1.0.0 */
107    public @NonNull String getFieldCode() { return this.fieldCode; }
108
109    /** Returns the fixed reason code.
110     * @return {@code REQUIRED}, {@code INVALID} or {@code INCOMPATIBLE}
111     * @since 1.0.0 */
112    public @NonNull String getReasonCode() { return this.reasonCode; }
113
114    /** Returns a fixed API documentation reference, without configuration data.
115     * @return static documentation reference
116     * @since 1.0.0 */
117    public @NonNull String getDocumentationReference() { return this.documentationReference; }
118
119    /** Returns a fixed explanation without configuration values.
120     * @return static explanation
121     * @since 1.0.0 */
122    public @NonNull String getMessage() { return this.message; }
123}