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 ScramMechanisms |
byName(java.lang.String name)
Gets a SCRAM mechanism, given its standard IANA name.
|
byte[] |
digest(byte[] message)
Calculate a message digest, according to the algorithm of the SCRAM mechanism.
|
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.
|
java.lang.String |
getName()
The name of the mechanism, which must be a value registered under IANA:
SASL SCRAM Family Mechanisms
|
byte[] |
hmac(byte[] key,
byte[] message)
Calculate the hmac of a key and a message, according to the algorithm of the SCRAM mechanism.
|
byte[] |
saltedPassword(StringPreparation stringPreparation,
java.lang.String password,
byte[] salt,
int iterations)
Compute the salted password
|
static 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.
|
private static java.util.Map<java.lang.String,ScramMechanisms> |
valuesAsMap() |
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 int algorithmKeyLength()
ScramMechanismalgorithmKeyLength in interface ScramMechanismpublic byte[] digest(byte[] message)
ScramMechanismdigest in interface ScramMechanismmessage - the messagepublic byte[] hmac(byte[] key,
byte[] message)
ScramMechanismhmac in interface ScramMechanismkey - the keymessage - the messagepublic byte[] saltedPassword(StringPreparation stringPreparation, java.lang.String password, byte[] salt, int iterations)
ScramMechanismsaltedPassword in interface ScramMechanismpublic static ScramMechanisms byName(java.lang.String name)
name - The standard IANA full name of the mechanism.public static ScramMechanism selectMatchingMechanism(boolean channelBinding, java.lang.String... peerMechanisms)
channelBinding - The type of matching mechanism searched forpeerMechanisms - The mechanisms supported by the other peerprivate static java.util.Map<java.lang.String,ScramMechanisms> valuesAsMap()