Class AbstractClientCredentialsClient
java.lang.Object
io.micronaut.security.oauth2.client.clientcredentials.AbstractClientCredentialsClient
- All Implemented Interfaces:
ClientCredentialsClient
- Direct Known Subclasses:
DefaultClientCredentialsClient
,DefaultClientCredentialsOpenIdClient
@Internal
public abstract class AbstractClientCredentialsClient
extends Object
implements ClientCredentialsClient
Abstract class to create a Client for client credentials grant.
- Since:
- 2.2.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final OauthClientConfiguration
protected final Map<String,
org.reactivestreams.Publisher<TokenResponse>> protected final TokenEndpointClient
-
Constructor Summary
ConstructorDescriptionAbstractClientCredentialsClient
(@NonNull OauthClientConfiguration oauthClientConfiguration, @NonNull TokenEndpointClient tokenEndpointClient) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ClientCredentialsTokenRequestContext
createTokenRequestContext
(@Nullable String scope) expirationDate
(@NonNull TokenResponse tokenResponse) getName()
protected boolean
protected boolean
isExpired
(@Nullable TokenResponse tokenResponse) @NonNull org.reactivestreams.Publisher<TokenResponse>
requestToken
(@Nullable String scope) @NonNull org.reactivestreams.Publisher<TokenResponse>
requestToken
(@Nullable String scope, boolean force) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.security.oauth2.client.clientcredentials.ClientCredentialsClient
requestToken, requestToken
-
Field Details
-
tokenEndpointClient
-
oauthClientConfiguration
-
scopeToPublisherMap
-
-
Constructor Details
-
AbstractClientCredentialsClient
public AbstractClientCredentialsClient(@NonNull @NonNull OauthClientConfiguration oauthClientConfiguration, @NonNull @NonNull TokenEndpointClient tokenEndpointClient) - Parameters:
tokenEndpointClient
- The token endpoint clientoauthClientConfiguration
- The client configuration
-
-
Method Details
-
getName
- Returns:
- the bean's name;
-
requestToken
@NonNull public @NonNull org.reactivestreams.Publisher<TokenResponse> requestToken(@Nullable @Nullable String scope) - Specified by:
requestToken
in interfaceClientCredentialsClient
- Parameters:
scope
- Requested scope values for the access token.- Returns:
- Response of an authorization server to a valid client credentials request.
-
requestToken
@NonNull public @NonNull org.reactivestreams.Publisher<TokenResponse> requestToken(@Nullable @Nullable String scope, boolean force) - Specified by:
requestToken
in interfaceClientCredentialsClient
- Parameters:
scope
- Requested scope values for the access token.force
- true to invalidate the cached token response and fetch a new one- Returns:
- Response of an authorization server to a valid client credentials request.
-
isExpired
- Parameters:
tokenResponse
- Token Response- Returns:
- true if any A) parameter token response is null B) if an expiration time cannot parsed C) (expiration date -
ClientCredentialsConfiguration.getAdvancedExpiration()
) before current date.
-
isExpired
- Parameters:
expirationDate
- Expiration- Returns:
- true if the (expiration date -
ClientCredentialsConfiguration.getAdvancedExpiration()
) before current date.
-
expirationDate
- Parameters:
tokenResponse
- Token Response- Returns:
- The expiration date from the exp claim in the access token is a JWT or the expiration date calculated from the expiresIn
-
createTokenRequestContext
protected abstract ClientCredentialsTokenRequestContext createTokenRequestContext(@Nullable @Nullable String scope) - Parameters:
scope
- The requested scope for the client credentials request- Returns:
- A client credentials token request context
-