Class CmsSessionInfo

java.lang.Object
org.opencms.main.CmsSessionInfo
All Implemented Interfaces:
Serializable, Comparable<CmsSessionInfo>

public class CmsSessionInfo extends Object implements Comparable<CmsSessionInfo>, 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
See Also:
  • Field Details

  • Constructor Details

    • 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 Details

    • getHourMinuteSecondTimeString

      public static String[] getHourMinuteSecondTimeString(long time)
      Returns a string for given time.

      Parameters:
      time - as timestamp
      Returns:
      string array containing string for hours, minutes, seconds
    • compareTo

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

      Specified by:
      compareTo in interface Comparable<CmsSessionInfo>
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • getAgeOfSession

      Gets the age of the session formattet as HOURS:MINUTES.

      Returns:
      string representation of session age
    • 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
    • getClientLabel

      Returns the optional label of the client this session was created for, taken once at session creation from the CmsRequestContext.ATTRIBUTE_CLIENT_LABEL context attribute.

      Returns:
      the client label, or null for a session created without one
    • 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

      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

      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 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
    • getTimeLastAction

      public long getTimeLastAction()
      Returns the time of the last user action.

      Returns:
      the list user action time
    • 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 Object
      See Also:
    • 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 String toString()
      Overrides:
      toString in class Object
      See Also:
    • 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
    • update

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

      Parameters:
      context - the request context to update the session with
      isHeartBeatRequest - in case of heart beat requests