Class OAuthTokenValidationResult
java.lang.Object
org.apache.camel.spi.OAuthTokenValidationResult
Result of validating an incoming OAuth 2.0 bearer token.
Contains the validation outcome (valid/invalid), extracted claims from the token, and an error message when the token
is invalid.
- Since:
- 4.21
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStable validation failure categories for rejected bearer tokens. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectgetAttribute(String name) Gets an attribute extracted from the token payload (JWT) or introspection response.<T> @Nullable TgetAttribute(String name, Class<T> type) Gets an attribute extracted from the token payload (JWT) or introspection response and casts it to the requested type.All attributes extracted from the token payload (JWT) or introspection response.Theaudclaim(s) from the token.@Nullable ObjectGets a claim extracted from the token payload (JWT) or introspection response.<T> @Nullable TGets a claim extracted from the token payload (JWT) or introspection response and casts it to the requested type.All claims from the token payload (JWT) or introspection response.@Nullable StringgetError()Human-readable error message when the token is invalid, or null when valid.@Nullable OAuthTokenValidationResult.ErrorCodeStable validation failure category when the token is invalid, or null when valid.longTheexpclaim as epoch seconds, or 0 if not present.@Nullable StringTheissclaim from the token, or null if not present.@Nullable StringgetName()The principal name for route-level decisions.Thescopeclaim from the token, split into individual scopes.@Nullable StringThesubclaim from the token, or null if not present.booleanWhether the token has the given OAuth scope.static OAuthTokenValidationResultCreates a result for a token that failed validation.static OAuthTokenValidationResultinvalid(OAuthTokenValidationResult.ErrorCode errorCode, String error) Creates a result for a token that failed validation.booleanisValid()Whether the token passed validation.static OAuthTokenValidationResultvalid(@Nullable String subject, @Nullable String issuer, @Nullable List<String> audience, @Nullable List<String> scopes, @Nullable Map<String, Object> claims, long expiresAt) Creates a result for a successfully validated token.
-
Method Details
-
valid
-
invalid
Creates a result for a token that failed validation.- Since:
- 4.21
-
invalid
public static OAuthTokenValidationResult invalid(OAuthTokenValidationResult.ErrorCode errorCode, String error) Creates a result for a token that failed validation.- Since:
- 4.21
-
isValid
public boolean isValid()Whether the token passed validation.- Since:
- 4.21
-
getSubject
Thesubclaim from the token, or null if not present.- Since:
- 4.21
-
getName
The principal name for route-level decisions. This implementation returns thesubclaim.- Since:
- 4.21
-
getIssuer
Theissclaim from the token, or null if not present.- Since:
- 4.21
-
getAudience
-
getScopes
-
hasScope
-
getClaims
-
getAttributes
All attributes extracted from the token payload (JWT) or introspection response. This is an alias forgetClaims()using principal-oriented terminology.- Since:
- 4.21
-
getAttribute
-
getAttribute
Gets an attribute extracted from the token payload (JWT) or introspection response and casts it to the requested type.- Throws:
ClassCastException- if the attribute exists but is not assignable to the requested type- Since:
- 4.21
-
getClaim
-
getClaim
Gets a claim extracted from the token payload (JWT) or introspection response and casts it to the requested type.- Throws:
ClassCastException- if the claim exists but is not assignable to the requested type- Since:
- 4.21
-
getExpiresAt
public long getExpiresAt()Theexpclaim as epoch seconds, or 0 if not present.- Since:
- 4.21
-
getErrorCode
Stable validation failure category when the token is invalid, or null when valid.- Since:
- 4.21
-
getError
Human-readable error message when the token is invalid, or null when valid.- Since:
- 4.21
-