com.silverpeas.session
Class SessionInfo

java.lang.Object
  extended by com.silverpeas.session.SessionInfo
Direct Known Subclasses:
HTTPSessionInfo

public class SessionInfo
extends Object

It gathers information about an opened session of a user.


Field Summary
static SessionInfo AnonymousSession
           
static SessionInfo NoneSession
           
 
Constructor Summary
SessionInfo(String sessionId, UserDetail user)
          Constructs a new instance about a given opened user session.
 
Method Summary
<T> T
getAttribute(String name)
          Gets the value of the attribute named by the specified name.
 InMemoryCacheService getCache()
          Provides a cache associated to the current session.
 String getIPAddress()
          Gets the IP address of the remote client that opened the session.
 long getLastAccessTimestamp()
          Gets the timestamp of the last access by the client behind this session.
 long getLastIdleDuration()
          Gets the last duration of its idle time.
 long getOpeningTimestamp()
          Gets the timestamp at which the session with Silverpeas was opened.
 String getSessionId()
          Gets the unique identifier of the session.
 UserDetail getUserDetail()
          Gets the profile of the user that opened the session.
 boolean isDefined()
          Is this session is defined?
 void onClosed()
          Frees the allocated resources used in the session management and carried by this session information.
 void setAsIdle()
          Sets this session as currently idle.
<T> void
setAttribute(String name, T value)
          Sets an attribute named by the specified name with the specified value.
 void setIPAddress(String ip)
          Sets the IP address of the remote client that requests a session opening with Silverpeas.
 void unsetAttribute(String name)
          Unsets the specified attribute.
 void updateLastAccess()
          Updates the last access timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NoneSession

public static final SessionInfo NoneSession

AnonymousSession

public static final SessionInfo AnonymousSession
Constructor Detail

SessionInfo

public SessionInfo(String sessionId,
                   UserDetail 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

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.

getIPAddress

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

Returns:
the client remote IP address.

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 UserDetail 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 is 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.

getCache

public InMemoryCacheService getCache()
Provides a cache associated to the current session.

Returns:


Copyright © 2016 Silverpeas. All Rights Reserved.