com.arsdigita.kernel
Class UserAuthentication

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.kernel.UserAuthentication

public class UserAuthentication
extends DomainObject

Provides user authentication methods on a contained User object.

Version:
1.0
Author:
Phong Nguyen
See Also:
User

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String versionId
           
 
Method Summary
static UserAuthentication createForUser(BigDecimal userID)
          Creates a UserAuthentication object for the user with the specified ID.
static UserAuthentication createForUser(OID userOID)
          Creates a UserAuthentication object for the user with the specified OID.
static UserAuthentication createForUser(User user)
          Creates a UserAuthentication object for a user.
protected  String getBaseDataObjectType()
          Returns the base data object type for this domain object class.
 String getPasswordQuestion()
          Retrieves the question used to reset the password for this user.
 User getUser()
          Returns the User object to provide authentication to.
 boolean isValidAnswer(String answer)
          Determines whether the given answer matches the answer for this user.
 boolean isValidPassword(String password)
          Determines whether the given password matches the password for this user.
static UserAuthentication retrieveForLoginName(String loginName)
          Retrieves a UserAuthentication object given a login name (currently, this is the primary email address of the user).
static UserAuthentication retrieveForUser(BigDecimal userID)
          Retrieves a UserAuthentication object for a user with the specified ID.
static UserAuthentication retrieveForUser(OID userOID)
          Retrieves a UserAuthentication object for the user with the specified OID.
static UserAuthentication retrieveForUser(User user)
          Retrieves a UserAuthentication object for a user.
 void setPassword(String password)
          Sets the password for this user.
 void setPasswordAnswer(String answer)
          Sets the answer to the password question for this user.
 void setPasswordQuestion(String question)
          Sets the question used to reset the password for this user.
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, beforeSave, clear, delete, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, initialize, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
Constant Field Values
Method Detail

retrieveForUser

public static UserAuthentication retrieveForUser(User user)
                                          throws DataObjectNotFoundException
Retrieves a UserAuthentication object for a user.

Parameters:
user - the user for which to retrieve authentication
Returns:
the UserAuthentication object for the specified user.
Throws:
DataObjectNotFoundException - if the specified user does not have any associated user authentication object.

retrieveForUser

public static UserAuthentication retrieveForUser(OID userOID)
                                          throws DataObjectNotFoundException
Retrieves a UserAuthentication object for the user with the specified OID.

Parameters:
userOID - the OID of the user for which to retrieve authentication
Returns:
the UserAuthentication object for the specified user.
Throws:
DataObjectNotFoundException - if the specified user does not have any associated user authentication object.

retrieveForUser

public static UserAuthentication retrieveForUser(BigDecimal userID)
                                          throws DataObjectNotFoundException
Retrieves a UserAuthentication object for a user with the specified ID.

Parameters:
userID - The value of the ID property of the user for which to retrieve authentication
Returns:
the UserAuthentication object for the specified user.
Throws:
DataObjectNotFoundException - if the specified user does not have any associated user authentication object.

retrieveForLoginName

public static UserAuthentication retrieveForLoginName(String loginName)
                                               throws DataObjectNotFoundException
Retrieves a UserAuthentication object given a login name (currently, this is the primary email address of the user).

Parameters:
loginName - the loginName of the user authentication object to retrieve
Returns:
the UserAuthentication object for the specified login name.
Throws:
DataObjectNotFoundException - if the specified user does not have any associated user authentication object.

createForUser

public static UserAuthentication createForUser(User user)
Creates a UserAuthentication object for a user.

Parameters:
user - the user for which to create a new user authentication
Returns:
a new user authentication object.

createForUser

public static UserAuthentication createForUser(OID userOID)
                                        throws DataObjectNotFoundException
Creates a UserAuthentication object for the user with the specified OID.

Parameters:
userOID - the OID of the user for which to create a new user authentication
Returns:
a new user authentication object.
Throws:
DataObjectNotFoundException

createForUser

public static UserAuthentication createForUser(BigDecimal userID)
                                        throws DataObjectNotFoundException
Creates a UserAuthentication object for the user with the specified ID.

Returns:
a new user authentication object.
Throws:
DataObjectNotFoundException

getUser

public User getUser()
Returns the User object to provide authentication to.

Returns:
the User object to provide authentication to.

getBaseDataObjectType

protected String getBaseDataObjectType()
Description copied from class: DomainObject
Returns the base data object type for this domain object class. Intended to be overrided by subclasses whenever the subclass will only work if their primary data object is of a certain base type.

Overrides:
getBaseDataObjectType in class DomainObject
Returns:
The fully qualified name ("modelName.typeName") of the base data object type for this domain object class, or null if there is no restriction on the data object type for the primary data object encapsulated by this class.

setPassword

public void setPassword(String password)
Sets the password for this user. Sets the salt to a new random value. The password is hashed with the salt and stored as a base-64 encoded string.

Parameters:
password - the new password for the user
Throws:
IllegalArgumentException - if the password is null or it has leading or trailing spaces.

isValidPassword

public boolean isValidPassword(String password)
Determines whether the given password matches the password for this user.

Parameters:
password - the password to verify
Returns:
true if the password is valid; false otherwise.
Throws:
IllegalArgumentException - if the password is null or if it has leading or trailing spaces.

getPasswordQuestion

public String getPasswordQuestion()
Retrieves the question used to reset the password for this user.

Returns:
the password question.

setPasswordQuestion

public void setPasswordQuestion(String question)
Sets the question used to reset the password for this user.

Parameters:
question - the password question

setPasswordAnswer

public void setPasswordAnswer(String answer)
Sets the answer to the password question for this user.

Parameters:
answer - the password question's answer

isValidAnswer

public boolean isValidAnswer(String answer)
Determines whether the given answer matches the answer for this user.

Parameters:
answer - the answer to verify
Returns:
true if the answer is valid; false otherwise.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC