Enum DigestAlgorithm

java.lang.Object
java.lang.Enum<DigestAlgorithm>
eu.europa.esig.dss.enumerations.DigestAlgorithm
All Implemented Interfaces:
OidAndUriBasedEnum, OidBasedEnum, UriBasedEnum, Serializable, Comparable<DigestAlgorithm>

public enum DigestAlgorithm extends Enum<DigestAlgorithm> implements OidAndUriBasedEnum
Supported Algorithms
  • Enum Constant Details

  • Method Details

    • values

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

      public static DigestAlgorithm valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • forName

      public static DigestAlgorithm forName(String name)
      Returns the digest algorithm associated to the given name.
      Parameters:
      name - the algorithm name
      Returns:
      the digest algorithm linked to the given name
      Throws:
      IllegalArgumentException - if the given name doesn't match any algorithm
    • forName

      public static DigestAlgorithm forName(String name, DigestAlgorithm defaultValue)
      Returns the digest algorithm associated to the given name.
      Parameters:
      name - the algorithm name
      defaultValue - The default value for the DigestAlgorithm
      Returns:
      the corresponding DigestAlgorithm or the default value
    • isSupportedAlgorithm

      public static boolean isSupportedAlgorithm(String name)
      Returns indication if the algorithm with given name is supported
      Parameters:
      name - String target algorithm's name
      Returns:
      TRUE if the algorithm is supported, FALSE otherwise
    • forJavaName

      public static DigestAlgorithm forJavaName(String javaName)
      Returns the digest algorithm associated to the given JCE name.
      Parameters:
      javaName - the JCE algorithm name
      Returns:
      the digest algorithm linked to the given name
      Throws:
      IllegalArgumentException - if the given name doesn't match any algorithm
    • forOID

      public static DigestAlgorithm forOID(String oid)
      Returns the digest algorithm associated to the given OID.
      Parameters:
      oid - the algorithm oid
      Returns:
      the digest algorithm linked to the oid
      Throws:
      IllegalArgumentException - if the oid doesn't match any digest algorithm
    • forXML

      public static DigestAlgorithm forXML(String xmlName)
      Returns the digest algorithm associated to the given XML url.
      Parameters:
      xmlName - the algorithm uri
      Returns:
      the digest algorithm linked to the given uri
      Throws:
      IllegalArgumentException - if the uri doesn't match any digest algorithm
    • forJAdES

      public static DigestAlgorithm forJAdES(String algoId)
      Returns the digest algorithm associated with the given identifier, according to TS 119 182-1, Annex E (Digest algorithms identifiers for JAdES signatures)
      Parameters:
      algoId - String JAdES algorithm identifier
      Returns:
      the digest algorithm linked to the given identifier
      Throws:
      IllegalArgumentException - if the name doesn't match any digest algorithm
    • forHttpHeader

      public static DigestAlgorithm forHttpHeader(String hashName)
      Returns the digest algorithm associated to the given JWS Http Header Hash Algorithm. See RFC 5843.
      Parameters:
      hashName - the algorithm name by RFC 5843
      Returns:
      the digest algorithm linked to the given name
      Throws:
      IllegalArgumentException - if the name doesn't match any digest algorithm
    • getName

      public String getName()
      Get the algorithm name
      Returns:
      the algorithm name
    • getJavaName

      public String getJavaName()
      Get the JCE algorithm name
      Returns:
      the java algorithm name
    • getOid

      public String getOid()
      Get the algorithm OID
      Specified by:
      getOid in interface OidBasedEnum
      Returns:
      the ASN1 algorithm OID
    • getUri

      public String getUri()
      Get the algorithm uri
      Specified by:
      getUri in interface UriBasedEnum
      Returns:
      the algorithm uri
    • getJAdESId

      public String getJAdESId()
      Get the algorithm id used in JAdES Signatures. TS 119-182 Annex E (normative): Digest algorithms identifiers for JAdES signatures
      Returns:
      the algorithm JAdES identifier
    • getHttpHeaderAlgo

      public String getHttpHeaderAlgo()
      Get the algorithm name according to RFC 5843
      Returns:
      the algorithm name
    • getSaltLength

      public int getSaltLength()
      Get the salt length (PSS)
      Returns:
      the salt length
    • getMessageDigest

      public MessageDigest getMessageDigest() throws NoSuchAlgorithmException
      Get a new instance of MessageDigest for the current digestAlgorithm
      Returns:
      an instance of MessageDigest
      Throws:
      NoSuchAlgorithmException - if the algorithm is not supported
    • getMessageDigest

      public MessageDigest getMessageDigest(Provider provider) throws NoSuchAlgorithmException
      Get a new instance of MessageDigest for the current digestAlgorithm
      Parameters:
      provider - the security provider to be used
      Returns:
      an instance of MessageDigest
      Throws:
      NoSuchAlgorithmException - if the algorithm is not supported