Class SignedRefreshTokenGenerator

java.lang.Object
io.micronaut.security.token.jwt.generator.SignedRefreshTokenGenerator
All Implemented Interfaces:
RefreshTokenGenerator, RefreshTokenValidator

@Singleton @Requires(beans=RefreshTokenConfiguration.class) public class SignedRefreshTokenGenerator extends Object implements RefreshTokenGenerator, RefreshTokenValidator
The default implementation of RefreshTokenGenerator and RefreshTokenValidator. Create and verify a JWS encoded object whose payload is a UUID with a hash-based message authentication code (HMAC).
Since:
2.0.0
Author:
Sergio del Amo
See Also:
  • Constructor Details

    • SignedRefreshTokenGenerator

      public SignedRefreshTokenGenerator(RefreshTokenConfiguration config)
      Parameters:
      config - Signed Refresh Token generator
  • Method Details

    • createKey

      @NonNull public @NonNull String createKey(@NonNull @NonNull Authentication authentication)
      Specified by:
      createKey in interface RefreshTokenGenerator
      Parameters:
      authentication - The user details
      Returns:
      The internal value that will persisted.
    • generate

      @NonNull public @NonNull Optional<String> generate(@NonNull @NonNull Authentication authentication, @NonNull @NonNull String token)
      Specified by:
      generate in interface RefreshTokenGenerator
      Parameters:
      authentication - The user details
      token - The internal value
      Returns:
      The refresh token
    • validate

      @NonNull public @NonNull Optional<String> validate(@NonNull @NonNull String refreshToken)
      Specified by:
      validate in interface RefreshTokenValidator
      Parameters:
      refreshToken - The refresh token
      Returns:
      The validated token wrapped in an Optional or Optional#empty() if the supplied token is invalid.