[Bug 362447] add setMaxNonceAge() to DigestAuthenticator

This commit is contained in:
Jesse McConnell 2011-11-02 16:39:22 -05:00
parent c83b02c4a7
commit 81e58f1f71
1 changed files with 17 additions and 2 deletions

View File

@ -87,8 +87,19 @@ public class DigestAuthenticator extends LoginAuthenticator
String mna=configuration.getInitParameter("maxNonceAge");
if (mna!=null)
{
synchronized (this)
{
_maxNonceAgeMs=Long.valueOf(mna);
}
}
}
/* ------------------------------------------------------------ */
public synchronized void setMaxNonceAge(long maxNonceAgeInMillis)
{
_maxNonceAgeMs = maxNonceAgeInMillis;
}
/* ------------------------------------------------------------ */
public String getAuthMethod()
@ -235,7 +246,11 @@ public class DigestAuthenticator extends LoginAuthenticator
private int checkNonce(Digest digest, Request request)
{
// firstly let's expire old nonces
long expired = request.getTimeStamp()-_maxNonceAgeMs;
long expired;
synchronized (this)
{
expired = request.getTimeStamp()-_maxNonceAgeMs;
}
Nonce nonce=_nonceQueue.peek();
while (nonce!=null && nonce._ts<expired)