Class CmsSessionInfo

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CmsSessionInfo>

    public class CmsSessionInfo
    extends java.lang.Object
    implements java.lang.Comparable<CmsSessionInfo>, 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
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(CmsSessionInfo obj)
      Allows sorting session info according to the user names.
      boolean equals​(java.lang.Object obj)  
      java.lang.String getAgeOfSession()
      Gets the age of the session formattet as HOURS:MINUTES.
      org.apache.commons.collections.Buffer getBroadcastQueue()
      Returns the broadcast queue of the user to which this session info belongs.
      static java.lang.String[] getHourMinuteSecondTimeString​(long time)
      Returns a string for given time.
      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 getTimeLastAction()
      Returns the time of the last user action.
      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.
      protected void update​(CmsRequestContext context, boolean isHeartBeatRequest)
      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
    • 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

      • getHourMinuteSecondTimeString

        public static java.lang.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 java.lang.Comparable<CmsSessionInfo>
        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)
      • getAgeOfSession

        public java.lang.String 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
      • 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
      • 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 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
      • 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