Class OAuthIntrospectionValidator
java.lang.Object
org.apache.juneau.rest.server.auth.oauth.OAuthIntrospectionValidator
- All Implemented Interfaces:
TokenValidator
TokenValidator that validates opaque OAuth 2.0 access tokens via the
RFC 7662 Token Introspection
endpoint.
Wraps Nimbus's TokenIntrospectionRequest / TokenIntrospectionResponse for the HTTP
round-trip and the JSON parsing. A TokenCache (default: bounded LRU cache) short-circuits
the round-trip on repeated lookups within the configured TTL window.
Usage
Defaults
- Cache TTL: 5 minutes, capped at 1 hour.
- Cache size: 1000 entries.
- Required scopes: none (scope enforcement lives on the validator, not the filter).
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Static creator.Returns the cache TTL.Returns the configured OAuth client ID.Returns the configured expected audience / resource-indicator set.Returns the configured introspection endpoint URL.Returns the required-scope set.Returns the underlying token cache.Validates the supplied bearer token and returns the associatedPrincipal.
-
Field Details
-
DEFAULT_CACHE_TTL
Default cache TTL. -
MAX_CACHE_TTL
Maximum cache TTL.
-
-
Constructor Details
-
OAuthIntrospectionValidator
Constructor.- Parameters:
b- The builder.
-
-
Method Details
-
create
Static creator.- Returns:
- A new builder.
-
getIntrospectionEndpoint
Returns the configured introspection endpoint URL.- Returns:
- The endpoint.
-
getClientId
Returns the configured OAuth client ID.- Returns:
- The client ID.
-
getCacheTtl
Returns the cache TTL.- Returns:
- The TTL.
-
getRequiredScopes
Returns the required-scope set.- Returns:
- An unmodifiable view.
-
getExpectedAudiences
Returns the configured expected audience / resource-indicator set.- Returns:
- An unmodifiable view. Empty when no audience/resource binding is configured (default).
-
getTokenCache
Returns the underlying token cache.- Returns:
- The token cache.
-
validate
Description copied from interface:TokenValidatorValidates the supplied bearer token and returns the associatedPrincipal.- Specified by:
validatein interfaceTokenValidator- Parameters:
token- The raw token string fromAuthorization: Bearer <token>. Nevernull .- Returns:
- The authenticated principal. Must not be
null on success. - Throws:
AuthenticationException- If the token is invalid, expired, revoked, or otherwise unacceptable.
-