org.clazzes.util.sec
Class PlainPasswordHasher
java.lang.Object
org.clazzes.util.sec.PlainPasswordHasher
- All Implemented Interfaces:
- PasswordHasher
- Direct Known Subclasses:
- CryptPasswordHasher, SSHA1PasswordHasher
public class PlainPasswordHasher
- extends java.lang.Object
- implements PasswordHasher
The Plain text (pseudo) hasher
Method Summary |
boolean |
checkPassword(java.lang.String cleartext,
java.lang.String hashed)
Checks if the given cleartext password conforms to the given hashed representation. |
java.lang.String |
getAlgorithmName()
|
java.lang.String |
getAlgorithmPrefix()
|
int |
getSaltLength()
|
java.lang.String |
hashPassword(java.lang.String cleartext)
Hashes the given password using a random salt. |
java.lang.String |
hashPassword(java.lang.String cleartext,
java.lang.String salt)
Hashes the given password using the given salt. |
protected java.lang.String |
prependAlgorithmKey(java.lang.String to_password)
|
protected java.lang.String |
stripAlgorithmKey(java.lang.String from_password)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
algo_prefix
protected final java.lang.String algo_prefix
PlainPasswordHasher
public PlainPasswordHasher()
hashPassword
public java.lang.String hashPassword(java.lang.String cleartext)
- Description copied from interface:
PasswordHasher
- Hashes the given password using a random salt.
- Specified by:
hashPassword
in interface PasswordHasher
- Parameters:
cleartext
- Password to hash.
- Returns:
- the hashed i.e. encrypted password. includes the algorithm prefix.
hashPassword
public java.lang.String hashPassword(java.lang.String cleartext,
java.lang.String salt)
- Description copied from interface:
PasswordHasher
- Hashes the given password using the given salt.
- Specified by:
hashPassword
in interface PasswordHasher
- Parameters:
cleartext
- Password to hash.salt
- the salt to use.
- Returns:
- the hashed i.e. encrypted password. includes the algorithm prefix.
checkPassword
public boolean checkPassword(java.lang.String cleartext,
java.lang.String hashed)
- Description copied from interface:
PasswordHasher
- Checks if the given cleartext password conforms to the given hashed representation.
- Specified by:
checkPassword
in interface PasswordHasher
- Parameters:
cleartext
- cleartext password to check.hashed
- hashed correct password to check against. may include the algorithm prefix.
- Returns:
- true if the password seems correct.
getAlgorithmName
public java.lang.String getAlgorithmName()
- Specified by:
getAlgorithmName
in interface PasswordHasher
- Returns:
- the name (key) of the algorithm implemented by this hasher, as used in the algorithm prefix of hashed passwords.
getAlgorithmPrefix
public java.lang.String getAlgorithmPrefix()
stripAlgorithmKey
protected java.lang.String stripAlgorithmKey(java.lang.String from_password)
- Parameters:
from_password
-
- Returns:
- The given hashed password without eventual leading "{algo_key}"
prependAlgorithmKey
protected java.lang.String prependAlgorithmKey(java.lang.String to_password)
- Parameters:
from_password
-
- Returns:
- The given hashed password with an eventual missing "{algo_key}"
prefix
getSaltLength
public int getSaltLength()
- Specified by:
getSaltLength
in interface PasswordHasher
- Returns:
- the (default resp. relevant) salt length for the hash algorithm
Copyright © 2009. All Rights Reserved.