Class ClientCredentialsAccessTokenProvider
java.lang.Object
de.aristaflow.adept2.core.eventmanager.mailevents.ClientCredentialsAccessTokenProvider
- All Implemented Interfaces:
OAuth2AccessTokenProvider
@ConfigurationDescription(properties={@Property(name="TokenEndpoint",isRequired=true,description="The HTTP-based endpoint used to acquire the OAuth 2.0 token."),,,,,})
public class ClientCredentialsAccessTokenProvider
extends Object
implements OAuth2AccessTokenProvider
An implementation of
OAuth2AccessTokenProvider that acquires an access token via the
OAuth 2.0 client credentials grant.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HttpClientThe currently usedclientornullif no client has been created or the last request failed.protected final HttpClient.BuilderThe builder for a newclient.protected final longDeprecated, for removal: This API element is subject to removal in a future version.static final StringConfiguration key for the client ID.static final StringConfiguration key for the client secret.static final StringConfiguration key for the HttpRequest timeout.static final StringConfiguration key for the scope.static final StringConfiguration key for the HttpClient timeout.static final StringConfiguration key for the token endpoint.protected final HttpRequest.BodyPublisherDeprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead.protected HttpRequestThe currently usedrequestornullif no request has been created or the last request failed.protected final HttpRequest.BuilderThe builder for a newrequest.protected final longDeprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead.protected final URIDeprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead. -
Constructor Summary
ConstructorsConstructorDescriptionClientCredentialsAccessTokenProvider(Configuration conf, EventManager em, Registry registry) Creates a new provider for an OAuth 2.0 token from a specific endpoint. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpRequest.BodyPublisherCreates aHttpRequest.BodyPublisherthat turns the values from the designated configuration into appropriate URL-encoded form data.Gets an OAuth2 access token for accessing the mailbox.
-
Field Details
-
CONF_TIMEOUT
Configuration key for the HttpClient timeout.- See Also:
-
CONF_REQUEST_TIMEOUT
Configuration key for the HttpRequest timeout.- See Also:
-
CONF_TOKEN_ENDPOINT
Configuration key for the token endpoint.- See Also:
-
CONF_CLIENT_ID
Configuration key for the client ID.- See Also:
-
CONF_CLIENT_SECRET
Configuration key for the client secret.- See Also:
-
CONF_SCOPE
Configuration key for the scope.- See Also:
-
tokenEndpoint
Deprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead.The token endpoint. -
postRequestData
@Deprecated(since="15.3.0", forRemoval=true) protected final HttpRequest.BodyPublisher postRequestDataDeprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead.The data to send as post request to get an OAuth 2.0 access token. -
clientTimeout
Deprecated, for removal: This API element is subject to removal in a future version.UseclientandclientBuilderinstead.The HttpClient timeout. -
requestTimeout
Deprecated, for removal: This API element is subject to removal in a future version.UserequestandrequestBuilderinstead.The HttpRequest timeout. -
clientBuilder
The builder for a newclient. -
requestBuilder
The builder for a newrequest. -
client
The currently usedclientornullif no client has been created or the last request failed. -
request
The currently usedrequestornullif no request has been created or the last request failed.
-
-
Constructor Details
-
ClientCredentialsAccessTokenProvider
public ClientCredentialsAccessTokenProvider(Configuration conf, EventManager em, Registry registry) throws AbortServiceException Creates a new provider for an OAuth 2.0 token from a specific endpoint.- Parameters:
conf- The configuration of this OAuth 2.0 token provider.em- The event manager this provider is a plugin of.registry- The registry starting this plugin.- Throws:
AbortServiceException- If there are problems creating aURIfor the configured endpoint, anAbortServiceExceptionwrapping the correspondingURISyntaxExceptionwill be thrown.
-
-
Method Details
-
createRequestData
Creates aHttpRequest.BodyPublisherthat turns the values from the designated configuration into appropriate URL-encoded form data.- Parameters:
conf- The configuration to get the request data from.- Returns:
- The designated data as URL-encoded form data.
-
getAccessToken
Description copied from interface:OAuth2AccessTokenProviderGets an OAuth2 access token for accessing the mailbox.- Specified by:
getAccessTokenin interfaceOAuth2AccessTokenProvider- Returns:
- An OAuth2 access token for accessing the mailbox
- Throws:
jakarta.mail.MessagingException- If there are problems retrieving the access token, aMessagingExceptionwill be thrown.
-
clientandclientBuilderinstead.