Package com.helger.security.mac
Enum EMacAlgorithm
- java.lang.Object
-
- java.lang.Enum<EMacAlgorithm>
-
- com.helger.security.mac.EMacAlgorithm
-
- All Implemented Interfaces:
Serializable,Comparable<EMacAlgorithm>
public enum EMacAlgorithm extends Enum<EMacAlgorithm>
A selection of common hash algorithms.- Author:
- Philip Helger
-
-
Enum Constant Summary
Enum Constants Enum Constant Description HMAC_MD5HMAC_SHA1HMAC_SHA224HMAC_SHA256HMAC_SHA384HMAC_SHA512
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MaccreateMac()MaccreateMac(Provider aSecurityProvider)SecretKeySpeccreateSecretKey(byte[] aKey)Create a newSecretKeySpecwith this algorithm and the provided key bytes.StringgetAlgorithm()static EMacAlgorithmgetFromStringIgnoreCase(String sAlgorithm)static EMacAlgorithmvalueOf(String name)Returns the enum constant of this type with the specified name.static EMacAlgorithm[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
HMAC_MD5
public static final EMacAlgorithm HMAC_MD5
-
HMAC_SHA1
public static final EMacAlgorithm HMAC_SHA1
-
HMAC_SHA224
public static final EMacAlgorithm HMAC_SHA224
-
HMAC_SHA256
public static final EMacAlgorithm HMAC_SHA256
-
HMAC_SHA384
public static final EMacAlgorithm HMAC_SHA384
-
HMAC_SHA512
public static final EMacAlgorithm HMAC_SHA512
-
-
Method Detail
-
values
public static EMacAlgorithm[] 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 (EMacAlgorithm c : EMacAlgorithm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EMacAlgorithm 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
-
getAlgorithm
@Nonnull @Nonempty public String getAlgorithm()
- Returns:
- The internal name of the message digest algorithm. Neither
nullnor empty.
-
createMac
@Nonnull public Mac createMac()
- Returns:
- A new Mac with this algorithm using the default security provider.
- Throws:
IllegalStateException- If this algorithm is not supported by this Java runtime.
-
createMac
@Nonnull public Mac createMac(@Nullable Provider aSecurityProvider)
- Parameters:
aSecurityProvider- The security provider to use. May benullto use the default security provider.- Returns:
- A new Mac with this algorithm using the provided or the default security provider.
- Throws:
IllegalStateException- If this algorithm is not supported by this Java runtime.
-
createSecretKey
@Nonnull public SecretKeySpec createSecretKey(@Nonnull byte[] aKey)
Create a newSecretKeySpecwith this algorithm and the provided key bytes.- Parameters:
aKey- The key bytes to use. May not benull.- Returns:
- The new
SecretKeySpec.
-
getFromStringIgnoreCase
@Nullable public static EMacAlgorithm getFromStringIgnoreCase(@Nullable String sAlgorithm)
-
-