org.apache.turbine.services.security.ldap
Class LDAPUser

java.lang.Object
  extended byorg.apache.torque.om.BaseObject
      extended byorg.apache.turbine.services.security.ldap.LDAPUser
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, org.apache.torque.om.Persistent, SecurityEntity, java.io.Serializable, User
Direct Known Subclasses:
ActiveDirectoryUser

public class LDAPUser
extends org.apache.torque.om.BaseObject
implements User

LDAPUser implements User and provides access to a user who accesses the system via LDAP.

Version:
$Id: LDAPUser.java 534527 2007-05-02 16:10:59Z tv $
Author:
Craig D. Berry, Tracy M. Adewunmi, Leonard J. Flournoy , Daniel Rall, Humberto Hernandez
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.torque.om.BaseObject
NEW_ID
 
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
LDAPUser()
          Constructor.
 
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 value of Confirmed variable
 java.util.Date getCreateDate()
          Gets the create date for this User.
 java.lang.String getDN()
          Gets the distinguished name (DN) of the User.
 java.lang.String getEmail()
          Returns the Email for this user.
 java.lang.String getFirstName()
          Returns the first name for this user.
 int getId()
          Not implemented.
 java.lang.Integer getIdAsObj()
          Not implemented.
 java.util.Date getLastAccessDate()
          Gets the last access date for this User.
 java.util.Date getLastLogin()
          Get last login date/time for this user.
 java.lang.String getLastName()
          Returns the last name for this user.
 javax.naming.directory.Attributes getLDAPAttributes()
          Get the JNDI Attributes used to store the user in LDAP.
 java.lang.String getName()
          Returns the username for this user.
 java.lang.String getPassword()
          Get password for this 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()
          This should only be used in the case where we want to save the data to the database.
 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()
          This should only be used in the case where we want to save the data to the database.
 int getTimeout()
          A User object can have a variable Timeout, which is defined in minutes.
 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 CONFIRM_VALUE column to see if it is equal to CONFIRM_DATA.
 java.lang.Object removeTemp(java.lang.String name)
          Remove an object from temporary storage and return the object.
 void save()
          Saves this object to the data store.
 void save(java.sql.Connection conn)
          not implemented
 void save(java.lang.String dbname)
          not implemented
 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)
          Set the users confirmed variable
 void setCreateDate(java.util.Date date)
          Sets the create date for this User.
 void setEmail(java.lang.String email)
          Set the users Email
 void setFirstName(java.lang.String fname)
          Set the users First Name
 void setHasLoggedIn(java.lang.Boolean value)
          This sets whether or not someone has logged in.
 void setId(int id)
          Not implemented.
 void setLastAccessDate()
          Sets the last access date for this User.
 void setLastLogin(java.util.Date date)
          Set last login date/time.
 void setLastName(java.lang.String lname)
          Set the users Last Name Sets the last name for this user.
 void setLDAPAttributes(javax.naming.directory.Attributes attribs)
          Populates the user with values obtained from the LDAP Service.
 void setName(java.lang.String name)
          Not implemented.
 void setPassword(java.lang.String password)
          Set password.
 void setPerm(java.lang.String name, java.lang.Object value)
          Put an object into permanent storage.
 void setPermStorage(java.util.Hashtable stuff)
          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 storage)
          This should only be used in the case where we want to save the data to the database.
 void setTimeout(int time)
          A User object can have a variable Timeout which is defined in minutes.
 void setUserName(java.lang.String username)
          Sets the username for 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.torque.om.BaseObject
equals, equals, getByName, getByPeerName, getByPosition, getLog, getPrimaryKey, getTableMap, hashCode, isModified, isNew, resetModified, setByName, setByPeerName, setByPosition, setModified, setNew, setPrimaryKey, setPrimaryKey, setPrimaryKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPUser

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

Method Detail

setLDAPAttributes

public void setLDAPAttributes(javax.naming.directory.Attributes attribs)
                       throws javax.naming.NamingException
Populates the user with values obtained from the LDAP Service. This method could be redefined in subclasses.

Parameters:
attribs - The attributes obtained from LDAP.
Throws:
javax.naming.NamingException - if there was an error with JNDI.

getLDAPAttributes

public javax.naming.directory.Attributes getLDAPAttributes()
                                                    throws javax.naming.NamingException
Get the JNDI Attributes used to store the user in LDAP. This method could be redefined in a subclass.

Returns:
The JNDI attributes of the user.
Throws:
javax.naming.NamingException - if there is a JNDI error.

getDN

public java.lang.String getDN()
Gets the distinguished name (DN) of the User. This method could be redefined in a subclass.

Returns:
The Distinguished Name of 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.

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.

getCreateDate

public java.util.Date getCreateDate()
Gets the create date for this User. This is the time at which the user object was created.

Specified by:
getCreateDate in interface User
Returns:
A Java Date with the date of creation for the user.

getConfirmed

public java.lang.String getConfirmed()
Returns the value of Confirmed variable

Specified by:
getConfirmed in interface User
Returns:
the confirm value.

getEmail

public java.lang.String getEmail()
Returns the Email for this user. If this is defined, then the user is considered logged in.

Specified by:
getEmail in interface User
Returns:
A String with the user's Email.

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.

getLastLogin

public java.util.Date getLastLogin()
Get last login date/time for this user.

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

getPassword

public java.lang.String getPassword()
Get password for this user.

Specified by:
getPassword in interface User
Returns:
A String with the password for the user.

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.

getPermStorage

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

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

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.

getTimeout

public int getTimeout()
A User object can have a variable Timeout, which is defined in minutes. If the user has been timed out, then the hasLoggedIn() value will return false.

Returns:
An int specifying the timeout.

getUserName

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

Returns the username for this user. If this is defined, then the user is considered logged in.

Specified by:
getUserName in interface User
Returns:
A String with the username.

getFirstName

public java.lang.String getFirstName()
Returns the first name for this user. If this is defined, then the user is considered logged in.

Specified by:
getFirstName in interface User
Returns:
A String with the user's first name.

getLastName

public java.lang.String getLastName()
Returns the last name for this user. If this is defined, then the user is considered logged in.

Specified by:
getLastName in interface User
Returns:
A String with the user's last name.

hasLoggedIn

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

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

isConfirmed

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

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

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

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.

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.

setConfirmed

public void setConfirmed(java.lang.String confirm)
Set the users confirmed variable

Specified by:
setConfirmed in interface User
Parameters:
confirm - The new confim value.

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

setCreateDate

public void setCreateDate(java.util.Date date)
Sets the create date for this User. This is the time at which the user object was created.

Specified by:
setCreateDate in interface User
Parameters:
date - The create date.

setEmail

public void setEmail(java.lang.String email)
Set the users Email

Specified by:
setEmail in interface User
Parameters:
email - The new email.

setFirstName

public void setFirstName(java.lang.String fname)
Set the users First Name

Specified by:
setFirstName in interface User
Parameters:
fname - The new firstname.

setLastLogin

public void setLastLogin(java.util.Date date)
Set last login date/time.

Specified by:
setLastLogin in interface User
Parameters:
date - The last login date.

setLastName

public void setLastName(java.lang.String lname)
Set the users Last Name Sets the last name for this user.

Specified by:
setLastName in interface User
Parameters:
lname - The new lastname.

setPassword

public void setPassword(java.lang.String password)
Set password.

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

setPerm

public void setPerm(java.lang.String name,
                    java.lang.Object value)
Put an object into permanent storage.

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

setPermStorage

public void setPermStorage(java.util.Hashtable stuff)
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:
stuff - A Hashtable.

getTempStorage

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

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

setTempStorage

public void setTempStorage(java.util.Hashtable storage)
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.

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.

setTemp

public void setTemp(java.lang.String name,
                    java.lang.Object value)
Put an object into temporary storage.

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

setTimeout

public void setTimeout(int time)
A User object can have a variable Timeout which is defined in minutes. If the user has been timed out, then the hasLoggedIn() value will return false.

Parameters:
time - The user's timeout.

setUserName

public void setUserName(java.lang.String username)
Sets the username for this user.

Specified by:
setUserName in interface User
Parameters:
username - The user's username.

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:
hsbe - The HttpSessionBindingEvent.

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:
hsbe - The HttpSessionBindingEvent.

getName

public java.lang.String getName()
Returns the username for this user. If this is defined, then the user is considered logged in.

Specified by:
getName in interface SecurityEntity
Returns:
A String with the username.

setName

public void setName(java.lang.String name)
Not implemented.

Specified by:
setName in interface SecurityEntity
Parameters:
name - the name of the User.

getId

public int getId()
Not implemented.

Specified by:
getId in interface SecurityEntity
Returns:
0

getIdAsObj

public java.lang.Integer getIdAsObj()
Not implemented.

Specified by:
getIdAsObj in interface SecurityEntity
Returns:
null

setId

public void setId(int id)
Not implemented.

Specified by:
setId in interface SecurityEntity
Parameters:
id - The id of the User.

save

public void save()
          throws java.lang.Exception
Saves this object to the data store.

Specified by:
save in interface org.apache.torque.om.Persistent
Throws:
java.lang.Exception - if it cannot be saved

save

public void save(java.sql.Connection conn)
          throws java.lang.Exception
not implemented

Specified by:
save in interface org.apache.torque.om.Persistent
Parameters:
conn - the database connection
Throws:
java.lang.Exception - if there is an error

save

public void save(java.lang.String dbname)
          throws java.lang.Exception
not implemented

Specified by:
save in interface org.apache.torque.om.Persistent
Parameters:
dbname - the database name
Throws:
java.lang.Exception - if there is an error


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