org.apache.jetspeed.om.security.ldap
Class LDAPUser

java.lang.Object
  extended byorg.apache.jetspeed.om.security.ldap.BaseLDAPObject
      extended byorg.apache.jetspeed.om.security.ldap.LDAPUser
All Implemented Interfaces:
javax.naming.Context, javax.naming.directory.DirContext, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, JetspeedUser, org.apache.turbine.om.security.SecurityEntity, java.io.Serializable, org.apache.turbine.om.security.User

public class LDAPUser
extends BaseLDAPObject
implements JetspeedUser, javax.servlet.http.HttpSessionBindingListener

Version:
$Id: LDAPUser.java,v 1.9 2005/04/27 14:08:24 raphael Exp $
Author:
Ender KILICOGLU, Sami Leino
See Also:
Serialized Form

Field Summary
protected static java.lang.String ATTR_CONFIRMED
           
protected static java.lang.String ATTR_CREATION_DATE
           
protected static java.lang.String ATTR_DISABLED
           
protected static java.lang.String ATTR_GIVEN_NAME
           
protected static java.lang.String ATTR_LAST_LOGIN_DATE
           
protected static java.lang.String ATTR_LAST_MODIFIED_DATE
           
protected static java.lang.String ATTR_MAIL
           
protected static java.lang.String ATTR_NAME
           
protected static java.lang.String ATTR_OBJECT_CLASS
           
protected static java.lang.String ATTR_OBJECT_DATA
           
protected static java.lang.String ATTR_SN
           
protected static java.lang.String ATTR_UID
           
protected static java.lang.String ATTR_UID_NUMBER
           
protected static java.lang.String ATTR_USER_GROUP_ROLE
           
protected static java.lang.String ATTR_USER_PASSWORD
           
protected  java.util.Vector groupRoles
          User's roles.
protected  boolean isNew
          Is this object "new" or does it already exist in the datastore?
protected  java.lang.String name
          Name of the user
protected static java.lang.String OBJECT_CLASS
           
protected static java.lang.String ORGANIZATIONAL_UNIT
           
 
Fields inherited from class org.apache.jetspeed.om.security.ldap.BaseLDAPObject
Id, LDAP_DATE_PATTERN, ldapurl, myAttrs, OK, rmAttrs, updated
 
Fields inherited from interface org.apache.jetspeed.om.security.JetspeedUser
DISABLED, PASSWORD_CHANGED, USER_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
 
Fields inherited from interface javax.naming.directory.DirContext
ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
LDAPUser()
           
LDAPUser(javax.naming.directory.Attributes attributes)
           
LDAPUser(LDAPURL ldapurl)
           
LDAPUser(java.lang.String username, boolean isNew)
          Constructor.
 
Method Summary
 void addGroupRole(java.lang.String groupName, java.lang.String roleName)
           
 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()
          Gets the confirmation value.
 java.util.Date getCreateDate()
          Gets the create date for this User.
 boolean getDisabled()
          Returns the disabled status for the user
 java.lang.String getEmail()
          Returns the email address for this user.
 java.lang.String getFirstName()
          Returns the first name for this user.
 java.util.Vector getGroupRoles()
           
 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.
 java.lang.String getName()
           
 java.lang.String getPassword()
          Get password for this user.
 java.util.Date getPasswordChanged()
          Returns the date of last password change
 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.
 java.lang.String getUserId()
          Returns the primary principle for this User, the user id.
 java.lang.String getUserName()
          Returns the username for this user.
 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.
 boolean isNew()
           
 void removeGroup(java.lang.String groupName)
           
 void removeGroupRole(java.lang.String groupName, java.lang.String roleName)
           
 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 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 value)
          Sets the confirmation value.
 void setCreateDate(java.util.Date date)
          Sets the create date for this User.
 void setDisabled(boolean disabled)
           
 void setEmail(java.lang.String address)
          Sets the email address.
 void setFirstName(java.lang.String firstName)
          Sets the first name for this user.
 void setHasLoggedIn(java.lang.Boolean value)
          This sets whether or not someone has logged in.
 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 lastName)
          Sets the last name for this user.
 void setName(java.lang.String name)
           
 void setPassword(java.lang.String password)
          Set password.
 void setPasswordChanged(java.util.Date value)
          Sets the date of last password change
 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 setUserId(java.lang.String id)
          Sets the primary principle for this User, the user id.
 void setUserName(java.lang.String username)
          Sets the username for this user.
 void update(boolean create)
           
 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.jetspeed.om.security.ldap.BaseLDAPObject
addToEnvironment, bind, bind, bind, bind, close, composeName, composeName, createId, createSubcontext, createSubcontext, createSubcontext, createSubcontext, deserializePerm, destroySubcontext, destroySubcontext, fastgetutil, formatDate, getAttributes, getAttributes, getAttributes, getAttributes, getEnvironment, getId, getldapurl, getNameInNamespace, getNameParser, getNameParser, getSchema, getSchema, getSchemaClassDefinition, getSchemaClassDefinition, getupdated, getutil, getutil, getutil, getutil, isOK, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, modifyAttributes, modifyAttributes, modifyAttributes, modifyAttributes, parseDate, parseDate, rebind, rebind, rebind, rebind, removeFromEnvironment, removeutil, rename, rename, search, search, search, search, search, search, search, search, serializePerm, setId, setLdapUrl, setObjectClass, setObjectClasses, setutil, setutil, setutil, setutil, toString, unbind, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OBJECT_CLASS

protected static final java.lang.String OBJECT_CLASS
See Also:
Constant Field Values

ORGANIZATIONAL_UNIT

protected static final java.lang.String ORGANIZATIONAL_UNIT
See Also:
Constant Field Values

ATTR_UID

protected static final java.lang.String ATTR_UID
See Also:
Constant Field Values

ATTR_UID_NUMBER

protected static final java.lang.String ATTR_UID_NUMBER
See Also:
Constant Field Values

ATTR_USER_PASSWORD

protected static final java.lang.String ATTR_USER_PASSWORD
See Also:
Constant Field Values

ATTR_NAME

protected static final java.lang.String ATTR_NAME
See Also:
Constant Field Values

ATTR_GIVEN_NAME

protected static final java.lang.String ATTR_GIVEN_NAME
See Also:
Constant Field Values

ATTR_SN

protected static final java.lang.String ATTR_SN
See Also:
Constant Field Values

ATTR_MAIL

protected static final java.lang.String ATTR_MAIL
See Also:
Constant Field Values

ATTR_OBJECT_DATA

protected static final java.lang.String ATTR_OBJECT_DATA
See Also:
Constant Field Values

ATTR_OBJECT_CLASS

protected static final java.lang.String ATTR_OBJECT_CLASS
See Also:
Constant Field Values

ATTR_USER_GROUP_ROLE

protected static final java.lang.String ATTR_USER_GROUP_ROLE
See Also:
Constant Field Values

ATTR_LAST_LOGIN_DATE

protected static final java.lang.String ATTR_LAST_LOGIN_DATE
See Also:
Constant Field Values

ATTR_LAST_MODIFIED_DATE

protected static final java.lang.String ATTR_LAST_MODIFIED_DATE
See Also:
Constant Field Values

ATTR_CREATION_DATE

protected static final java.lang.String ATTR_CREATION_DATE
See Also:
Constant Field Values

ATTR_CONFIRMED

protected static final java.lang.String ATTR_CONFIRMED
See Also:
Constant Field Values

ATTR_DISABLED

protected static final java.lang.String ATTR_DISABLED
See Also:
Constant Field Values

name

protected java.lang.String name
Name of the user


isNew

protected boolean isNew
Is this object "new" or does it already exist in the datastore?


groupRoles

protected java.util.Vector groupRoles
User's roles.

Constructor Detail

LDAPUser

public LDAPUser()

LDAPUser

public LDAPUser(java.lang.String username,
                boolean isNew)
Constructor. Create a new User and set the createDate.


LDAPUser

public LDAPUser(LDAPURL ldapurl)

LDAPUser

public LDAPUser(javax.naming.directory.Attributes attributes)
Method Detail

update

public void update(boolean create)
            throws JetspeedSecurityException
Throws:
JetspeedSecurityException

getGroupRoles

public java.util.Vector getGroupRoles()

addGroupRole

public void addGroupRole(java.lang.String groupName,
                         java.lang.String roleName)

removeGroup

public void removeGroup(java.lang.String groupName)

removeGroupRole

public void removeGroupRole(java.lang.String groupName,
                            java.lang.String roleName)

getUserId

public java.lang.String getUserId()
Returns the primary principle for this User, the user id.

Specified by:
getUserId in interface JetspeedUser
Returns:
the user id.

setUserId

public void setUserId(java.lang.String id)
Description copied from interface: JetspeedUser
Sets the primary principle for this User, the user id.

Specified by:
setUserId in interface JetspeedUser
Parameters:
id - the principle

getAccessCounterForSession

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

Specified by:
getAccessCounterForSession in interface org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.User
Returns:
A Java Date with the date of creation for the user.

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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.User
Parameters:
name - The object's name.
def - A default value to return.
Returns:
An Object with the given name.

getUserName

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

Specified by:
getUserName in interface org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.User
Returns:
Whether the user has logged in.

getEmail

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

Specified by:
getEmail in interface org.apache.turbine.om.security.User
Returns:
A String with the user's email address.

incrementAccessCounter

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

Specified by:
incrementAccessCounter in interface org.apache.turbine.om.security.User

incrementAccessCounterForSession

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

Specified by:
incrementAccessCounterForSession in interface org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.User
Parameters:
cnt - The new count.

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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.User
Parameters:
date - The create date.

setLastLogin

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

Specified by:
setLastLogin in interface org.apache.turbine.om.security.User
Parameters:
date - The last login date.

setPassword

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

Specified by:
setPassword in interface org.apache.turbine.om.security.User
Parameters:
password - The new password.

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 TurbineUser is currently a Hashtable and null is not a valid value.

Specified by:
setPerm in interface org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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 org.apache.turbine.om.security.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. If the value is null, it will convert that to a "" because the underlying storage mechanism within TurbineUser is currently a Hashtable and null is not a valid value.

Specified by:
setTemp in interface org.apache.turbine.om.security.User
Parameters:
name - The object's name.
value - The object.

setUserName

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

Specified by:
setUserName in interface org.apache.turbine.om.security.User
Parameters:
username - The user's username.

setFirstName

public void setFirstName(java.lang.String firstName)
Sets the first name for this user.

Specified by:
setFirstName in interface org.apache.turbine.om.security.User
Parameters:
firstName - User's first name.

setLastName

public void setLastName(java.lang.String lastName)
Sets the last name for this user.

Specified by:
setLastName in interface org.apache.turbine.om.security.User
Parameters:
lastName - User's last name.

setEmail

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

Specified by:
setEmail in interface org.apache.turbine.om.security.User
Parameters:
address - The email address.

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 org.apache.turbine.om.security.User
Returns:
True if the user has been confirmed.

setConfirmed

public void setConfirmed(java.lang.String value)
Sets the confirmation value. The value should be either a random string or User.CONFIRM_DATA

Specified by:
setConfirmed in interface org.apache.turbine.om.security.User
Parameters:
value - The confirmation key value.

getConfirmed

public java.lang.String getConfirmed()
Gets the confirmation value.

Specified by:
getConfirmed in interface org.apache.turbine.om.security.User
Returns:
status The confirmation value for this User

updateLastLogin

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

Specified by:
updateLastLogin in interface org.apache.turbine.om.security.User
Throws:
Exception, - a generic exception.
java.lang.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.

save

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

Throws:
java.lang.Exception

getDisabled

public boolean getDisabled()
Returns the disabled status for the user

Specified by:
getDisabled in interface JetspeedUser
Returns:
True when the account is disabled

setDisabled

public void setDisabled(boolean disabled)
Specified by:
setDisabled in interface JetspeedUser

getName

public java.lang.String getName()
Specified by:
getName in interface org.apache.turbine.om.security.SecurityEntity
Overrides:
getName in class BaseLDAPObject

setName

public void setName(java.lang.String name)
Specified by:
setName in interface org.apache.turbine.om.security.SecurityEntity
Overrides:
setName in class BaseLDAPObject

isNew

public boolean isNew()
Specified by:
isNew in interface JetspeedUser
Overrides:
isNew in class BaseLDAPObject

getPasswordChanged

public java.util.Date getPasswordChanged()
Returns the date of last password change

Specified by:
getPasswordChanged in interface JetspeedUser
Returns:
date

setPasswordChanged

public void setPasswordChanged(java.util.Date value)
Sets the date of last password change

Specified by:
setPasswordChanged in interface JetspeedUser
Parameters:
value - Date


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