Class SessionInfo
- java.lang.Object
-
- org.silverpeas.core.security.session.SessionInfo
-
- All Implemented Interfaces:
SilverpeasUserSession
- Direct Known Subclasses:
HTTPSessionInfo
,OneShotSessionInfo
public abstract class SessionInfo extends Object implements SilverpeasUserSession
Default implementation of a user session in Silverpeas. It gathers information about an opened session of a user. It is an abstract class providing a default implementation of a user session in Silverpeas for whatever technical session in use. It is the responsibility of the concrete class extending theSessionInfo
abstract class to define on which technical session the user sessions in Silverpeas have to be built.
-
-
Field Summary
Fields Modifier and Type Field Description static SessionInfo
NoneSession
A non defined session.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SessionInfo(String sessionId, User user)
Constructs a new instance about a given opened user session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getAttribute(String name)
Gets the value of the attribute named by the specified name.org.silverpeas.kernel.cache.model.SimpleCache
getCache()
Provides a cache associated to the current session.String
getId()
Gets the unique identifier of the 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.User
getUser()
Gets the user which as opened to session.User
getUserDetail()
Gets the profile of the user that opened the session.boolean
isAnonymous()
Is this session an anonymous one?boolean
isDefined()
Is this session defined?boolean
isOneShot()
Is this session a one-shot one?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.void
setAsOneShot()
Sets this session as a one-shot one.<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.
-
-
-
Field Detail
-
NoneSession
public static final SessionInfo NoneSession
A non defined session. To use instead of null or to represent a session info not bound to any user session.
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:SilverpeasUserSession
Gets the unique identifier of the session.- Specified by:
getId
in interfaceSilverpeasUserSession
- Returns:
- the unique identifier as string.
-
getUser
public User getUser()
Description copied from interface:SilverpeasUserSession
Gets the user which as opened to session.- Specified by:
getUser
in interfaceSilverpeasUserSession
- Returns:
- a
User
instance.
-
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. A one-shot session cannot be in idle state. Invoking this method on such a session will throw anIllegalStateException
exception.- Returns:
- the session alive timestamp.
-
setAsIdle
public void setAsIdle()
Sets this session as currently idle. A one-shot session cannot be in idle state. Invoking this method on such a session will throw anIllegalStateException
exception.
-
setAsOneShot
public void setAsOneShot()
Sets this session as a one-shot one. A one-shot session cannot become a long-living session after.
-
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. A one-shot session cannot used in several user calls. Invoking this method on such a session will throw anIllegalStateException
exception.
-
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.- Specified by:
setAttribute
in interfaceSilverpeasUserSession
- 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.- Specified by:
getAttribute
in interfaceSilverpeasUserSession
- 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.- Specified by:
unsetAttribute
in interfaceSilverpeasUserSession
- Parameters:
name
- the name of the attribute 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.- Specified by:
isDefined
in interfaceSilverpeasUserSession
- 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 a transparent anonymous user account.- Specified by:
isAnonymous
in interfaceSilverpeasUserSession
- Returns:
- true if this session is a defined anonymous one, false otherwise.
-
isOneShot
public boolean isOneShot()
Is this session a one-shot one? A one-shot session is a short time living session that doesn't live over the scope of a functional call (id est over the scope of an HTTP request).- Specified by:
isOneShot
in interfaceSilverpeasUserSession
- Returns:
- true if this session is a one-shot one, false otherwise.
-
getCache
public org.silverpeas.kernel.cache.model.SimpleCache getCache()
Provides a cache associated to the current session.- Returns:
- the user session cache.
-
-