Class JwtValidatorVertxImpl
java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.impl.JwtValidatorVertxImpl
- All Implemented Interfaces:
JwtValidator
Token validation for vertx - implementation of
JwtValidator
.- Author:
- Jim Talbut
-
Constructor Summary
ConstructorsConstructorDescriptionJwtValidatorVertxImpl
(JsonWebKeySetHandler jsonWebKeySetHandler, IssuerAcceptabilityHandler issuerAcceptabilityHandler) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddPermittedAlgorithm
(String algorithm) Add a single algorithm to the current set of permitted algorithms.Get a copy of the current set of permitted algorithms.setPermittedAlgorithms
(Set<String> algorithms) Replace the current set of permitted algorithms with a new set.setRequireExp
(boolean requireExp) Set to true if the token is required to have an exp claim.setRequireNbf
(boolean requireNbf) Set to true if the token is required to have an nbf claim.setTimeLeeway
(Duration timeLeeway) Set the maximum amount of time that can pass between the exp and now.io.vertx.core.Future
<Jwt> validateToken
(String issuer, String token, List<String> requiredAudList, boolean ignoreRequiredAud) Validate the token and either throw an exception or return it's constituent parts.
-
Constructor Details
-
JwtValidatorVertxImpl
public JwtValidatorVertxImpl(JsonWebKeySetHandler jsonWebKeySetHandler, IssuerAcceptabilityHandler issuerAcceptabilityHandler) Constructor.- Parameters:
jsonWebKeySetHandler
- Handler for obtaining JWKsissuerAcceptabilityHandler
- Handler for validating issuers found in the JWT.
-
-
Method Details
-
getPermittedAlgorithms
Description copied from interface:JwtValidator
Get a copy of the current set of permitted algorithms.- Specified by:
getPermittedAlgorithms
in interfaceJwtValidator
- Returns:
- a copy of the current set of permitted algorithms.
-
setPermittedAlgorithms
Description copied from interface:JwtValidator
Replace the current set of permitted algorithms with a new set.- Specified by:
setPermittedAlgorithms
in interfaceJwtValidator
- Parameters:
algorithms
- The new set of permitted algorithms.- Returns:
- this for fluent configuration.
- Throws:
NoSuchAlgorithmException
- if any of the algorithms passed in are not recognised.
-
addPermittedAlgorithm
Description copied from interface:JwtValidator
Add a single algorithm to the current set of permitted algorithms.- Specified by:
addPermittedAlgorithm
in interfaceJwtValidator
- Parameters:
algorithm
- The algorithm to add to the current set of permitted algorithms.- Returns:
- this for fluent configuration.
- Throws:
NoSuchAlgorithmException
- if the algorithm passed is not recognised.
-
setTimeLeeway
Set the maximum amount of time that can pass between the exp and now.- Specified by:
setTimeLeeway
in interfaceJwtValidator
- Parameters:
timeLeeway
- the maximum amount of time that can pass between the exp and now.- Returns:
- this for fluent configuration.
-
setRequireExp
Set to true if the token is required to have an exp claim.- Specified by:
setRequireExp
in interfaceJwtValidator
- Parameters:
requireExp
- true if the token is required to have an exp claim.- Returns:
- this for fluent configuration.
-
setRequireNbf
Set to true if the token is required to have an nbf claim.- Specified by:
setRequireNbf
in interfaceJwtValidator
- Parameters:
requireNbf
- true if the token is required to have an nbf claim.- Returns:
- this for fluent configuration.
-
validateToken
public io.vertx.core.Future<Jwt> validateToken(String issuer, String token, List<String> requiredAudList, boolean ignoreRequiredAud) Validate the token and either throw an exception or return it's constituent parts.- Specified by:
validateToken
in interfaceJwtValidator
- Parameters:
issuer
- The token issuer.token
- The token.requiredAudList
- List of audiences, all of which must be claimed by the token. If null the defaultRequiredAud is used.ignoreRequiredAud
- Do not check for required audiences.- Returns:
- The token's parts.
-