org.apache.turbine.services.security.torque
Class TorqueUser

java.lang.Object
  extended by org.apache.turbine.services.security.torque.TorqueObject
      extended by org.apache.turbine.services.security.torque.TorqueUser
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, org.apache.torque.om.Persistent, SecurityEntity, User

public class TorqueUser
extends TorqueObject
implements User

This is the User class used by the TorqueSecurity Service. It decouples all the database peer access from the actual Peer object

Version:
$Id: TorqueUser.java 534527 2007-05-02 16:10:59Z tv $
Author:
Josh Lucas, Jon S. Stevens, John D. McNally, Frank Y. Kim, Craig D. Berry, Martin Poeschl, Daniel Rall, Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.turbine.services.security.torque.TorqueObject
obj
 
Fields inherited from interface org.apache.turbine.om.security.User
ACCESS_COUNTER, CONFIRM_DATA, CONFIRM_VALUE, EMAIL, FIRST_NAME, HAS_LOGGED_IN, LAST_LOGIN, LAST_NAME, PASSWORD, SESSION_ACCESS_COUNTER, SESSION_KEY, USERNAME
 
Constructor Summary
TorqueUser()
          Constructor.
TorqueUser(org.apache.torque.om.Persistent obj)
          This Constructor is used when the UserPeerManager has retrieved a list of Database Objects from the peer and must 'wrap' them into TorqueRole Objects.
 
Method Summary
 int getAccessCounter()
          Gets the access counter for a user from perm storage.
 int getAccessCounterForSession()
          Gets the access counter for a user during a session.
 java.lang.String getConfirmed()
          Returns the confirm value of the user
 java.util.Date getCreateDate()
          Returns the creation date of the user
 java.lang.String getEmail()
          Returns the email address of the user
 java.lang.String getFirstName()
          Returns the first name of the User
 int getId()
          Gets the Id of this object
 java.lang.Integer getIdAsObj()
          Gets the Id of this object
 java.util.Date getLastAccessDate()
          Gets the last access date for this User.
 java.util.Date getLastLogin()
          Returns the date of the last login of the user
 java.lang.String getLastName()
          Returns the last name of the User
 java.lang.String getName()
          Returns the name of this object.
 byte[] getObjectdata()
          Returns the value of the objectdata for this user.
 java.lang.String getPassword()
          Returns the password of the User
 java.lang.Object getPerm(java.lang.String name)
          Get an object from permanent storage.
 java.lang.Object getPerm(java.lang.String name, java.lang.Object def)
          Get an object from permanent storage; return default if value is null.
 java.util.Hashtable getPermStorage()
          Returns the permanent storage.
 org.apache.torque.om.Persistent getPersistentObj()
          Returns the underlying Object for the Peer Used in the UserPeerManager when building a new Criteria.
 java.lang.Object getTemp(java.lang.String name)
          Get an object from temporary storage.
 java.lang.Object getTemp(java.lang.String name, java.lang.Object def)
          Get an object from temporary storage; return default if value is null.
 java.util.Hashtable getTempStorage()
          Returns the temporary storage.
 java.lang.String getUserName()
          Deprecated. Use getName() instead.
 boolean hasLoggedIn()
          The user is considered logged in if they have not timed out.
 void incrementAccessCounter()
          Increments the permanent hit counter for the user.
 void incrementAccessCounterForSession()
          Increments the session hit counter for the user.
 boolean isConfirmed()
          This method reports whether or not the user has been confirmed in the system by checking the User.CONFIRM_VALUE column in the users record to see if it is equal to User.CONFIRM_DATA.
 java.lang.Object removeTemp(java.lang.String name)
          Remove an object from temporary storage and return the object.
 void save()
          Makes changes made to the User attributes permanent.
 void save(java.sql.Connection con)
          Stores the object in the database.
 void save(java.lang.String torqueName)
          Stores the object in the database.
 void setAccessCounter(int cnt)
          Sets the access counter for a user, saved in perm storage.
 void setAccessCounterForSession(int cnt)
          Sets the session access counter for a user, saved in temp storage.
 void setConfirmed(java.lang.String confirm)
          Sets the new confirm value of the user
 void setCreateDate(java.util.Date createDate)
          Sets the new creation date of the user
 void setEmail(java.lang.String email)
          Sets the new email address of the user
 void setFirstName(java.lang.String firstName)
          Sets the first name of the User
 void setHasLoggedIn(java.lang.Boolean value)
          This sets whether or not someone has logged in.
 void setId(int id)
          Sets the Id of this object
 void setLastAccessDate()
          Sets the last access date for this User.
 void setLastLogin(java.util.Date lastLogin)
          Sets the new date of the last login of the user
 void setLastName(java.lang.String lastName)
          Sets the last name of User
 void setName(java.lang.String name)
          Sets the name of this object
 void setObjectdata(byte[] objectdata)
          Sets the value of the objectdata for the user
 void setPassword(java.lang.String password)
          Sets the password of the User
 void setPerm(java.lang.String name, java.lang.Object value)
          Put an object into permanent storage.
 void setPermStorage(java.util.Hashtable permStorage)
          This should only be used in the case where we want to save the data to the database.
 void setTemp(java.lang.String name, java.lang.Object value)
          Put an object into temporary storage.
 void setTempStorage(java.util.Hashtable tempStorage)
          This should only be used in the case where we want to save the data to the database.
 void setUserName(java.lang.String name)
          Sets the name of this user.
 void updateLastLogin()
          Updates the last login date in the database.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent hsbe)
          Implement this method if you wish to be notified when the User has been Bound to the session.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent hsbe)
          Implement this method if you wish to be notified when the User has been Unbound from the session.
 
Methods inherited from class org.apache.turbine.services.security.torque.TorqueObject
compareTo, equals, equals, getPrimaryKey, hashCode, isModified, isNew, setModified, setNew, setPrimaryKey, setPrimaryKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TorqueUser

public TorqueUser()
Constructor. Create a new User and set the createDate.


TorqueUser

public TorqueUser(org.apache.torque.om.Persistent obj)
This Constructor is used when the UserPeerManager has retrieved a list of Database Objects from the peer and must 'wrap' them into TorqueRole Objects. You should not use it directly!

Parameters:
obj - An Object from the peer
Method Detail

getPersistentObj

public org.apache.torque.om.Persistent getPersistentObj()
Returns the underlying Object for the Peer Used in the UserPeerManager when building a new Criteria.

Specified by:
getPersistentObj in class TorqueObject
Returns:
The underlying persistent object

save

public void save(java.lang.String torqueName)
          throws java.lang.Exception
Stores the object in the database. If the object is new, it inserts it; otherwise an update is performed.

Specified by:
save in interface org.apache.torque.om.Persistent
Overrides:
save in class TorqueObject
Parameters:
torqueName - The name under which the object should be stored.
Throws:
java.lang.Exception - This method might throw an exceptions

save

public void save(java.sql.Connection con)
          throws java.lang.Exception
Stores the object in the database. If the object is new, it inserts it; otherwise an update is performed. This method is meant to be used as part of a transaction, otherwise use the save() method and the connection details will be handled internally

Specified by:
save in interface org.apache.torque.om.Persistent
Overrides:
save in class TorqueObject
Parameters:
con - A Connection object to save the object
Throws:
java.lang.Exception - This method might throw an exceptions

save

public void save()
          throws TurbineSecurityException
Makes changes made to the User attributes permanent.

Specified by:
save in interface org.apache.torque.om.Persistent
Specified by:
save in class TorqueObject
Throws:
TurbineSecurityException - if there is a problem while saving data.

getName

public java.lang.String getName()
Returns the name of this object.

Specified by:
getName in interface SecurityEntity
Specified by:
getName in class TorqueObject
Returns:
The name of the object.

setName

public void setName(java.lang.String name)
Sets the name of this object

Specified by:
setName in interface SecurityEntity
Specified by:
setName in class TorqueObject
Parameters:
name - The name of the object

getId

public int getId()
Gets the Id of this object

Specified by:
getId in interface SecurityEntity
Returns:
The Id of the object

getIdAsObj

public java.lang.Integer getIdAsObj()
Gets the Id of this object

Specified by:
getIdAsObj in interface SecurityEntity
Returns:
The Id of the object

setId

public void setId(int id)
Sets the Id of this object

Specified by:
setId in interface SecurityEntity
Parameters:
id - The new Id

getUserName

public java.lang.String getUserName()
Deprecated. Use getName() instead.

Returns the name of this user.

Specified by:
getUserName in interface User
Returns:
The name of the user.

setUserName

public void setUserName(java.lang.String name)
Sets the name of this user.

Specified by:
setUserName in interface User
Parameters:
name - The name of the user.

getPassword

public java.lang.String getPassword()
Returns the password of the User

Specified by:
getPassword in interface User
Returns:
The password of the User

setPassword

public void setPassword(java.lang.String password)
Sets the password of the User

Specified by:
setPassword in interface User
Parameters:
password - The new password of the User

getFirstName

public java.lang.String getFirstName()
Returns the first name of the User

Specified by:
getFirstName in interface User
Returns:
The first name of the User

setFirstName

public void setFirstName(java.lang.String firstName)
Sets the first name of the User

Specified by:
setFirstName in interface User
Parameters:
firstName - The new first name of the User

getLastName

public java.lang.String getLastName()
Returns the last name of the User

Specified by:
getLastName in interface User
Returns:
The last name of the User

setLastName

public void setLastName(java.lang.String lastName)
Sets the last name of User

Specified by:
setLastName in interface User
Parameters:
lastName - The new last name of the User

getEmail

public java.lang.String getEmail()
Returns the email address of the user

Specified by:
getEmail in interface User
Returns:
The email address of the user

setEmail

public void setEmail(java.lang.String email)
Sets the new email address of the user

Specified by:
setEmail in interface User
Parameters:
email - The new email address of the user

getConfirmed

public java.lang.String getConfirmed()
Returns the confirm value of the user

Specified by:
getConfirmed in interface User
Returns:
The confirm value of the user

setConfirmed

public void setConfirmed(java.lang.String confirm)
Sets the new confirm value of the user

Specified by:
setConfirmed in interface User
Parameters:
confirm - The new confirm value of the user

getCreateDate

public java.util.Date getCreateDate()
Returns the creation date of the user

Specified by:
getCreateDate in interface User
Returns:
The creation date of the user

setCreateDate

public void setCreateDate(java.util.Date createDate)
Sets the new creation date of the user

Specified by:
setCreateDate in interface User
Parameters:
createDate - The new creation date of the user

getLastLogin

public java.util.Date getLastLogin()
Returns the date of the last login of the user

Specified by:
getLastLogin in interface User
Returns:
The date of the last login of the user

setLastLogin

public void setLastLogin(java.util.Date lastLogin)
Sets the new date of the last login of the user

Specified by:
setLastLogin in interface User
Parameters:
lastLogin - The new the date of the last login of the user

getObjectdata

public byte[] getObjectdata()
Returns the value of the objectdata for this user. Objectdata is a VARBINARY column in the table used to store the permanent storage table from the User object.

Returns:
The bytes in the objectdata for this user

setObjectdata

public void setObjectdata(byte[] objectdata)
Sets the value of the objectdata for the user

Parameters:
objectdata - The new the date of the last login of the user

getAccessCounter

public int getAccessCounter()
Gets the access counter for a user from perm storage.

Specified by:
getAccessCounter in interface User
Returns:
The access counter for the user.

getAccessCounterForSession

public int getAccessCounterForSession()
Gets the access counter for a user during a session.

Specified by:
getAccessCounterForSession in interface User
Returns:
The access counter for the user for the session.

incrementAccessCounter

public void incrementAccessCounter()
Increments the permanent hit counter for the user.

Specified by:
incrementAccessCounter in interface User

incrementAccessCounterForSession

public void incrementAccessCounterForSession()
Increments the session hit counter for the user.

Specified by:
incrementAccessCounterForSession in interface User

setAccessCounter

public void setAccessCounter(int cnt)
Sets the access counter for a user, saved in perm storage.

Specified by:
setAccessCounter in interface User
Parameters:
cnt - The new count.

setAccessCounterForSession

public void setAccessCounterForSession(int cnt)
Sets the session access counter for a user, saved in temp storage.

Specified by:
setAccessCounterForSession in interface User
Parameters:
cnt - The new count.

isConfirmed

public boolean isConfirmed()
This method reports whether or not the user has been confirmed in the system by checking the User.CONFIRM_VALUE column in the users record to see if it is equal to User.CONFIRM_DATA.

Specified by:
isConfirmed in interface User
Returns:
True if the user has been confirmed.

hasLoggedIn

public boolean hasLoggedIn()
The user is considered logged in if they have not timed out.

Specified by:
hasLoggedIn in interface User
Returns:
Whether the user has logged in.

setHasLoggedIn

public void setHasLoggedIn(java.lang.Boolean value)
This sets whether or not someone has logged in. hasLoggedIn() returns this value.

Specified by:
setHasLoggedIn in interface User
Parameters:
value - Whether someone has logged in or not.

getLastAccessDate

public java.util.Date getLastAccessDate()
Gets the last access date for this User. This is the last time that the user object was referenced.

Specified by:
getLastAccessDate in interface User
Returns:
A Java Date with the last access date for the user.

setLastAccessDate

public void setLastAccessDate()
Sets the last access date for this User. This is the last time that the user object was referenced.

Specified by:
setLastAccessDate in interface User

getPermStorage

public java.util.Hashtable getPermStorage()
Returns the permanent storage. This is implemented as a Hashtable and backed by an VARBINARY column in the database.

Specified by:
getPermStorage in interface User
Returns:
A Hashtable.

setPermStorage

public void setPermStorage(java.util.Hashtable permStorage)
This should only be used in the case where we want to save the data to the database.

Specified by:
setPermStorage in interface User
Parameters:
storage - A Hashtable.

getTempStorage

public java.util.Hashtable getTempStorage()
Returns the temporary storage. This is implemented as a Hashtable

Specified by:
getTempStorage in interface User
Returns:
A Hashtable.

setTempStorage

public void setTempStorage(java.util.Hashtable tempStorage)
This should only be used in the case where we want to save the data to the database.

Specified by:
setTempStorage in interface User
Parameters:
storage - A Hashtable.

getPerm

public java.lang.Object getPerm(java.lang.String name)
Get an object from permanent storage.

Specified by:
getPerm in interface User
Parameters:
name - The object's name.
Returns:
An Object with the given name.

getPerm

public java.lang.Object getPerm(java.lang.String name,
                                java.lang.Object def)
Get an object from permanent storage; return default if value is null.

Specified by:
getPerm in interface User
Parameters:
name - The object's name.
def - A default value to return.
Returns:
An Object with the given name.

setPerm

public void setPerm(java.lang.String name,
                    java.lang.Object value)
Put an object into permanent storage. If the value is null, it will convert that to a "" because the underlying storage mechanism within TorqueUser is currently a Hashtable and null is not a valid value.

Specified by:
setPerm in interface User
Parameters:
name - The object's name.
value - The object.

getTemp

public java.lang.Object getTemp(java.lang.String name)
Get an object from temporary storage.

Specified by:
getTemp in interface User
Parameters:
name - The object's name.
Returns:
An Object with the given name.

getTemp

public java.lang.Object getTemp(java.lang.String name,
                                java.lang.Object def)
Get an object from temporary storage; return default if value is null.

Specified by:
getTemp in interface User
Parameters:
name - The object's name.
def - A default value to return.
Returns:
An Object with the given name.

setTemp

public void setTemp(java.lang.String name,
                    java.lang.Object value)
Put an object into temporary storage. If the value is null, it will convert that to a "" because the underlying storage mechanism within TorqueUser is currently a Hashtable and null is not a valid value.

Specified by:
setTemp in interface User
Parameters:
name - The object's name.
value - The object.

removeTemp

public java.lang.Object removeTemp(java.lang.String name)
Remove an object from temporary storage and return the object.

Specified by:
removeTemp in interface User
Parameters:
name - The name of the object to remove.
Returns:
An Object.

updateLastLogin

public void updateLastLogin()
                     throws java.lang.Exception
Updates the last login date in the database.

Specified by:
updateLastLogin in interface User
Throws:
java.lang.Exception - A generic exception.

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Bound to the session.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - Indication of value/session binding.

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Unbound from the session.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - Indication of value/session unbinding.


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.