Class JWTClaimsSetGenerator

java.lang.Object
io.micronaut.security.token.jwt.generator.claims.JWTClaimsSetGenerator
All Implemented Interfaces:
ClaimsGenerator

@Singleton public class JWTClaimsSetGenerator extends Object implements ClaimsGenerator
Since:
1.0
Author:
Sergio del Amo
  • Constructor Details

    • JWTClaimsSetGenerator

      public JWTClaimsSetGenerator(TokenConfiguration tokenConfiguration, @Nullable @Nullable JtiGenerator jwtIdGenerator, @Nullable @Nullable ClaimsAudienceProvider claimsAudienceProvider, @Nullable @Nullable io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
      Parameters:
      tokenConfiguration - Token Configuration
      jwtIdGenerator - Generator which creates unique JWT ID
      claimsAudienceProvider - Provider which identifies the recipients that the JWT is intended for.
      applicationConfiguration - The application configuration
  • Method Details

    • generateClaims

      public Map<String,Object> generateClaims(Authentication authentication, @Nullable @Nullable Integer expiration)
      Specified by:
      generateClaims in interface ClaimsGenerator
      Parameters:
      authentication - Authenticated user's representation.
      expiration - expiration time in seconds
      Returns:
      The authentication claims
    • populateIss

      protected void populateIss(com.nimbusds.jwt.JWTClaimsSet.Builder builder)
      Populates iss claim.
      Parameters:
      builder - The Claims Builder
      See Also:
    • populateSub

      protected void populateSub(com.nimbusds.jwt.JWTClaimsSet.Builder builder, Authentication authentication)
      Populates sub claim.
      Parameters:
      builder - The Claims Builder
      authentication - Authenticated user's representation.
      See Also:
    • populateAud

      protected void populateAud(com.nimbusds.jwt.JWTClaimsSet.Builder builder)
      Populates aud claim.
      Parameters:
      builder - The Claims Builder
      See Also:
    • populateExp

      protected void populateExp(com.nimbusds.jwt.JWTClaimsSet.Builder builder, @Nullable @Nullable Integer expiration)
      Populates exp claim.
      Parameters:
      builder - The Claims Builder
      expiration - expiration time in seconds
      See Also:
    • populateNbf

      protected void populateNbf(com.nimbusds.jwt.JWTClaimsSet.Builder builder)
      Populates nbf claim.
      Parameters:
      builder - The Claims Builder
      See Also:
    • populateIat

      protected void populateIat(com.nimbusds.jwt.JWTClaimsSet.Builder builder)
      Populates iat claim.
      Parameters:
      builder - The Claims Builder
      See Also:
    • populateJti

      protected void populateJti(com.nimbusds.jwt.JWTClaimsSet.Builder builder)
      Populates jti claim.
      Parameters:
      builder - The Claims Builder
      See Also:
    • populateWithAuthentication

      protected void populateWithAuthentication(com.nimbusds.jwt.JWTClaimsSet.Builder builder, Authentication authentication)
      Populates Claims with Authentication object.
      Parameters:
      builder - the Claims Builder
      authentication - Authenticated user's representation.
    • generateClaimsSet

      public Map<String,Object> generateClaimsSet(Map<String,?> oldClaims, Integer expiration)
      Description copied from interface: ClaimsGenerator
      Generate a claims set based on claims.
      Specified by:
      generateClaimsSet in interface ClaimsGenerator
      Parameters:
      oldClaims - The old claims to use as a base in the new token generation.
      expiration - expiration time in seconds
      Returns:
      Instance of JWTClaimsSet