public abstract class AbstractSessionManager extends AbstractLifeCycle implements SessionManager
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractSessionManager.SessionIf
Interface that any session wrapper should implement so that
SessionManager may access the Jetty session implementation.
|
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty
Constructor and Description |
---|
AbstractSessionManager() |
Modifier and Type | Method and Description |
---|---|
HttpCookie |
access(javax.servlet.http.HttpSession session,
boolean secure)
Called by the
SessionHandler when a session is first accessed by a request. |
void |
addEventListener(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,
String name,
Object old,
Object value) |
void |
doStart() |
void |
doStop() |
String |
getClusterId(javax.servlet.http.HttpSession session) |
ContextHandler.Context |
getContext() |
ContextHandler |
getContextHandler() |
Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes() |
Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
boolean |
getHttpOnly() |
javax.servlet.http.HttpSession |
getHttpSession(String nodeId)
Returns the
HttpSession with the given session id |
SessionIdManager |
getIdManager()
Deprecated.
|
int |
getMaxCookieAge() |
int |
getMaxInactiveInterval() |
int |
getMaxSessions()
Deprecated.
|
SessionIdManager |
getMetaManager()
Deprecated.
|
int |
getMinSessions()
Deprecated.
always returns 0. no replacement available.
|
String |
getNodeId(javax.servlet.http.HttpSession session) |
int |
getRefreshCookieAge() |
boolean |
getSecureCookies() |
abstract AbstractSession |
getSession(String idInCluster)
Get a known existing session
|
String |
getSessionCookie() |
HttpCookie |
getSessionCookie(javax.servlet.http.HttpSession session,
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() |
String |
getSessionDomain() |
SessionHandler |
getSessionHandler() |
SessionIdManager |
getSessionIdManager() |
String |
getSessionIdPathParameterName() |
String |
getSessionIdPathParameterNamePrefix() |
Map |
getSessionMap()
Deprecated.
Need to review if it is needed.
|
String |
getSessionPath() |
int |
getSessions() |
int |
getSessionsMax() |
int |
getSessionsTotal() |
long |
getSessionTimeMax() |
double |
getSessionTimeMean() |
double |
getSessionTimeStdDev() |
long |
getSessionTimeTotal() |
protected abstract void |
invalidateSessions() |
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(EventListener listener)
Removes an event listener for for session-related events.
|
void |
removeSession(AbstractSession session,
boolean invalidate)
Remove session from manager
|
void |
removeSession(javax.servlet.http.HttpSession session,
boolean invalidate)
Remove session from manager
|
protected abstract boolean |
removeSession(String idInCluster) |
static javax.servlet.http.HttpSession |
renewSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession httpSession,
boolean authenticated) |
void |
resetStats()
Deprecated.
|
void |
setCheckingRemoteSessionIdEncoding(boolean remote) |
void |
setHttpOnly(boolean httpOnly) |
void |
setIdManager(SessionIdManager metaManager)
Deprecated.
|
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) |
void |
setSessionCookie(String cookieName) |
void |
setSessionHandler(SessionHandler sessionHandler)
Sets the
SessionHandler . |
void |
setSessionIdManager(SessionIdManager metaManager)
Sets the cross context session id manager
|
void |
setSessionIdPathParameterName(String param)
Sets the session id URL path parameter name.
|
void |
setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes) |
void |
setUsingCookies(boolean usingCookies) |
void |
statsReset()
Reset statistics values
|
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public Set<javax.servlet.SessionTrackingMode> __defaultSessionTrackingModes
public static final String SESSION_KNOWN_ONLY_TO_AUTHENTICATED
public static final int __distantFuture
protected int _dftMaxIdleSecs
protected SessionHandler _sessionHandler
protected boolean _httpOnly
protected SessionIdManager _sessionIdManager
protected boolean _secureCookies
protected boolean _secureRequestOnly
protected final List<javax.servlet.http.HttpSessionAttributeListener> _sessionAttributeListeners
protected final List<javax.servlet.http.HttpSessionListener> _sessionListeners
protected ClassLoader _loader
protected ContextHandler.Context _context
protected String _sessionCookie
protected String _sessionIdPathParameterName
protected String _sessionIdPathParameterNamePrefix
protected String _sessionDomain
protected String _sessionPath
protected int _maxCookieAge
protected int _refreshCookieAge
protected boolean _nodeIdInSessionId
protected boolean _checkingRemoteSessionIdEncoding
protected String _sessionComment
public Set<javax.servlet.SessionTrackingMode> _sessionTrackingModes
protected final CounterStatistic _sessionsStats
protected final SampleStatistic _sessionTimeStats
public static javax.servlet.http.HttpSession renewSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpSession httpSession, boolean authenticated)
public ContextHandler.Context getContext()
public ContextHandler getContextHandler()
public String getSessionPath()
public int getMaxCookieAge()
public HttpCookie access(javax.servlet.http.HttpSession session, boolean secure)
SessionManager
SessionHandler
when a session is first accessed by a request.access
in interface SessionManager
session
- the session objectsecure
- whether the request is secure or notSessionManager.complete(HttpSession)
public void addEventListener(EventListener listener)
SessionManager
addEventListener
in interface SessionManager
listener
- 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()
SessionManager
clearEventListeners
in interface SessionManager
SessionManager.removeEventListener(EventListener)
public void complete(javax.servlet.http.HttpSession session)
SessionManager
SessionHandler
when a session is last accessed by a request.complete
in interface SessionManager
session
- the session objectSessionManager.access(HttpSession, boolean)
public void doStart() throws Exception
doStart
in class AbstractLifeCycle
Exception
public void doStop() throws Exception
doStop
in class AbstractLifeCycle
Exception
public boolean getHttpOnly()
getHttpOnly
in interface SessionManager
HttpCookie.isHttpOnly()
public javax.servlet.http.HttpSession getHttpSession(String nodeId)
SessionManager
HttpSession
with the given session idgetHttpSession
in interface SessionManager
nodeId
- the session idHttpSession
with the corresponding id or null if no session with the given id existspublic SessionIdManager getIdManager()
getSessionIdManager()
public SessionIdManager getSessionIdManager()
getSessionIdManager
in interface SessionManager
SessionManager.setSessionIdManager(SessionIdManager)
public int getMaxInactiveInterval()
getMaxInactiveInterval
in interface SessionManager
SessionManager.setMaxInactiveInterval(int)
@Deprecated public int getMaxSessions()
getSessionsMax()
public int getSessionsMax()
public int getSessionsTotal()
@Deprecated public SessionIdManager getMetaManager()
getSessionIdManager()
getMetaManager
in interface SessionManager
@Deprecated public int getMinSessions()
public int getRefreshCookieAge()
public boolean getSecureCookies()
public boolean isSecureRequestOnly()
public void setSecureRequestOnly(boolean secureRequestOnly)
public String getSessionCookie()
public HttpCookie getSessionCookie(javax.servlet.http.HttpSession session, String contextPath, boolean requestIsSecure)
getSessionCookie
in interface SessionManager
session
- 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)
public String getSessionDomain()
public SessionHandler getSessionHandler()
public Map getSessionMap()
public int getSessions()
public String getSessionIdPathParameterName()
getSessionIdPathParameterName
in interface SessionManager
SessionManager.setSessionIdPathParameterName(String)
public String getSessionIdPathParameterNamePrefix()
getSessionIdPathParameterNamePrefix
in interface SessionManager
SessionManager.getSessionIdPathParameterName()
, by default
";" + sessionIdParameterName + "=", for easier lookup in URL strings.SessionManager.getSessionIdPathParameterName()
public boolean isUsingCookies()
isUsingCookies
in interface SessionManager
public boolean isValid(javax.servlet.http.HttpSession session)
isValid
in interface SessionManager
session
- the session to test for validitypublic String getClusterId(javax.servlet.http.HttpSession session)
getClusterId
in interface SessionManager
session
- the session objectSessionManager.getNodeId(HttpSession)
public String getNodeId(javax.servlet.http.HttpSession session)
getNodeId
in interface SessionManager
session
- the session objectSessionManager.getClusterId(HttpSession)
public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
newHttpSession
in interface SessionManager
request
- the HttpServletRequest containing the requested session idHttpSession
public void removeEventListener(EventListener listener)
SessionManager
removeEventListener
in interface SessionManager
listener
- the session event listener to removeSessionManager.addEventListener(EventListener)
@Deprecated public void resetStats()
statsReset()
public void statsReset()
public void setHttpOnly(boolean httpOnly)
httpOnly
- The httpOnly to set.public void setIdManager(SessionIdManager metaManager)
setSessionIdManager(SessionIdManager)
metaManager
- The metaManager used for cross context session management.public void setSessionIdManager(SessionIdManager metaManager)
SessionManager
setSessionIdManager
in interface SessionManager
metaManager
- The metaManager used for cross context session management.SessionManager.getSessionIdManager()
public void setMaxInactiveInterval(int seconds)
SessionManager
setMaxInactiveInterval
in interface SessionManager
seconds
- SessionManager.getMaxInactiveInterval()
public void setRefreshCookieAge(int ageInSeconds)
public void setSessionCookie(String cookieName)
public void setSessionHandler(SessionHandler sessionHandler)
SessionManager
SessionHandler
.setSessionHandler
in interface SessionManager
sessionHandler
- The sessionHandler to set.public void setSessionIdPathParameterName(String param)
SessionManager
setSessionIdPathParameterName
in interface SessionManager
param
- 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)
public abstract AbstractSession getSession(String idInCluster)
idInCluster
- The session ID in the cluster, stripped of any worker name.protected abstract AbstractSession newSession(javax.servlet.http.HttpServletRequest request)
request
- public 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 void 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(String idInCluster)
public long getSessionTimeMax()
public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes
in interface SessionManager
public Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes
in interface SessionManager
public void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes
in interface SessionManager
public boolean isUsingURLs()
isUsingURLs
in interface SessionManager
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig
in interface SessionManager
public long getSessionTimeTotal()
public double getSessionTimeMean()
public double getSessionTimeStdDev()
public boolean isCheckingRemoteSessionIdEncoding()
isCheckingRemoteSessionIdEncoding
in interface SessionManager
SessionManager.isCheckingRemoteSessionIdEncoding()
public void setCheckingRemoteSessionIdEncoding(boolean remote)
setCheckingRemoteSessionIdEncoding
in interface SessionManager
remote
- True if absolute URLs are check for remoteness before being session encoded.SessionManager.setCheckingRemoteSessionIdEncoding(boolean)
public void doSessionAttributeListeners(AbstractSession session, String name, Object old, Object value)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.