atg.security
Class MD5PasswordHasher

java.lang.Object
  extended by atg.security.MD5PasswordHasher
All Implemented Interfaces:
PasswordHasher, java.io.Serializable

public class MD5PasswordHasher
extends java.lang.Object
implements PasswordHasher

Implementation of a PasswordHasher using MD5 encryption algorithm with a randomized initial state. When serialized, the initial state of the hash function is encoded as part of this object's wire representation.

This is intended to be useful for applications where a one-time hash is desired, e.g. when performing a client/server log-in.

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
           
 
Constructor Summary
MD5PasswordHasher()
          Construct a new MD5PasswordHasher with a randomized initial state.
MD5PasswordHasher(java.lang.Long pInitialHashState)
          Construct a new MD5PasswordHasher with the given initial state.
 
Method Summary
 boolean checkPassword(java.lang.String pLoginPassword, java.lang.String pEncryptedPassword, java.lang.Object pHashKey)
          Returns true if the login password matches the encrypted password.
 java.lang.String encryptPassword(java.lang.String pPassword)
          Hashes a password suitably for long-term storage.
 PasswordHasher getLoginPasswordHasher()
          Returns a password hasher instance useful for performing a login.
 java.lang.Object getPasswordHashKey()
          Returns the hash key that was used for hashing the password for login.
 java.lang.String hashPasswordForLogin(java.lang.String pPassword)
          Performs the appropriate hashing function for a login process.
static void main(java.lang.String[] args)
          Simple command-line interface for deriving MD5 hashed passwords.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

MD5PasswordHasher

public MD5PasswordHasher()
Construct a new MD5PasswordHasher with a randomized initial state.


MD5PasswordHasher

public MD5PasswordHasher(java.lang.Long pInitialHashState)
Construct a new MD5PasswordHasher with the given initial state.

Method Detail

encryptPassword

public java.lang.String encryptPassword(java.lang.String pPassword)
Hashes a password suitably for long-term storage. This will always return the same value.

Specified by:
encryptPassword in interface PasswordHasher

checkPassword

public boolean checkPassword(java.lang.String pLoginPassword,
                             java.lang.String pEncryptedPassword,
                             java.lang.Object pHashKey)
Returns true if the login password matches the encrypted password.

Specified by:
checkPassword in interface PasswordHasher

hashPasswordForLogin

public java.lang.String hashPasswordForLogin(java.lang.String pPassword)
Performs the appropriate hashing function for a login process. This value will later be passed to checkPassword().

Specified by:
hashPasswordForLogin in interface PasswordHasher

getPasswordHashKey

public java.lang.Object getPasswordHashKey()
Returns the hash key that was used for hashing the password for login. This must be passed to checkPassword() to verify the validity of the hash.

Specified by:
getPasswordHashKey in interface PasswordHasher

getLoginPasswordHasher

public PasswordHasher getLoginPasswordHasher()
Returns a password hasher instance useful for performing a login. This instance may have a unique password hash key so that each login attempt is hashed differently.

Specified by:
getLoginPasswordHasher in interface PasswordHasher

main

public static void main(java.lang.String[] args)
Simple command-line interface for deriving MD5 hashed passwords. This is mostly useful for creating initial passwords.