Enum Class OCTAlgorithm

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

public enum OCTAlgorithm extends Enum<OCTAlgorithm> implements JWAAlgorithm<OCTJWK>

Octect symmetric algorithms as defined by RFC7518.

Signature algorithms:

  • HS256
  • HS384
  • HS512

Key Management algorithms:

  • A128KW
  • A256KW
  • A512KW
  • A128GCMKW
  • A192GCMKW
  • A256GCMKW

Encryption algorithms:

  • A128GCM
  • A192GCM
  • A256GCM
  • A128CBC-HS256
  • A192CBC-HS384
  • A256CBC-HS512
Since:
1.5
Author:
Jeremy Kuhn
  • Enum Constant Details

  • Method Details

    • values

      public static OCTAlgorithm[] 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 OCTAlgorithm 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<OCTJWK>
      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<OCTJWK>
      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<OCTJWK>
      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<OCTJWK>
      Returns:
      true if the algorithm is an encryption algorithm, false otherwise
    • createSigner

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

      Creates a signer from the algorithm.

      Specified by:
      createSigner in interface JWAAlgorithm<OCTJWK>
      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(OCTJWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a key manager from the algorithm.

      Specified by:
      createKeyManager in interface JWAAlgorithm<OCTJWK>
      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(OCTJWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a cipher from the algorithm.

      Specified by:
      createCipher in interface JWAAlgorithm<OCTJWK>
      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
    • getEncryptionKeyLength

      public int getEncryptionKeyLength()

      Returns the encryption key length in bytes.

      Returns:
      the encryption key length in bytes
    • getInitializationVectorLength

      public Integer getInitializationVectorLength()

      Returns the initialization vector length in bytes.

      Note that this only applies to encryption algorithms.

      Returns:
      the initialization vector key length in bytes or null
    • getAuthenticationTagLength

      public Integer getAuthenticationTagLength()

      Returns the authentication tag length in bytes.

      Note that this only applies to encryption algorithms.

      Returns:
      the authentication tag key length in bytes or null
    • getMacAlgorithm

      public String getMacAlgorithm()

      Return the JCA Mac algorithm.

      Note that this only applies to algorithms where a MAC is computed.

      Returns:
      a JCA Mac algorithm or null
    • getMacKeyLength

      public Integer getMacKeyLength()

      Return the Mac key length in bytes.

      Note that this only applies to algorithms where a MAC is computed.

      Returns:
      a Mac key length in bytes
    • fromAlgorithm

      public static OCTAlgorithm fromAlgorithm(String alg) throws IllegalArgumentException

      Returns the Octet symmetric algorithm corresponding to the specified JWA registered algorithm name.

      Parameters:
      alg - a JWA registered algorithm name
      Returns:
      an octet symmetric algorithm
      Throws:
      IllegalArgumentException - if the specified algorithm is not an OCT algorithm.