Compoze Software, Inc.

com.compoze.security
Class User

java.lang.Object
  |
  +--com.compoze.security.PrincipalImpl
        |
        +--com.compoze.security.User
All Implemented Interfaces:
java.security.Principal, java.io.Serializable

public class User
extends PrincipalImpl
implements java.io.Serializable

This class represents an application User. To instantiate a user, you can use the constructor or one of the create() methods.

See Also:
Group, IUserAuthenticationFactory, Serialized Form

Field Summary
protected  java.util.Date m_lastLoginDate
           
 
Constructor Summary
User()
          Constructor.
User(java.lang.String sName)
          Creates a new anonymous user with default time zone and locale and the specified unique user name.
User(UserInfo userInfo)
          Creates a new user with the specified user information and default time zone and locale.
 
Method Summary
 void addGroup(Group g)
          Adds the group to the user.
static User create(java.lang.String sName, java.lang.String[] groupNames)
          Creates a new user with the specified name and group membership.
 boolean equals(java.lang.Object obj)
          Compares this principal to the specified object.
 java.lang.String getEmailAddress()
          Gets the email address for this user.
 InfoStore getInfoStore()
          Gets the info store for this user.
 java.util.Date getLastLoginDate()
          Gets the last login date.
 java.util.Locale getLocale()
          Gets the locale for this user.
 java.lang.Object getProperty(java.lang.String sPropertyTag)
          Gets a property of the principal.
 java.util.TimeZone getTimeZone()
          Gets the time zone for this user.
 UserInfo getUserInfo()
          Gets the user information object for the user.
 java.util.List groups()
          Returns an un-modifiable list of the groups this user has membership.
 boolean hasEmailAddress()
          Checks if the user has an email address set.
 boolean isAnonymous()
          Checks if this user is anonymous.
 boolean isMember(Group group)
          Checks if this user is a member of the specified group.
 java.util.Map properties()
          Gets the map of properties for this user.
 void setAnonymous(boolean bAnonymous)
          Sets the if this user is anonymous.
 void setEmailAddress(java.lang.String sEmailAddress)
          Sets the email address for this user.
 void setInfoStore(InfoStore infoStore)
          Sets the info store for this user.
 void setLastLoginDate(java.util.Date lastLoginDate)
          Sets the last login date.
 void setLocale(java.util.Locale locale)
          Sets the locale for this user.
 void setProperty(java.lang.String sPropertyTag, java.lang.Object property)
          Sets the property for the user.
 void setTimeZone(java.util.TimeZone timeZone)
          Sets the time zone for this user.
 void setUserInfo(UserInfo userInfo)
          Sets the user information object for the user.
 java.lang.String toString()
          Returns a string representation of this user.
 
Methods inherited from class com.compoze.security.PrincipalImpl
getName, getPrincipal, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
hashCode
 

Field Detail

m_lastLoginDate

protected java.util.Date m_lastLoginDate
Constructor Detail

User

public User()
Constructor. NOTE: This default constructor technically leaves the user in an invalid state.

User

public User(java.lang.String sName)
Creates a new anonymous user with default time zone and locale and the specified unique user name.
Parameters:
sName - the unique user name (may not be null)

User

public User(UserInfo userInfo)
Creates a new user with the specified user information and default time zone and locale.
Parameters:
userInfo - the user information for this user
Method Detail

create

public static User create(java.lang.String sName,
                          java.lang.String[] groupNames)
Creates a new user with the specified name and group membership.
Parameters:
sName - the unique user name (may not be null)
groupNames - an array of unique group names the user has membership (null for none)
Returns:
the new user

getLocale

public java.util.Locale getLocale()
Gets the locale for this user.
Returns:
the locale

getLastLoginDate

public java.util.Date getLastLoginDate()
Gets the last login date.
Returns:
the date or null if not available

setLastLoginDate

public void setLastLoginDate(java.util.Date lastLoginDate)
Sets the last login date. Normally, this method is called when a session is created.
Parameters:
lastLoginDate - the date or null for not set

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale for this user.
Parameters:
locale - the locale for this user (may not be null)

getTimeZone

public java.util.TimeZone getTimeZone()
Gets the time zone for this user.
Returns:
the time zone or the system default time zone if time zone not set

setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for this user.
Parameters:
timeZone - the time zone for this user (may not be null)

setEmailAddress

public void setEmailAddress(java.lang.String sEmailAddress)
Sets the email address for this user.
Parameters:
sEmailAddress - the email address

hasEmailAddress

public boolean hasEmailAddress()
Checks if the user has an email address set. The email address is considered set if it is not null or empty.
Parameters:
true - if the user has an email address set; false otherwise

getEmailAddress

public java.lang.String getEmailAddress()
Gets the email address for this user.
Returns:
the email address

isAnonymous

public boolean isAnonymous()
Checks if this user is anonymous.
Returns:
true if this user is anonymous; false otherwise

setAnonymous

public void setAnonymous(boolean bAnonymous)
Sets the if this user is anonymous.
Parameters:
bAnonymous - true if this user is anonymous; false otherwise

getInfoStore

public InfoStore getInfoStore()
Gets the info store for this user. The info store defines the data source, username and password to use when connecting to the database. The default setting for the data store are taken from ejbruntime.properties.
Returns:
the info store for this user

setInfoStore

public void setInfoStore(InfoStore infoStore)
Sets the info store for this user. The info store defines the data source, username and password to use when connecting to the database.
Parameters:
infoStore - the info store for this user (may not be null)

equals

public boolean equals(java.lang.Object obj)
Compares this principal to the specified object.
Overrides:
equals in class PrincipalImpl
Parameters:
obj - principal to compare with
Returns:
true if the principal passed in is the same as that encapsulated by this principal; false otherwise

getUserInfo

public UserInfo getUserInfo()
Gets the user information object for the user. The user info object contains information such as name and user credential.
Returns:
the user info

setUserInfo

public void setUserInfo(UserInfo userInfo)
Sets the user information object for the user. The user info object contains information such as name and user credential.
Parameters:
userInfo - the user info (may not be null)

setProperty

public void setProperty(java.lang.String sPropertyTag,
                        java.lang.Object property)
Sets the property for the user.
Parameters:
sPropertyTag - the property tag
property - the property value

getProperty

public java.lang.Object getProperty(java.lang.String sPropertyTag)
Gets a property of the principal.
Parameters:
sPropertyTag - the property tag to get
Returns:
the value of the property or null if property does not exist

properties

public java.util.Map properties()
Gets the map of properties for this user.
Returns:
a map of properties associated with this user (un-modifiable)

addGroup

public void addGroup(Group g)
Adds the group to the user.
Parameters:
g - the group to add (may not be null)

groups

public java.util.List groups()
Returns an un-modifiable list of the groups this user has membership.
Returns:
a list of the groups (Group)

isMember

public boolean isMember(Group group)
Checks if this user is a member of the specified group.
Parameters:
group - the group whose membership is to be checked
Returns:
true if this user is a member of the group; false otherwise

toString

public java.lang.String toString()
Returns a string representation of this user.
Overrides:
toString in class PrincipalImpl
Returns:
the string representation of this user

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.