SessionManager, org.eclipse.jetty.util.component.LifeCycleHashSessionManager, JDBCSessionManager@ManagedObject("Abstract Session Manager")
public abstract class AbstractSessionManager
extends org.eclipse.jetty.util.component.ContainerLifeCycle
implements SessionManager
The partial implementation of SessionManager interface provides the majority of the handling required to implement a SessionManager. Concrete implementations of SessionManager based on AbstractSessionManager need only implement the newSession method to return a specialized version of the Session inner class that provides an attribute Map.
| Modifier and Type | Class | Description |
|---|---|---|
class |
AbstractSessionManager.CookieConfig |
CookieConfig
Implementation of the javax.servlet.SessionCookieConfig.
|
static interface |
AbstractSessionManager.SessionIf |
Interface that any session wrapper should implement so that
SessionManager may access the Jetty session implementation.
|
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener| Modifier and Type | Field | Description |
|---|---|---|
java.util.Set<javax.servlet.SessionTrackingMode> |
__defaultSessionTrackingModes |
|
static int |
__distantFuture |
|
protected boolean |
_checkingRemoteSessionIdEncoding |
|
protected ContextHandler.Context |
_context |
|
protected int |
_dftMaxIdleSecs |
|
protected boolean |
_httpOnly |
|
protected java.lang.ClassLoader |
_loader |
|
protected int |
_maxCookieAge |
|
protected boolean |
_nodeIdInSessionId |
|
protected int |
_refreshCookieAge |
|
protected boolean |
_secureCookies |
|
protected boolean |
_secureRequestOnly |
|
protected java.util.List<javax.servlet.http.HttpSessionAttributeListener> |
_sessionAttributeListeners |
|
protected java.lang.String |
_sessionComment |
|
protected java.lang.String |
_sessionCookie |
|
protected java.lang.String |
_sessionDomain |
|
protected SessionHandler |
_sessionHandler |
|
protected java.util.List<javax.servlet.http.HttpSessionIdListener> |
_sessionIdListeners |
|
protected SessionIdManager |
_sessionIdManager |
|
protected java.lang.String |
_sessionIdPathParameterName |
|
protected java.lang.String |
_sessionIdPathParameterNamePrefix |
|
protected java.util.List<javax.servlet.http.HttpSessionListener> |
_sessionListeners |
|
protected java.lang.String |
_sessionPath |
|
protected org.eclipse.jetty.util.statistic.CounterStatistic |
_sessionsStats |
|
protected org.eclipse.jetty.util.statistic.SampleStatistic |
_sessionTimeStats |
|
java.util.Set<javax.servlet.SessionTrackingMode> |
_sessionTrackingModes |
|
static java.math.BigDecimal |
MAX_INACTIVE_MINUTES |
Web.xml session-timeout is set in minutes, but is stored as an int in seconds by HttpSession and
the sessionmanager.
|
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty| Constructor | Description |
|---|---|
AbstractSessionManager() |
| Modifier and Type | Method | Description |
|---|---|---|
org.eclipse.jetty.http.HttpCookie |
access(javax.servlet.http.HttpSession session,
boolean secure) |
Called by the
SessionHandler when a session is first accessed by a request. |
void |
addEventListener(java.util.EventListener listener) |
Adds an event listener for session-related events.
|
protected abstract void |
addSession(AbstractSession session) |
|
protected void |
addSession(AbstractSession session,
boolean created) |
Add the session Registers the session with this manager and registers the
session ID with the sessionIDManager;
|
void |
clearEventListeners() |
Removes all event listeners for session-related events.
|
void |
complete(javax.servlet.http.HttpSession session) |
Called by the
SessionHandler when a session is last accessed by a request. |
void |
doSessionAttributeListeners(AbstractSession session,
java.lang.String name,
java.lang.Object old,
java.lang.Object value) |
|
void |
doStart() |
|
void |
doStop() |
|
java.lang.String |
getClusterId(javax.servlet.http.HttpSession session) |
|
ContextHandler.Context |
getContext() |
|
ContextHandler |
getContextHandler() |
|
java.util.Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes() |
|
java.util.Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
|
boolean |
getHttpOnly() |
|
javax.servlet.http.HttpSession |
getHttpSession(java.lang.String nodeId) |
Returns the
HttpSession with the given session id |
int |
getMaxCookieAge() |
|
int |
getMaxInactiveInterval() |
|
SessionIdManager |
getMetaManager() |
Deprecated.
|
java.lang.String |
getNodeId(javax.servlet.http.HttpSession session) |
|
int |
getRefreshCookieAge() |
|
boolean |
getSecureCookies() |
|
abstract AbstractSession |
getSession(java.lang.String idInCluster) |
Get a known existing session
|
java.lang.String |
getSessionCookie() |
|
org.eclipse.jetty.http.HttpCookie |
getSessionCookie(javax.servlet.http.HttpSession session,
java.lang.String contextPath,
boolean requestIsSecure) |
A sessioncookie is marked as secure IFF any of the following conditions are true:
SessionCookieConfig.setSecure == true
SessionCookieConfig.setSecure == false && _secureRequestOnly==true && request is HTTPS
According to SessionCookieConfig javadoc, case 1 can be used when:
"...
|
javax.servlet.SessionCookieConfig |
getSessionCookieConfig() |
|
java.lang.String |
getSessionDomain() |
|
SessionHandler |
getSessionHandler() |
|
SessionIdManager |
getSessionIdManager() |
|
java.lang.String |
getSessionIdPathParameterName() |
|
java.lang.String |
getSessionIdPathParameterNamePrefix() |
|
java.lang.String |
getSessionPath() |
|
int |
getSessions() |
|
int |
getSessionsMax() |
|
int |
getSessionsTotal() |
|
long |
getSessionTimeMax() |
|
double |
getSessionTimeMean() |
|
double |
getSessionTimeStdDev() |
|
long |
getSessionTimeTotal() |
|
boolean |
isCheckingRemoteSessionIdEncoding() |
|
boolean |
isNodeIdInSessionId() |
|
boolean |
isSecureRequestOnly() |
|
boolean |
isUsingCookies() |
|
boolean |
isUsingURLs() |
|
boolean |
isValid(javax.servlet.http.HttpSession session) |
|
javax.servlet.http.HttpSession |
newHttpSession(javax.servlet.http.HttpServletRequest request) |
Create a new HttpSession for a request
|
protected abstract AbstractSession |
newSession(javax.servlet.http.HttpServletRequest request) |
Create a new session instance
|
void |
removeEventListener(java.util.EventListener listener) |
Removes an event listener for for session-related events.
|
protected abstract boolean |
removeSession(java.lang.String idInCluster) |
|
void |
removeSession(javax.servlet.http.HttpSession session,
boolean invalidate) |
Remove session from manager
|
boolean |
removeSession(AbstractSession session,
boolean invalidate) |
Remove session from manager
|
void |
renewSessionId(java.lang.String oldClusterId,
java.lang.String oldNodeId,
java.lang.String newClusterId,
java.lang.String newNodeId) |
Tell the HttpSessionIdListeners the id changed.
|
void |
setCheckingRemoteSessionIdEncoding(boolean remote) |
|
void |
setHttpOnly(boolean httpOnly) |
|
void |
setMaxInactiveInterval(int seconds) |
Sets the max period of inactivity, after which the session is invalidated, in seconds.
|
void |
setNodeIdInSessionId(boolean nodeIdInSessionId) |
|
void |
setRefreshCookieAge(int ageInSeconds) |
|
void |
setSecureRequestOnly(boolean secureRequestOnly) |
HTTPS request.
|
void |
setSessionCookie(java.lang.String cookieName) |
|
void |
setSessionHandler(SessionHandler sessionHandler) |
Sets the
SessionHandler. |
void |
setSessionIdManager(SessionIdManager metaManager) |
Sets the cross context session id manager
|
void |
setSessionIdPathParameterName(java.lang.String param) |
Sets the session id URL path parameter name.
|
void |
setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes) |
|
void |
setUsingCookies(boolean usingCookies) |
|
protected abstract void |
shutdownSessions() |
Prepare sessions for session manager shutdown
|
void |
statsReset() |
Reset statistics values
|
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeanspublic java.util.Set<javax.servlet.SessionTrackingMode> __defaultSessionTrackingModes
public static final int __distantFuture
public static final java.math.BigDecimal MAX_INACTIVE_MINUTES
protected int _dftMaxIdleSecs
protected SessionHandler _sessionHandler
protected boolean _httpOnly
protected SessionIdManager _sessionIdManager
protected boolean _secureCookies
protected boolean _secureRequestOnly
protected final java.util.List<javax.servlet.http.HttpSessionAttributeListener> _sessionAttributeListeners
protected final java.util.List<javax.servlet.http.HttpSessionListener> _sessionListeners
protected final java.util.List<javax.servlet.http.HttpSessionIdListener> _sessionIdListeners
protected java.lang.ClassLoader _loader
protected ContextHandler.Context _context
protected java.lang.String _sessionCookie
protected java.lang.String _sessionIdPathParameterName
protected java.lang.String _sessionIdPathParameterNamePrefix
protected java.lang.String _sessionDomain
protected java.lang.String _sessionPath
protected int _maxCookieAge
protected int _refreshCookieAge
protected boolean _nodeIdInSessionId
protected boolean _checkingRemoteSessionIdEncoding
protected java.lang.String _sessionComment
public java.util.Set<javax.servlet.SessionTrackingMode> _sessionTrackingModes
protected final org.eclipse.jetty.util.statistic.CounterStatistic _sessionsStats
protected final org.eclipse.jetty.util.statistic.SampleStatistic _sessionTimeStats
public ContextHandler.Context getContext()
public ContextHandler getContextHandler()
@ManagedAttribute("path of the session cookie, or null for default")
public java.lang.String getSessionPath()
@ManagedAttribute("if greater the zero, the time in seconds a session cookie will last for")
public int getMaxCookieAge()
public org.eclipse.jetty.http.HttpCookie access(javax.servlet.http.HttpSession session,
boolean secure)
SessionManagerSessionHandler when a session is first accessed by a request.access in interface SessionManagersession - the session objectsecure - whether the request is secure or notSessionManager.complete(HttpSession)public void addEventListener(java.util.EventListener listener)
SessionManageraddEventListener in interface SessionManagerlistener - the session event listener to add
Individual SessionManagers implementations may accept arbitrary listener types,
but they are expected to at least handle HttpSessionActivationListener,
HttpSessionAttributeListener, HttpSessionBindingListener and HttpSessionListener.SessionManager.removeEventListener(EventListener)public void clearEventListeners()
SessionManagerclearEventListeners in interface SessionManagerSessionManager.removeEventListener(EventListener)public void complete(javax.servlet.http.HttpSession session)
SessionManagerSessionHandler when a session is last accessed by a request.complete in interface SessionManagersession - the session objectSessionManager.access(HttpSession, boolean)public void doStart()
throws java.lang.Exception
doStart in class org.eclipse.jetty.util.component.ContainerLifeCyclejava.lang.Exceptionpublic void doStop()
throws java.lang.Exception
doStop in class org.eclipse.jetty.util.component.ContainerLifeCyclejava.lang.Exception@ManagedAttribute("true if cookies use the http only flag")
public boolean getHttpOnly()
getHttpOnly in interface SessionManagerHttpCookie.isHttpOnly()public javax.servlet.http.HttpSession getHttpSession(java.lang.String nodeId)
SessionManagerHttpSession with the given session idgetHttpSession in interface SessionManagernodeId - the session idHttpSession with the corresponding id or null if no session with the given id exists@ManagedAttribute("Session ID Manager")
public SessionIdManager getSessionIdManager()
getSessionIdManager in interface SessionManagerSessionManager.setSessionIdManager(SessionIdManager)@ManagedAttribute("defailt maximum time a session may be idle for (in s)")
public int getMaxInactiveInterval()
getMaxInactiveInterval in interface SessionManagerSessionManager.setMaxInactiveInterval(int)@ManagedAttribute("maximum number of simultaneous sessions")
public int getSessionsMax()
@ManagedAttribute("total number of sessions")
public int getSessionsTotal()
@ManagedAttribute("time before a session cookie is re-set (in s)")
public int getRefreshCookieAge()
@ManagedAttribute("if true, secure cookie flag is set on session cookies")
public boolean getSecureCookies()
public boolean isSecureRequestOnly()
public void setSecureRequestOnly(boolean secureRequestOnly)
secureRequestOnly - true to set Session Cookie Config as secure@ManagedAttribute("the set session cookie")
public java.lang.String getSessionCookie()
public org.eclipse.jetty.http.HttpCookie getSessionCookie(javax.servlet.http.HttpSession session,
java.lang.String contextPath,
boolean requestIsSecure)
For case 2, you can use _secureRequestOnly to determine if you want the Servlet Spec 3.0 default behavior when SessionCookieConfig.setSecure==false, which is: "they shall be marked as secure only if the request that initiated the corresponding session was also secure"
The default for _secureRequestOnly is true, which gives the above behavior. If you set it to false, then a session cookie is NEVER marked as secure, even if the initiating request was secure.
getSessionCookie in interface SessionManagersession - the session to which the cookie should refer.contextPath - the context to which the cookie should be linked.
The client will only send the cookie value when requesting resources under this path.requestIsSecure - whether the client is accessing the server over a secure protocol (i.e. HTTPS).SessionManager uses cookies, then this method will return a new
cookie object that should be set on the client in order to link future HTTP requests
with the session. If cookies are not in use, this method returns null.SessionManager.getSessionCookie(javax.servlet.http.HttpSession, java.lang.String, boolean)@ManagedAttribute("domain of the session cookie, or null for the default")
public java.lang.String getSessionDomain()
public SessionHandler getSessionHandler()
@ManagedAttribute("number of currently active sessions")
public int getSessions()
@ManagedAttribute("name of use for URL session tracking")
public java.lang.String getSessionIdPathParameterName()
getSessionIdPathParameterName in interface SessionManagerSessionManager.setSessionIdPathParameterName(String)public java.lang.String getSessionIdPathParameterNamePrefix()
getSessionIdPathParameterNamePrefix in interface SessionManagerSessionManager.getSessionIdPathParameterName(), by default
";" + sessionIdParameterName + "=", for easier lookup in URL strings.SessionManager.getSessionIdPathParameterName()public boolean isUsingCookies()
isUsingCookies in interface SessionManagerpublic boolean isValid(javax.servlet.http.HttpSession session)
isValid in interface SessionManagersession - the session to test for validitypublic java.lang.String getClusterId(javax.servlet.http.HttpSession session)
getClusterId in interface SessionManagersession - the session objectSessionManager.getNodeId(HttpSession)public java.lang.String getNodeId(javax.servlet.http.HttpSession session)
getNodeId in interface SessionManagersession - the session objectSessionManager.getClusterId(HttpSession)public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
newHttpSession in interface SessionManagerrequest - the HttpServletRequest containing the requested session idHttpSessionpublic void removeEventListener(java.util.EventListener listener)
SessionManagerremoveEventListener in interface SessionManagerlistener - the session event listener to removeSessionManager.addEventListener(EventListener)@ManagedOperation(value="reset statistics",
impact="ACTION")
public void statsReset()
public void setHttpOnly(boolean httpOnly)
httpOnly - The httpOnly to set.public void setSessionIdManager(SessionIdManager metaManager)
SessionManagersetSessionIdManager in interface SessionManagermetaManager - The metaManager used for cross context session management.SessionManager.getSessionIdManager()public void setMaxInactiveInterval(int seconds)
SessionManagersetMaxInactiveInterval in interface SessionManagerseconds - the max inactivity period, in seconds.SessionManager.getMaxInactiveInterval()public void setRefreshCookieAge(int ageInSeconds)
public void setSessionCookie(java.lang.String cookieName)
public void setSessionHandler(SessionHandler sessionHandler)
SessionManagerSessionHandler.setSessionHandler in interface SessionManagersessionHandler - The sessionHandler to set.public void setSessionIdPathParameterName(java.lang.String param)
SessionManagersetSessionIdPathParameterName in interface SessionManagerparam - the URL path parameter name for session id URL rewriting (null or "none" for no rewriting).SessionManager.getSessionIdPathParameterName(),
SessionManager.getSessionIdPathParameterNamePrefix()public void setUsingCookies(boolean usingCookies)
usingCookies - The usingCookies to set.protected abstract void addSession(AbstractSession session)
protected void addSession(AbstractSession session, boolean created)
session - the sessioncreated - true if session was createdpublic abstract AbstractSession getSession(java.lang.String idInCluster)
idInCluster - The session ID in the cluster, stripped of any worker name.protected abstract void shutdownSessions()
throws java.lang.Exception
java.lang.Exception - if unable to shutdown sesssionsprotected abstract AbstractSession newSession(javax.servlet.http.HttpServletRequest request)
request - the request to build the session frompublic boolean isNodeIdInSessionId()
HttpSession.getId(). Default is false.public void setNodeIdInSessionId(boolean nodeIdInSessionId)
nodeIdInSessionId - true if the cluster node id (worker id) will be returned as part of the session id by HttpSession.getId(). Default is false.public void removeSession(javax.servlet.http.HttpSession session,
boolean invalidate)
session - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.public boolean removeSession(AbstractSession session, boolean invalidate)
session - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.protected abstract boolean removeSession(java.lang.String idInCluster)
@ManagedAttribute("maximum amount of time sessions have remained active (in s)")
public long getSessionTimeMax()
public java.util.Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes in interface SessionManagerpublic java.util.Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes in interface SessionManagerpublic void setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes in interface SessionManagerpublic boolean isUsingURLs()
isUsingURLs in interface SessionManagerpublic javax.servlet.SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig in interface SessionManager@ManagedAttribute("total time sessions have remained valid")
public long getSessionTimeTotal()
@ManagedAttribute("mean time sessions remain valid (in s)")
public double getSessionTimeMean()
@ManagedAttribute("standard deviation a session remained valid (in s)")
public double getSessionTimeStdDev()
@ManagedAttribute("check remote session id encoding")
public boolean isCheckingRemoteSessionIdEncoding()
isCheckingRemoteSessionIdEncoding in interface SessionManagerSessionManager.isCheckingRemoteSessionIdEncoding()public void setCheckingRemoteSessionIdEncoding(boolean remote)
setCheckingRemoteSessionIdEncoding in interface SessionManagerremote - True if absolute URLs are check for remoteness before being session encoded.SessionManager.setCheckingRemoteSessionIdEncoding(boolean)public void renewSessionId(java.lang.String oldClusterId,
java.lang.String oldNodeId,
java.lang.String newClusterId,
java.lang.String newNodeId)
renewSessionId in interface SessionManageroldClusterId - the old cluster idoldNodeId - the old node idnewClusterId - the new cluster idnewNodeId - the new node idSessionManager.renewSessionId(java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void doSessionAttributeListeners(AbstractSession session, java.lang.String name, java.lang.Object old, java.lang.Object value)
@Deprecated public SessionIdManager getMetaManager()
getMetaManager in interface SessionManagerCopyright © 1995–2018 Webtide. All rights reserved.