fr.gouv.culture.sdx.user
Class UserInformation

java.lang.Object
  extended byfr.gouv.culture.sdx.user.UserInformation
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled
Direct Known Subclasses:
AnonymousUserInformation, SuperuserInformation

public class UserInformation
extends java.lang.Object
implements org.apache.avalon.framework.logger.LogEnabled

Basic user information used in sessions.

This class handles the username, the groups the user belongs to, and the preferred locale. If the locale is not set for a user, the user information object will refer to the application's default locale.


Field Summary
static java.lang.String ANONYMOUS_USERNAME
          The anonymous user name
protected  java.lang.String host
          Possible remote host externally setted to inform toSAX()
protected  java.lang.String ip
          Possible remote IP externally setted to inform toSAX()
static java.lang.String SESSION_PROPERTY
          The session property name for user information.
 
Constructor Summary
UserInformation()
          Creates the object A logger must be set and then this object must be setUp.
 
Method Summary
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Sets the logger.
 java.lang.String getAppId()
           
 java.lang.String getEmail()
           
 java.lang.String getFirstname()
          Returns the firstname.
 java.util.Hashtable getGroups()
          Returns the list of groups this user belongs to.
 java.lang.String getHost()
          Get an host if setted
 java.lang.String getId()
          Returns the username.
 java.lang.String getIp()
          Get an IP if setted
 java.lang.String getLastname()
          Returns the lastname.
 java.util.Locale getPreferredLocale()
          Returns the preferred locale.
 boolean isAdmin()
          Returns isAdmin.
 boolean isMember(java.lang.String groupname)
          Returns whether this user is member of a group.
 boolean isMember(java.lang.String[] groupnames)
          Returns whether this user is member of at least one of the groups.
 boolean isMember(java.lang.String[] groupnames, boolean all)
          Test whether this user is member of some groups.
 boolean isSuperuser()
          Returns true if this user is an SDX superuser.
 void setEmail(java.lang.String email)
           
 void setFirstname(java.lang.String firstname)
          Sets the firstname (may be null).
 void setGroups(java.util.Hashtable groups)
          Sets the groups the user belongs to.
 void setHost(java.lang.String host)
          Set a remote Host externally, probably from acceptRequest
 void setId(java.lang.String id)
          Sets the username (may not be null).
 void setIp(java.lang.String ip)
          Set an IP externally, probably from acceptRequest
 void setLastname(java.lang.String lastname)
          Sets the firstname (may be null).
 void setPreferredLocale(java.util.Locale preferredLocale)
          Sets the preferred locale (may not be null).
 void setUp(java.lang.String appId, java.lang.String id, java.util.Hashtable groups, java.util.Locale locale, java.lang.String firstname, java.lang.String lastname, java.lang.String email, java.lang.String adminGroup)
          Creates user information.
 void toSAX(org.xml.sax.ContentHandler handler)
          Sends information about this anonymous user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ip

protected java.lang.String ip
Possible remote IP externally setted to inform toSAX()


host

protected java.lang.String host
Possible remote host externally setted to inform toSAX()


SESSION_PROPERTY

public static final java.lang.String SESSION_PROPERTY
The session property name for user information.

See Also:
Constant Field Values

ANONYMOUS_USERNAME

public static final java.lang.String ANONYMOUS_USERNAME
The anonymous user name

See Also:
Constant Field Values
Constructor Detail

UserInformation

public UserInformation()
Creates the object

A logger must be set and then this object must be setUp.

See Also:
enableLogging(org.apache.avalon.framework.logger.Logger), setUp(java.lang.String, java.lang.String, java.util.Hashtable, java.util.Locale, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
Method Detail

setUp

public void setUp(java.lang.String appId,
                  java.lang.String id,
                  java.util.Hashtable groups,
                  java.util.Locale locale,
                  java.lang.String firstname,
                  java.lang.String lastname,
                  java.lang.String email,
                  java.lang.String adminGroup)
           throws SDXException
Creates user information.

Parameters:
id - The username.
groups - The groups it belongs to (may be null or empty).
locale - Thhye user's preferred locale. If logging is desired the logger should be set after creation.
Throws:
SDXException - An exception if the username or the locale are null.
See Also:
enableLogging(org.apache.avalon.framework.logger.Logger)

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Sets the logger.

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Parameters:
logger - The logger to use.

getGroups

public java.util.Hashtable getGroups()
Returns the list of groups this user belongs to.


setGroups

public void setGroups(java.util.Hashtable groups)
               throws SDXException
Sets the groups the user belongs to.

Parameters:
groups - The list of group names (may not be null).
Throws:
SDXException

getId

public java.lang.String getId()
Returns the username.


isAdmin

public boolean isAdmin()
Returns isAdmin.


setId

public void setId(java.lang.String id)
           throws SDXException
Sets the username (may not be null).

Throws:
SDXException

getFirstname

public java.lang.String getFirstname()
Returns the firstname.


setFirstname

public void setFirstname(java.lang.String firstname)
                  throws SDXException
Sets the firstname (may be null).

Throws:
SDXException

getLastname

public java.lang.String getLastname()
Returns the lastname.


setLastname

public void setLastname(java.lang.String lastname)
                 throws SDXException
Sets the firstname (may be null).

Throws:
SDXException

getPreferredLocale

public java.util.Locale getPreferredLocale()
Returns the preferred locale.


setPreferredLocale

public void setPreferredLocale(java.util.Locale preferredLocale)
                        throws SDXException
Sets the preferred locale (may not be null).

Parameters:
preferredLocale - The locale
Throws:
SDXException

getEmail

public java.lang.String getEmail()

setEmail

public void setEmail(java.lang.String email)

getAppId

public java.lang.String getAppId()

isMember

public boolean isMember(java.lang.String[] groupnames,
                        boolean all)
Test whether this user is member of some groups.

Parameters:
groupnames - The list of groups.
all - If true, the user must be member of each groups ; otherwise of at least one of them.

isMember

public boolean isMember(java.lang.String[] groupnames)
Returns whether this user is member of at least one of the groups. This method is a shortcut for isMember(groupnames, false).

Parameters:
groupnames - The list of group names.

isMember

public boolean isMember(java.lang.String groupname)
Returns whether this user is member of a group.

Parameters:
groupname - The name of the group.

setIp

public void setIp(java.lang.String ip)
Set an IP externally, probably from acceptRequest

Parameters:
ip -

getIp

public java.lang.String getIp()
Get an IP if setted


setHost

public void setHost(java.lang.String host)
Set a remote Host externally, probably from acceptRequest

Parameters:
host -

getHost

public java.lang.String getHost()
Get an host if setted


toSAX

public void toSAX(org.xml.sax.ContentHandler handler)
           throws org.xml.sax.SAXException
Sends information about this anonymous user.

The information sent is basically a user definition with nested groups

Parameters:
handler - The handler where to send events.
Throws:
org.xml.sax.SAXException

isSuperuser

public boolean isSuperuser()
Returns true if this user is an SDX superuser.

This class always return false. Subclasses such as SuperuserInformation may return true.



Copyright © 2000-2004 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.