userman
Class HashedPassword

java.lang.Object
  extended by userman.HashedPassword

public class HashedPassword
extends java.lang.Object

This class allows the creation and comparing of hashed passwords. Hashed passwords are stored in databases instead of in their clear text form in case password files are compromised.


Constructor Summary
HashedPassword(byte[] hashBytes)
          Use this constructor after retrieving a user's hashed password from the database.
HashedPassword(java.lang.String password, java.lang.String algorithm)
          Use this constructor when a user is submitting credentials for login.
 
Method Summary
 boolean equals(java.lang.Object o)
          Use this to test hashed password equality.
 byte[] getHashBytes()
          Use this accessor to get the hash string from a hashed password in order to store the string in the database.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashedPassword

public HashedPassword(java.lang.String password,
                      java.lang.String algorithm)
Use this constructor when a user is submitting credentials for login.

Parameters:
password - the password as a string
algorithm - the hash algorithm to use, for example "SHA-512"

HashedPassword

public HashedPassword(byte[] hashBytes)
Use this constructor after retrieving a user's hashed password from the database.

Parameters:
hashBytes - the hashed byte string stored in the database
Method Detail

equals

public boolean equals(java.lang.Object o)
Use this to test hashed password equality. Succeeds if this object's hash string matches the other object's hash string byte for byte.

Overrides:
equals in class java.lang.Object
Parameters:
o - the other hashed password object
Returns:
whether the two objects' hash strings match

getHashBytes

public byte[] getHashBytes()
Use this accessor to get the hash string from a hashed password in order to store the string in the database.

Returns:
the hash string for this hashed password object