fr.gouv.culture.sdx.user
Class UserInformation

java.lang.Object
  extended by fr.gouv.culture.sdx.utils.AbstractSdxObject
      extended by fr.gouv.culture.sdx.user.UserInformation
All Implemented Interfaces:
Describable, Encodable, Identifiable, Localizable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable
Direct Known Subclasses:
AnonymousUserInformation, SuperuserInformation

public class UserInformation
extends AbstractSdxObject

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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
SdxObject.ConfigurationNode
 
Field Summary
static java.lang.String ANONYMOUS_USERNAME
          The anonymous user name
static java.lang.String CLASS_NAME_SUFFIX
           
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.
 
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized
 
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
DEFAULT_ENCODING
 
Constructor Summary
UserInformation()
          Creates the object A super.getLog() must be set and then this object must be setUp.
 
Method Summary
 java.lang.String getAppId()
           
protected  java.lang.String getClassNameSuffix()
          Tells whether this user may admin an application.
 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 getIp()
          Get an IP if setted
 java.lang.String getLastname()
          Returns the lastname.
 java.util.Locale getPreferredLocale()
          Returns the preferred locale.
protected  boolean initToSax()
          Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
protected  void initVolatileObjectsToSax()
          Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called
 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 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 fr.gouv.culture.sdx.utils.AbstractSdxObject
configure, configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, verifyConfigurationResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME_SUFFIX

public static final java.lang.String CLASS_NAME_SUFFIX
See Also:
Constant Field Values

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 super.getLog() must be set and then this object must be setUp.

See Also:
AbstractSdxObject.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 super.getLog() should be set after creation.
Throws:
SDXException - An exception if the username or the locale are null.
See Also:
AbstractSdxObject.enableLogging(org.apache.avalon.framework.logger.Logger)

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

isAdmin

public boolean isAdmin()
Returns isAdmin.


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

Specified by:
toSAX in interface org.apache.excalibur.xml.sax.XMLizable
Overrides:
toSAX in class AbstractSdxObject
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.


getClassNameSuffix

protected java.lang.String getClassNameSuffix()
Tells whether this user may admin an application.

Specified by:
getClassNameSuffix in class AbstractSdxObject
Parameters:
app - The application ID.
admin - If true, user may admin.

initToSax

protected boolean initToSax()
Description copied from class: AbstractSdxObject
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML

Specified by:
initToSax in class AbstractSdxObject

initVolatileObjectsToSax

protected void initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called

Specified by:
initVolatileObjectsToSax in class AbstractSdxObject


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