Package org.forgerock.secrets.oauth2
Class AccessTokenSecretStore.Builder
- java.lang.Object
-
- org.forgerock.secrets.oauth2.AccessTokenSecretStore.Builder
-
- Enclosing class:
- AccessTokenSecretStore
public static class AccessTokenSecretStore.Builder extends Object
Builder object for the access token secret store. You must at least configure theforPurpose(Purpose)
,withClock(Clock)
,withInitialGrantTypeHandler(GrantTypeHandler)
, andwithTokenEndpoint(URI)
options, otherwise an exception will be thrown when building the object.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessTokenSecretStore
build()
Builds the access token secret store.AccessTokenSecretStore.Builder
forPurpose(Purpose<GenericSecret> purpose)
Configures the purpose for which this access token store is to be used.AccessTokenSecretStore.Builder
withClientSecretBasicAuth(String clientId, SecretReference<GenericSecret> clientSecretRef)
Configures the token store to supply client credentials via HTTP Basic Authentication.AccessTokenSecretStore.Builder
withClientSecretPostAuth(String clientId, SecretReference<GenericSecret> clientSecretRef)
Configures the token store to supply client credentials via client_secret_post method.AccessTokenSecretStore.Builder
withClock(Clock clock)
The clock to use for determining when an access token has expired.AccessTokenSecretStore.Builder
withHandler(Handler handler)
Configures theHandler
to use for sending requests to the token endpoint.AccessTokenSecretStore.Builder
withInitialGrantTypeHandler(GrantTypeHandler grantType)
Configures the initial grant type handler to use for calling the token endpoint.AccessTokenSecretStore.Builder
withTokenEndpoint(String tokenEndpoint)
Configures the URI of the OAuth 2 token endpoint to call to obtain access tokens.AccessTokenSecretStore.Builder
withTokenEndpoint(URI tokenEndpoint)
Configures the URI of the OAuth 2 token endpoint to call to obtain access tokens.
-
-
-
Method Detail
-
forPurpose
public AccessTokenSecretStore.Builder forPurpose(Purpose<GenericSecret> purpose)
Configures the purpose for which this access token store is to be used.- Parameters:
purpose
- the purpose for which access tokens are being used.- Returns:
- this builder object.
-
withHandler
public AccessTokenSecretStore.Builder withHandler(Handler handler)
Configures theHandler
to use for sending requests to the token endpoint.- Parameters:
handler
- the client handler.- Returns:
- this builder object.
-
withClientSecretBasicAuth
public AccessTokenSecretStore.Builder withClientSecretBasicAuth(String clientId, SecretReference<GenericSecret> clientSecretRef)
Configures the token store to supply client credentials via HTTP Basic Authentication.- Parameters:
clientId
- the client id.clientSecretRef
- a reference to the client secret.- Returns:
- this builder object.
-
withClientSecretPostAuth
public AccessTokenSecretStore.Builder withClientSecretPostAuth(String clientId, SecretReference<GenericSecret> clientSecretRef)
Configures the token store to supply client credentials via client_secret_post method.- Parameters:
clientId
- the client id.clientSecretRef
- a reference to retrieve the client secret.- Returns:
- this builder object.
-
withInitialGrantTypeHandler
public AccessTokenSecretStore.Builder withInitialGrantTypeHandler(GrantTypeHandler grantType)
Configures the initial grant type handler to use for calling the token endpoint. If the response from the token endpoint includes a refresh token, then the store will switch to using a refresh token grant from then on.- Parameters:
grantType
- the initial grant type handler.- Returns:
- this object.
-
withClock
public AccessTokenSecretStore.Builder withClock(Clock clock)
The clock to use for determining when an access token has expired.- Parameters:
clock
- the clock.- Returns:
- this builder object.
-
withTokenEndpoint
public AccessTokenSecretStore.Builder withTokenEndpoint(URI tokenEndpoint)
Configures the URI of the OAuth 2 token endpoint to call to obtain access tokens.- Parameters:
tokenEndpoint
- the token endpoint URI.- Returns:
- this builder object.
-
withTokenEndpoint
public AccessTokenSecretStore.Builder withTokenEndpoint(String tokenEndpoint)
Configures the URI of the OAuth 2 token endpoint to call to obtain access tokens.- Parameters:
tokenEndpoint
- the token endpoint URI.- Returns:
- this builder object.
-
build
public AccessTokenSecretStore build() throws HttpApplicationException
Builds the access token secret store.- Returns:
- the access token secret store.
- Throws:
HttpApplicationException
- if noHttpClientHandler
is available.NullPointerException
- if any mandatory configuration options have not been configured.
-
-