Class IdTokenValidatorAdapter
IDTokenValidator to validate an OpenID Connect ID token's signature and claims
and project the verified claims onto a Juneau ClaimsPrincipal.
Nimbus's IDTokenValidator performs the full OIDC ID-token validation in one call: signature
verification against the IdP JWKS, exact iss match, aud contains the client id,
azp when there are multiple audiences, exp (with clock skew), required iat,
and — when supplied — nonce match. This adapter owns only the configuration and
the projection to ClaimsPrincipal; no bespoke crypto.
The signing-algorithm allowlist defaults to [RS256, ES256] (both SHA-256 based). The unsafe
"none" algorithm is permanently rejected (a token signed with none has no key and so
fails the key selector), and SHA-1-family algorithms are excluded by virtue of not being on the
allowlist — consistent with the juneau-rest-server-auth-jwt strict-default stance.
For production, configure IdTokenValidatorAdapter.Builder.jwksUri(URI) (Nimbus builds a cached remote key source).
For tests / HSM-backed signers / multi-issuer setups, inject a IdTokenValidatorAdapter.Builder.jwkSet(JWKSet) or
IdTokenValidatorAdapter.Builder.jwkSource(JWKSource) directly.
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Static creator.Validates an ID token and projects the verified claims onto aClaimsPrincipal.
-
Constructor Details
-
IdTokenValidatorAdapter
Constructor.- Parameters:
b- The builder.
-
-
Method Details
-
create
Static creator.- Returns:
- A new builder.
-
validate
public ClaimsPrincipal validate(String idToken, String expectedNonce) throws AuthenticationException Validates an ID token and projects the verified claims onto aClaimsPrincipal.- Parameters:
idToken- The raw (compact) ID token JWT. Must not benull or blank.expectedNonce- Thenoncethe relying party stored before the redirect; the ID token'snonceclaim must match. May benull only if the flow did not use a nonce (the RP always supplies one).- Returns:
- The verified claims as a
ClaimsPrincipalwhose name is thesubclaim. - Throws:
AuthenticationException- If parsing, signature verification, or any claim check fails.
-