Merge remote-tracking branch 'origin/jetty-7' into jetty-8
This commit is contained in:
commit
60a6340f8f
|
@ -37,6 +37,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
protected Random _random;
|
||||
protected boolean _weakRandom;
|
||||
protected String _workerName;
|
||||
protected long _reseed=100000L;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public AbstractSessionIdManager()
|
||||
|
@ -50,6 +51,24 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return the reseed probability
|
||||
*/
|
||||
public long getReseed()
|
||||
{
|
||||
return _reseed;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the reseed probability.
|
||||
* @param reseed If non zero then when a random long modulo the reseed value == 1, the {@link SecureRandom} will be reseeded.
|
||||
*/
|
||||
public void setReseed(long reseed)
|
||||
{
|
||||
_reseed = reseed;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Get the workname. If set, the workername is dot appended to the session
|
||||
|
@ -125,6 +144,22 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
:_random.nextLong();
|
||||
if (r0<0)
|
||||
r0=-r0;
|
||||
|
||||
// random chance to reseed
|
||||
if (_reseed>0 && (r0%_reseed)== 1L)
|
||||
{
|
||||
LOG.debug("Reseeding {}",this);
|
||||
if (_random instanceof SecureRandom)
|
||||
{
|
||||
SecureRandom secure = (SecureRandom)_random;
|
||||
secure.setSeed(secure.generateSeed(8));
|
||||
}
|
||||
else
|
||||
{
|
||||
_random.setSeed(_random.nextLong()^System.currentTimeMillis()^request.hashCode()^Runtime.getRuntime().freeMemory());
|
||||
}
|
||||
}
|
||||
|
||||
long r1=_weakRandom
|
||||
?(hashCode()^Runtime.getRuntime().freeMemory()^_random.nextInt()^(((long)request.hashCode())<<32))
|
||||
:_random.nextLong();
|
||||
|
|
Loading…
Reference in New Issue