summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-01-23 12:10:52 -0600
committerEndi Sukma Dewata <edewata@redhat.com>2013-01-29 19:16:26 -0500
commit8390f25a4b5556af787ca5078dec221075dc9420 (patch)
treed4b198729a1b5493e72a3e59137789522e4a9034 /base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java
parent95e41dc9043a3fbbeea2abd58cca84d1442c0102 (diff)
downloadpki-8390f25a4b5556af787ca5078dec221075dc9420.tar.gz
pki-8390f25a4b5556af787ca5078dec221075dc9420.tar.xz
pki-8390f25a4b5556af787ca5078dec221075dc9420.zip
Session-based nonces.ticket-474-1
Previously nonces were stored in a global map which might not scale well due to some issues: 1. The map uses the nonces as map keys. There were possible nonce collisions which required special handling. 2. The collision handling code was not thread safe. There were possible race conditions during concurrent modifications. 3. The map was shared and size limited. If there were a lot of users using the system, valid nonces could get pruned. 4. The map maps the nonces to client certificates. This limits the possible authentication methods that can be supported. Now the code has been modified such that each user has a private map in the user's session to store the nonces. Additional locking has been implemented to protect against concurrent modifications. The map now uses the target of the operation as the map key, eliminating possible collisions and allowing the use of other authentication methods. Since this is a private map, it's not affected by the number of users using the system. Ticket #474
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java')
-rw-r--r--base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java
index 61a04a630..2b3ef83bb 100644
--- a/base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileReviewServlet.java
@@ -19,6 +19,7 @@ package com.netscape.cms.servlet.profile;
import java.util.Enumeration;
import java.util.Locale;
+import java.util.Map;
import java.util.Random;
import javax.servlet.ServletConfig;
@@ -29,11 +30,9 @@ import javax.servlet.http.HttpServletResponse;
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.IAuthToken;
-import com.netscape.certsrv.authority.IAuthority;
import com.netscape.certsrv.authorization.AuthzToken;
import com.netscape.certsrv.authorization.EAuthzAccessDenied;
import com.netscape.certsrv.base.EBaseException;
-import com.netscape.certsrv.base.Nonces;
import com.netscape.certsrv.ca.ICertificateAuthority;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.profile.EProfileException;
@@ -68,8 +67,8 @@ public class ProfileReviewServlet extends ProfileServlet {
private static final String PROP_AUTHORITY_ID = "authorityId";
private String mAuthorityId = null;
+ ICertificateAuthority authority = null;
private Random mRandom = null;
- private Nonces mNonces = null;
public ProfileReviewServlet() {
}
@@ -84,12 +83,10 @@ public class ProfileReviewServlet extends ProfileServlet {
super.init(sc);
mAuthorityId = sc.getInitParameter(PROP_AUTHORITY_ID);
- ICertificateAuthority authority = null;
if (mAuthorityId != null)
authority = (ICertificateAuthority) CMS.getSubsystem(mAuthorityId);
if (authority != null && authority.noncesEnabled()) {
- mNonces = authority.getNonces();
mRandom = new Random();
}
}
@@ -168,7 +165,6 @@ public class ProfileReviewServlet extends ProfileServlet {
}
// retrieve request
- IAuthority authority = (IAuthority) CMS.getSubsystem(mAuthorityId);
if (authority == null) {
CMS.debug("ProfileReviewServlet: Authority " + mAuthorityId +
@@ -253,12 +249,11 @@ public class ProfileReviewServlet extends ProfileServlet {
}
}
- if (mNonces != null) {
+ if (authority != null && authority.noncesEnabled()) {
long n = mRandom.nextLong();
- long m = mNonces.addNonce(n, getSSLClientCertificate(request));
- if ((n + m) != 0) {
- args.set(ARG_REQUEST_NONCE, Long.toString(m));
- }
+ Map<Object, Long> nonces = authority.getNonces(request, "cert-request");
+ nonces.put(req.getRequestId().toBigInteger(), n);
+ args.set(ARG_REQUEST_NONCE, Long.toString(n));
}
args.set(ARG_REQUEST_ID, req.getRequestId().toString());