Class SecretSignature
java.lang.Object
io.micronaut.security.token.jwt.signature.AbstractSignatureConfiguration
io.micronaut.security.token.jwt.signature.secret.SecretSignature
- All Implemented Interfaces:
SignatureConfiguration
,SignatureGeneratorConfiguration
@EachBean(SecretSignatureConfiguration.class)
public class SecretSignature
extends AbstractSignatureConfiguration
implements SignatureGeneratorConfiguration
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Field Summary
Fields inherited from class io.micronaut.security.token.jwt.signature.AbstractSignatureConfiguration
algorithm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets secret byte[] with a string with UTF_8 charset.com.nimbusds.jwt.SignedJWT
sign
(com.nimbusds.jwt.JWTClaimsSet claims) Generate a signed JWT based on claims.boolean
supports
(com.nimbusds.jose.JWSAlgorithm algorithm) Whether this signature configuration supports this algorithm.boolean
verify
(com.nimbusds.jwt.SignedJWT jwt) Verify a signed JWT.Methods inherited from class io.micronaut.security.token.jwt.signature.AbstractSignatureConfiguration
getAlgorithm, setAlgorithm
-
Constructor Details
-
SecretSignature
- Parameters:
config
-SecretSignatureConfiguration
configuration
-
-
Method Details
-
supportedAlgorithmsMessage
- Specified by:
supportedAlgorithmsMessage
in interfaceSignatureConfiguration
- Returns:
- message explaining the supported algorithms
-
supports
public boolean supports(com.nimbusds.jose.JWSAlgorithm algorithm) Description copied from interface:SignatureConfiguration
Whether this signature configuration supports this algorithm.- Specified by:
supports
in interfaceSignatureConfiguration
- Parameters:
algorithm
- the signature algorithm- Returns:
- whether this signature configuration supports this algorithm
-
sign
public com.nimbusds.jwt.SignedJWT sign(com.nimbusds.jwt.JWTClaimsSet claims) throws com.nimbusds.jose.JOSEException Description copied from interface:SignatureGeneratorConfiguration
Generate a signed JWT based on claims.- Specified by:
sign
in interfaceSignatureGeneratorConfiguration
- Parameters:
claims
- the provided claims- Returns:
- the signed JWT
- Throws:
com.nimbusds.jose.JOSEException
- could be thrown while signing the JWT token
-
verify
public boolean verify(com.nimbusds.jwt.SignedJWT jwt) throws com.nimbusds.jose.JOSEException Description copied from interface:SignatureConfiguration
Verify a signed JWT.- Specified by:
verify
in interfaceSignatureConfiguration
- Parameters:
jwt
- the signed JWT- Returns:
- whether the signed JWT is verified
- Throws:
com.nimbusds.jose.JOSEException
- exception when verifying the JWT
-
getSecret
- Returns:
- a string build the secret byte[] and UTF_8 charset
-
setSecret
Sets secret byte[] with a string with UTF_8 charset.- Parameters:
secret
- UTF_8 string
-