10Duke Java Core
|
Authorization provider implementation that triggers token refresh when needed.
This class is stateful as it holds an OAuth token response and performs access token refresh when needed, if a refresh token has been provided.
NOTE: When using an instance of this class in mode AuthorizationHeaderMode#ID_TOKEN
the authorization server (Identity Provider) is expected to issue a new Id Token on each access token refresh request.
Configuration and setup: after providing the required construction arguments the owner of an instance of this class may also use setupTokenResponseListener()
to enable automated token response listening that then further enables refreshing access tokens (for clients that are issued with refresh tokens).
Classes | |
enum | AuthorizationHeaderMode |
Used to control the authorization header's type. More... | |
Public Member Functions | |
String | buildAuthorizationHeader () |
Builds value for Authorization header to use for authorizing API calls to the 10Duke Scale API. | |
String | signingKeyId () |
Returns the key identifier of the key that was used to sign the Authorization header token. | |
void | setupTokenResponseListener () |
Registers this instance as a subscriber for token responses emitted by the PKCe client instance member. | |
![]() |
Protected Member Functions | |
boolean | tokenRequiresRefresh (final VerifiedOAuthTokenResponse token) |
Checks if the currently held token (held in the token response object) has expired or will expire shortly. | |
boolean | accessTokenRequiresRefresh (final VerifiedOAuthTokenResponse token) |
Checks if the OAuth access token (held in the token response object) has expired. | |
boolean | idTokenRequiresRefresh (final VerifiedOAuthTokenResponse token) |
Checks if the Id Token (held in the token response object) has expired. | |
void | refreshToken (final VerifiedOAuthTokenResponse currentToken) |
Tries to refresh the current access token held in the OAuthTokenResponse object. | |
String | serizalizeHeader () |
Serializes the header value with expectation that token validation has passed. | |
|
protected |
Checks if the OAuth access token (held in the token response object) has expired.
token | The token response object with the access Token. |
String tenduke.sdk.core.auth.SingleUserAuthorizationProvider.buildAuthorizationHeader | ( | ) |
Builds value for Authorization header to use for authorizing API calls to the 10Duke Scale API.
Note: does not include the header name and colon Authorization:
.
Authorization
header value. Implements tenduke.sdk.core.service.AuthorizationProvider.
|
protected |
Checks if the Id Token (held in the token response object) has expired.
token | The token response object with the Id Token. |
|
protected |
Tries to refresh the current access token held in the OAuthTokenResponse object.
currentToken | Previous token response object that provides the refresh token needed for the access token refresh call. |
|
protected |
Serializes the header value with expectation that token validation has passed.
void tenduke.sdk.core.auth.SingleUserAuthorizationProvider.setupTokenResponseListener | ( | ) |
Registers this instance as a subscriber for token responses emitted by the PKCe client instance member.
This setup is required when wanting the most extensive level of automation that this class offers (access token renewal depends on this instance having a handle to the latest token response).
String tenduke.sdk.core.auth.SingleUserAuthorizationProvider.signingKeyId | ( | ) |
Returns the key identifier of the key that was used to sign the Authorization header token.
Implements tenduke.sdk.core.service.AuthorizationProvider.
|
protected |
Checks if the currently held token (held in the token response object) has expired or will expire shortly.
token | The token response object. |