Class HMACVerifier

java.lang.Object
io.fusionauth.jwt.hmac.HMACVerifier
All Implemented Interfaces:
Verifier

public class HMACVerifier extends Object implements Verifier
This class is used to verify a JWT signed with an HMAC algorithm.
Author:
Daniel DeGroff
  • Method Details

    • newVerifier

      public static HMACVerifier newVerifier(String secret)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      secret - The secret.
      Returns:
      a new instance of the HMAC verifier.
    • newVerifier

      public static HMACVerifier newVerifier(Path path)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      path - The path to the secret.
      Returns:
      a new instance of the HMAC verifier.
    • newVerifier

      public static HMACVerifier newVerifier(byte[] bytes)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      bytes - The bytes of the secret.
      Returns:
      a new instance of the HMAC verifier.
    • newVerifier

      public static HMACVerifier newVerifier(String secret, CryptoProvider cryptoProvider)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      secret - The secret.
      cryptoProvider - The crypto provider used to get the MAC digest algorithm.
      Returns:
      a new instance of the HMAC verifier.
    • newVerifier

      public static HMACVerifier newVerifier(Path path, CryptoProvider cryptoProvider)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      path - The path to the secret.
      cryptoProvider - The crypto provider used to get the MAC digest algorithm.
      Returns:
      a new instance of the HMAC verifier.
    • newVerifier

      public static HMACVerifier newVerifier(byte[] bytes, CryptoProvider cryptoProvider)
      Return a new instance of the HMAC Verifier with the provided secret.
      Parameters:
      bytes - The bytes of the secret.
      cryptoProvider - The crypto provider used to get the MAC digest algorithm.
      Returns:
      a new instance of the HMAC verifier.
    • canVerify

      public boolean canVerify(Algorithm algorithm)
      Specified by:
      canVerify in interface Verifier
      Parameters:
      algorithm - The algorithm required to verify the signature on this JWT.
      Returns:
      True if this Verifier is able to verify a signature using the specified algorithm.
    • verify

      public void verify(Algorithm algorithm, byte[] message, byte[] signature)
      Description copied from interface: Verifier
      Verify the signature of the encoded JWT payload.
      Specified by:
      verify in interface Verifier
      Parameters:
      algorithm - The algorithm used to verify the JWT signature.
      message - The JWT message. The header and claims, the first two segments of the dot separated JWT.
      signature - The signature to verify.