Class SessionInfo

    • Field Detail

      • NoneSession

        public static final SessionInfo NoneSession
      • AnonymousSession

        public static final SessionInfo AnonymousSession
    • Constructor Detail

      • SessionInfo

        public SessionInfo​(String sessionId,
                           User user)
        Constructs a new instance about a given opened user session.
        Parameters:
        sessionId - the identifier of the opened session.
        user - the user for which a session was opened.
    • Method Detail

      • getIPAddress

        public String getIPAddress()
        Gets the IP address of the remote client that opened the session.
        Returns:
        the client remote IP address.
      • setIPAddress

        public void setIPAddress​(String ip)
        Sets the IP address of the remote client that requests a session opening with Silverpeas.
        Parameters:
        ip - the IP address of the remote client.
      • getLastAccessTimestamp

        public long getLastAccessTimestamp()
        Gets the timestamp of the last access by the client behind this session.
        Returns:
        timestamp of the last access.
      • getOpeningTimestamp

        public long getOpeningTimestamp()
        Gets the timestamp at which the session with Silverpeas was opened.
        Returns:
        the session opening timestamp.
      • getLastIdleDuration

        public long getLastIdleDuration()
        Gets the last duration of its idle time.
        Returns:
        the session alive timestamp.
      • setAsIdle

        public void setAsIdle()
        Sets this session as currently idle. A session is idle if it is not used since a given time but it is still in alive.
      • getSessionId

        public String getSessionId()
        Gets the unique identifier of the session.
        Returns:
        the session identifier.
      • getUserDetail

        public User getUserDetail()
        Gets the profile of the user that opened the session.
        Returns:
        a UserDetail instance with the profile information on the user.
      • updateLastAccess

        public void updateLastAccess()
        Updates the last access timestamp.
      • setAttribute

        public <T> void setAttribute​(String name,
                                     T value)
        Sets an attribute named by the specified name with the specified value. If no attribute exists with the specified name, then it is added to the session.
        Type Parameters:
        T - the type of the attribute value.
        Parameters:
        name - the name of the attribute to set.
        value - the value of the attribute to set.
      • getAttribute

        public <T> T getAttribute​(String name)
        Gets the value of the attribute named by the specified name.
        Type Parameters:
        T - the type of the attribute value.
        Parameters:
        name - the name of the attribute to get.
        Returns:
        the value of the attribute or null if no such attribute exists.
      • unsetAttribute

        public void unsetAttribute​(String name)
        Unsets the specified attribute. The consequence of an unset is the attribute is then removed from the session.
        Parameters:
        name - the name of the attibute to unset.
      • onClosed

        public void onClosed()
        Frees the allocated resources used in the session management and carried by this session information. This method must be called at session closing by the session management system.
      • isDefined

        public boolean isDefined()
        Is this session defined? A session is defined if it's a session opened to a user in Silverpeas.
        Returns:
        true if this session is defined, false otherwise.
      • isAnonymous

        public boolean isAnonymous()
        Is this session an anonymous one? A session is anonymous when no users are explicitly authenticated and then identified and the users uses Silverpeas under the cover of an anonymous user account.
        Returns:
        true if this session is a defined anonymous one, false otherwise.
      • getCache

        public SimpleCache getCache()
        Provides a cache associated to the current session.
        Returns:
        the user session cache.