|
10Duke Java Core
|
Base class for OAuth client implementations.
Note: the second phase construction method init() must be used prior to running an OAuth flow.
Public Member Functions | |
| AbstractOAuthClient (final AuthConfig config, final OkHttpProvider okHttpProvider, final JwtServiceProvider jwtServiceProvider, final ObjectMapper mapper) | |
| Class constructor. | |
| void | init () |
| Second phase construction hook provided for controlling potentially slow loading of remote OpenId configuration. | |
| VerifiedOAuthTokenResponse | refreshToken (final String refreshToken) throws IOException |
| Makes an access token refresh request to the authorization server. | |
| boolean | checkIfJwksUriIsConfigured () |
| Checks if this client instance has configuration for the JWKS endpoint. | |
| boolean | reloadJwks () |
| Requests this client instance to reload keys from the JWKS endpoint and persistent storage. | |
| boolean | reloadOnlineJwks () |
| Requests this client instance to reload keys from the JWKS endpoint and persistent storage. | |
| boolean | reloadPersistentJwks () |
| Requests this client instance to reload keys from the JWKS persistent storage, if available. | |
Protected Member Functions | |
| VerifiedOAuthTokenResponse | parseTokenResponse (final Response response) |
| Parses a token response received from the authorization server (Identity Provider). | |
| void | assertStateIsValid () |
| Analyzes state and configuration. | |
| void | loadOpenIdConnectConfiguration () |
| Loads OpenId configuration from configured URL (only if discovery URL is available in configuration). | |
| String | formatConfigMissingMessage (final String formatValue) |
| Formats a message for a missing configuration value. | |
| String | formatRuntimeDependencyMissingMessage (final String formatValue) |
| Formats a message for a missing configuration value. | |
| abstract boolean | supportsTokenRefresh () |
| Returns flag that tells if the OAuth client implementation supports token refresh. | |
| boolean | updateSigningKeys (final OpenIdConfiguration effectiveOidcConfig, final JwtServiceProvider jwtSp) |
| Updates signing keys based on OpenIdConfiguration that has been loaded or changed. | |
| boolean | reloadOnlineSigningKeys (final OpenIdConfiguration effectiveOidcConfig, final JwtServiceProvider jwtSp) |
| Reloads signing keys based on OpenIdConfiguration that has been loaded or changed. | |
| boolean | reloadPersistentSigningKeys (final JwtServiceProvider jwtSp) |
| Reloads signing keys based on persistence, if available. | |
| tenduke.sdk.core.auth.AbstractOAuthClient.AbstractOAuthClient | ( | final AuthConfig | config, |
| final OkHttpProvider | okHttpProvider, | ||
| final JwtServiceProvider | jwtServiceProvider, | ||
| final ObjectMapper | mapper ) |
Class constructor.
| config | The configuration to use for OAuth client_id and endpoints at the authorization provider, |
| okHttpProvider | Provides OkHttpClient instance(s). |
| jwtServiceProvider | Provides JwtService instances. |
| mapper | Jackson object mapper, needed for parsing access token response JSON. |
|
protected |
Analyzes state and configuration.
Throws IllegalStateException if:
Required values are checked to ensure they are not null and conform to expected grammar (for example URIs are formatted correctly).
Reimplemented in tenduke.sdk.core.auth.AbstractPkceClient, tenduke.sdk.core.auth.DeviceFlowClient, and tenduke.sdk.core.auth.WebAppPkceClient.
| boolean tenduke.sdk.core.auth.AbstractOAuthClient.checkIfJwksUriIsConfigured | ( | ) |
Checks if this client instance has configuration for the JWKS endpoint.
|
protected |
Formats a message for a missing configuration value.
The message takes shape: "{0} is not configured."
| formatValue | The value for the single format element. |
|
protected |
Formats a message for a missing configuration value.
The message takes shape: "{0} is not configured."
| formatValue | The value for the single format element. |
| void tenduke.sdk.core.auth.AbstractOAuthClient.init | ( | ) |
Second phase construction hook provided for controlling potentially slow loading of remote OpenId configuration.
Calling this method will induce an HTTP request if the AuthConfig#idpOidcDiscoveryUrl() is configured. Otherwise the provided AuthConfig is used as such.
Reimplemented in tenduke.sdk.core.auth.DesktopPkceClient.
|
protected |
Parses a token response received from the authorization server (Identity Provider).
| response | The HTTP response object. |
| VerifiedOAuthTokenResponse tenduke.sdk.core.auth.AbstractOAuthClient.refreshToken | ( | final String | refreshToken | ) | throws IOException |
Makes an access token refresh request to the authorization server.
| refreshToken | The client's current refresh token. |
OAuthTokenResponse#checkIsSuccess() and OAuthTokenResponse#checkIsError() methods of OAuthTokenResponse to determine if getting the id token or error handling is the next step.| java.io.IOException | if the request could not be executed due to cancellation, a connectivity problem or timeout. |
| boolean tenduke.sdk.core.auth.AbstractOAuthClient.reloadJwks | ( | ) |
Requests this client instance to reload keys from the JWKS endpoint and persistent storage.
If the JWT service provider supports persistent storage, this method will also ensure that newly loaded keys are persisted for future use.
| boolean tenduke.sdk.core.auth.AbstractOAuthClient.reloadOnlineJwks | ( | ) |
Requests this client instance to reload keys from the JWKS endpoint and persistent storage.
If the JWT service provider supports persistent storage, this method will also ensure that newly loaded keys are persisted for future use.
|
protected |
Reloads signing keys based on OpenIdConfiguration that has been loaded or changed.
This method will load keys from the JWKS endpoint if supported. If the JWT service provider supports persistent storage, the keys will be automatically persisted during the loading process.
| effectiveOidcConfig | The OpenIdConfiguration containing an optional JWKS URL. |
| jwtSp | The JWT service provider to trigger key update for. |
| boolean tenduke.sdk.core.auth.AbstractOAuthClient.reloadPersistentJwks | ( | ) |
Requests this client instance to reload keys from the JWKS persistent storage, if available.
|
protected |
Reloads signing keys based on persistence, if available.
| jwtSp | The JWT service provider to trigger key update for. |
|
abstractprotected |
Returns flag that tells if the OAuth client implementation supports token refresh.
Reimplemented in tenduke.sdk.core.auth.AbstractPkceClient, and tenduke.sdk.core.auth.DeviceFlowClient.
|
protected |
Updates signing keys based on OpenIdConfiguration that has been loaded or changed.
This method will load keys from the JWKS endpoint if supported. If the JWT service provider supports persistent storage, the keys will be automatically persisted during the loading process.
This method also reloads persistent keys, if available.
| effectiveOidcConfig | The OpenIdConfiguration containing an optional JWKS URL. |
| jwtSp | The JWT service provider to trigger key update for. |