Class MessageDigestPassword.Encoder
- All Implemented Interfaces:
Password.Encoder<MessageDigestPassword,
MessageDigestPassword.Encoder>
- Enclosing class:
MessageDigestPassword
A MessageDigest
based password encoder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default algorithm:SHA-512
.static final int
The default salt length in bytes:16
.static final byte[]
The default secret:new byte[0]
. -
Constructor Summary
ConstructorDescriptionEncoder()
Creates a default message digest password encoder.Creates a message digest password encoder using the specified algorithm.Creates a message digest password encoder using the specified algorithm and secret.Creates a message digest password encoder using the specified algorithm, secret and salt length.Encoder
(String algorithm, byte[] secret, int saltLength, SecureRandom secureRandom) Creates a message digest password encoder using the specified algorithm, secret, salt length and secure random. -
Method Summary
Modifier and TypeMethodDescriptionEncodes the specified raw password.boolean
Returns the algorithm.int
Returns the salt length in kikibytes.byte[]
Returns the secret.Returns the secure random.int
hashCode()
boolean
Matches the specified raw password with the specified encoded representation.Recovers a password from its encoded representation generated with this encoder.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.security.authentication.password.Password.Encoder
matches
-
Field Details
-
DEFAULT_ALGORITHM
The default algorithm:SHA-512
.- See Also:
-
DEFAULT_SECRET
public static final byte[] DEFAULT_SECRETThe default secret:new byte[0]
. -
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTHThe default salt length in bytes:16
.- See Also:
-
-
Constructor Details
-
Encoder
public Encoder()Creates a default message digest password encoder.
-
Encoder
Creates a message digest password encoder using the specified algorithm.
- Parameters:
algorithm
- the algorithm
-
Encoder
Creates a message digest password encoder using the specified algorithm and secret.
- Parameters:
algorithm
- the algorithmsecret
- the secret
-
Encoder
Creates a message digest password encoder using the specified algorithm, secret and salt length.
- Parameters:
algorithm
- the algorithmsecret
- the secretsaltLength
- the salt length in kikibytes
-
Encoder
Creates a message digest password encoder using the specified algorithm, secret, salt length and secure random.
- Parameters:
algorithm
- the algorithmsecret
- the secretsaltLength
- the salt length in kikibytessecureRandom
- the secure random
-
-
Method Details
-
getAlgorithm
Returns the algorithm.
- Returns:
- the algorithm
-
getSecret
public byte[] getSecret()Returns the secret.
- Returns:
- the secret
-
getSaltLength
public int getSaltLength()Returns the salt length in kikibytes.
- Returns:
- the salt length
-
getSecureRandom
Returns the secure random.
- Returns:
- the secure random
-
recover
Description copied from interface:Password.Encoder
Recovers a password from its encoded representation generated with this encoder.
- Specified by:
recover
in interfacePassword.Encoder<MessageDigestPassword,
MessageDigestPassword.Encoder> - Parameters:
encoded
- an encoded password representation- Returns:
- a password
- Throws:
PasswordException
- if there was an error recovering the password or if the specified encoded representation was not generated with this encoder
-
encode
Description copied from interface:Password.Encoder
Encodes the specified raw password.
- Specified by:
encode
in interfacePassword.Encoder<MessageDigestPassword,
MessageDigestPassword.Encoder> - Parameters:
raw
- a raw password- Returns:
- an encoded password
- Throws:
PasswordException
- if there was an error encoding the password
-
matches
Description copied from interface:Password.Encoder
Matches the specified raw password with the specified encoded representation.
- Specified by:
matches
in interfacePassword.Encoder<MessageDigestPassword,
MessageDigestPassword.Encoder> - Parameters:
raw
- a raw passwordencoded
- an encoded password- Returns:
- true if passwords match, false otherwise
- Throws:
PasswordException
- if there was an error matching passwords
-
hashCode
public int hashCode() -
equals
-