Class DefaultAccessRefreshTokenGenerator

java.lang.Object
io.micronaut.security.token.generator.DefaultAccessRefreshTokenGenerator
All Implemented Interfaces:
AccessRefreshTokenGenerator

@Requires(beans={AccessTokenConfiguration.class,TokenRenderer.class,TokenGenerator.class,ClaimsGenerator.class}) @Singleton public class DefaultAccessRefreshTokenGenerator extends Object implements AccessRefreshTokenGenerator
Generates http responses with access and refresh token.
Since:
1.0
Author:
Sergio del Amo
  • Field Details

    • beanContext

      protected final io.micronaut.context.BeanContext beanContext
    • refreshTokenGenerator

      protected final RefreshTokenGenerator refreshTokenGenerator
    • claimsGenerator

      protected final ClaimsGenerator claimsGenerator
    • accessTokenConfiguration

      protected final AccessTokenConfiguration accessTokenConfiguration
    • tokenRenderer

      protected final TokenRenderer tokenRenderer
    • tokenGenerator

      protected final TokenGenerator tokenGenerator
    • refreshTokenGeneratedEventPublisher

      protected final io.micronaut.context.event.ApplicationEventPublisher<RefreshTokenGeneratedEvent> refreshTokenGeneratedEventPublisher
    • accessTokenGeneratedEventPublisher

      protected final io.micronaut.context.event.ApplicationEventPublisher<AccessTokenGeneratedEvent> accessTokenGeneratedEventPublisher
  • Constructor Details

    • DefaultAccessRefreshTokenGenerator

      public DefaultAccessRefreshTokenGenerator(AccessTokenConfiguration accessTokenConfiguration, TokenRenderer tokenRenderer, TokenGenerator tokenGenerator, io.micronaut.context.BeanContext beanContext, @Nullable @Nullable RefreshTokenGenerator refreshTokenGenerator, ClaimsGenerator claimsGenerator, io.micronaut.context.event.ApplicationEventPublisher<RefreshTokenGeneratedEvent> refreshTokenGeneratedEventPublisher, io.micronaut.context.event.ApplicationEventPublisher<AccessTokenGeneratedEvent> accessTokenGeneratedEventPublisher)
      Parameters:
      accessTokenConfiguration - The access token generator config
      tokenRenderer - The token renderer
      tokenGenerator - The token generator
      beanContext - Bean Context
      refreshTokenGenerator - The refresh token generator
      claimsGenerator - Claims generator
      refreshTokenGeneratedEventPublisher - The Application event publisher for RefreshTokenGeneratedEvent.
      accessTokenGeneratedEventPublisher - The Application event publisher for AccessTokenGeneratedEvent.
  • Method Details

    • generate

      @NonNull public @NonNull Optional<AccessRefreshToken> generate(@NonNull @NonNull Authentication authentication)
      Generate an AccessRefreshToken response for the given user details.
      Specified by:
      generate in interface AccessRefreshTokenGenerator
      Parameters:
      authentication - Authenticated user's representation.
      Returns:
      The http response
    • generateRefreshToken

      @NonNull public @NonNull Optional<String> generateRefreshToken(@NonNull @NonNull Authentication authentication)
      Generates a refresh token and emits a RefreshTokenGeneratedEvent.
      Specified by:
      generateRefreshToken in interface AccessRefreshTokenGenerator
      Parameters:
      authentication - Authenticated user's representation.
      Returns:
      Optional#empty() if refresh token was not generated or the refresh token wrapped in an Optional.
    • generate

      @NonNull public @NonNull Optional<AccessRefreshToken> generate(@Nullable @Nullable String refreshToken, @NonNull @NonNull Map<String,?> oldClaims)
      Generate an AccessRefreshToken response for the given refresh token and claims.
      Specified by:
      generate in interface AccessRefreshTokenGenerator
      Parameters:
      refreshToken - The refresh token
      oldClaims - The claims to generate the access token
      Returns:
      The http response
    • generate

      @NonNull public @NonNull Optional<AccessRefreshToken> generate(@Nullable @Nullable String refreshToken, @NonNull @NonNull Authentication authentication)
      Generate a new access refresh token.
      Specified by:
      generate in interface AccessRefreshTokenGenerator
      Parameters:
      refreshToken - The refresh token
      authentication - The user details to create a new access token
      Returns:
      The optional access refresh token
    • accessTokenExpiration

      @NonNull public @NonNull Integer accessTokenExpiration(@NonNull @NonNull Authentication authentication)
      Parameters:
      authentication - User details for which the access token is being generated
      Returns:
      expiration of the new access token
    • accessTokenExpiration

      @NonNull public @NonNull Integer accessTokenExpiration(@NonNull @NonNull Map<String,?> oldClaims)
      Parameters:
      oldClaims - The old claims used to build the new token
      Returns:
      expiration of the new access token