Package net.jsign
Enum DigestAlgorithm
- java.lang.Object
-
- java.lang.Enum<DigestAlgorithm>
-
- net.jsign.DigestAlgorithm
-
- All Implemented Interfaces:
Serializable
,Comparable<DigestAlgorithm>
public enum DigestAlgorithm extends Enum<DigestAlgorithm>
Digest algorithm.- Since:
- 1.3
- Author:
- Florent Daigniere
-
-
Field Summary
Fields Modifier and Type Field Description String
id
The JCE name of the algorithmASN1ObjectIdentifier
oid
The object identifier of the algorithm
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DigestAlgorithm
getDefault()
Return the default algorithm (currently SHA-256, SHA-1 has been deprecated since January 1st 2016).MessageDigest
getMessageDigest()
Return a MessageDigest for this algorithm.static DigestAlgorithm
of(String name)
Parse the specified value and returns the corresponding digest algorithm.static DigestAlgorithm
of(ASN1ObjectIdentifier oid)
Return the algorithm matching the specified object identifier.static DigestAlgorithm
valueOf(String name)
Returns the enum constant of this type with the specified name.static DigestAlgorithm[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
MD5
public static final DigestAlgorithm MD5
-
SHA1
public static final DigestAlgorithm SHA1
-
SHA256
public static final DigestAlgorithm SHA256
-
SHA384
public static final DigestAlgorithm SHA384
-
SHA512
public static final DigestAlgorithm SHA512
-
-
Field Detail
-
oid
public final ASN1ObjectIdentifier oid
The object identifier of the algorithm
-
-
Method Detail
-
values
public static DigestAlgorithm[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DigestAlgorithm c : DigestAlgorithm.values()) System.out.println(c);
- 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 nameNullPointerException
- if the argument is null
-
of
public static DigestAlgorithm of(String name)
Parse the specified value and returns the corresponding digest algorithm. This method is more permissive thanvalueOf(String)
, it's case insensitive and ignores hyphens.- Parameters:
name
- the name of the digest algorithm- Returns:
- the digest algorithm, or
null
if the name specified doesn't match any supported algorithm
-
of
public static DigestAlgorithm of(ASN1ObjectIdentifier oid)
Return the algorithm matching the specified object identifier.- Parameters:
oid
- the ASN.1 object identifier of the algorithm- Returns:
- the digest algorithm, or
null
if none matches the specified oid
-
getMessageDigest
public MessageDigest getMessageDigest()
Return a MessageDigest for this algorithm.- Returns:
- a MessageDigest for this algorithm
-
getDefault
public static DigestAlgorithm getDefault()
Return the default algorithm (currently SHA-256, SHA-1 has been deprecated since January 1st 2016).- Returns:
- the default algorithm (
SHA256
) - See Also:
- Windows Root Certificate Program - Technical Requirements version 2.0, Common Questions about SHA2 and Windows
-
-