| |
|
| java.lang.Object com.lutris.appserver.server.sessionEnhydra.StandardSessionManager
All known Subclasses: com.lutris.appserver.server.sessionEnhydra.SimpleServletSessionManager,
StandardSessionManager | public class StandardSessionManager implements SessionManager,StandardSessionIdleHandler(Code) | | This session manager maintains the mapping between session keys and sessions.
It generates secure session keys that are safe to use as cookie values in web
applications. It also manages the life of a session. If a session is not used
(touched) for a preconfigured amount of time, then it is expired and removed
from the session manager. The following parameters can be used to configure
the session manager. They should be grouped together in a section, normally
SessionManager , which is specified to the constructor.
SessionLifetimeMax: {int}
The maximum number of minutes a session is valid. If this value us zero, then
there is no lifetime limit. This parameter must be set in the configuration
file.
SessionIdleTimeMax: {int}
Maximum number of minutes a session may be idle before the session is expired
(deleted). If this value is less than or equal to zero, then the session may
be idle indefinitly.
SessionNoUserIdleTimeMax: {int}
Maximum number of minutes a session that does not have a User
object assocaited with it may be idle before the session is expired
(deleted). If this value is less than or equal to zero, then the session may
be idle indefinitly. Default is the same as MaxIdleTime
IdleScanInterval: {int}
How often, in seconds, the session manager tests if any sessions should be
expired. This parameter must be greater than zero.
RandomizerIntervals: {int [,int]...}
The set of varying intervals to use for adding user-generated entropy to the
random number generator. It is a good idea to use several different prime
numbers. These intervals are in seconds.
SessionHome.Mode: {BASIC | PAGE_TO_DISK | PAGE_TO_DB | CUSTOM}
Indicates the mode (StandardSessionHome interface) that the standard session
manager will use. In 'BASIC' mode the standard session manager uses the
BasicSessionHome to manage sessions. In 'PAGE_TO_DISK' the
standard session manager uses the DiskPagedSessionHome to
manage sessions. In 'PAGE_TO_DB' the standard session manager used the
PersistentSessionHome to manage sessions. In 'CUSTOM' the
application specifies the classes that should be loaded and provide the
StandardSessionHome implementation. If set to 'CUSTOM' then
the settings SessionHome.Class and
SessionUserTable.Class should be set.
SessionHome.Class: {String}
The class that implements the StandardSessionHome interface. This class is
loaded by StandardSessionManager and used to managed the collection of
sessions. If this option is not specified then BasicSessionHome is used. The
SessionHome that is loaded by the session manager is expected to contain a
consturctor that takes the following arguments:
SessionHome(StandardSessionManager mgr,
com.lutris.util.Config config,
ClassLoader loader)
SessionUserTable.Class: {String}
The class that implements the StandardSessiondUserTable interface. This class
is loaded by StandardSessionManager and used to managed the session to user
relationships. If this option is not specified then BasicSessionUserTable is
used. The SessionUserTable that is loaded by the session manager is expected
to contain a consturctor that takes the following arguments:
SessionUserTable(com.lutris.util.Config config)
MemoryPersistence: {true|false}
Indicate that should we keep sessions in memory when stop application
version: $Revision: 1.4 $ author: John Marco author: Shawn McMurdo author: Kyle Clark author: Mark Diekhans See Also: com.lutris.util.Config See Also: StandardSessionHome See Also: StandardSessionUserTable See Also: BasicSessionHome See Also: DiskPagedSessionHome See Also: com.lutris.appserver.server.sessionEnhydra.persistent.PersistentSessionHome |
Method Summary | |
public int | activeSessionCount() Gets the number of currently active sessions. | public void | cleanUpIdleSessions() Scans session table to determine if any sessions need to be expired. | public Session | createSession() Create a new Session object and associate a unique random
key. | public Session | createSession(String ipPortToken) Create a new Session object and associate a unique random
key. | public Session | createSession(HttpPresentationComms comms) | protected void | debug(int level, String msg) Prints debug information under Logger.DEBUG. | public synchronized void | deleteSession(Session session) Removes a session from the Session Table. | public synchronized void | deleteSession(String sessionKey) Removes a session from the Session Table. | public boolean | getEmptySessionPath() | public boolean | getEncodeFirstUrl() Returns the url encoding rule for the first application page
(true/false). | public String | getEncodeUrlState() Returns the url encoding state. | public long | getMaxNoUserSessionIdleTime() Returns the maximum no-user session idle time, in seconds. | public long | getMaxSessionIdleTime() Returns the maximum session idle time, in seconds. | public long | getMaxSessionLifeTime() Returns the maximum session life time, in seconds. | public int | getMode() Returns the current mode for the session manager. | public synchronized Session | getSaveSession(Thread thread, String sessionKey) Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is NOT!!! updated to the current time.
This method is for save reporting without change the last time used.
Parameters: thread - the thread to associate with the session. Parameters: sessionKey - The String used to reference a Session object. | public synchronized Session | getSession(String sessionKey) Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is updated to the current time.
Parameters: sessionKey - The String used to reference a Session object. | public synchronized Session | getSession(Thread thread, String sessionKey) Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is updated to the current time.
Parameters: thread - the thread to associate with the session. Parameters: sessionKey - The String used to reference a Session object. | public synchronized Session | getSession(Thread thread, String sessionKey, HttpPresentationComms comms) | public synchronized Enumeration | getSessionKeys() Get all of the active sessions. | public synchronized Enumeration | getSessionKeys(User user) Lookup the keys for the active sessions for a user. | protected int | isSessionExpired(StandardSession session) Determine if a session should be expired based on the idle time. | protected StandardSessionHome | loadSessionHome(Config config) Loads the StandardSessionHome used by this session manager. | protected StandardSessionUserTable | loadSessionUserTable(Config config) Loads the StandardSessiondUserTable used by this session manager. | public int | maxSessionCount() Gets the maximum number of concurent sessions that existed at any time
since this object was created, or resetMaxSessionCount()
was called. | public Date | maxSessionCountDate() Gets the time when the maximum refered to by maxSessionCount()
occured. | protected StandardSession | newSession(String sessionKey) Allocate a new StandardSession object. | public int | pagedSessionCount() Gets the number of session that are paged to persistent store. | public void | passivateSession(Thread thread, String sessionKey) Puts a session into the 'passive' state. | protected synchronized void | registerUser(Session session) Adds a session's user to the session-to-user table. | public void | resetMaxSessionCount() Reset the maximum session count. | protected void | sessionDeleted(Session session, int reason) Method called when a session is deleted. | public synchronized boolean | sessionExists(String sessionKey) Returns whether the Session object associated with the
specified session key exists.
Parameters: sessionKey - The String used to reference a Session object. | public void | setMaxSessionIdleTime(long maxSessionIdleTime) Sets the maximum session idle time, in seconds. | public synchronized void | shutdown() Shutdown this session manager, stopping threads that are associated with
it. | protected synchronized void | unregisterUser(Session session) Removes a session's user from the session-to-user table. |
CFG_EMPTY_SESSION_PATH | final public static String CFG_EMPTY_SESSION_PATH(Code) | | The name of the config variable for the EmptySessionPath.
|
CFG_ENCODE_FIRST_URL | final public static String CFG_ENCODE_FIRST_URL(Code) | | Url encoding for first page state (to force it or not)
CFG_ENCODE_URL_STATE must not be set to NEVER for this parameter to take
efect
|
CFG_ENCODE_URL_STATE | final public static String CFG_ENCODE_URL_STATE(Code) | | The name of the config variable for the url encoding state
|
CFG_IDLE | final public static String CFG_IDLE(Code) | | The name of the config variable for the max session idle time.
|
CFG_LIFE | final public static String CFG_LIFE(Code) | | The name of the config variable for the max session lifetime.
|
CFG_NOUSER_IDLE | final public static String CFG_NOUSER_IDLE(Code) | | The name of the config variable for the max idle time for sessions with
no user.
|
CFG_RANDOM | final public static String CFG_RANDOM(Code) | | The name of the config variable for the interval between introduction of
randomness to the session key generator.
|
CFG_SCAN | final public static String CFG_SCAN(Code) | | The name of the config variable for the interval between scans for idle
sessions.
|
CFG_SESSION_HOME | final public static String CFG_SESSION_HOME(Code) | | The name of the config variable for the session home settings.
|
CFG_SESSION_HOME_TYPE | final public static String CFG_SESSION_HOME_TYPE(Code) | | The name of the config variable for the session home type.
|
ENCODE_RANDOM_NO | final public static String ENCODE_RANDOM_NO(Code) | | |
ENCODE_RANDOM_YES | final public static String ENCODE_RANDOM_YES(Code) | | |
MODE_CUSTOM | final public static int MODE_CUSTOM(Code) | | Indicates that the session manager is using the custom home interface to
manage sessions.
See Also: StandardSessionManager.getMode |
defaultEmptySessionPath | protected static boolean defaultEmptySessionPath(Code) | | Determins whether to use empty path (/) as session cookie path attribute
value! Default value is false which means - use application context path.
|
defaultEncodeUrlState | protected static String defaultEncodeUrlState(Code) | | Indicates url encoding status. Assumes that
comms.response.writeHTML(HTMLDocument doc) is used to commit the response
to the client. The default is to Auto.
Never indicates urls are never encoded with session keys.
This indicates that session cookies have to be used or no session state
can be maintained.
Always indicates that urls are always encoded with session
keys. Session cookies are never used.
Auto indicates that session cookies will be if available.
If not, urls will automatically be encoded.
See Also: StandardSessionManager.getEncodeUrlState |
defaultIdleScanInterval | protected static long defaultIdleScanInterval(Code) | | Default interval, in seconds, to scan for sessions to expire. A derived
SessionManager may override this value. Default value is
30 seconds.
|
defaultMaxSessionIdleTime | protected static long defaultMaxSessionIdleTime(Code) | | Default maximum session idle time, in seconds. A derived SessionManager
may override this value to use the default expiration logic or override
isSessionExpired to define custom expiration logic. A
value less-than or equal to zero disables idle checking. Default value is
30 minutes.
See Also: StandardSessionManager.getMaxSessionIdleTime |
defaultMaxSessionLifeTime | protected static long defaultMaxSessionLifeTime(Code) | | Default maximum session life time, in seconds. Zero if there is no limit.
A derived SessionManager may override this value to use
the default expiration logic or override isSessionExpired
to define custom expiration logic.
See Also: lutris.session.StandardSessionManager.getMaxSessionLifeTime |
defaultRandomizerIntervals | protected static long[] defaultRandomizerIntervals(Code) | | Default list of randomize key generator time intervals, in seconds. A
list of prime numbers is recommended. A derived SessionManager
may override this value.
|
emptySessionPath | protected boolean emptySessionPath(Code) | | determins whether to use empty path (/) as session cookie path attribute
value!
|
encodeFirstUrl | protected boolean encodeFirstUrl(Code) | | Url encoding for first page state (force it or not)
|
encodeUrlState | protected String encodeUrlState(Code) | | The url encoding state. Either Never
Always Auto .
|
maxNoUserSessionIdleTime | protected long maxNoUserSessionIdleTime(Code) | | Maximum session idle time, in seconds for sessions that don't have a
User object associated with them. A value less-than or
equal to zero disables idle checking.
See Also: StandardSessionManager.getMaxNoUserSessionIdleTime |
maxSessions | protected int maxSessions(Code) | | |
maxSessionsDate | protected Date maxSessionsDate(Code) | | |
mode | protected int mode(Code) | | Represents the current session management mode.
|
scanInterval | protected long scanInterval(Code) | | The time in seconds between scans for idle sessions to expire.
|
sessionHome | protected StandardSessionHome sessionHome(Code) | | Table of currently active user sessions is managed by the session home.
Different implementations of StandardSessionHome can be loaded by this
manager. A specific implementation can manage failover persistence,
paging, etc.
|
sessionHomeType | String sessionHomeType(Code) | | The session home interface type being used.
|
StandardSessionManager | public StandardSessionManager()(Code) | | |
StandardSessionManager | public StandardSessionManager(Application application, Config config, LogChannel sessionMgrLogChannel) throws ConfigException, SessionException(Code) | | Creates a new SessionManager object. This constructor will
first looks for the session manager configuration parameters that have
the specified configuration prefix prepended to the standard session
manager configuration option.
Parameters: app - the application associate with this session manager. Parameters: config - Object parsed from configuration file. This should be for thesection constaining the session manager configuration. Parameters: sessionMgrLogChannel - If not null , channel to log debugginginformation to. exception: ConfigException - signifies a problem in the configuration file. exception: SessionException - if all classes (Home and UserTable) couldn't be loaded bythe session manager. |
activeSessionCount | public int activeSessionCount() throws SessionException(Code) | | Gets the number of currently active sessions.
The number of currently active sessions. exception: SessionException - If the session cannot be calculated. |
cleanUpIdleSessions | public void cleanUpIdleSessions() throws SessionException(Code) | | Scans session table to determine if any sessions need to be expired.
exception: SessionException - if an error occurs. |
createSession | public Session createSession() throws SessionException(Code) | | Create a new Session object and associate a unique random
key. No User is initially associated with (Session.getUser()
returns null /
session The new Session object. exception: SessionException - if the session cannot be created. See Also: Session |
createSession | public Session createSession(String ipPortToken) throws SessionException(Code) | | Create a new Session object and associate a unique random
key. No User is initially associated with (Session.getUser()
returns null /
Parameters: ipPortToken - The base64 encoded IP and Port number to include in sessionkey session The new Session object. exception: SessionException - if the session cannot be created. See Also: Session |
debug | protected void debug(int level, String msg)(Code) | | Prints debug information under Logger.DEBUG.
Parameters: level - the debug level. Parameters: msg - the message to print. |
deleteSession | public synchronized void deleteSession(Session session) throws SessionException(Code) | | Removes a session from the Session Table. This method is used to log a
user off the application. Note that sessionDeleted() is
called.
Parameters: session - Session object to remove from table removed. exception: SessionException - If the session cannot be deleted. |
deleteSession | public synchronized void deleteSession(String sessionKey) throws SessionException(Code) | | Removes a session from the Session Table. This method is used to log a
user off the application. Note that sessionDeleted() is
called.
Parameters: sessionKey - A key corresponding to a user session to be removed. exception: SessionException - If the session cannot be deleted. |
getEmptySessionPath | public boolean getEmptySessionPath()(Code) | | |
getEncodeFirstUrl | public boolean getEncodeFirstUrl()(Code) | | Returns the url encoding rule for the first application page
(true/false).
CFG_ENCODE_URL_STATE must not be set to NEVER for this parameter to take
efect
|
getEncodeUrlState | public String getEncodeUrlState()(Code) | | Returns the url encoding state. Either Never
Always Auto
|
getMaxNoUserSessionIdleTime | public long getMaxNoUserSessionIdleTime()(Code) | | Returns the maximum no-user session idle time, in seconds.
|
getMaxSessionIdleTime | public long getMaxSessionIdleTime()(Code) | | Returns the maximum session idle time, in seconds.
|
getMaxSessionLifeTime | public long getMaxSessionLifeTime()(Code) | | Returns the maximum session life time, in seconds.
|
getSaveSession | public synchronized Session getSaveSession(Thread thread, String sessionKey) throws SessionException(Code) | | Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is NOT!!! updated to the current time.
This method is for save reporting without change the last time used.
Parameters: thread - the thread to associate with the session. Parameters: sessionKey - The String used to reference a Session object. If the key is associated with an active session, then thecorresponding Session object is returned.Otherwise null is returned. See Also: Session See Also: StandardSession.touch exception: SessionException - If the session cannot be retrieved. author: schubi@die-schubis.de |
getSession | public synchronized Session getSession(String sessionKey) throws SessionException(Code) | | Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is updated to the current time.
Parameters: sessionKey - The String used to reference a Session object. If the key is associated with an active session, then thecorresponding Session object is returned.Otherwise null is returned. See Also: Session See Also: StandardSession.touch exception: SessionException - If the session cannot be retrieved. |
getSession | public synchronized Session getSession(Thread thread, String sessionKey) throws SessionException(Code) | | Lookup the Session object associated with the specified
session key.
Each time a session is returned via this method, the session's last used
(referenced) time is updated to the current time.
Parameters: thread - the thread to associate with the session. Parameters: sessionKey - The String used to reference a Session object. If the key is associated with an active session, then thecorresponding Session object is returned.Otherwise null is returned. See Also: Session See Also: StandardSession.touch exception: SessionException - If the session cannot be retrieved. |
getSessionKeys | public synchronized Enumeration getSessionKeys(User user) throws SessionException(Code) | | Lookup the keys for the active sessions for a user. A given user may have
multiple sessions associated with it (using FTP as an example, the
"anonymous" account).
Parameters: user - The user to search for. An enumeration containing the session keys of the active sessionsfor the user. exception: SessionException - If the sessions cannot be retrieved. |
maxSessionCount | public int maxSessionCount()(Code) | | Gets the maximum number of concurent sessions that existed at any time
since this object was created, or resetMaxSessionCount()
was called. This is a historical highwater mark.
The highwater mark for number of sessions, or -1. |
maxSessionCountDate | public Date maxSessionCountDate()(Code) | | Gets the time when the maximum refered to by maxSessionCount()
occured.
The Date of when the maximum number of sessions occured. |
newSession | protected StandardSession newSession(String sessionKey) throws CreateSessionException, SessionException(Code) | | Allocate a new StandardSession object. This maybe
overridden by derived session managers to allocated a Session
object derived from StandardSession . This is called by
createSession .
Parameters: sessionKey - The session key to associate with the session. session The new StandardSession object. See Also: StandardSession |
pagedSessionCount | public int pagedSessionCount() throws SessionException(Code) | | Gets the number of session that are paged to persistent store.
The number of currently paged sessions. exception: SessionException - If the session cannot be calculated. |
passivateSession | public void passivateSession(Thread thread, String sessionKey) throws SessionException(Code) | | Puts a session into the 'passive' state. A 'passive' session may be made
persistent.
Parameters: thread - the thread currently associated with the session. Parameters: sessionKey - the session key for the session that will be made persistent. exception: SessionException - If the session cannot be put into the passive state. |
resetMaxSessionCount | public void resetMaxSessionCount() throws SessionException(Code) | | Reset the maximum session count. See maxSessionCount() .
The highwater mark should be reset to the current number of sessions.
exception: SessionException - if the max session count cannot be reset. |
sessionDeleted | protected void sessionDeleted(Session session, int reason)(Code) | | Method called when a session is deleted. This method is designed to be
overriden by derived classes that want need to take specific action, such
as saving the sessions state. The default implementation of this method
does nothing.
Parameters: session - Session that is being delete. Parameters: reason - The reason the session was being deleted. One of SESSION_MAX_TIME ,SESSION_IDLE_EXPIRE , SESSION_EXPLICT_DELETE . See Also: StandardSessionManager.isSessionExpired |
sessionExists | public synchronized boolean sessionExists(String sessionKey) throws SessionException(Code) | | Returns whether the Session object associated with the
specified session key exists.
Parameters: sessionKey - The String used to reference a Session object. If the key is associated with an active session, then returntrue, otherwise return false. exception: SessionException - If existence of the session cannot be tested. |
setMaxSessionIdleTime | public void setMaxSessionIdleTime(long maxSessionIdleTime)(Code) | | Sets the maximum session idle time, in seconds.
|
shutdown | public synchronized void shutdown()(Code) | | Shutdown this session manager, stopping threads that are associated with
it.
|
unregisterUser | protected synchronized void unregisterUser(Session session) throws SessionException(Code) | | Removes a session's user from the session-to-user table. This is called
by the Session object to disassoicate a user from a
session.
Parameters: session - The now Session instance the user is beinglogged out from. See Also: Session exception: SessionException - if an error occurs. |
|
|
|