public enum ScramMechanisms extends java.lang.Enum<ScramMechanisms> implements ScramMechanism
MessageDigest: "Every implementation of the Java platform is required to support the
following standard MessageDigest algorithms: MD5, SHA-1, SHA-256".
Mac: "Every implementation of the Java platform is required to support the following
standard Mac algorithms: HmacMD5, HmacSHA1, HmacSHA256".| Enum Constant and Description |
|---|
SCRAM_SHA_1 |
SCRAM_SHA_1_PLUS |
SCRAM_SHA_256 |
SCRAM_SHA_256_PLUS |
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<java.lang.String,ScramMechanisms> |
BY_NAME_MAPPING |
private static java.lang.String |
CHANNEL_BINDING_SUFFIX |
private boolean |
channelBinding |
private java.lang.String |
hashAlgorithmName |
private java.lang.String |
hmacAlgorithmName |
private int |
keyLength |
private java.lang.String |
mechanismName |
private static java.lang.String |
PBKDF2_PREFIX_ALGORITHM_NAME |
private int |
priority |
private static java.lang.String |
SCRAM_MECHANISM_NAME_PREFIX |
| Modifier and Type | Method and Description |
|---|---|
int |
algorithmKeyLength()
Returns the length of the key length of the algorithm.
|
static java.util.Optional<ScramMechanisms> |
byName(java.lang.String name)
Gets a SCRAM mechanism, given its standard IANA name.
|
protected java.lang.String |
getHashAlgorithmName()
Method that returns the name of the hash algorithm.
|
protected java.lang.String |
getHmacAlgorithmName()
Method that returns the name of the HMAC algorithm.
|
javax.crypto.Mac |
getMacInstance()
Gets a constructed
Mac instance, according to the algorithm of the SCRAM mechanism. |
java.security.MessageDigest |
getMessageDigestInstance()
Gets a constructed
MessageDigest instance, according to the algorithm of the SCRAM mechanism. |
java.lang.String |
getName()
The name of the mechanism, which must be a value registered under IANA:
SASL SCRAM Family Mechanisms
|
javax.crypto.SecretKeyFactory |
secretKeyFactory()
Gets a SecretKeyFactory for the given algorithm.
|
javax.crypto.spec.SecretKeySpec |
secretKeySpec(byte[] key)
Generates a key of the algorith used, based on the key given.
|
static java.util.Optional<ScramMechanism> |
selectMatchingMechanism(boolean channelBinding,
java.lang.String... peerMechanisms)
This class classifies SCRAM mechanisms by two properties: whether they support channel binding;
and a priority, which is higher for safer algorithms (like SHA-256 vs SHA-1).
|
boolean |
supportsChannelBinding()
Whether this mechanism supports channel binding
|
static ScramMechanisms |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ScramMechanisms[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ScramMechanisms SCRAM_SHA_1
public static final ScramMechanisms SCRAM_SHA_1_PLUS
public static final ScramMechanisms SCRAM_SHA_256
public static final ScramMechanisms SCRAM_SHA_256_PLUS
private static final java.lang.String SCRAM_MECHANISM_NAME_PREFIX
private static final java.lang.String CHANNEL_BINDING_SUFFIX
private static final java.lang.String PBKDF2_PREFIX_ALGORITHM_NAME
private static final java.util.Map<java.lang.String,ScramMechanisms> BY_NAME_MAPPING
private final java.lang.String mechanismName
private final java.lang.String hashAlgorithmName
private final int keyLength
private final java.lang.String hmacAlgorithmName
private final boolean channelBinding
private final int priority
public static ScramMechanisms[] values()
for (ScramMechanisms c : ScramMechanisms.values()) System.out.println(c);
public static ScramMechanisms valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullprotected java.lang.String getHashAlgorithmName()
protected java.lang.String getHmacAlgorithmName()
public java.lang.String getName()
ScramMechanismgetName in interface ScramMechanismpublic boolean supportsChannelBinding()
ScramMechanismsupportsChannelBinding in interface ScramMechanismpublic java.security.MessageDigest getMessageDigestInstance()
ScramMechanismMessageDigest instance, according to the algorithm of the SCRAM mechanism.getMessageDigestInstance in interface ScramMechanismpublic javax.crypto.Mac getMacInstance()
ScramMechanismMac instance, according to the algorithm of the SCRAM mechanism.getMacInstance in interface ScramMechanismpublic javax.crypto.spec.SecretKeySpec secretKeySpec(byte[] key)
ScramMechanismsecretKeySpec in interface ScramMechanismkey - The bytes of the key to usepublic javax.crypto.SecretKeyFactory secretKeyFactory()
ScramMechanismsecretKeyFactory in interface ScramMechanismpublic int algorithmKeyLength()
ScramMechanismalgorithmKeyLength in interface ScramMechanismpublic static java.util.Optional<ScramMechanisms> byName(java.lang.String name)
name - The standard IANA full name of the mechanism.public static java.util.Optional<ScramMechanism> selectMatchingMechanism(boolean channelBinding, java.lang.String... peerMechanisms)
channelBinding - The type of matching mechanism searched forpeerMechanisms - The mechanisms supported by the other peer