Package uk.co.spudsoft.jwtvalidatorvertx
Interface JwtValidatorVertx
- All Known Implementing Classes:
JwtValidatorVertxImpl
public interface JwtValidatorVertx
Validate JWTs, obtaining keys via OpenID Discovery is necessary.
- Author:
- jtalbut
-
Method Summary
Modifier and TypeMethodDescriptionaddPermittedAlgorithm
(JsonWebAlgorithm algorithm) Add a single algorithm to the current set of permitted algorithms.static JwtValidatorVertx
create
(io.vertx.core.Vertx vertx, Collection<String> acceptableIssuerRegexes, Duration defaultJwkCacheDuration) Create a JwtValidatorVertx.Get a copy of the current set of permitted algorithms.setPermittedAlgorithms
(EnumSet<JsonWebAlgorithm> 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.setTimeLeewaySeconds
(long timeLeewaySeconds) Set the maximum amount of time that can pass between the exp and now.io.vertx.core.Future<JWT>
validateToken
(String token, List<String> requiredAudList, boolean ignoreRequiredAud) Validate the token and either throw an exception or return it's constituent parts.
-
Method Details
-
create
static JwtValidatorVertx create(io.vertx.core.Vertx vertx, Collection<String> acceptableIssuerRegexes, Duration defaultJwkCacheDuration) Create a JwtValidatorVertx.- Parameters:
vertx
- The Vertx instance that will be used for asynchronous communication with JWKS endpoints.acceptableIssuerRegexes
- List of acceptable issuers.defaultJwkCacheDuration
- Time to keep JWKs in cache if no cache-control: max-age header is found.- Returns:
- A newly created JwtValidatorVertx.
-
getPermittedAlgorithms
EnumSet<JsonWebAlgorithm> getPermittedAlgorithms()Get a copy of the current set of permitted algorithms.- Returns:
- a copy of the current set of permitted algorithms.
-
setPermittedAlgorithms
Replace the current set of permitted algorithms with a new set.- Parameters:
algorithms
- The new set of permitted algorithms.- Returns:
- this for fluent configuration.
-
addPermittedAlgorithm
Add a single algorithm to the current set of permitted algorithms.- Parameters:
algorithm
- The algorithm to add to the current set of permitted algorithms.- Returns:
- this for fluent configuration.
-
setRequireExp
Set to true if the token is required to have an exp claim.- 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.- Parameters:
requireNbf
- true if the token is required to have an nbf claim.- Returns:
- this for fluent configuration.
-
setTimeLeewaySeconds
Set the maximum amount of time that can pass between the exp and now.- Parameters:
timeLeewaySeconds
- the maximum amount of time that can pass between the exp and now.- Returns:
- this for fluent configuration.
-
validateToken
io.vertx.core.Future<JWT> validateToken(String token, List<String> requiredAudList, boolean ignoreRequiredAud) Validate the token and either throw an exception or return it's constituent parts.- Parameters:
token
- The token.requiredAudList
- List of audiences, all of which must be claimed by the token.ignoreRequiredAud
- Do not check for required audiences.- Returns:
- The token's parts.
-