Class JwtTokenGenerator
java.lang.Object
io.micronaut.security.token.jwt.generator.JwtTokenGenerator
- All Implemented Interfaces:
TokenGenerator
JWT Token Generation.
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ClaimsGenerator
protected final EncryptionConfiguration
protected final SignatureGeneratorConfiguration
-
Constructor Summary
ConstructorDescriptionJwtTokenGenerator
(@Nullable SignatureGeneratorConfiguration signatureConfiguration, @Nullable EncryptionConfiguration encryptionConfiguration, ClaimsGenerator claimsGenerator) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Generate a JWT from a map of claims.generateToken
(Authentication authentication, @Nullable Integer expiration) generateToken
(Map<String, Object> claims) encryptionConfiguration getter.signatureConfiguration getter.protected String
internalGenerate
(com.nimbusds.jwt.JWTClaimsSet claimsSet) Generate a JWT from a claims set.
-
Field Details
-
claimsGenerator
-
signatureConfiguration
-
encryptionConfiguration
-
-
Constructor Details
-
JwtTokenGenerator
public JwtTokenGenerator(@Nullable @Named("generator") @Nullable SignatureGeneratorConfiguration signatureConfiguration, @Nullable @Named("generator") @Nullable EncryptionConfiguration encryptionConfiguration, ClaimsGenerator claimsGenerator) - Parameters:
signatureConfiguration
- JWT Generator signature configurationencryptionConfiguration
- JWT Generator encryption configurationclaimsGenerator
- Claims generator
-
-
Method Details
-
getSignatureConfiguration
signatureConfiguration getter.- Returns:
- Instance of
SignatureGeneratorConfiguration
-
getEncryptionConfiguration
encryptionConfiguration getter.- Returns:
- Instance of
EncryptionConfiguration
-
internalGenerate
protected String internalGenerate(com.nimbusds.jwt.JWTClaimsSet claimsSet) throws com.nimbusds.jose.JOSEException, ParseException Generate a JWT from a claims set.- Parameters:
claimsSet
- the claims set- Returns:
- the JWT
- Throws:
com.nimbusds.jose.JOSEException
- thrown in the JWT generationParseException
- thrown in the JWT generation
-
generate
protected String generate(Map<String, Object> claims) throws com.nimbusds.jose.JOSEException, ParseExceptionGenerate a JWT from a map of claims.- Parameters:
claims
- the map of claims- Returns:
- the created JWT
- Throws:
com.nimbusds.jose.JOSEException
- thrown in the JWT generationParseException
- thrown in the JWT generation
-
generateToken
public Optional<String> generateToken(Authentication authentication, @Nullable @Nullable Integer expiration) - Specified by:
generateToken
in interfaceTokenGenerator
- Parameters:
authentication
- Authenticated user's representation.expiration
- The amount of time in seconds until the token expires- Returns:
- JWT token
-
generateToken
- Specified by:
generateToken
in interfaceTokenGenerator
- Parameters:
claims
- JWT claims- Returns:
- JWT token
-