Class Nimbus
- All Implemented Interfaces:
OidcProvider,OidcProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
OidcProvider based on Nimbus OAuth 2.0 / OIDC SDK.
Provides functionality for:
- Access token introspection via the OIDC provider’s introspection endpoint.
- Optional end-session redirection to the provider’s logout endpoint.
-
Constructor Summary
ConstructorsConstructorDescriptionNimbus(OidcConfigurationService config) Constructs a newOidcProviderImplinstance using the provided configuration and discovery services. -
Method Summary
Modifier and TypeMethodDescriptionvoidendSession(String idToken) Ends the authenticated user’s session with the OpenID Connect (OIDC) provider without redirecting the user’s browser.voidReturns the OpenID Connect (OIDC) ID token associated with the current user session.getLogoutUrl(String redirectUri) Returns the url that needs to be called to terminate the session of the implementing oidc provider containing the redirect uri where the user is redirected to after logout.getToken()Returns the jwt access token as string associated with the current session if any or null otherwise.introspectToken(String token) Introspects the given OAuth 2.0 access token using the OIDC provider's token introspection endpoint as defined in RFC 7662.voidLogin method called when hitting the oidc login button.parseToken(String token) voidregisterCallback(OidcCallback callback) Register anyOidcCallbackat the implementing oidc provider.
-
Constructor Details
-
Nimbus
Constructs a newOidcProviderImplinstance using the provided configuration and discovery services.This constructor is annotated with
, which allows Guice to provide this dependency automatically.invalid reference
Inject- Parameters:
config- The configuration service providing validated client credentials and issuer URI.- Throws:
GeneralExceptionIOException
-
-
Method Details
-
fetchMetadata
- Specified by:
fetchMetadatain interfaceOidcProvider- Throws:
GeneralExceptionIOException
-
introspectToken
Introspects the given OAuth 2.0 access token using the OIDC provider's token introspection endpoint as defined in RFC 7662.Token introspection is a mechanism that allows a protected resource to query the authorization server for metadata about an access token, including whether the token is currently active (valid) and additional claims describing the token's context.
Implementations are expected to throw an
IllegalStateExceptionif the token is invalid, inactive, or if the introspection request fails for any reason (network error, malformed response, missing endpoint, etc.).- Specified by:
introspectTokenin interfaceOidcProvider- Parameters:
token- The access token to validate. Must be a non-null, non-empty string.- Returns:
- A map of token claims as defined by RFC 7662, if the token is valid
and active. The returned map is guaranteed to contain the
activeclaim, as mandated by RFC 7662, and may include additional claims such asexp,scope,client_id,sub, etc., depending on the OIDC provider and token type.
-
parseToken
- Specified by:
parseTokenin interfaceOidcProvider
-
endSession
Description copied from interface:OidcProviderEnds the authenticated user’s session with the OpenID Connect (OIDC) provider without redirecting the user’s browser.This variant calls the provider’s end-session (logout) endpoint directly using the
id_token_hintparameter to identify the session to terminate. It is used in backend logout scenarios or when the application needs to trigger logout silently without user interaction, e.g. on errors.- Specified by:
endSessionin interfaceOidcProvider- Parameters:
idToken- the ID token of the authenticated user, used asid_token_hintin the logout request. Must not benull.
-
getLogoutUrl
Returns the url that needs to be called to terminate the session of the implementing oidc provider containing the redirect uri where the user is redirected to after logout.- Specified by:
getLogoutUrlin interfaceOidcProvider- Parameters:
redirectUri- The redirect uri to be included in the logout url.- Returns:
- The oidc logout url including the redirect uri.
-
getToken
Returns the jwt access token as string associated with the current session if any or null otherwise.- Specified by:
getTokenin interfaceOidcProvider- Returns:
- The jwt access token or null if no session.
-
getIdToken
Returns the OpenID Connect (OIDC) ID token associated with the current user session.The ID token is a token issued by the OIDC provider during authentication. It primarily contains identity information about the authenticated user (e.g.
sub,preferred_username,email).Unlike the access token, which is used to authorize API calls and can be introspected by the resource server, the ID token is meant for the client itself to verify the user’s identity.
- Specified by:
getIdTokenin interfaceOidcProvider- Returns:
- the ID token or
nullif no ID token is available
-
login
Login method called when hitting the oidc login button. This method redirects to the actual login of the implementing oidc provider.- Specified by:
loginin interfaceOidcProvider- Parameters:
locale- The locale to be used on oidc provider login page.
-