Class JwtValidatorVertxImpl

java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.impl.JwtValidatorVertxImpl
All Implemented Interfaces:
JwtValidator

public class JwtValidatorVertxImpl extends Object implements JwtValidator
Token validation for vertx - implementation of JwtValidator.
Author:
Jim Talbut
  • Constructor Details

    • JwtValidatorVertxImpl

      public JwtValidatorVertxImpl(JsonWebKeySetHandler jsonWebKeySetHandler, IssuerAcceptabilityHandler issuerAcceptabilityHandler)
      Constructor.
      Parameters:
      jsonWebKeySetHandler - Handler for obtaining JWKs
      issuerAcceptabilityHandler - Handler for validating issuers found in the JWT.
  • Method Details

    • getPermittedAlgorithms

      public Set<String> getPermittedAlgorithms()
      Description copied from interface: JwtValidator
      Get a copy of the current set of permitted algorithms.
      Specified by:
      getPermittedAlgorithms in interface JwtValidator
      Returns:
      a copy of the current set of permitted algorithms.
    • setPermittedAlgorithms

      public JwtValidator setPermittedAlgorithms(Set<String> algorithms) throws NoSuchAlgorithmException
      Description copied from interface: JwtValidator
      Replace the current set of permitted algorithms with a new set.
      Specified by:
      setPermittedAlgorithms in interface JwtValidator
      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

      public JwtValidator addPermittedAlgorithm(String algorithm) throws NoSuchAlgorithmException
      Description copied from interface: JwtValidator
      Add a single algorithm to the current set of permitted algorithms.
      Specified by:
      addPermittedAlgorithm in interface JwtValidator
      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

      public JwtValidator setTimeLeeway(Duration timeLeeway)
      Set the maximum amount of time that can pass between the exp and now.
      Specified by:
      setTimeLeeway in interface JwtValidator
      Parameters:
      timeLeeway - the maximum amount of time that can pass between the exp and now.
      Returns:
      this for fluent configuration.
    • setRequireExp

      public JwtValidator setRequireExp(boolean requireExp)
      Set to true if the token is required to have an exp claim.
      Specified by:
      setRequireExp in interface JwtValidator
      Parameters:
      requireExp - true if the token is required to have an exp claim.
      Returns:
      this for fluent configuration.
    • setRequireNbf

      public JwtValidator setRequireNbf(boolean requireNbf)
      Set to true if the token is required to have an nbf claim.
      Specified by:
      setRequireNbf in interface JwtValidator
      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 interface JwtValidator
      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.