java.lang.Object
com.irurueta.authserver.serviceclient.infrastructure.resourceserver.ServiceTokens

@Component public class ServiceTokens extends Object
Gives the access token the service client uses, for the CLI that is asked to print it. It goes through the same authorized client manager as the calls, so the token is the cached one while it is valid and no extra request is made.
  • Field Details

    • manager

      private final org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager manager
      Obtains and renews the access tokens.
    • principalMapper

      private final PrincipalMapper principalMapper
      Builds the principals the tokens are cached under.
    • properties

      private final ServiceClientAuthProperties properties
      Settings of the service client.
  • Constructor Details

    • ServiceTokens

      public ServiceTokens()
  • Method Details

    • clientCredentialsToken

      public String clientCredentialsToken()
      Gives the access token of the client credentials grant.
      Returns:
      the token value.
      Throws:
      DocumentAccessException - if the token cannot be obtained.
    • exchangedToken

      public String exchangedToken(String subjectToken)
      Gives the access token the authorization server issues for the client acting on behalf of a user.
      Parameters:
      subjectToken - access token of the user.
      Returns:
      the exchanged token value.
      Throws:
      DocumentAccessException - if the exchange fails.
    • token

      private String token(String registrationId, org.springframework.security.core.Authentication principal)
      Obtains a token.
      Parameters:
      registrationId - registration of the OAuth2 client.
      principal - principal the token is cached under.
      Returns:
      the token value.