|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lutris.appserver.server.session.StandardSessionManager
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)
Config
,
StandardSessionHome
,
StandardSessionUserTable
,
BasicSessionHome
,
DiskPagedSessionHome
,
com.lutris.appserver.server.session.persistent.PersistentSessionHome
Field Summary | |
static java.lang.String |
CFG_ENCODE_URL_STATE
The name of the config variable for the url encoding state |
static java.lang.String |
CFG_IDLE
The name of the config variable for the max session idle time. |
static java.lang.String |
CFG_LIFE
The name of the config variable for the max session lifetime. |
static java.lang.String |
CFG_NOUSER_IDLE
The name of the config variable for the max idle time for sessions with no user. |
static java.lang.String |
CFG_RANDOM
The name of the config variable for the interval between introduction of randomness to the session key generator. |
static java.lang.String |
CFG_SCAN
The name of the config variable for the interval between scans for idle sessions. |
static java.lang.String |
CFG_SESSION_HOME
The name of the config variable for the session home settings. |
static java.lang.String |
CFG_SESSION_HOME_TYPE
The name of the config variable for the session home type. |
protected static java.lang.String |
defaultEncodeUrlState
Indicates url encoding status. |
protected static long |
defaultIdleScanInterval
Default interval, in seconds, to scan for sessions to expire. |
protected static long |
defaultMaxSessionIdleTime
Default maximum session idle time, in seconds. |
protected static long |
defaultMaxSessionLifeTime
Default maximum session life time, in seconds. |
protected static long[] |
defaultRandomizerIntervals
Default list of randomize key generator time intervals, in seconds. |
static java.lang.String |
ENCODE_URL_ALWAYS
Indicates that url encoding of session ids is always preformed. |
static java.lang.String |
ENCODE_URL_AUTO
Indicates that url encoding of session ids is preformed only when cookies are disabled on the client browser. |
static java.lang.String |
ENCODE_URL_NEVER
Indicates that url encoding of session ids is never preformed. |
protected java.lang.String |
encodeUrlState
The url encoding state. |
protected long |
maxNoUserSessionIdleTime
Maximum session idle time, in seconds for sessions that don't have a User object associated with them. |
protected long |
maxSessionIdleTime
Maximum session idle time, in seconds. |
protected int |
mode
Represents the current session management mode. |
static int |
MODE_BASIC
Indicates that the session manager is using the basic session home interface to manage sessions. |
static int |
MODE_CUSTOM
Indicates that the session manager is using the custom home interface to manage sessions. |
static int |
MODE_PAGE_TO_DB
Indicates that the session manager is using the page to database home interface to manage sessions. |
static int |
MODE_PAGE_TO_DISK
Indicates that the session manager is using the page to disk home interface to manage sessions. |
protected long |
scanInterval
The time in seconds between scans for idle sessions to expire. |
static int |
SESSION_ACTIVE
Indicates that a sesson is still active. |
static int |
SESSION_EXPLICT_DELETE
Indicates that a sesson was explictly deleted. |
static int |
SESSION_IDLE_EXPIRE
Indicates that a sesson was deleted due to idle time being exceeded. |
static int |
SESSION_MAX_TIME
Indicates that a sesson was deleted due to max time being exceeded. |
Constructor Summary | |
StandardSessionManager(Application application,
Config config,
LogChannel sessionMgrLogChannel)
Creates a new SessionManager object. |
|
StandardSessionManager(java.lang.ClassLoader classLoader,
Config config,
LogChannel sessionMgrLogChannel)
|
Method Summary | |
int |
activeSessionCount()
Gets the number of currently active sessions. |
void |
cleanUpIdleSessions()
Scans session table to determine if any sessions need to be expired. |
Session |
createSession()
Create a new Session object and associate a unique random
key. |
Session |
createSession(java.lang.String ipPortToken)
Create a new Session object and associate a unique random
key. |
void |
deleteSession(Session session)
Removes a session from the Session Table. |
void |
deleteSession(java.lang.String sessionKey)
Removes a session from the Session Table. |
java.lang.String |
getEncodeUrlState()
Returns the url encoding state. |
long |
getMaxNoUserSessionIdleTime()
Returns the maximum no-user session idle time, in seconds. |
long |
getMaxSessionIdleTime()
Returns the maximum session idle time, in seconds. |
long |
getMaxSessionLifeTime()
Returns the maximum session life time, in seconds. |
int |
getMode()
Returns the current mode for the session manager. |
Session |
getSession(java.lang.String sessionKey)
Lookup the Session object associated with the
specified session key. |
Session |
getSession(java.lang.Thread thread,
java.lang.String sessionKey)
Lookup the Session object associated with the
specified session key. |
java.util.Enumeration |
getSessionKeys()
Get all of the active sessions. |
java.util.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. |
int |
maxSessionCount()
Gets the maximum number of concurent sessions that existed at any time since this object was created, or resetMaxSessionCount() was called. |
java.util.Date |
maxSessionCountDate()
Gets the time when the maximum refered to by maxSessionCount() occured. |
protected StandardSession |
newSession(java.lang.String sessionKey)
Deprecated. The instance of StandardSessionHome should be replaced instead of extending this method. |
int |
pagedSessionCount()
Gets the number of session that are paged to persistent store. |
void |
passivateSession(java.lang.Thread thread,
java.lang.String sessionKey)
Puts a session into the 'passive' state. |
protected void |
registerUser(Session session)
Adds a session's user to the session-to-user table. |
void |
resetMaxSessionCount()
Reset the maximum session count. |
protected void |
sessionDeleted(Session session,
int reason)
Method called when a session is deleted. |
boolean |
sessionExists(java.lang.String sessionKey)
Returns whether the Session object associated with
the specified session key exists. |
void |
setMaxSessionIdleTime(long maxSessionIdleTime)
Sets the maximum session idle time, in seconds. |
void |
shutdown()
Shutdown this session manager, stopping threads that are associated with it. |
protected void |
unregisterUser(Session session)
Removes a session's user from the session-to-user table. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected int mode
public static final int MODE_BASIC
getMode()
,
com.lutris.appserver.server.session.BasicSessionHome
public static final int MODE_PAGE_TO_DISK
getMode()
,
com.lutris.appserver.server.session.DiskPagedSessionHome
public static final int MODE_PAGE_TO_DB
getMode()
,
com.lutris.appserver.server.session.persistent.PersistentSessionHome
public static final int MODE_CUSTOM
getMode()
public static final java.lang.String ENCODE_URL_NEVER
getEncodeUrlState()
public static final java.lang.String ENCODE_URL_ALWAYS
getEncodeUrlState()
public static final java.lang.String ENCODE_URL_AUTO
getEncodeUrlState()
protected static long defaultMaxSessionLifeTime
SessionManager
may override this value
to use the default expiration logic or override
isSessionExpired
to define custom expiration logic.lutris.session.StandardSessionManager#getMaxSessionLifeTime
protected static long defaultMaxSessionIdleTime
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.getMaxSessionIdleTime()
protected static java.lang.String defaultEncodeUrlState
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.getEncodeUrlState()
protected static long defaultIdleScanInterval
SessionManager
may override this value.
Default value is 30 seconds.protected static long[] defaultRandomizerIntervals
SessionManager
may override this value.public static final java.lang.String CFG_LIFE
public static final java.lang.String CFG_IDLE
public static final java.lang.String CFG_ENCODE_URL_STATE
public static final java.lang.String CFG_NOUSER_IDLE
public static final java.lang.String CFG_SCAN
public static final java.lang.String CFG_RANDOM
public static final java.lang.String CFG_SESSION_HOME
public static final java.lang.String CFG_SESSION_HOME_TYPE
public static final int SESSION_ACTIVE
sessionDeleted(com.lutris.appserver.server.session.Session, int)
public static final int SESSION_MAX_TIME
sessionDeleted(com.lutris.appserver.server.session.Session, int)
public static final int SESSION_IDLE_EXPIRE
sessionDeleted(com.lutris.appserver.server.session.Session, int)
public static final int SESSION_EXPLICT_DELETE
sessionDeleted(com.lutris.appserver.server.session.Session, int)
protected long maxSessionIdleTime
getMaxSessionIdleTime()
protected java.lang.String encodeUrlState
Never
Always
Auto
.protected long maxNoUserSessionIdleTime
User
object associated with them.
A value less-than or equal to zero disables idle checking.getMaxNoUserSessionIdleTime()
protected long scanInterval
Constructor Detail |
public StandardSessionManager(Application application, Config config, LogChannel sessionMgrLogChannel) throws ConfigException, SessionException
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.app
- the application associate with this session
manager.config
- Object parsed from configuration file. This should be
for the section constaining the session manager configuration.sessionMgrLogChannel
- If not null
, channel to
log debugging information to.public StandardSessionManager(java.lang.ClassLoader classLoader, Config config, LogChannel sessionMgrLogChannel) throws ConfigException, SessionException
Method Detail |
protected StandardSessionHome loadSessionHome(Config config) throws ConfigException, SessionException
config
- This session manager's config section.protected StandardSessionUserTable loadSessionUserTable(Config config) throws ConfigException, SessionException
config
- This session manager's config section.public void shutdown()
protected StandardSession newSession(java.lang.String sessionKey) throws CreateSessionException, SessionException
StandardSession
object. This maybe
overridden by derived session managers to allocated a
Session
object derived from StandardSession
.
This is called by createSession
.sessionKey
- The session key to associate with the
session.StandardSession
object.StandardSession
public Session createSession() throws SessionException
Session
object and associate a unique random
key. No User
is initially associated with
(Session.getUser()
returns null
/Session
object.Session
public Session createSession(java.lang.String ipPortToken) throws SessionException
Session
object and associate a unique random
key. No User
is initially associated with
(Session.getUser()
returns null
/ipPortToken
- The base64 encoded IP and Port number to include in session keySession
object.Session
protected void registerUser(Session session) throws SessionException
Session
object to associate
a session with a user.session
- The now logged-in Session
instance to
store in the session table.Session
,
User
,
unregisterUser(com.lutris.appserver.server.session.Session)
protected void unregisterUser(Session session) throws SessionException
Session
object to disassoicate
a user from a session.session
- The now Session
instance
the user is being logged out from.Session
protected int isSessionExpired(StandardSession session)
session
- Session to check.SESSION_MAX_TIME
,
SESSION_IDLE_EXPIRE
, or
SESSION_ACTIVE
, to indicate that the session
is not expired.sessionDeleted(com.lutris.appserver.server.session.Session, int)
,
maxSessionIdleTime
,
maxNoUserSessionIdleTime
protected void sessionDeleted(Session session, int reason)
session
- Session that is being delete.reason
- The reason the session was being deleted.
One of SESSION_MAX_TIME
,
SESSION_IDLE_EXPIRE
,
SESSION_EXPLICT_DELETE
.isSessionExpired(com.lutris.appserver.server.session.StandardSession)
public void deleteSession(Session session) throws SessionException
sessionDeleted()
is called.session
- Session object to remove from table removed.public void deleteSession(java.lang.String sessionKey) throws SessionException
sessionDeleted()
is called.sessionKey
- A key corresponding to a user session to be
removed.public void passivateSession(java.lang.Thread thread, java.lang.String sessionKey) throws SessionException
thread
- the thread currently associated with the session.sessionKey
- the session key for the session
that will be made persistent.public void cleanUpIdleSessions() throws SessionException
public boolean sessionExists(java.lang.String sessionKey) throws SessionException
Session
object associated with
the specified session key exists.sessionKey
- The String used to reference a
Session
object.public Session getSession(java.lang.String sessionKey) throws SessionException
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.
sessionKey
- The String used to reference a
Session
object.Session
object is
returned. Otherwise null
is returned.Session
,
StandardSession.touch()
public Session getSession(java.lang.Thread thread, java.lang.String sessionKey) throws SessionException
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.
thread
- the thread to associate with the session.sessionKey
- The String used to reference a
Session
object.Session
object is
returned. Otherwise null
is returned.Session
,
StandardSession.touch()
public java.util.Enumeration getSessionKeys() throws SessionException
public java.util.Enumeration getSessionKeys(User user) throws SessionException
user
- The user to search for.public int activeSessionCount() throws SessionException
public int pagedSessionCount() throws SessionException
public int getMode() throws SessionException
MODE_BASIC
,
MODE_PAGE_TO_DISK
,
MODE_PAGE_TO_DB
,
MODE_CUSTOM
public int maxSessionCount()
resetMaxSessionCount()
was called.
This is a historical highwater mark.public java.util.Date maxSessionCountDate()
maxSessionCount()
occured.public void resetMaxSessionCount() throws SessionException
maxSessionCount()
.
The highwater mark should be reset to the current number of sessions.public long getMaxSessionLifeTime()
public void setMaxSessionIdleTime(long maxSessionIdleTime)
public long getMaxSessionIdleTime()
public java.lang.String getEncodeUrlState()
Never
Always
Auto
public long getMaxNoUserSessionIdleTime()
|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |