org.opencms.main
Class CmsSessionInfo

java.lang.Object
  extended by org.opencms.main.CmsSessionInfo
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class CmsSessionInfo
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Stores information about a user that has authenticated himself the OpenCms security system.

This object is used to provide information about all authenticated users in the system with the CmsSessionManager.

This object is available for all authenticated users after login. If a user has not logged in, he may have a session on the servlet engine, but he will have no session info object attached. For example the "Guest" user may have multiple sessions, but no session info is created for him.

Since:
6.0.0
Version:
$Revision: 1.24 $
Author:
Alexander Kandzior, Andreas Zahner
See Also:
Serialized Form

Field Summary
static java.lang.String ATTRIBUTE_SESSION_ID
          Name of the http session attribute the OpenCms session id is stored in.
static int QUEUE_SIZE
          Maximum size of the broadcast queue for one user.
 
Constructor Summary
CmsSessionInfo(CmsRequestContext context, CmsUUID sessionId, int maxInactiveInterval)
          Creates a new CmsSessionInfo object.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Allows sorting session info according to the user names.
 boolean equals(java.lang.Object obj)
           
 org.apache.commons.collections.Buffer getBroadcastQueue()
          Returns the broadcast queue of the user to which this session info belongs.
 int getMaxInactiveInterval()
          Returns the maximum time, in seconds, this session info is allowed to be inactive.
 java.lang.String getOrganizationalUnitFqn()
          Returns the fully qualified name of the organizational unit for this session.
 CmsUUID getProject()
          Returns the id of the project of the user.
 CmsUUID getSessionId()
          Returns the id of the OpenCms (http) session this session info belongs to.
 java.lang.String getSiteRoot()
          Returns the current site root of the user.
 long getTimeActive()
          Returns the time, in milliseconds, this session has been active, that is the time of the last update minus the creation time.
 long getTimeCreated()
          Returns the time this session info was created.
 long getTimeUpdated()
          Returns the time this session info was last updated.
 CmsUUID getUserId()
          Returns the id of the user to which this session info belongs.
 int hashCode()
           
 boolean isExpired()
          Returns true if this session info has expired, that is it has not been updated in the time set by the maximum inactivity interval.
protected  void setProject(CmsUUID projectId)
          Sets the id of the current project of the user of this session info.
 java.lang.String toString()
           
protected  void update(CmsRequestContext context)
          Updates the session info object with the information from the given request context.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTE_SESSION_ID

public static final java.lang.String ATTRIBUTE_SESSION_ID
Name of the http session attribute the OpenCms session id is stored in.

See Also:
Constant Field Values

QUEUE_SIZE

public static final int QUEUE_SIZE
Maximum size of the broadcast queue for one user.

See Also:
Constant Field Values
Constructor Detail

CmsSessionInfo

public CmsSessionInfo(CmsRequestContext context,
                      CmsUUID sessionId,
                      int maxInactiveInterval)
Creates a new CmsSessionInfo object.

Parameters:
context - the user context to create this session info for
sessionId - OpenCms id of the (http) session this session info belongs to
maxInactiveInterval - the maximum time, in seconds, this session info is allowed to be inactive
Method Detail

compareTo

public int compareTo(java.lang.Object obj)
Allows sorting session info according to the user names.

Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getBroadcastQueue

public org.apache.commons.collections.Buffer getBroadcastQueue()
Returns the broadcast queue of the user to which this session info belongs.

Returns:
the broadcast queue of the user to which this session info belongs

getMaxInactiveInterval

public int getMaxInactiveInterval()
Returns the maximum time, in seconds, this session info is allowed to be inactive.

The inactive time is the time since the last call to the update(CmsRequestContext) method. If the inactive time is greater then the maximum allowed time, this session info will be removed from the session manager.

Returns:
the maximum time, in seconds, this session info is allowed to be inactive
See Also:
HttpSession.getMaxInactiveInterval()

getOrganizationalUnitFqn

public java.lang.String getOrganizationalUnitFqn()
Returns the fully qualified name of the organizational unit for this session.

Returns:
the fully qualified name of the organizational unit for this session

getProject

public CmsUUID getProject()
Returns the id of the project of the user.

Returns:
the id of the project

getSessionId

public CmsUUID getSessionId()
Returns the id of the OpenCms (http) session this session info belongs to.

Returns:
the id of the OpenCms (http) session this session info belongs to
See Also:
HttpSession.getId()

getSiteRoot

public java.lang.String getSiteRoot()
Returns the current site root of the user.

Returns:
the current site root of the user

getTimeActive

public long getTimeActive()
Returns the time, in milliseconds, this session has been active, that is the time of the last update minus the creation time.

Returns:
the time, in milliseconds, this session has been active

getTimeCreated

public long getTimeCreated()
Returns the time this session info was created.

Returns:
the time this session info was created

getTimeUpdated

public long getTimeUpdated()
Returns the time this session info was last updated.

Returns:
the time this session info was last updated

getUserId

public CmsUUID getUserId()
Returns the id of the user to which this session info belongs.

Returns:
the id of the user to which this session info belongs

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isExpired

public boolean isExpired()
Returns true if this session info has expired, that is it has not been updated in the time set by the maximum inactivity interval.

Returns:
true if this session info has expired

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

setProject

protected void setProject(CmsUUID projectId)
Sets the id of the current project of the user of this session info.

Parameters:
projectId - the project id to set

update

protected void update(CmsRequestContext context)
Updates the session info object with the information from the given request context.

Parameters:
context - the request context to update the session with