Package org.apache.turbine.om.security
Class DefaultUserImpl
- java.lang.Object
-
- org.apache.turbine.om.security.DefaultUserImpl
-
- All Implemented Interfaces:
Serializable
,EventListener
,HttpSessionBindingListener
,org.apache.fulcrum.security.entity.ExtendedUser
,org.apache.fulcrum.security.entity.SecurityEntity
,org.apache.fulcrum.security.entity.User
,org.apache.fulcrum.security.model.turbine.entity.TurbineUser
,org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRoleEntity
,TurbineUserDelegate
,User
public class DefaultUserImpl extends Object implements User
This is the Default user implementation. It is a wrapper around a TurbineUser object- Version:
- $Id: TorqueUser.java 1199856 2011-11-09 17:06:04Z tv $
- Author:
- Thomas Vandahl
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.turbine.om.security.User
ACCESS_COUNTER, CONFIRM_DATA, CONFIRM_VALUE, CREATE_DATE, HAS_LOGGED_IN, LAST_LOGIN, SESSION_ACCESS_COUNTER, SESSION_KEY
-
-
Constructor Summary
Constructors Constructor Description DefaultUserImpl(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUserGroupRole(org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole userGroupRole)
Add a User/Group/Role relation to this entityint
getAccessCounter()
Gets the access counter for a user from perm storage.int
getAccessCounterForSession()
Gets the access counter for a user during a session.String
getConfirmed()
Returns the confirm value of the userDate
getCreateDate()
Returns the creation date of the userString
getEmail()
Returns the email address for this user.String
getFirstName()
Returns the first name for this user.Object
getId()
Get the Id of the SecurityEntity.Date
getLastAccessDate()
Gets the last access date for this User.Date
getLastLogin()
Returns the date of the last login of the userString
getLastName()
Returns the last name for this user.String
getName()
Get the Name of the SecurityEntity.byte[]
getObjectdata()
Returns the value of the objectdata for this user.String
getPassword()
Returns the user's password.Object
getPerm(String name)
Get an object from permanent storage.Object
getPerm(String name, Object def)
Get an object from permanent storage; return default if value is null.Map<String,Object>
getPermStorage()
Returns the permanent storage.Object
getTemp(String name)
Get an object from temporary storage.Object
getTemp(String name, Object def)
Get an object from temporary storage; return default if value is null.Map<String,Object>
getTempStorage()
Returns the temporary storage.org.apache.fulcrum.security.model.turbine.entity.TurbineUser
getUserDelegate()
Get the delegated user<T extends org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole>
Set<T>getUserGroupRoleSet()
Get the User/Group/Role set associated with this entityboolean
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.Object
removeTemp(String name)
Remove an object from temporary storage and return the object.void
removeUserGroupRole(org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole userGroupRole)
Remove a User/Group/Role relation from this entityvoid
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(String confirm)
Sets the new confirm value of the uservoid
setCreateDate(Date createDate)
Sets the new creation date of the uservoid
setEmail(String address)
Sets the email address.void
setFirstName(String firstName)
Sets the first name for this user.void
setHasLoggedIn(Boolean value)
This sets whether or not someone has logged in.void
setId(Object id)
Sets the Id of the SecurityEntity.void
setLastAccessDate()
Sets the last access date for this User.void
setLastLogin(Date lastLogin)
Sets the new date of the last login of the uservoid
setLastName(String lastName)
Sets the last name for this user.void
setName(String name)
Sets the Name of the SecurityEntity.void
setObjectdata(byte[] objectdata)
Sets the value of the objectdata for the uservoid
setPassword(String password)
Set password.void
setPerm(String name, Object value)
Put an object into permanent storage.void
setPermStorage(Map<String,Object> permStorage)
This should only be used in the case where we want to make the data persistent.void
setTemp(String name, Object value)
Put an object into temporary storage.void
setTempStorage(Map<String,Object> tempStorage)
This should only be used in the case where we want to save the data to the database.void
setUserDelegate(org.apache.fulcrum.security.model.turbine.entity.TurbineUser userDelegate)
Set the delegated user<T extends org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole>
voidsetUserGroupRoleSet(Set<T> userGroupRoleSet)
Set the User/Group/Role set associated with this entityvoid
updateLastLogin()
Updates the last login date in the database.void
valueBound(HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Bound to the session.void
valueUnbound(HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Unbound from the session.
-
-
-
Constructor Detail
-
DefaultUserImpl
public DefaultUserImpl(org.apache.fulcrum.security.model.turbine.entity.TurbineUser user)
Constructor- Parameters:
user
- the user object to wrap
-
-
Method Detail
-
valueBound
public void valueBound(HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Bound to the session.- Specified by:
valueBound
in interfaceHttpSessionBindingListener
- Parameters:
hsbe
- Indication of value/session binding.
-
valueUnbound
public void valueUnbound(HttpSessionBindingEvent hsbe)
Implement this method if you wish to be notified when the User has been Unbound from the session.- Specified by:
valueUnbound
in interfaceHttpSessionBindingListener
- Parameters:
hsbe
- Indication of value/session unbinding.
-
getName
public String getName()
Get the Name of the SecurityEntity.- Specified by:
getName
in interfaceorg.apache.fulcrum.security.entity.SecurityEntity
- Returns:
- The Name of the SecurityEntity.
-
setName
public void setName(String name)
Sets the Name of the SecurityEntity.- Specified by:
setName
in interfaceorg.apache.fulcrum.security.entity.SecurityEntity
- Parameters:
name
- Name of the SecurityEntity.
-
getId
public Object getId()
Get the Id of the SecurityEntity.- Specified by:
getId
in interfaceorg.apache.fulcrum.security.entity.SecurityEntity
- Returns:
- The Id of the SecurityEntity.
-
setId
public void setId(Object id)
Sets the Id of the SecurityEntity.- Specified by:
setId
in interfaceorg.apache.fulcrum.security.entity.SecurityEntity
- Parameters:
id
- The new Id of the SecurityEntity
-
getPassword
public String getPassword()
Returns the user's password. This method should not be used by the application directly, because it's meaning depends upon the implementation of UserManager that manages this particular user object. Some implementations will use this attribute for storing a password encrypted in some way, other will not use it at all, when user entered password is presented to some external authority (like NT domain controller) to validate it. See alsoUserManager.authenticate(User,String)
.- Specified by:
getPassword
in interfaceorg.apache.fulcrum.security.entity.User
- Returns:
- A String with the password for the user.
-
setPassword
public void setPassword(String password)
Set password. Application should not use this method directly, seegetPassword()
. See alsoUserManager.changePassword(User,String,String)
.- Specified by:
setPassword
in interfaceorg.apache.fulcrum.security.entity.User
- Parameters:
password
- The new password.
-
getFirstName
public String getFirstName()
Returns the first name for this user.- Specified by:
getFirstName
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Returns:
- A String with the user's first name.
-
setFirstName
public void setFirstName(String firstName)
Sets the first name for this user.- Specified by:
setFirstName
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Parameters:
firstName
- User's first name.
-
getLastName
public String getLastName()
Returns the last name for this user.- Specified by:
getLastName
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Returns:
- A String with the user's last name.
-
setLastName
public void setLastName(String lastName)
Sets the last name for this user.- Specified by:
setLastName
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Parameters:
lastName
- User's last name.
-
getEmail
public String getEmail()
Returns the email address for this user.- Specified by:
getEmail
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Returns:
- A String with the user's email address.
-
setEmail
public void setEmail(String address)
Sets the email address.- Specified by:
setEmail
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Parameters:
address
- The email address.
-
getObjectdata
public byte[] getObjectdata()
Returns the value of the objectdata for this user. Objectdata is a storage area used to store the permanent storage table from the User object.- Specified by:
getObjectdata
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Returns:
- The bytes in the objectdata for this user
-
setObjectdata
public void setObjectdata(byte[] objectdata)
Sets the value of the objectdata for the user- Specified by:
setObjectdata
in interfaceorg.apache.fulcrum.security.entity.ExtendedUser
- Parameters:
objectdata
- The new permanent storage for the user
-
getUserGroupRoleSet
public <T extends org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole> Set<T> getUserGroupRoleSet() throws org.apache.fulcrum.security.util.DataBackendException
Get the User/Group/Role set associated with this entity- Specified by:
getUserGroupRoleSet
in interfaceorg.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRoleEntity
- Returns:
- a set of User/Group/Role relations
- Throws:
org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.
-
setUserGroupRoleSet
public <T extends org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole> void setUserGroupRoleSet(Set<T> userGroupRoleSet)
Set the User/Group/Role set associated with this entity- Specified by:
setUserGroupRoleSet
in interfaceorg.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRoleEntity
- Parameters:
userGroupRoleSet
- a set of User/Group/Role relations
-
addUserGroupRole
public void addUserGroupRole(org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole userGroupRole) throws org.apache.fulcrum.security.util.DataBackendException
Add a User/Group/Role relation to this entity- Specified by:
addUserGroupRole
in interfaceorg.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRoleEntity
- Parameters:
userGroupRole
- a User/Group/Role relation to add- Throws:
org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.
-
removeUserGroupRole
public void removeUserGroupRole(org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole userGroupRole) throws org.apache.fulcrum.security.util.DataBackendException
Remove a User/Group/Role relation from this entity- Specified by:
removeUserGroupRole
in interfaceorg.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRoleEntity
- Parameters:
userGroupRole
- a User/Group/Role relation to remove- Throws:
org.apache.fulcrum.security.util.DataBackendException
- if there was an error accessing the data backend.
-
getAccessCounter
public int getAccessCounter()
Gets the access counter for a user from perm storage.- Specified by:
getAccessCounter
in interfaceUser
- 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 interfaceUser
- 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 interfaceUser
-
incrementAccessCounterForSession
public void incrementAccessCounterForSession()
Increments the session hit counter for the user.- Specified by:
incrementAccessCounterForSession
in interfaceUser
-
setAccessCounter
public void setAccessCounter(int cnt)
Sets the access counter for a user, saved in perm storage.- Specified by:
setAccessCounter
in interfaceUser
- 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 interfaceUser
- Parameters:
cnt
- The new count.
-
getLastAccessDate
public 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 interfaceUser
- 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 interfaceUser
-
getPermStorage
public Map<String,Object> getPermStorage()
Returns the permanent storage. This is implemented as a Map- Specified by:
getPermStorage
in interfaceUser
- Returns:
- A Map.
-
setPermStorage
public void setPermStorage(Map<String,Object> permStorage)
This should only be used in the case where we want to make the data persistent.- Specified by:
setPermStorage
in interfaceUser
- Parameters:
permStorage
- A Map.
-
getTempStorage
public Map<String,Object> getTempStorage()
Returns the temporary storage. This is implemented as a Map- Specified by:
getTempStorage
in interfaceUser
- Returns:
- A Map.
-
setTempStorage
public void setTempStorage(Map<String,Object> tempStorage)
This should only be used in the case where we want to save the data to the database.- Specified by:
setTempStorage
in interfaceUser
- Parameters:
tempStorage
- A Map.
-
getPerm
public Object getPerm(String name, Object def)
Get an object from permanent storage; return default if value is null.
-
getTemp
public Object getTemp(String name, Object def)
Get an object from temporary storage; return default if value is null.
-
removeTemp
public Object removeTemp(String name)
Remove an object from temporary storage and return the object.- Specified by:
removeTemp
in interfaceUser
- Parameters:
name
- The name of the object to remove.- Returns:
- An Object.
-
getConfirmed
public String getConfirmed()
Returns the confirm value of the user- Specified by:
getConfirmed
in interfaceUser
- Returns:
- The confirm value of the user
-
setConfirmed
public void setConfirmed(String confirm)
Sets the new confirm value of the user- Specified by:
setConfirmed
in interfaceUser
- Parameters:
confirm
- The new confirm value of the user
-
getCreateDate
public Date getCreateDate()
Returns the creation date of the user- Specified by:
getCreateDate
in interfaceUser
- Returns:
- The creation date of the user
-
setCreateDate
public void setCreateDate(Date createDate)
Sets the new creation date of the user- Specified by:
setCreateDate
in interfaceUser
- Parameters:
createDate
- The new creation date of the user
-
getLastLogin
public Date getLastLogin()
Returns the date of the last login of the user- Specified by:
getLastLogin
in interfaceUser
- Returns:
- The date of the last login of the user
-
setLastLogin
public void setLastLogin(Date lastLogin)
Sets the new date of the last login of the user- Specified by:
setLastLogin
in interfaceUser
- Parameters:
lastLogin
- The new the date of the last login of the user
-
hasLoggedIn
public boolean hasLoggedIn()
The user is considered logged in if they have not timed out.- Specified by:
hasLoggedIn
in interfaceUser
- Returns:
- Whether the user has logged in.
-
setHasLoggedIn
public void setHasLoggedIn(Boolean value)
This sets whether or not someone has logged in. hasLoggedIn() returns this value.- Specified by:
setHasLoggedIn
in interfaceUser
- Parameters:
value
- Whether someone has logged in or not.
-
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 interfaceUser
- Returns:
- True if the user has been confirmed.
-
updateLastLogin
public void updateLastLogin() throws Exception
Updates the last login date in the database.- Specified by:
updateLastLogin
in interfaceUser
- Throws:
Exception
- A generic exception.
-
getUserDelegate
public org.apache.fulcrum.security.model.turbine.entity.TurbineUser getUserDelegate()
Description copied from interface:TurbineUserDelegate
Get the delegated user- Specified by:
getUserDelegate
in interfaceTurbineUserDelegate
- Returns:
- the userDelegate
-
setUserDelegate
public void setUserDelegate(org.apache.fulcrum.security.model.turbine.entity.TurbineUser userDelegate)
Description copied from interface:TurbineUserDelegate
Set the delegated user- Specified by:
setUserDelegate
in interfaceTurbineUserDelegate
- Parameters:
userDelegate
- the userDelegate to set
-
-