Interface TokenValidator
- All Known Implementing Classes:
JwtTokenValidator,OAuthIntrospectionValidator,StubBearerTokenValidator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Principal.
BearerTokenGuard extracts the token from the Authorization: Bearer <token> header
and delegates verification to a TokenValidator the host supplies. The validator is the
authoritative source of "is this token still good?" — signature, expiry, audience, issuer,
revocation, etc.
Implementations:
- JWT — the optional
juneau-rest-server-auth-jwtsub-module shipsJwtTokenValidator, which performs JWKS-backed signature verification with fulliss/aud/exp/nbf/ algorithm-allowlist enforcement. - Opaque token — e.g. a 32-byte random token stored in a database; the validator
looks the token up in the store and returns the associated user record wrapped as a
Principal. - Introspection — e.g. RFC 7662 token introspection over HTTP against the issuing IdP; the validator caches successful responses for a short TTL.
Contract
On success, return a non-null Principal. On failure, throw AuthenticationException
with a WWW-Authenticate challenge string set via
AuthenticationException.wwwAuthenticate(String). Returning
The supplied token string is exactly what followed "Bearer " in the Authorization
header — the guard does not pre-trim or unquote. Validators should treat it as untrusted input
(no logging of full tokens, no exception messages echoing the token, etc.).
See Also:
- Since:
- 10.0.0
-
Method Summary
-
Method Details
-
validate
Validates the supplied bearer token and returns the associatedPrincipal.- 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.
-