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 Details

  • Constructor Details

    • AbstractClientCredentialsClient

      public AbstractClientCredentialsClient(@NonNull @NonNull OauthClientConfiguration oauthClientConfiguration, @NonNull @NonNull TokenEndpointClient tokenEndpointClient)
      Parameters:
      tokenEndpointClient - The token endpoint client
      oauthClientConfiguration - The client configuration
  • Method Details

    • getName

      public String getName()
      Returns:
      the bean's name;
    • requestToken

      @NonNull public @NonNull org.reactivestreams.Publisher<TokenResponse> requestToken(@Nullable @Nullable String scope)
      Specified by:
      requestToken in interface ClientCredentialsClient
      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 interface ClientCredentialsClient
      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

      protected boolean isExpired(@Nullable @Nullable TokenResponse tokenResponse)
      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

      protected boolean isExpired(@NonNull @NonNull Date expirationDate)
      Parameters:
      expirationDate - Expiration
      Returns:
      true if the (expiration date - ClientCredentialsConfiguration.getAdvancedExpiration()) before current date.
    • expirationDate

      protected Optional<Date> expirationDate(@NonNull @NonNull TokenResponse tokenResponse)
      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