Package org.opencms.main
Class CmsSessionInfo
java.lang.Object
org.opencms.main.CmsSessionInfo
- All Implemented Interfaces:
Serializable
,Comparable<CmsSessionInfo>
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
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the http session attribute the OpenCms session id is stored in.static final int
Maximum size of the broadcast queue for one user. -
Constructor Summary
ConstructorDescriptionCmsSessionInfo
(CmsRequestContext context, CmsUUID sessionId, int maxInactiveInterval) Creates a new CmsSessionInfo object. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(CmsSessionInfo obj) Allows sorting session info according to the user names.boolean
Gets the age of the session formattet as HOURS:MINUTES.org.apache.commons.collections.Buffer
Returns the broadcast queue of the user to which this session info belongs.static String[]
getHourMinuteSecondTimeString
(long time) Returns a string for given time.int
Returns the maximum time, in seconds, this session info is allowed to be inactive.Returns the fully qualified name of the organizational unit for this session.Returns the id of the project of the user.Returns the id of the OpenCms (http) session this session info belongs to.Returns the current site root of the user.long
Returns the time, in milliseconds, this session has been active, that is the time of the last update minus the creation time.long
Returns the time this session info was created.long
Returns the time of the last user action.long
Returns the time this session info was last updated.Returns the id of the user to which this session info belongs.int
hashCode()
boolean
Returnstrue
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.toString()
protected void
update
(CmsRequestContext context) Updates the session info object with the information from the given request context.protected void
update
(CmsRequestContext context, boolean isHeartBeatRequest) Updates the session info object with the information from the given request context.
-
Field Details
-
ATTRIBUTE_SESSION_ID
Name of the http session attribute the OpenCms session id is stored in.- See Also:
-
QUEUE_SIZE
Maximum size of the broadcast queue for one user.- See Also:
-
-
Constructor Details
-
CmsSessionInfo
Creates a new CmsSessionInfo object.- Parameters:
context
- the user context to create this session info forsessionId
- OpenCms id of the (http) session this session info belongs tomaxInactiveInterval
- the maximum time, in seconds, this session info is allowed to be inactive
-
-
Method Details
-
getHourMinuteSecondTimeString
Returns a string for given time.- Parameters:
time
- as timestamp- Returns:
- string array containing string for hours, minutes, seconds
-
compareTo
Allows sorting session info according to the user names.- Specified by:
compareTo
in interfaceComparable<CmsSessionInfo>
- See Also:
-
equals
-
getAgeOfSession
Gets the age of the session formattet as HOURS:MINUTES.- Returns:
- string representation of session age
-
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
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
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
Returns the id of the project of the user.- Returns:
- the id of the project
-
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
Returns the current site root of the user.- Returns:
- the current site root of the user
-
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
Returns the time this session info was created.- Returns:
- the time this session info was created
-
getTimeLastAction
Returns the time of the last user action.- Returns:
- the list user action time
-
getTimeUpdated
Returns the time this session info was last updated.- Returns:
- the time this session info was last updated
-
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
-
isExpired
Returnstrue
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
-
setProject
Sets the id of the current project of the user of this session info.- Parameters:
projectId
- the project id to set
-
update
Updates the session info object with the information from the given request context.- Parameters:
context
- the request context to update the session with
-
update
Updates the session info object with the information from the given request context.- Parameters:
context
- the request context to update the session withisHeartBeatRequest
- in case of heart beat requests
-