public enum ScramMechanisms extends 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 | Method and Description |
---|---|
int |
algorithmKeyLength()
Returns the length of the key length of the algorithm.
|
static Optional<ScramMechanisms> |
byName(String name)
Gets a SCRAM mechanism, given its standard IANA name.
|
protected String |
getHashAlgorithmName()
Method that returns the name of the hash algorithm.
|
protected String |
getHmacAlgorithmName()
Method that returns the name of the HMAC algorithm.
|
Mac |
getMacInstance()
Gets a constructed
Mac instance, according to the algorithm of the SCRAM mechanism. |
MessageDigest |
getMessageDigestInstance()
Gets a constructed
MessageDigest instance, according to the algorithm of the SCRAM mechanism. |
String |
getName()
The name of the mechanism, which must be a value registered under IANA:
SASL SCRAM Family Mechanisms
|
SecretKeyFactory |
secretKeyFactory()
Gets a SecretKeyFactory for the given algorithm.
|
SecretKeySpec |
secretKeySpec(byte[] key)
Generates a key of the algorith used, based on the key given.
|
static Optional<ScramMechanism> |
selectMatchingMechanism(boolean channelBinding,
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(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
public static ScramMechanisms[] values()
for (ScramMechanisms c : ScramMechanisms.values()) System.out.println(c);
public static ScramMechanisms valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullprotected String getHashAlgorithmName()
protected String getHmacAlgorithmName()
public String getName()
ScramMechanism
getName
in interface ScramMechanism
public boolean supportsChannelBinding()
ScramMechanism
supportsChannelBinding
in interface ScramMechanism
public MessageDigest getMessageDigestInstance()
ScramMechanism
MessageDigest
instance, according to the algorithm of the SCRAM mechanism.getMessageDigestInstance
in interface ScramMechanism
public Mac getMacInstance()
ScramMechanism
Mac
instance, according to the algorithm of the SCRAM mechanism.getMacInstance
in interface ScramMechanism
public SecretKeySpec secretKeySpec(byte[] key)
ScramMechanism
secretKeySpec
in interface ScramMechanism
key
- The bytes of the key to usepublic SecretKeyFactory secretKeyFactory()
ScramMechanism
secretKeyFactory
in interface ScramMechanism
public int algorithmKeyLength()
ScramMechanism
algorithmKeyLength
in interface ScramMechanism
public static Optional<ScramMechanisms> byName(String name)
name
- The standard IANA full name of the mechanism.public static Optional<ScramMechanism> selectMatchingMechanism(boolean channelBinding, String... peerMechanisms)
channelBinding
- The type of matching mechanism searched forpeerMechanisms
- The mechanisms supported by the other peerCopyright © 2017–2020. All rights reserved.