diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2013-01-23 12:10:52 -0600 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2013-02-04 12:06:40 -0500 |
commit | 6259ba064f4c17b7f6891fcb61501103348936be (patch) | |
tree | ae79ff683cb7e7b2c53b2b3fcef1740810c3d89d /base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java | |
parent | 9c6f3df2193de627f83c1f22fe47cd61e6e3578a (diff) | |
download | pki-6259ba064f4c17b7f6891fcb61501103348936be.tar.gz pki-6259ba064f4c17b7f6891fcb61501103348936be.tar.xz pki-6259ba064f4c17b7f6891fcb61501103348936be.zip |
Session-based nonces.
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/cert/RevocationProcessor.java')
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java index 341314887..e555d1ac6 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java +++ b/base/common/src/com/netscape/cms/servlet/cert/RevocationProcessor.java @@ -26,7 +26,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Locale; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import com.netscape.certsrv.authorization.EAuthzException; import netscape.security.x509.CRLExtensions; import netscape.security.x509.CRLReasonExtension; import netscape.security.x509.InvalidityDateExtension; @@ -39,6 +44,7 @@ import com.netscape.certsrv.base.BadRequestException; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.EPropertyNotFound; import com.netscape.certsrv.base.ForbiddenException; +import com.netscape.certsrv.base.PKIException; import com.netscape.certsrv.base.UnauthorizedException; import com.netscape.certsrv.ca.ICertificateAuthority; import com.netscape.certsrv.dbs.certdb.CertId; @@ -188,47 +194,24 @@ public class RevocationProcessor extends CertProcessor { return request; } - public void validateNonce(X509Certificate clientCert, Long nonce) { + public boolean isMemberOfSubsystemGroup(X509Certificate clientCert) { - if (nonces != null) { - boolean nonceVerified = false; - boolean skipNonceVerification = false; + if (clientCert == null) { + return false; + } - if (clientCert != null) { - X509Certificate certChain[] = new X509Certificate[1]; - certChain[0] = clientCert; - IUser user = null; - try { - user = ul.locateUser(new Certificates(certChain)); - } catch (Exception e) { - CMS.debug("RevocationProcessor: Failed to map certificate '" + - clientCert.getSubjectDN().getName() + "' to user."); - } - if (ug.isMemberOf(user, "Subsystem Group")) { - skipNonceVerification = true; - } - } + try { + X509Certificate certChain[] = new X509Certificate[1]; + certChain[0] = clientCert; - if (nonce != null) { - X509Certificate storedCert = nonces.getCertificate(nonce); - if (storedCert == null) { - CMS.debug("RevocationProcessor: Unknown nonce"); + IUser user = ul.locateUser(new Certificates(certChain)); + return ug.isMemberOf(user, "Subsystem Group"); - } else if (clientCert != null && storedCert.equals(clientCert)) { - nonceVerified = true; - nonces.removeNonce(nonce); - } - } else { - CMS.debug("RevocationProcessor: Missing nonce"); - } - - CMS.debug("RevocationProcessor: nonceVerified=" + nonceVerified); - CMS.debug("RevocationProcessor: skipNonceVerification=" + skipNonceVerification); - if ((!nonceVerified) && (!skipNonceVerification)) { - throw new ForbiddenException("Invalid nonce."); - } + } catch (Exception e) { + CMS.debug("RevocationProcessor: Failed to map certificate '" + + clientCert.getSubjectDN().getName() + "' to user."); + return false; } - } public void validateCertificateToRevoke(String subjectDN, ICertRecord targetRecord, boolean revokingCACert) { |