org.apache.james.userrepository
Class DefaultUser

java.lang.Object
  extended by org.apache.james.userrepository.DefaultUser
All Implemented Interfaces:
java.io.Serializable, User
Direct Known Subclasses:
DefaultJamesUser

public class DefaultUser
extends java.lang.Object
implements User, java.io.Serializable

Implementation of User Interface. Instances of this class do not allow the the user name to be reset.

Version:
CVS $Revision: 450935 $
See Also:
Serialized Form

Constructor Summary
DefaultUser(java.lang.String name, java.lang.String hashAlg)
          Standard constructor.
DefaultUser(java.lang.String name, java.lang.String passwordHash, java.lang.String hashAlg)
          Constructor for repositories that are construcing user objects from separate fields, e.g. databases.
 
Method Summary
protected  java.lang.String getHashAlgorithm()
          Method to access the hashing algorithm of the password.
protected  java.lang.String getHashedPassword()
          Method to access hash of password
 java.lang.String getUserName()
          Accessor for immutable name
 boolean setPassword(java.lang.String newPass)
          Sets new password from String.
 boolean verifyPassword(java.lang.String pass)
          Method to verify passwords.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUser

public DefaultUser(java.lang.String name,
                   java.lang.String hashAlg)
Standard constructor.

Parameters:
name - the String name of this user
hashAlg - the algorithm used to generate the hash of the password

DefaultUser

public DefaultUser(java.lang.String name,
                   java.lang.String passwordHash,
                   java.lang.String hashAlg)
Constructor for repositories that are construcing user objects from separate fields, e.g. databases.

Parameters:
name - the String name of this user
passwordHash - the String hash of this users current password
hashAlg - the String algorithm used to generate the hash of the password
Method Detail

getUserName

public java.lang.String getUserName()
Accessor for immutable name

Specified by:
getUserName in interface User
Returns:
the String of this users name

verifyPassword

public boolean verifyPassword(java.lang.String pass)
Method to verify passwords.

Specified by:
verifyPassword in interface User
Parameters:
pass - the String that is claimed to be the password for this user
Returns:
true if the hash of pass with the current algorithm matches the stored hash.

setPassword

public boolean setPassword(java.lang.String newPass)
Sets new password from String. No checks made on guessability of password.

Specified by:
setPassword in interface User
Parameters:
newPass - the String that is the new password.
Returns:
true if newPass successfuly hashed

getHashedPassword

protected java.lang.String getHashedPassword()
Method to access hash of password

Returns:
the String of the hashed Password

getHashAlgorithm

protected java.lang.String getHashAlgorithm()
Method to access the hashing algorithm of the password.

Returns:
the name of the hashing algorithm used for this user's password


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.