Class JWTClaimsSetGenerator
java.lang.Object
io.micronaut.security.token.jwt.generator.claims.JWTClaimsSetGenerator
- All Implemented Interfaces:
ClaimsGenerator
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Constructor Summary
ConstructorDescriptionJWTClaimsSetGenerator
(TokenConfiguration tokenConfiguration, @Nullable JtiGenerator jwtIdGenerator, @Nullable ClaimsAudienceProvider claimsAudienceProvider, @Nullable io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) -
Method Summary
Modifier and TypeMethodDescriptiongenerateClaims
(Authentication authentication, @Nullable Integer expiration) generateClaimsSet
(Map<String, ?> oldClaims, Integer expiration) Generate a claims set based on claims.protected void
populateAud
(com.nimbusds.jwt.JWTClaimsSet.Builder builder) Populates aud claim.protected void
populateExp
(com.nimbusds.jwt.JWTClaimsSet.Builder builder, @Nullable Integer expiration) Populates exp claim.protected void
populateIat
(com.nimbusds.jwt.JWTClaimsSet.Builder builder) Populates iat claim.protected void
populateIss
(com.nimbusds.jwt.JWTClaimsSet.Builder builder) Populates iss claim.protected void
populateJti
(com.nimbusds.jwt.JWTClaimsSet.Builder builder) Populates jti claim.protected void
populateNbf
(com.nimbusds.jwt.JWTClaimsSet.Builder builder) Populates nbf claim.protected void
populateSub
(com.nimbusds.jwt.JWTClaimsSet.Builder builder, Authentication authentication) Populates sub claim.protected void
populateWithAuthentication
(com.nimbusds.jwt.JWTClaimsSet.Builder builder, Authentication authentication) Populates Claims with Authentication object.
-
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 ConfigurationjwtIdGenerator
- Generator which creates unique JWT IDclaimsAudienceProvider
- 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 interfaceClaimsGenerator
- 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 Builderauthentication
- 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 Builderexpiration
- 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 Builderauthentication
- Authenticated user's representation.
-
generateClaimsSet
Description copied from interface:ClaimsGenerator
Generate a claims set based on claims.- Specified by:
generateClaimsSet
in interfaceClaimsGenerator
- Parameters:
oldClaims
- The old claims to use as a base in the new token generation.expiration
- expiration time in seconds- Returns:
- Instance of
JWTClaimsSet
-