Package rs.baselib.crypto
Class CombinedPasswordHasher
java.lang.Object
rs.baselib.crypto.CombinedPasswordHasher
- All Implemented Interfaces:
PasswordHasher
Implements a combined strategy to hash passwords.
The object will use a default
ExtendedPasswordHasher
in order
to create hashes but will use all defined hashers to test a given password hash.
- Since:
- 1.2.9
- Author:
- ralph
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PasswordHasher
A UNIX strategy to hash and check passwords (withBlowfishPasswordHasher
as default).static final PasswordHasher
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default).static final PasswordHasher
A UNIX strategy to hash and check passwords (withPhpPasswordHasher
as default).static final PasswordHasher
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default).static final PasswordHasher
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default). -
Constructor Summary
ConstructorDescriptionCombinedPasswordHasher
(ExtendedPasswordHasher... passwordHashers) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default password hasher, that is the hasher used for hashing passwords.getPasswordHash
(String plainPassword) Returns a hash of the given plain password.Returns the password hashers used.boolean
testPassword
(String plainPassword, String passwordHash) Tests a plain Password whether it is the same as a previously hashed password.
-
Field Details
-
UNIX_STRATEGY_MD5
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default).This instance used (in order of check):
-
UNIX_STRATEGY_BLOWFISH
A UNIX strategy to hash and check passwords (withBlowfishPasswordHasher
as default).This instance used (in order of check):
-
UNIX_STRATEGY_PHP
A UNIX strategy to hash and check passwords (withPhpPasswordHasher
as default).This instance used (in order of check):
-
UNIX_STRATEGY_SHA512
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default).This instance used (in order of check):
-
UNIX_STRATEGY_SHA256
A UNIX strategy to hash and check passwords (withMd5PasswordHasher
as default).This instance used (in order of check):
-
-
Constructor Details
-
CombinedPasswordHasher
Constructor.- Parameters:
passwordHashers
- the list of hash algorithms to be used. the first algorithm will be used for hashing a password (default hasher).
-
-
Method Details
-
getPasswordHash
Returns a hash of the given plain password.- Specified by:
getPasswordHash
in interfacePasswordHasher
- Parameters:
plainPassword
- the password to be hashed- Returns:
- the hash of the password
-
testPassword
Tests a plain Password whether it is the same as a previously hashed password.- Specified by:
testPassword
in interfacePasswordHasher
- Parameters:
plainPassword
- the plain password to be checkedpasswordHash
- the hash of another password- Returns:
true
when both passwords match each other
-
getPasswordHashers
Returns the password hashers used.- Returns:
- the password hashers
-
getDefaultPasswordHasher
Returns the default password hasher, that is the hasher used for hashing passwords.- Returns:
- the default password hasher
-