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. | |
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. | |
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.
|
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.
effectiveOidcConfig | The OpenIdConfiguration containing an optional JWKS URL. |
jwtSp | The JWT service provider to trigger key update for. |