Class PBKDF2Password.Encoder
- All Implemented Interfaces:
Password.Encoder<PBKDF2Password,
PBKDF2Password.Encoder>
- Enclosing class:
PBKDF2Password
A PBKDF2 based password encoder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default hash length in kikibytes:32
.static final int
Default iteration count:1000
.static final String
Default pseudorandom function.static final int
Default salt length in kikibytes:16
.static final String
SHA256 pseudorandom function.static final String
SHA384 pseudorandom function.static final String
SHA512 pseudorandom function. -
Constructor Summary
ConstructorDescriptionEncoder()
Creates a default PBKDF2 password encoder.Creates a PBKDF2 password encoder with the specified pseudorandom function.Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length and hash length.Encoder
(String prf, int iterationCount, int saltLength, int hashLength, SecureRandom secureRandom) Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length, hash length and secure random. -
Method Summary
Modifier and TypeMethodDescriptionEncodes the specified raw password.boolean
int
Returns the hash length in kikibytes.int
Returns the iteration count.Returns the pseudorandom function.int
Returns the salt length in kikibytes.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
-
PRF_SHA256
SHA256 pseudorandom function.- See Also:
-
PRF_SHA384
SHA384 pseudorandom function.- See Also:
-
PRF_SHA512
SHA512 pseudorandom function.- See Also:
-
DEFAULT_PRF
Default pseudorandom function.- See Also:
-
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTHDefault salt length in kikibytes:16
.- See Also:
-
DEFAULT_HASH_LENGTH
public static final int DEFAULT_HASH_LENGTHDefault hash length in kikibytes:32
.- See Also:
-
DEFAULT_ITERATION_COUNT
public static final int DEFAULT_ITERATION_COUNTDefault iteration count:1000
.- See Also:
-
-
Constructor Details
-
Encoder
public Encoder()Creates a default PBKDF2 password encoder.
-
Encoder
Creates a PBKDF2 password encoder with the specified pseudorandom function.
- Parameters:
prf
- the pseudorandom function
-
Encoder
Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length and hash length.
- Parameters:
prf
- the pseudorandom functioniterationCount
- the iteration countsaltLength
- the salt length in kikibyteshashLength
- the hash length in kikibytes
-
Encoder
public Encoder(String prf, int iterationCount, int saltLength, int hashLength, SecureRandom secureRandom) Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length, hash length and secure random.
- Parameters:
prf
- the pseudorandom functioniterationCount
- the iteration countsaltLength
- the salt length in kikibyteshashLength
- the hash length in kikibytessecureRandom
- the secure random
-
-
Method Details
-
getPseudoRandomFunction
Returns the pseudorandom function.
- Returns:
- the pseudorandom function
-
getIterationCount
public int getIterationCount()Returns the iteration count.
- Returns:
- the iteration count
-
getSaltLength
public int getSaltLength()Returns the salt length in kikibytes.
- Returns:
- the salt length
-
getHashLength
public int getHashLength()Returns the hash length in kikibytes.
- Returns:
- the hash 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<PBKDF2Password,
PBKDF2Password.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<PBKDF2Password,
PBKDF2Password.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<PBKDF2Password,
PBKDF2Password.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
-