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
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
Constructors Constructor Description SecretSignature(SecretSignatureConfiguration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getSecret()
void
setSecret(java.lang.String secret)
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.java.lang.String
supportedAlgorithmsMessage()
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 Detail
-
SecretSignature
public SecretSignature(SecretSignatureConfiguration config)
- Parameters:
config
-SecretSignatureConfiguration
configuration
-
-
Method Detail
-
supportedAlgorithmsMessage
public java.lang.String 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
public java.lang.String getSecret()
- Returns:
- a string build the secret byte[] and UTF_8 charset
-
setSecret
public void setSecret(java.lang.String secret)
Sets secret byte[] with a string with UTF_8 charset.- Parameters:
secret
- UTF_8 string
-
-