Enum Class JwtAlgorithm

java.lang.Object
java.lang.Enum<JwtAlgorithm>
tech.lastbox.jwt.JwtAlgorithm
All Implemented Interfaces:
Serializable, Comparable<JwtAlgorithm>, Constable

public enum JwtAlgorithm extends Enum<JwtAlgorithm>
Enum representing the different JWT signing algorithms. This enum provides various HMAC (Hash-based Message Authentication Code) algorithms for signing JSON Web Tokens (JWTs).

Each constant in this enum represents a different HMAC algorithm variant (HMAC256, HMAC384, HMAC512). The corresponding algorithm can be obtained by providing a secret key, which will be used to create a JWT signature.

  • Enum Constant Details

    • HMAC256

      public static final JwtAlgorithm HMAC256
      HMAC256 algorithm for signing JWTs using a 256-bit key.
    • HMAC384

      public static final JwtAlgorithm HMAC384
      HMAC384 algorithm for signing JWTs using a 384-bit key.
    • HMAC512

      public static final JwtAlgorithm HMAC512
      HMAC512 algorithm for signing JWTs using a 512-bit key.
  • Method Details

    • values

      public static JwtAlgorithm[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JwtAlgorithm valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getAlgorithm

      public abstract com.auth0.jwt.algorithms.Algorithm getAlgorithm(String secretKey)
      Abstract method that must be implemented by each constant to return the corresponding Algorithm instance using the provided secret key.
      Parameters:
      secretKey - the secret key to be used for signing the JWT.
      Returns:
      the Algorithm instance corresponding to the selected HMAC variant.