public final class JwtTokenHandler extends Object implements TokenHandler
Constructor and Description |
---|
JwtTokenHandler(JweAlgorithm jweAlgorithm,
EncryptionMethod jweMethod,
KeyPair jweKeyPair,
JwsAlgorithm jwsAlgorithm,
SigningHandler jwsHandler)
Constructs a new JWT token handler that never expires.
|
JwtTokenHandler(JweAlgorithm jweAlgorithm,
EncryptionMethod jweMethod,
KeyPair jweKeyPair,
JwsAlgorithm jwsAlgorithm,
SigningHandler jwsHandler,
Optional<Long> tokenLifeTimeInSeconds,
int tokenStatePaddingLength)
Constructs a new JWT token handler.
|
Modifier and Type | Method and Description |
---|---|
String |
generate(JsonValue state)
Generates a new token using the state.
|
void |
validate(String snapshotToken)
Validates the passed token.
|
JsonValue |
validateAndExtractState(String snapshotToken)
Validates and parses the token, extracting any encapsulated state.
|
public JwtTokenHandler(JweAlgorithm jweAlgorithm, EncryptionMethod jweMethod, KeyPair jweKeyPair, JwsAlgorithm jwsAlgorithm, SigningHandler jwsHandler)
jweAlgorithm
- the JWE algorithm use to construct the key pairjweMethod
- the encryption method to usejweKeyPair
- key pair for the purpose of encryptionjwsAlgorithm
- the JWS algorithm to usejwsHandler
- the signing handlerpublic JwtTokenHandler(JweAlgorithm jweAlgorithm, EncryptionMethod jweMethod, KeyPair jweKeyPair, JwsAlgorithm jwsAlgorithm, SigningHandler jwsHandler, Optional<Long> tokenLifeTimeInSeconds, int tokenStatePaddingLength)
jweAlgorithm
- the JWE algorithm use to construct the key pairjweMethod
- the encryption method to usejweKeyPair
- key pair for the purpose of encryptionjwsAlgorithm
- the JWS algorithm to usejwsHandler
- the signing handlertokenLifeTimeInSeconds
- token life time in secondstokenStatePaddingLength
- desired length of state claim after paddingpublic String generate(JsonValue state) throws TokenHandlerException
TokenHandler
generate
in interface TokenHandler
state
- the stateTokenHandlerException
- on failure to generate tokenpublic void validate(String snapshotToken) throws TokenHandlerException
TokenHandler
validate
in interface TokenHandler
snapshotToken
- the token to be validatedInvalidTokenException
- on invalid tokenExpiredTokenException
- on expired tokenTokenHandlerException
- on other failure to validate tokenpublic JsonValue validateAndExtractState(String snapshotToken) throws TokenHandlerException
TokenHandler
validateAndExtractState
in interface TokenHandler
snapshotToken
- the token to be validated and parsedInvalidTokenException
- on invalid tokenExpiredTokenException
- on expired tokenTokenHandlerException
- on other failure to validate or extract tokenCopyright 2010-2022 ForgeRock AS.