public class DefaultSessionIdManager extends AbstractLifeCycle implements SessionIdManager
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
protected HouseKeeper |
_houseKeeper |
protected Random |
_random |
protected long |
_reseed |
protected Server |
_server |
protected boolean |
_weakRandom |
protected String |
_workerAttr |
protected String |
_workerName |
protected static AtomicLong |
COUNTER |
Constructor and Description |
---|
DefaultSessionIdManager(Server server) |
DefaultSessionIdManager(Server server,
Random random) |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart() |
protected void |
doStop() |
void |
expireAll(String id)
Remove an id from use by telling all contexts to remove a session with this id.
|
String |
getExtendedId(String clusterId,
javax.servlet.http.HttpServletRequest request)
Get the session ID with any worker ID.
|
String |
getId(String extendedId)
Get the session ID without any worker ID.
|
Random |
getRandom() |
long |
getReseed() |
Server |
getServer() |
Set<SessionHandler> |
getSessionHandlers()
Get SessionManager for every context.
|
String |
getWorkerName()
Get the workname.
|
void |
initRandom()
Set up a random number generator for the sessionids.
|
void |
invalidateAll(String id)
Invalidate all sessions on all contexts that share the same id.
|
boolean |
isIdInUse(String id) |
String |
newSessionId(javax.servlet.http.HttpServletRequest request,
long created)
Create a new session id if necessary.
|
String |
newSessionId(long seedTerm) |
void |
renewSessionId(String oldClusterId,
String oldNodeId,
javax.servlet.http.HttpServletRequest request)
Generate a new id for a session and update across
all SessionManagers.
|
void |
setRandom(Random random) |
void |
setReseed(long reseed)
Set the reseed probability.
|
void |
setServer(Server server) |
void |
setSessionHouseKeeper(HouseKeeper houseKeeper) |
void |
setWorkerName(String workerName)
Set the workername.
|
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
protected static final AtomicLong COUNTER
protected Random _random
protected boolean _weakRandom
protected String _workerName
protected String _workerAttr
protected long _reseed
protected Server _server
protected HouseKeeper _houseKeeper
public DefaultSessionIdManager(Server server)
server
- the server associated with the id managerpublic void setServer(Server server)
server
- the server associated with this id managerpublic Server getServer()
public void setSessionHouseKeeper(HouseKeeper houseKeeper)
houseKeeper
- the housekeeperpublic String getWorkerName()
getWorkerName
in interface SessionIdManager
public void setWorkerName(String workerName)
workerName
- the name of the workerpublic Random getRandom()
public void setRandom(Random random)
random
- a random number generator for generating idspublic long getReseed()
public void setReseed(long reseed)
reseed
- If non zero then when a random long modulo the reseed value == 1, the SecureRandom
will be reseeded.public String newSessionId(javax.servlet.http.HttpServletRequest request, long created)
newSessionId
in interface SessionIdManager
request
- the request with the sesioncreated
- the timestamp for when the session was createdSessionIdManager.newSessionId(javax.servlet.http.HttpServletRequest, long)
public String newSessionId(long seedTerm)
seedTerm
- the seed for RNGpublic boolean isIdInUse(String id)
isIdInUse
in interface SessionIdManager
id
- The plain session ID (ie no workername extension)SessionIdManager.isIdInUse(java.lang.String)
protected void doStart() throws Exception
doStart
in class AbstractLifeCycle
Exception
AbstractLifeCycle.doStart()
protected void doStop() throws Exception
doStop
in class AbstractLifeCycle
Exception
AbstractLifeCycle.doStop()
public void initRandom()
public String getExtendedId(String clusterId, javax.servlet.http.HttpServletRequest request)
getExtendedId
in interface SessionIdManager
clusterId
- the cluster idrequest
- the requestpublic String getId(String extendedId)
getId
in interface SessionIdManager
extendedId
- the session id with the worker extensionpublic void expireAll(String id)
expireAll
in interface SessionIdManager
id
- The session ID without any cluster node extensionSessionIdManager.expireAll(java.lang.String)
public void invalidateAll(String id)
SessionIdManager
invalidateAll
in interface SessionIdManager
id
- the session idpublic void renewSessionId(String oldClusterId, String oldNodeId, javax.servlet.http.HttpServletRequest request)
renewSessionId
in interface SessionIdManager
oldClusterId
- the old plain session idoldNodeId
- the old fully qualified idrequest
- the request containing the sessionSessionIdManager.renewSessionId(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest)
public Set<SessionHandler> getSessionHandlers()
getSessionHandlers
in interface SessionIdManager
Copyright © 1995–2016 Mort Bay Consulting. All rights reserved.