public interface JwtReaderFactory
JwtReader.| Modifier and Type | Method and Description |
|---|---|
JwtReader |
getReader(String jwt)
Returns a jwt reader to be used for verifying tokens signed using a symmetric algorithm.
|
JwtReader |
getReader(String jwt,
Date date)
This method is similar to
getReader(String) but allows to specify the Date to be used
when operating with the time-based claims of the JWT message. |
JwtReader |
getReader(String jwt,
RSAPublicKey publicKey)
Returns a jwt reader that should be used for verifying tokens signed using an asymmetric algorithm.
|
JwtReader |
getReader(String jwt,
RSAPublicKey publicKey,
Date date)
This method is similar to
getReader(String, RSAPublicKey) but allows to specify the Date to be used
when operating with the time-based claims of the JWT message. |
@Nonnull JwtReader getReader(@Nonnull String jwt) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException, JwtIssuerLacksSharedSecretException
jwt - encoded JWT messageJwtReader for reading this JWT messageJwsUnsupportedAlgorithmException - if the JWT message's stated algorithm is not implementedJwtParseException - if the JWT message appears to be mangledJwtUnknownIssuerException - if the JWT message's "iss" claim value is not recognizedJwtIssuerLacksSharedSecretException - if the JWT message's algorithm requires a shared secret but the claimed issuer does not have one associated@Nonnull JwtReader getReader(@Nonnull String jwt, @Nonnull Date date) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException, JwtIssuerLacksSharedSecretException
getReader(String) but allows to specify the Date to be used
when operating with the time-based claims of the JWT message. This is useful when the JWT verification may happen
with a significant delay after the message containing that JWT has been consumed by a service e.g. due to queueing.jwt - encoded JWT messagedate - date to use when operating with time-based claims of the JWT message, useful for delayed JWT message verificationJwtReader for reading this JWT messageJwsUnsupportedAlgorithmException - if the JWT message's stated algorithm is not implementedJwtParseException - if the JWT message appears to be mangledJwtUnknownIssuerException - if the JWT message's "iss" claim value is not recognizedJwtIssuerLacksSharedSecretException - if the JWT message's algorithm requires a shared secret but the claimed issuer does not have one associated@Nonnull JwtReader getReader(@Nonnull String jwt, RSAPublicKey publicKey) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException
JwtParser jwtParser = new SimpleJwtParser(); // in practice, you may inject this rather than instantiating it like this
String issuer = jwtParser.parse(jwt).getIssuer();
RSAPublicKey publicKey = <retrieve public key for this issuer>
JwtReader jwtReader = jwtReaderFactory.getReader(jwt, publicKey);
return jwtReader.readAndVerify(jwt, Collections.<String, JwtClaimVerifier>emptyMap());
jwt - encoded JWT messagepublicKey - public key to use to verify jwt's signatureJwtReader for reading this JWT messageJwsUnsupportedAlgorithmException - if the JWT message's stated algorithm is not implementedJwtUnknownIssuerException - if the JWT message's "iss" claim value is not recognizedJwtParseException - if the JWT message appears to be mangled@Nonnull JwtReader getReader(@Nonnull String jwt, RSAPublicKey publicKey, @Nonnull Date date) throws JwsUnsupportedAlgorithmException, JwtUnknownIssuerException, JwtParseException
getReader(String, RSAPublicKey) but allows to specify the Date to be used
when operating with the time-based claims of the JWT message. This is useful when the JWT verification may happen
with a significant delay after the message containing that JWT has been consumed by a service e.g. due to queueing.jwt - encoded JWT messagepublicKey - public key to use to verify jwt's signaturedate - date to use when operating with time-based claims of the JWT message, useful for delayed JWT message verificationJwtReader for reading this JWT messageJwsUnsupportedAlgorithmException - if the JWT message's stated algorithm is not implementedJwtUnknownIssuerException - if the JWT message's "iss" claim value is not recognizedJwtParseException - if the JWT message appears to be mangledCopyright © 2023 Atlassian. All rights reserved.