Enum Class PBES2Algorithm

java.lang.Object
java.lang.Enum<PBES2Algorithm>
io.inverno.mod.security.jose.jwa.PBES2Algorithm
All Implemented Interfaces:
JWAAlgorithm<PBES2JWK>, Serializable, Comparable<PBES2Algorithm>, Constable

public enum PBES2Algorithm extends Enum<PBES2Algorithm> implements JWAAlgorithm<PBES2JWK>

Password-based encryption key management algorithms as defined by RFC7518.

Key Management algorithms:

  • PBES2-HS256+A128KW
  • PBES2-HS384+A192KW
  • PBES2-HS512+A256KW
Since:
1.5
Author:
Jeremy Kuhn
  • Enum Constant Details

  • Field Details

    • MINIMUM_SALT_LENGTH

      public static final int MINIMUM_SALT_LENGTH
      The minimum salt length.
      See Also:
    • DEFAULT_SALT_LENGTH

      public static final int DEFAULT_SALT_LENGTH
      The default salt length.
      See Also:
    • MINIMUM_ITERATION_COUNT

      public static final int MINIMUM_ITERATION_COUNT
      The minimum iteration count.
      See Also:
    • DEFAULT_ITERATION_COUNT

      public static final int DEFAULT_ITERATION_COUNT
      The default iteration count.
      See Also:
  • Method Details

    • values

      public static PBES2Algorithm[] 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 PBES2Algorithm 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 String getAlgorithm()
      Description copied from interface: JWAAlgorithm

      Returns the JWA registered name of the algorithm.

      Specified by:
      getAlgorithm in interface JWAAlgorithm<PBES2JWK>
      Returns:
      a JWA registered name
    • isSignature

      public boolean isSignature()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is a signature algorithm.

      Specified by:
      isSignature in interface JWAAlgorithm<PBES2JWK>
      Returns:
      true if the algorithm is a signature algorithm, false otherwise
    • isKeyManagement

      public boolean isKeyManagement()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is a key management algorithm.

      Specified by:
      isKeyManagement in interface JWAAlgorithm<PBES2JWK>
      Returns:
      true if the algorithm is a key management algorithm, false otherwise
    • isEncryption

      public boolean isEncryption()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is an encryption algorithm.

      Specified by:
      isEncryption in interface JWAAlgorithm<PBES2JWK>
      Returns:
      true if the algorithm is an encryption algorithm, false otherwise
    • createSigner

      public JWASigner createSigner(PBES2JWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a signer from the algorithm.

      Specified by:
      createSigner in interface JWAAlgorithm<PBES2JWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA signer
      Throws:
      JWAProcessingException - if the algorithm is not a signature algorithm or if there was an error creating the signer
    • createKeyManager

      public JWAKeyManager createKeyManager(PBES2JWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a key manager from the algorithm.

      Specified by:
      createKeyManager in interface JWAAlgorithm<PBES2JWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA key manager
      Throws:
      JWAProcessingException - if the algorithm is not a key management algorithm or if there was an error creating the key manager
    • createCipher

      public JWACipher createCipher(PBES2JWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a cipher from the algorithm.

      Specified by:
      createCipher in interface JWAAlgorithm<PBES2JWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA cipher
      Throws:
      JWAProcessingException - if the algorithm is not an encryption algorithm or if there was an error creating the cipher
    • getJcaAlgorithm

      public String getJcaAlgorithm()

      Return the JCA algorithm corresponding to the JWA algorithm.

      Returns:
      a JCA algorithm name
    • getJcaEncryptionAlgorithm

      public String getJcaEncryptionAlgorithm()

      Return the JCA encryption algorithm.

      Returns:
      a JCA algorithm name
    • getEncryptionKeyLength

      public int getEncryptionKeyLength()

      Returns the encryption key length in bytes.

      Returns:
      the encryption key length in bytes
    • fromAlgorithm

      public static PBES2Algorithm fromAlgorithm(String alg)

      Returns the password-based encryption key management algorithm corresponding to the specified JWA registered algorithm name.

      Parameters:
      alg - a JWA registered algorithm name
      Returns:
      a password-based encryption key management algorithm
      Throws:
      IllegalArgumentException - if the specified algorithm is not a PBES2 algorithm.