efcdb2
From cc97f8628b23f8ea75308bb97a31307cb4f162b9 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Tue, 23 Jun 2015 12:23:15 -0400
efcdb2
Subject: [PATCH 01/21] Fixed selftests log message.
efcdb2
efcdb2
The SelfTestSubsystem has been modified to display a 'successful'
efcdb2
message only if all tests have passed. If a test fails, it will
efcdb2
log a failure, subsequent tests will not be executed, and the
efcdb2
subsystem will shutdown immediately.
efcdb2
efcdb2
The runSelfTest() in various tests have been cleaned up to throw
efcdb2
the original exception to help troubleshooting. The unused
efcdb2
RAPresence test has been removed.
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/1249
efcdb2
---
efcdb2
 .../com/netscape/certsrv/selftests/ISelfTest.java  |   5 +-
efcdb2
 .../certsrv/selftests/ISelfTestSubsystem.java      |   5 +-
efcdb2
 .../src/com/netscape/cms/selftests/ASelfTest.java  |   5 +-
efcdb2
 .../com/netscape/cms/selftests/ca/CAPresence.java  |  97 +++-----
efcdb2
 .../com/netscape/cms/selftests/ca/CAValidity.java  | 102 ++++----
efcdb2
 .../selftests/common/SystemCertsVerification.java  |  35 ++-
efcdb2
 .../netscape/cms/selftests/kra/KRAPresence.java    |  84 +++----
efcdb2
 .../netscape/cms/selftests/ocsp/OCSPPresence.java  | 123 ++++------
efcdb2
 .../netscape/cms/selftests/ocsp/OCSPValidity.java  | 127 ++++------
efcdb2
 .../com/netscape/cms/selftests/ra/RAPresence.java  | 261 --------------------
efcdb2
 .../cms/selftests/tks/TKSKnownSessionKey.java      |  56 +++--
efcdb2
 .../cms/servlet/admin/CMSAdminServlet.java         |   6 +-
efcdb2
 .../cmscore/selftests/SelfTestSubsystem.java       | 271 ++++++++++-----------
efcdb2
 .../server/tps/selftests/TPSPresence.java          |  38 ++-
efcdb2
 .../server/tps/selftests/TPSValidity.java          |  43 ++--
efcdb2
 15 files changed, 449 insertions(+), 809 deletions(-)
efcdb2
 delete mode 100644 base/server/cms/src/com/netscape/cms/selftests/ra/RAPresence.java
efcdb2
efcdb2
diff --git a/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java b/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java
efcdb2
index 24ad623..0ffc74b 100644
efcdb2
--- a/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java
efcdb2
+++ b/base/common/src/com/netscape/certsrv/selftests/ISelfTest.java
efcdb2
@@ -126,8 +126,7 @@ public interface ISelfTest {
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException;
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception;
efcdb2
 }
efcdb2
diff --git a/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java b/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java
efcdb2
index 214ee17..29adde0 100644
efcdb2
--- a/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java
efcdb2
+++ b/base/common/src/com/netscape/certsrv/selftests/ISelfTestSubsystem.java
efcdb2
@@ -206,10 +206,9 @@ public interface ISelfTestSubsystem
efcdb2
      * 

efcdb2
      *
efcdb2
      * @exception EMissingSelfTestException subsystem has missing name
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTestsAtStartup()
efcdb2
-            throws EMissingSelfTestException, ESelfTestException;
efcdb2
+    public void runSelfTestsAtStartup() throws Exception;
efcdb2
 
efcdb2
     //
efcdb2
     // methods associated with the list of self test instances
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ASelfTest.java b/base/server/cms/src/com/netscape/cms/selftests/ASelfTest.java
efcdb2
index e77ece5..c77514f 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ASelfTest.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/ASelfTest.java
efcdb2
@@ -186,8 +186,7 @@ public abstract class ASelfTest
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public abstract void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException;
efcdb2
+    public abstract void runSelfTest(ILogEventListener logger) throws Exception;
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ca/CAPresence.java b/base/server/cms/src/com/netscape/cms/selftests/ca/CAPresence.java
efcdb2
index 83caa00..ab491c7 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ca/CAPresence.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/ca/CAPresence.java
efcdb2
@@ -191,72 +191,55 @@ public class CAPresence
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        ICertificateAuthority ca = null;
efcdb2
-        X509CertImpl caCert = null;
efcdb2
-        X509Key caPubKey = null;
efcdb2
-
efcdb2
-        ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
 
efcdb2
+        ICertificateAuthority ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId);
efcdb2
         if (ca == null) {
efcdb2
             // log that the CA is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the CA certificate
efcdb2
-            caCert = ca.getCACert();
efcdb2
-
efcdb2
-            if (caCert == null) {
efcdb2
-                // log that the CA is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_CA_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the CA certificate public key
efcdb2
-            try {
efcdb2
-                caPubKey = (X509Key) caCert.get(X509CertImpl.PUBLIC_KEY);
efcdb2
-
efcdb2
-                if (caPubKey == null) {
efcdb2
-                    // log that something is seriously wrong with the CA
efcdb2
-                    logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_CORRUPT",
efcdb2
-                                                    getSelfTestName());
efcdb2
-
efcdb2
-                    mSelfTestSubsystem.log(logger,
efcdb2
-                                            logMessage);
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                    throw new ESelfTestException(logMessage);
efcdb2
-                }
efcdb2
-            } catch (CertificateParsingException e) {
efcdb2
-                // log that something is seriously wrong with the CA
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        e.toString());
efcdb2
+        // Retrieve the CA certificate
efcdb2
+        X509CertImpl caCert = ca.getCACert();
efcdb2
+        if (caCert == null) {
efcdb2
+            // log that the CA is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                throw new ESelfTestException(e.toString());
efcdb2
-            }
efcdb2
+        // Retrieve the CA certificate public key
efcdb2
+        X509Key caPubKey;
efcdb2
+        try {
efcdb2
+            caPubKey = (X509Key) caCert.get(X509CertImpl.PUBLIC_KEY);
efcdb2
 
efcdb2
-            // log that the CA is present
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
+        } catch (CertificateParsingException e) {
efcdb2
+            // log that something is seriously wrong with the CA
efcdb2
+            mSelfTestSubsystem.log(logger, e.toString());
efcdb2
+            throw e;
efcdb2
+        }
efcdb2
 
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
+        if (caPubKey == null) {
efcdb2
+            // log that something is seriously wrong with the CA
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_CORRUPT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        // log that the CA is present
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_CA_IS_PRESENT",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ca/CAValidity.java b/base/server/cms/src/com/netscape/cms/selftests/ca/CAValidity.java
efcdb2
index b1751ec..4d90be1 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ca/CAValidity.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/ca/CAValidity.java
efcdb2
@@ -191,72 +191,56 @@ public class CAValidity
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        ICertificateAuthority ca = null;
efcdb2
-        X509CertImpl caCert = null;
efcdb2
-
efcdb2
-        ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
 
efcdb2
+        ICertificateAuthority ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId);
efcdb2
         if (ca == null) {
efcdb2
             // log that the CA is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the CA certificate
efcdb2
-            caCert = ca.getCACert();
efcdb2
-
efcdb2
-            if (caCert == null) {
efcdb2
-                // log that the CA is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_CA_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the CA validity period
efcdb2
-            try {
efcdb2
-                caCert.checkValidity();
efcdb2
-            } catch (CertificateNotYetValidException e) {
efcdb2
-                // log that the CA is not yet valid
efcdb2
-                logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_YET_VALID",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            } catch (CertificateExpiredException e) {
efcdb2
-                // log that the CA is expired
efcdb2
-                logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_EXPIRED",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            // log that the CA is valid
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_VALID",
efcdb2
-                                            getSelfTestName());
efcdb2
+        // Retrieve the CA certificate
efcdb2
+        X509CertImpl caCert = ca.getCACert();
efcdb2
+        if (caCert == null) {
efcdb2
+            // log that the CA is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
+        // Retrieve the CA validity period
efcdb2
+        try {
efcdb2
+            caCert.checkValidity();
efcdb2
+
efcdb2
+        } catch (CertificateNotYetValidException e) {
efcdb2
+            // log that the CA is not yet valid
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_NOT_YET_VALID",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw e;
efcdb2
+
efcdb2
+        } catch (CertificateExpiredException e) {
efcdb2
+            // log that the CA is expired
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_CA_IS_EXPIRED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        // log that the CA is valid
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_CA_IS_VALID",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/common/SystemCertsVerification.java b/base/server/cms/src/com/netscape/cms/selftests/common/SystemCertsVerification.java
efcdb2
index f5b0939..5c1e97b 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/common/SystemCertsVerification.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/common/SystemCertsVerification.java
efcdb2
@@ -185,29 +185,22 @@ public class SystemCertsVerification
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        boolean rc = false;
efcdb2
-
efcdb2
-        rc = CMS.verifySystemCerts();
efcdb2
-        if (rc == true) {
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_SUCCESS",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-        } else {
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_FAILURE",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
+
efcdb2
+        boolean status = CMS.verifySystemCerts();
efcdb2
+        if (!status) {
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_FAILURE",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_SUCCESS",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/kra/KRAPresence.java b/base/server/cms/src/com/netscape/cms/selftests/kra/KRAPresence.java
efcdb2
index 832d2b7..ff0c3fb 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/kra/KRAPresence.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/kra/KRAPresence.java
efcdb2
@@ -188,64 +188,46 @@ public class KRAPresence
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        IKeyRecoveryAuthority kra = null;
efcdb2
-        org.mozilla.jss.crypto.X509Certificate kraCert = null;
efcdb2
-        PublicKey kraPubKey = null;
efcdb2
-
efcdb2
-        kra = (IKeyRecoveryAuthority) CMS.getSubsystem(mSubId);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
 
efcdb2
+        IKeyRecoveryAuthority kra = (IKeyRecoveryAuthority) CMS.getSubsystem(mSubId);
efcdb2
         if (kra == null) {
efcdb2
             // log that the KRA is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the KRA certificate
efcdb2
-            kraCert = kra.getTransportCert();
efcdb2
-
efcdb2
-            if (kraCert == null) {
efcdb2
-                // log that the RA is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_KRA_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the KRA certificate public key
efcdb2
-            kraPubKey = kraCert.getPublicKey();
efcdb2
-
efcdb2
-            if (kraPubKey == null) {
efcdb2
-                // log that something is seriously wrong with the KRA
efcdb2
-                logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_CORRUPT",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_KRA_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            // log that the KRA is present
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
+        // Retrieve the KRA certificate
efcdb2
+        org.mozilla.jss.crypto.X509Certificate kraCert = kra.getTransportCert();
efcdb2
+        if (kraCert == null) {
efcdb2
+            // log that the RA is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_KRA_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
+        // Retrieve the KRA certificate public key
efcdb2
+        PublicKey kraPubKey = kraCert.getPublicKey();
efcdb2
+        if (kraPubKey == null) {
efcdb2
+            // log that something is seriously wrong with the KRA
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_KRA_IS_CORRUPT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        // log that the KRA is present
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_KRA_IS_PRESENT",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java b/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java
efcdb2
index a3d9e3a..db9d237 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java
efcdb2
@@ -192,89 +192,66 @@ public class OCSPPresence
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        IOCSPAuthority ocsp = null;
efcdb2
-        ISigningUnit ocspSigningUnit = null;
efcdb2
-        X509CertImpl ocspCert = null;
efcdb2
-        X509Key ocspPubKey = null;
efcdb2
-
efcdb2
-        ocsp = (IOCSPAuthority) CMS.getSubsystem(mOcspSubId);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
 
efcdb2
+        IOCSPAuthority ocsp = (IOCSPAuthority) CMS.getSubsystem(mOcspSubId);
efcdb2
         if (ocsp == null) {
efcdb2
             // log that the OCSP is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the OCSP signing unit
efcdb2
-            ocspSigningUnit = ocsp.getSigningUnit();
efcdb2
-
efcdb2
-            if (ocspSigningUnit == null) {
efcdb2
-                // log that the OCSP is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the OCSP certificate
efcdb2
-            ocspCert = ocspSigningUnit.getCertImpl();
efcdb2
-
efcdb2
-            if (ocspCert == null) {
efcdb2
-                // log that the OCSP is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the OCSP certificate public key
efcdb2
-            try {
efcdb2
-                ocspPubKey = (X509Key)
efcdb2
-                             ocspCert.get(X509CertImpl.PUBLIC_KEY);
efcdb2
-
efcdb2
-                if (ocspPubKey == null) {
efcdb2
-                    // log that something is seriously wrong with the OCSP
efcdb2
-                    logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_CORRUPT",
efcdb2
-                                                    getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                    mSelfTestSubsystem.log(logger,
efcdb2
-                                            logMessage);
efcdb2
+        // Retrieve the OCSP signing unit
efcdb2
+        ISigningUnit ocspSigningUnit = ocsp.getSigningUnit();
efcdb2
+        if (ocspSigningUnit == null) {
efcdb2
+            // log that the OCSP is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                    throw new ESelfTestException(logMessage);
efcdb2
-                }
efcdb2
-            } catch (CertificateParsingException e) {
efcdb2
-                // log that something is seriously wrong with the OCSP
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        e.toString());
efcdb2
+        // Retrieve the OCSP certificate
efcdb2
+        X509CertImpl ocspCert = ocspSigningUnit.getCertImpl();
efcdb2
+        if (ocspCert == null) {
efcdb2
+            // log that the OCSP is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                throw new ESelfTestException(e.toString());
efcdb2
-            }
efcdb2
+        // Retrieve the OCSP certificate public key
efcdb2
+        X509Key ocspPubKey;
efcdb2
+        try {
efcdb2
+            ocspPubKey = (X509Key)ocspCert.get(X509CertImpl.PUBLIC_KEY);
efcdb2
 
efcdb2
-            // log that the OCSP is present
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
+        } catch (CertificateParsingException e) {
efcdb2
+            // log that something is seriously wrong with the OCSP
efcdb2
+            mSelfTestSubsystem.log(logger, e.toString());
efcdb2
+            throw e;
efcdb2
+        }
efcdb2
 
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
+        if (ocspPubKey == null) {
efcdb2
+            // log that something is seriously wrong with the OCSP
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_CORRUPT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        // log that the OCSP is present
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_OCSP_IS_PRESENT",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java b/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java
efcdb2
index 383779d..6aadf84 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java
efcdb2
@@ -192,89 +192,68 @@ public class OCSPValidity
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
         String logMessage = null;
efcdb2
-        IOCSPAuthority ocsp = null;
efcdb2
-        ISigningUnit ocspSigningUnit = null;
efcdb2
-        X509CertImpl ocspCert = null;
efcdb2
-
efcdb2
-        ocsp = (IOCSPAuthority) CMS.getSubsystem(mOcspSubId);
efcdb2
 
efcdb2
+        IOCSPAuthority ocsp = (IOCSPAuthority) CMS.getSubsystem(mOcspSubId);
efcdb2
         if (ocsp == null) {
efcdb2
             // log that the OCSP is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the OCSP signing unit
efcdb2
-            ocspSigningUnit = ocsp.getSigningUnit();
efcdb2
-
efcdb2
-            if (ocspSigningUnit == null) {
efcdb2
-                // log that the OCSP is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the OCSP certificate
efcdb2
-            ocspCert = ocspSigningUnit.getCertImpl();
efcdb2
-
efcdb2
-            if (ocspCert == null) {
efcdb2
-                // log that the OCSP is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the OCSP validity period
efcdb2
-            try {
efcdb2
-                ocspCert.checkValidity();
efcdb2
-            } catch (CertificateNotYetValidException e) {
efcdb2
-                // log that the OCSP is not yet valid
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                                 "SELFTESTS_OCSP_IS_NOT_YET_VALID",
efcdb2
-                                 getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            } catch (CertificateExpiredException e) {
efcdb2
-                // log that the OCSP is expired
efcdb2
-                logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_EXPIRED",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
+            logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
+        // Retrieve the OCSP signing unit
efcdb2
+        ISigningUnit ocspSigningUnit = ocsp.getSigningUnit();
efcdb2
+        if (ocspSigningUnit == null) {
efcdb2
+            // log that the OCSP is not yet initialized
efcdb2
+            logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            // log that the OCSP is valid
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_VALID",
efcdb2
-                                            getSelfTestName());
efcdb2
+        // Retrieve the OCSP certificate
efcdb2
+        X509CertImpl ocspCert = ocspSigningUnit.getCertImpl();
efcdb2
+        if (ocspCert == null) {
efcdb2
+            // log that the OCSP is not yet initialized
efcdb2
+            logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
+        }
efcdb2
 
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
+        // Retrieve the OCSP validity period
efcdb2
+        try {
efcdb2
+            ocspCert.checkValidity();
efcdb2
+
efcdb2
+        } catch (CertificateNotYetValidException e) {
efcdb2
+            // log that the OCSP is not yet valid
efcdb2
+            logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_NOT_YET_VALID",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw e;
efcdb2
+
efcdb2
+        } catch (CertificateExpiredException e) {
efcdb2
+            // log that the OCSP is expired
efcdb2
+            logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_OCSP_IS_EXPIRED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
 
efcdb2
-        return;
efcdb2
+        // log that the OCSP is valid
efcdb2
+        logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_OCSP_IS_VALID",
efcdb2
+                getSelfTestName());
efcdb2
+        mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/ra/RAPresence.java b/base/server/cms/src/com/netscape/cms/selftests/ra/RAPresence.java
efcdb2
deleted file mode 100644
efcdb2
index 6facd80..0000000
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/ra/RAPresence.java
efcdb2
+++ /dev/null
efcdb2
@@ -1,261 +0,0 @@
efcdb2
-// --- BEGIN COPYRIGHT BLOCK ---
efcdb2
-// This program is free software; you can redistribute it and/or modify
efcdb2
-// it under the terms of the GNU General Public License as published by
efcdb2
-// the Free Software Foundation; version 2 of the License.
efcdb2
-//
efcdb2
-// This program is distributed in the hope that it will be useful,
efcdb2
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
efcdb2
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
efcdb2
-// GNU General Public License for more details.
efcdb2
-//
efcdb2
-// You should have received a copy of the GNU General Public License along
efcdb2
-// with this program; if not, write to the Free Software Foundation, Inc.,
efcdb2
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
efcdb2
-//
efcdb2
-// (C) 2007 Red Hat, Inc.
efcdb2
-// All rights reserved.
efcdb2
-// --- END COPYRIGHT BLOCK ---
efcdb2
-// package statement //
efcdb2
-///////////////////////
efcdb2
-
efcdb2
-package com.netscape.cms.selftests.ra;
efcdb2
-
efcdb2
-///////////////////////
efcdb2
-// import statements //
efcdb2
-///////////////////////
efcdb2
-
efcdb2
-import java.security.PublicKey;
efcdb2
-import java.util.Locale;
efcdb2
-
efcdb2
-import com.netscape.certsrv.apps.CMS;
efcdb2
-import com.netscape.certsrv.base.EBaseException;
efcdb2
-import com.netscape.certsrv.base.IConfigStore;
efcdb2
-import com.netscape.certsrv.logging.ILogEventListener;
efcdb2
-import com.netscape.certsrv.ra.IRegistrationAuthority;
efcdb2
-import com.netscape.certsrv.selftests.EDuplicateSelfTestException;
efcdb2
-import com.netscape.certsrv.selftests.EInvalidSelfTestException;
efcdb2
-import com.netscape.certsrv.selftests.EMissingSelfTestException;
efcdb2
-import com.netscape.certsrv.selftests.ESelfTestException;
efcdb2
-import com.netscape.certsrv.selftests.ISelfTestSubsystem;
efcdb2
-import com.netscape.cms.selftests.ASelfTest;
efcdb2
-
efcdb2
-//////////////////////
efcdb2
-// class definition //
efcdb2
-//////////////////////
efcdb2
-
efcdb2
-/**
efcdb2
- * This class implements a self test to check for RA presence.
efcdb2
- * 

efcdb2
- *
efcdb2
- * 
efcdb2
- * NOTE:  This self-test is for Registration Authorities prior to
efcdb2
- *        Netscape Certificate Management System 7.0.  It does NOT
efcdb2
- *        apply to the Registration Authority found in
efcdb2
- *        Red Hat Certificate System 7.3 or later (including
efcdb2
- *        ALL versions of Dogtag Certificate System).
efcdb2
- * 
efcdb2
- * 

efcdb2
- *
efcdb2
- * @deprecated
efcdb2
- * @author mharmsen
efcdb2
- * @author thomask
efcdb2
- * @version $Revision$, $Date$
efcdb2
- */
efcdb2
-public class RAPresence
efcdb2
-        extends ASelfTest {
efcdb2
-    ////////////////////////
efcdb2
-    // default parameters //
efcdb2
-    ////////////////////////
efcdb2
-
efcdb2
-    ///////////////////////////
efcdb2
-    // RAPresence parameters //
efcdb2
-    ///////////////////////////
efcdb2
-
efcdb2
-    // parameter information
efcdb2
-    public static final String PROP_RA_SUB_ID = "RaSubId";
efcdb2
-    private String mRaSubId = null;
efcdb2
-
efcdb2
-    /////////////////////
efcdb2
-    // default methods //
efcdb2
-    /////////////////////
efcdb2
-
efcdb2
-    ////////////////////////
efcdb2
-    // RAPresence methods //
efcdb2
-    ////////////////////////
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Initializes this subsystem with the configuration store
efcdb2
-     * associated with this instance name.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @param subsystem the associated subsystem
efcdb2
-     * @param instanceName the name of this self test instance
efcdb2
-     * @param parameters configuration store (self test parameters)
efcdb2
-     * @exception EDuplicateSelfTestException subsystem has duplicate name/value
efcdb2
-     * @exception EInvalidSelfTestException subsystem has invalid name/value
efcdb2
-     * @exception EMissingSelfTestException subsystem has missing name/value
efcdb2
-     */
efcdb2
-    public void initSelfTest(ISelfTestSubsystem subsystem,
efcdb2
-                              String instanceName,
efcdb2
-                              IConfigStore parameters)
efcdb2
-            throws EDuplicateSelfTestException,
efcdb2
-            EInvalidSelfTestException,
efcdb2
-            EMissingSelfTestException {
efcdb2
-        super.initSelfTest(subsystem, instanceName, parameters);
efcdb2
-
efcdb2
-        // retrieve mandatory parameter(s)
efcdb2
-        try {
efcdb2
-            mRaSubId = mConfig.getString(PROP_RA_SUB_ID);
efcdb2
-            if (mRaSubId != null) {
efcdb2
-                mRaSubId = mRaSubId.trim();
efcdb2
-            } else {
efcdb2
-                mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(),
efcdb2
-                                        CMS.getLogMessage(
efcdb2
-                                                "SELFTESTS_MISSING_VALUES",
efcdb2
-                                                getSelfTestName(),
efcdb2
-                                                mPrefix
efcdb2
-                                                        + "."
efcdb2
-                                                        + PROP_RA_SUB_ID));
efcdb2
-
efcdb2
-                throw new EMissingSelfTestException(PROP_RA_SUB_ID);
efcdb2
-            }
efcdb2
-        } catch (EBaseException e) {
efcdb2
-            mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(),
efcdb2
-                                    CMS.getLogMessage(
efcdb2
-                                            "SELFTESTS_MISSING_NAME",
efcdb2
-                                            getSelfTestName(),
efcdb2
-                                            mPrefix
efcdb2
-                                                    + "."
efcdb2
-                                                    + PROP_RA_SUB_ID));
efcdb2
-
efcdb2
-            throw new EMissingSelfTestException(mPrefix,
efcdb2
-                                                 PROP_RA_SUB_ID,
efcdb2
-                                                 null);
efcdb2
-        }
efcdb2
-
efcdb2
-        // retrieve optional parameter(s)
efcdb2
-
efcdb2
-        return;
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Notifies this subsystem if it is in execution mode.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @exception ESelfTestException failed to start
efcdb2
-     */
efcdb2
-    public void startupSelfTest()
efcdb2
-            throws ESelfTestException {
efcdb2
-        return;
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Stops this subsystem. The subsystem may call shutdownSelfTest
efcdb2
-     * anytime after initialization.
efcdb2
-     * 

efcdb2
-     */
efcdb2
-    public void shutdownSelfTest() {
efcdb2
-        return;
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Returns the name associated with this self test. This method may
efcdb2
-     * return null if the self test has not been intialized.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @return instanceName of this self test
efcdb2
-     */
efcdb2
-    public String getSelfTestName() {
efcdb2
-        return super.getSelfTestName();
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Returns the root configuration storage (self test parameters)
efcdb2
-     * associated with this subsystem.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @return configuration store (self test parameters) of this subsystem
efcdb2
-     */
efcdb2
-    public IConfigStore getSelfTestConfigStore() {
efcdb2
-        return super.getSelfTestConfigStore();
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Retrieves description associated with an individual self test.
efcdb2
-     * This method may return null.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @param locale locale of the client that requests the description
efcdb2
-     * @return description of self test
efcdb2
-     */
efcdb2
-    public String getSelfTestDescription(Locale locale) {
efcdb2
-        return CMS.getUserMessage(locale,
efcdb2
-                                   "CMS_SELFTESTS_RA_PRESENCE_DESCRIPTION");
efcdb2
-    }
efcdb2
-
efcdb2
-    /**
efcdb2
-     * Execute an individual self test.
efcdb2
-     * 

efcdb2
-     *
efcdb2
-     * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
-     */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        IRegistrationAuthority ra = null;
efcdb2
-        org.mozilla.jss.crypto.X509Certificate raCert = null;
efcdb2
-        PublicKey raPubKey = null;
efcdb2
-
efcdb2
-        ra = (IRegistrationAuthority) CMS.getSubsystem(mRaSubId);
efcdb2
-
efcdb2
-        if (ra == null) {
efcdb2
-            // log that the RA is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_NOT_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            // Retrieve the RA certificate
efcdb2
-            raCert = ra.getRACert();
efcdb2
-
efcdb2
-            if (raCert == null) {
efcdb2
-                // log that the RA is not yet initialized
efcdb2
-                logMessage = CMS.getLogMessage(
efcdb2
-                             "SELFTESTS_RA_IS_NOT_INITIALIZED",
efcdb2
-                             getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // Retrieve the RA certificate public key
efcdb2
-            raPubKey = raCert.getPublicKey();
efcdb2
-
efcdb2
-            if (raPubKey == null) {
efcdb2
-                // log that something is seriously wrong with the RA
efcdb2
-                logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_CORRUPT",
efcdb2
-                                                getSelfTestName());
efcdb2
-
efcdb2
-                mSelfTestSubsystem.log(logger,
efcdb2
-                                        logMessage);
efcdb2
-
efcdb2
-                throw new ESelfTestException(logMessage);
efcdb2
-            }
efcdb2
-
efcdb2
-            // log that the RA is present
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_PRESENT",
efcdb2
-                                            getSelfTestName());
efcdb2
-
efcdb2
-            mSelfTestSubsystem.log(logger,
efcdb2
-                                    logMessage);
efcdb2
-        }
efcdb2
-
efcdb2
-        return;
efcdb2
-    }
efcdb2
-}
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java b/base/server/cms/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java
efcdb2
index d5e7c11..1686ba5 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java
efcdb2
@@ -104,7 +104,7 @@ public class TKSKnownSessionKey
efcdb2
         mMacKey = getConfigByteArray("macKey", 16);
efcdb2
         mUseSoftToken = getConfigString("useSoftToken");
efcdb2
 
efcdb2
-        // AC: KDF SPEC CHANGE 
efcdb2
+        // AC: KDF SPEC CHANGE
efcdb2
         // read CUID for the KDD field
efcdb2
         mKDD = getConfigByteArray("CUID", 10);
efcdb2
         //
efcdb2
@@ -143,7 +143,7 @@ public class TKSKnownSessionKey
efcdb2
                     getSelfTestName(), mPrefix + ".nistSP800-108KdfUseCuidAsKdd"));
efcdb2
                 throw new EMissingSelfTestException("nistSP800-108KdfUseCuidAsKdd");
efcdb2
         }
efcdb2
-        
efcdb2
+
efcdb2
         String defKeySetMacKey = null;
efcdb2
         tks = CMS.getSubsystem(mTksSubId);
efcdb2
         if (tks != null) {
efcdb2
@@ -175,7 +175,7 @@ public class TKSKnownSessionKey
efcdb2
             if (mSessionKey == null) {
efcdb2
                 mSessionKey = SessionKey.ComputeSessionKey(mToken, mKeyName,
efcdb2
                                                             mCardChallenge, mHostChallenge,
efcdb2
-                                                            mKeyInfo, 
efcdb2
+                                                            mKeyInfo,
efcdb2
                                                             mNistSP800_108KdfOnKeyVersion,   // AC: KDF SPEC CHANGE - pass in configuration self-test value
efcdb2
                                                             mNistSP800_108KdfUseCuidAsKdd,   // AC: KDF SPEC CHANGE - pass in configuration self-test value
efcdb2
                                                             mCUID,
efcdb2
@@ -320,13 +320,12 @@ public class TKSKnownSessionKey
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        IConfigStore cs = CMS.getConfigStore();
efcdb2
-        String sharedSecretName;
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
+
efcdb2
         try {
efcdb2
+            IConfigStore cs = CMS.getConfigStore();
efcdb2
             boolean useNewNames = cs.getBoolean("tks.useNewSharedSecretNames", false);
efcdb2
             if (useNewNames) {
efcdb2
                 String tpsList = cs.getString("tps.list", "");
efcdb2
@@ -336,29 +335,39 @@ public class TKSKnownSessionKey
efcdb2
                 }
efcdb2
 
efcdb2
                 for (String tpsID : tpsList.split(",")) {
efcdb2
-                    sharedSecretName = cs.getString("tps." + tpsID + ".nickname", "");
efcdb2
+                    String sharedSecretName = cs.getString("tps." + tpsID + ".nickname", "");
efcdb2
                     if (!sharedSecretName.isEmpty()) {
efcdb2
                         CMS.debug("TKSKnownSessionKey: testing with key " + sharedSecretName);
efcdb2
-                        generateSessionKey(logger, sharedSecretName);
efcdb2
+                        generateSessionKey(sharedSecretName);
efcdb2
                     }
efcdb2
                 }
efcdb2
+
efcdb2
             } else {
efcdb2
                 // legacy systems
efcdb2
-                sharedSecretName = cs.getString("tks.tksSharedSymKeyName", "sharedSecret");
efcdb2
-                generateSessionKey(logger, sharedSecretName);
efcdb2
+                String sharedSecretName = cs.getString("tks.tksSharedSymKeyName", "sharedSecret");
efcdb2
+                generateSessionKey(sharedSecretName);
efcdb2
             }
efcdb2
-        } catch (EBaseException e) {
efcdb2
-            e.printStackTrace();
efcdb2
-            CMS.debug("TKSKnownSessionKey: failed to read config file to set up test");
efcdb2
-            String logMessage = CMS.getLogMessage("SELFTESTS_TKS_FAILED", getSelfTestName(), getSelfTestName());
efcdb2
+
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TKS_SUCCEEDED",
efcdb2
+                    getSelfTestName(),
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            CMS.debug("TKSKnownSessionKey self test SUCCEEDED");
efcdb2
+
efcdb2
+        } catch (Exception e) {
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TKS_FAILED",
efcdb2
+                    getSelfTestName(),
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
+
efcdb2
         return;
efcdb2
     }
efcdb2
 
efcdb2
-    private void generateSessionKey(ILogEventListener logger, String sharedSecretName) throws ESelfTestException {
efcdb2
-        String logMessage;
efcdb2
+    private void generateSessionKey(String sharedSecretName) throws Exception {
efcdb2
         String keySet = "defKeySet";
efcdb2
 
efcdb2
         byte[] sessionKey = SessionKey.ComputeSessionKey(
efcdb2
@@ -374,14 +383,7 @@ public class TKSKnownSessionKey
efcdb2
         // For FIPS compliance, the routine now returns a wrapped key, which can't be extracted and compared.
efcdb2
         if (sessionKey == null) {
efcdb2
             CMS.debug("TKSKnownSessionKey: generated no session key");
efcdb2
-            CMS.debug("TKSKnownSessionKey self test FAILED");
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TKS_FAILED", getSelfTestName(), getSelfTestName());
efcdb2
-            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
-        } else {
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TKS_SUCCEEDED", getSelfTestName(), getSelfTestName());
efcdb2
-            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            CMS.debug("TKSKnownSessionKey self test SUCCEEDED");
efcdb2
+            throw new Exception("No session key generated");
efcdb2
         }
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/CMSAdminServlet.java b/base/server/cms/src/com/netscape/cms/servlet/admin/CMSAdminServlet.java
efcdb2
index b8cf27c..b6325b7 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/servlet/admin/CMSAdminServlet.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/servlet/admin/CMSAdminServlet.java
efcdb2
@@ -3248,7 +3248,11 @@ public final class CMSAdminServlet extends AdminServlet {
efcdb2
 
efcdb2
                         // store this information for console notification
efcdb2
                         content += "COMPLETED SUCCESSFULLY\n";
efcdb2
-                    } catch (ESelfTestException e) {
efcdb2
+
efcdb2
+                    } catch (Exception e) {
efcdb2
+
efcdb2
+                        CMS.debug(e);
efcdb2
+
efcdb2
                         // Check to see if the self test was critical:
efcdb2
                         if (mSelfTestSubsystem.isSelfTestCriticalOnDemand(
efcdb2
                                 instanceName)) {
efcdb2
diff --git a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
efcdb2
index ad1a1b0..d060f81 100644
efcdb2
--- a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
efcdb2
+++ b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java
efcdb2
@@ -530,7 +530,11 @@ public class SelfTestSubsystem
efcdb2
                     }
efcdb2
 
efcdb2
                     test.runSelfTest(mLogger);
efcdb2
-                } catch (ESelfTestException e) {
efcdb2
+
efcdb2
+                } catch (Exception e) {
efcdb2
+
efcdb2
+                    CMS.debug(e);
efcdb2
+
efcdb2
                     // Check to see if the self test was critical:
efcdb2
                     if (isSelfTestCriticalOnDemand(instanceName)) {
efcdb2
                         log(mLogger,
efcdb2
@@ -810,146 +814,76 @@ public class SelfTestSubsystem
efcdb2
      * 
efcdb2
      *
efcdb2
      * @exception EMissingSelfTestException subsystem has missing name
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTestsAtStartup()
efcdb2
-            throws EMissingSelfTestException, ESelfTestException {
efcdb2
-        String auditMessage = null;
efcdb2
+    public void runSelfTestsAtStartup() throws Exception {
efcdb2
 
efcdb2
-        // ensure that any low-level exceptions are reported
efcdb2
-        // to the signed audit log and stored as failures
efcdb2
-        try {
efcdb2
-            if (CMS.debugOn()) {
efcdb2
-                CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():"
efcdb2
-                        + "  ENTERING . . .");
efcdb2
-            }
efcdb2
+        // log that execution of startup self tests has begun
efcdb2
+        log(mLogger,
efcdb2
+                CMS.getLogMessage(
efcdb2
+                        "CMSCORE_SELFTESTS_RUN_AT_STARTUP"));
efcdb2
 
efcdb2
-            // loop through all self test plugin instances
efcdb2
-            // specified to be executed at server startup
efcdb2
-            Enumeration<SelfTestOrderedInstance> instances = mStartupOrder.elements();
efcdb2
+        // loop through all self test plugin instances
efcdb2
+        // specified to be executed at server startup
efcdb2
+        Enumeration<SelfTestOrderedInstance> instances = mStartupOrder.elements();
efcdb2
 
efcdb2
-            while (instances.hasMoreElements()) {
efcdb2
-                SelfTestOrderedInstance instance = instances.nextElement();
efcdb2
+        while (instances.hasMoreElements()) {
efcdb2
+            SelfTestOrderedInstance instance = instances.nextElement();
efcdb2
 
efcdb2
-                String instanceFullName = null;
efcdb2
-                String instanceName = instance.getSelfTestName();
efcdb2
+            String instanceFullName = null;
efcdb2
+            String instanceName = instance.getSelfTestName();
efcdb2
 
efcdb2
-                if (instanceName != null) {
efcdb2
-                    instanceName = instanceName.trim();
efcdb2
-                    instanceFullName = getFullName(mPrefix,
efcdb2
-                                instanceName);
efcdb2
-                } else {
efcdb2
-                    log(mLogger,
efcdb2
-                            CMS.getLogMessage(
efcdb2
-                                    "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL"));
efcdb2
+            if (instanceName == null) {
efcdb2
+                log(mLogger,
efcdb2
+                        CMS.getLogMessage(
efcdb2
+                                "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL"));
efcdb2
 
efcdb2
-                    // store a message in the signed audit log file
efcdb2
-                    auditMessage = CMS.getLogMessage(
efcdb2
-                                LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
-                                ILogger.SYSTEM_UID,
efcdb2
-                                ILogger.FAILURE);
efcdb2
+                throw new EMissingSelfTestException();
efcdb2
+            }
efcdb2
 
efcdb2
-                    audit(auditMessage);
efcdb2
+            instanceName = instanceName.trim();
efcdb2
+            instanceFullName = getFullName(mPrefix, instanceName);
efcdb2
 
efcdb2
-                    throw new EMissingSelfTestException();
efcdb2
-                }
efcdb2
+            if (!mSelfTestInstances.containsKey(instanceName)) {
efcdb2
+                // self test plugin instance property name is not present
efcdb2
+                log(mLogger,
efcdb2
+                        CMS.getLogMessage(
efcdb2
+                                "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME",
efcdb2
+                                instanceFullName));
efcdb2
 
efcdb2
-                if (mSelfTestInstances.containsKey(instanceName)) {
efcdb2
-                    ISelfTest test = mSelfTestInstances.get(instanceName);
efcdb2
-
efcdb2
-                    try {
efcdb2
-                        if (CMS.debugOn()) {
efcdb2
-                            CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():"
efcdb2
-                                    + "    running \""
efcdb2
-                                    + test.getSelfTestName()
efcdb2
-                                    + "\"");
efcdb2
-                        }
efcdb2
-
efcdb2
-                        test.runSelfTest(mLogger);
efcdb2
-                    } catch (ESelfTestException e) {
efcdb2
-                        // Check to see if the self test was critical:
efcdb2
-                        if (isSelfTestCriticalAtStartup(instanceName)) {
efcdb2
-                            log(mLogger,
efcdb2
-                                    CMS.getLogMessage(
efcdb2
-                                            "CMSCORE_SELFTESTS_RUN_AT_STARTUP_FAILED",
efcdb2
-                                            instanceFullName));
efcdb2
-
efcdb2
-                            // store a message in the signed audit log file
efcdb2
-                            auditMessage = CMS.getLogMessage(
efcdb2
-                                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
-                                        ILogger.SYSTEM_UID,
efcdb2
-                                        ILogger.FAILURE);
efcdb2
-
efcdb2
-                            audit(auditMessage);
efcdb2
-
efcdb2
-                            // shutdown the system gracefully
efcdb2
-                            CMS.shutdown();
efcdb2
-
efcdb2
-                            IConfigStore cs = CMS.getConfigStore();
efcdb2
-                            String instanceID = cs.get("instanceId");
efcdb2
-                            String subsystemID = cs.get("cs.type").toLowerCase();
efcdb2
-
efcdb2
-                            System.out.println("SelfTestSubsystem: Disabling \"" + subsystemID + "\" subsystem due to selftest failure.");
efcdb2
-
efcdb2
-                            try {
efcdb2
-                                ProcessBuilder pb = new ProcessBuilder("pki-server", "subsystem-disable", "-i", instanceID, subsystemID);
efcdb2
-                                Process process = pb.inheritIO().start();
efcdb2
-                                int rc = process.waitFor();
efcdb2
-
efcdb2
-                                if (rc != 0) {
efcdb2
-                                    System.out.println("SelfTestSubsystem: Unable to disable \"" + subsystemID + "\". RC: " + rc);
efcdb2
-                                }
efcdb2
-
efcdb2
-                            } catch (Exception e2) {
efcdb2
-                                e.printStackTrace();
efcdb2
-                            }
efcdb2
-
efcdb2
-                            return;
efcdb2
-                        }
efcdb2
-                    }
efcdb2
-                } else {
efcdb2
-                    // self test plugin instance property name is not present
efcdb2
-                    log(mLogger,
efcdb2
-                            CMS.getLogMessage(
efcdb2
-                                    "CMSCORE_SELFTESTS_PROPERTY_MISSING_NAME",
efcdb2
-                                    instanceFullName));
efcdb2
+                throw new EMissingSelfTestException(instanceFullName);
efcdb2
+            }
efcdb2
 
efcdb2
-                    // store a message in the signed audit log file
efcdb2
-                    auditMessage = CMS.getLogMessage(
efcdb2
-                                LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
-                                ILogger.SYSTEM_UID,
efcdb2
-                                ILogger.FAILURE);
efcdb2
+            ISelfTest test = mSelfTestInstances.get(instanceName);
efcdb2
 
efcdb2
-                    audit(auditMessage);
efcdb2
+            try {
efcdb2
+                CMS.debug("SelfTestSubsystem: running " + test.getSelfTestName());
efcdb2
+                test.runSelfTest(mLogger);
efcdb2
 
efcdb2
-                    throw new EMissingSelfTestException(instanceFullName);
efcdb2
-                }
efcdb2
-            }
efcdb2
+            } catch (Exception e) {
efcdb2
 
efcdb2
-            // store a message in the signed audit log file
efcdb2
-            auditMessage = CMS.getLogMessage(
efcdb2
-                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
-                        ILogger.SYSTEM_UID,
efcdb2
-                        ILogger.SUCCESS);
efcdb2
+                CMS.debug(e);
efcdb2
 
efcdb2
-            audit(auditMessage);
efcdb2
+                // Check to see if the self test was critical:
efcdb2
+                if (!isSelfTestCriticalAtStartup(instanceName)) {
efcdb2
+                    continue;
efcdb2
+                }
efcdb2
+
efcdb2
+                log(mLogger,
efcdb2
+                        CMS.getLogMessage(
efcdb2
+                                "CMSCORE_SELFTESTS_RUN_AT_STARTUP_FAILED",
efcdb2
+                                instanceFullName));
efcdb2
 
efcdb2
-            if (CMS.debugOn()) {
efcdb2
-                CMS.debug("SelfTestSubsystem::runSelfTestsAtStartup():"
efcdb2
-                        + "  EXITING.");
efcdb2
+                throw e;
efcdb2
             }
efcdb2
-        } catch (EMissingSelfTestException eAudit1) {
efcdb2
-            // store a message in the signed audit log file
efcdb2
-            auditMessage = CMS.getLogMessage(
efcdb2
-                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
-                        ILogger.SYSTEM_UID,
efcdb2
-                        ILogger.FAILURE);
efcdb2
+        }
efcdb2
 
efcdb2
-            audit(auditMessage);
efcdb2
+        // log that execution of all "critical" startup self tests
efcdb2
+        // has completed "successfully"
efcdb2
+        log(mLogger,
efcdb2
+                CMS.getLogMessage(
efcdb2
+                        "CMSCORE_SELFTESTS_RUN_AT_STARTUP_SUCCEEDED"));
efcdb2
 
efcdb2
-            // rethrow the specific exception to be handled later
efcdb2
-            throw eAudit1;
efcdb2
-        }
efcdb2
     }
efcdb2
 
efcdb2
     public void log(int level, String msg) {
efcdb2
@@ -1831,39 +1765,88 @@ public class SelfTestSubsystem
efcdb2
      *
efcdb2
      * @exception EBaseException base CMS exception
efcdb2
      */
efcdb2
-    public void startup()
efcdb2
-            throws EBaseException {
efcdb2
+    public void startup() throws EBaseException {
efcdb2
+
efcdb2
         // loop through all self test plugin instances
efcdb2
         Enumeration<ISelfTest> instances = mSelfTestInstances.elements();
efcdb2
 
efcdb2
         while (instances.hasMoreElements()) {
efcdb2
             ISelfTest instance = instances.nextElement();
efcdb2
-
efcdb2
             instance.startupSelfTest();
efcdb2
         }
efcdb2
 
efcdb2
-        if (!CMS.isPreOpMode()) {
efcdb2
-            // run all self test plugin instances (designated at startup)
efcdb2
-            Enumeration<SelfTestOrderedInstance> selftests = mStartupOrder.elements();
efcdb2
+        if (CMS.isPreOpMode()) {
efcdb2
+            // do not run selftests in pre-op mode
efcdb2
+            return;
efcdb2
+        }
efcdb2
 
efcdb2
-            if (selftests.hasMoreElements()) {
efcdb2
-                // log that execution of startup self tests has begun
efcdb2
-                log(mLogger,
efcdb2
-                        CMS.getLogMessage(
efcdb2
-                                "CMSCORE_SELFTESTS_RUN_AT_STARTUP"));
efcdb2
+        // run all self test plugin instances (designated at startup)
efcdb2
+        Enumeration<SelfTestOrderedInstance> selftests = mStartupOrder.elements();
efcdb2
 
efcdb2
-                // execute all startup self tests
efcdb2
-                runSelfTestsAtStartup();
efcdb2
+        if (!selftests.hasMoreElements()) {
efcdb2
+            log(mLogger,
efcdb2
+                    CMS.getLogMessage(
efcdb2
+                            "CMSCORE_SELFTESTS_NOT_RUN_AT_STARTUP"));
efcdb2
+            return;
efcdb2
+        }
efcdb2
 
efcdb2
-                // log that execution of all "critical" startup self tests
efcdb2
-                // has completed "successfully"
efcdb2
-                log(mLogger,
efcdb2
-                        CMS.getLogMessage(
efcdb2
-                                "CMSCORE_SELFTESTS_RUN_AT_STARTUP_SUCCEEDED"));
efcdb2
-            } else {
efcdb2
-                log(mLogger,
efcdb2
-                        CMS.getLogMessage(
efcdb2
-                                "CMSCORE_SELFTESTS_NOT_RUN_AT_STARTUP"));
efcdb2
+        // ensure that any low-level exceptions are reported
efcdb2
+        // to the signed audit log and stored as failures
efcdb2
+        try {
efcdb2
+            // execute all startup self tests
efcdb2
+            runSelfTestsAtStartup();
efcdb2
+
efcdb2
+            // store a message in the signed audit log file
efcdb2
+            String auditMessage = CMS.getLogMessage(
efcdb2
+                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
+                        ILogger.SYSTEM_UID,
efcdb2
+                        ILogger.SUCCESS);
efcdb2
+
efcdb2
+            audit(auditMessage);
efcdb2
+
efcdb2
+        } catch (EMissingSelfTestException e) {
efcdb2
+
efcdb2
+            // store a message in the signed audit log file
efcdb2
+            String auditMessage = CMS.getLogMessage(
efcdb2
+                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
+                        ILogger.SYSTEM_UID,
efcdb2
+                        ILogger.FAILURE);
efcdb2
+
efcdb2
+            audit(auditMessage);
efcdb2
+
efcdb2
+            // rethrow the specific exception to be handled later
efcdb2
+            throw e;
efcdb2
+
efcdb2
+        } catch (Exception e) {
efcdb2
+
efcdb2
+            // store a message in the signed audit log file
efcdb2
+            String auditMessage = CMS.getLogMessage(
efcdb2
+                        LOGGING_SIGNED_AUDIT_SELFTESTS_EXECUTION,
efcdb2
+                        ILogger.SYSTEM_UID,
efcdb2
+                        ILogger.FAILURE);
efcdb2
+
efcdb2
+            audit(auditMessage);
efcdb2
+
efcdb2
+            // shutdown the system gracefully
efcdb2
+            CMS.shutdown();
efcdb2
+
efcdb2
+            IConfigStore cs = CMS.getConfigStore();
efcdb2
+            String instanceID = cs.get("instanceId");
efcdb2
+            String subsystemID = cs.get("cs.type").toLowerCase();
efcdb2
+
efcdb2
+            System.out.println("SelfTestSubsystem: Disabling \"" + subsystemID + "\" subsystem due to selftest failure.");
efcdb2
+
efcdb2
+            try {
efcdb2
+                ProcessBuilder pb = new ProcessBuilder("pki-server", "subsystem-disable", "-i", instanceID, subsystemID);
efcdb2
+                Process process = pb.inheritIO().start();
efcdb2
+                int rc = process.waitFor();
efcdb2
+
efcdb2
+                if (rc != 0) {
efcdb2
+                    System.out.println("SelfTestSubsystem: Unable to disable \"" + subsystemID + "\". RC: " + rc);
efcdb2
+                }
efcdb2
+
efcdb2
+            } catch (Exception e2) {
efcdb2
+                e.printStackTrace();
efcdb2
             }
efcdb2
         }
efcdb2
     }
efcdb2
diff --git a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
efcdb2
index 65ac197..665f068 100644
efcdb2
--- a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
efcdb2
+++ b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
efcdb2
@@ -140,48 +140,60 @@ public class TPSPresence extends ASelfTest {
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
+
efcdb2
         TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
efcdb2
         if (tps == null) {
efcdb2
             // log that the TPS is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_PRESENT", getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
         // Retrieve the TPS certificate
efcdb2
-        org.mozilla.jss.crypto.X509Certificate tpsCert = null;
efcdb2
+        org.mozilla.jss.crypto.X509Certificate tpsCert;
efcdb2
         try {
efcdb2
             tpsCert = tps.getSubsystemCert();
efcdb2
+
efcdb2
         } catch (Exception e) {
efcdb2
-            e.printStackTrace();
efcdb2
             // cert does not exist or is not yet configured
efcdb2
             // tpsCert will remain null
efcdb2
+            // log that the TPS is not yet initialized
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_INITIALIZED",
efcdb2
+                    getSelfTestName());
efcdb2
+            mSelfTestSubsystem.log(logger, logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
 
efcdb2
         if (tpsCert == null) {
efcdb2
             // log that the TPS is not yet initialized
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_INITIALIZED",
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_INITIALIZED",
efcdb2
                     getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
         // Retrieve the TPS certificate public key
efcdb2
         PublicKey tpsPubKey = tpsCert.getPublicKey();
efcdb2
         if (tpsPubKey == null) {
efcdb2
             // log that something is seriously wrong with the TPS
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_CORRUPT", getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_CORRUPT",
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
         // log that the TPS is present
efcdb2
-        logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_PRESENT", getSelfTestName());
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_TPS_IS_PRESENT",
efcdb2
+                getSelfTestName());
efcdb2
         mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
efcdb2
index f140d6e..28ac38d 100644
efcdb2
--- a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
efcdb2
+++ b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
efcdb2
@@ -144,54 +144,59 @@ public class TPSValidity extends ASelfTest {
efcdb2
      * 

efcdb2
      *
efcdb2
      * @param logger specifies logging subsystem
efcdb2
-     * @exception ESelfTestException self test exception
efcdb2
+     * @exception Exception self test exception
efcdb2
      */
efcdb2
-    public void runSelfTest(ILogEventListener logger)
efcdb2
-            throws ESelfTestException {
efcdb2
-        String logMessage = null;
efcdb2
-        TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
efcdb2
+    public void runSelfTest(ILogEventListener logger) throws Exception {
efcdb2
 
efcdb2
+        TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
efcdb2
         if (tps == null) {
efcdb2
             // log that the TPS is not installed
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_PRESENT", getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_PRESENT",
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw new Exception(logMessage);
efcdb2
         }
efcdb2
 
efcdb2
         // Retrieve the TPS subsystem certificate
efcdb2
-        X509CertImpl tpsCert = null;
efcdb2
+        X509CertImpl tpsCert;
efcdb2
         try {
efcdb2
             tpsCert = new X509CertImpl(tps.getSubsystemCert().getEncoded());
efcdb2
         } catch (Exception e) {
efcdb2
             // certificate is not present or has not been configured
efcdb2
-            // tpsCert will remain null
efcdb2
-        }
efcdb2
-
efcdb2
-        if (tpsCert == null) {
efcdb2
             // log that the TPS is not yet initialized
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_INITIALIZED",
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_INITIALIZED",
efcdb2
                     getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
 
efcdb2
         // Check the TPS validity period
efcdb2
         try {
efcdb2
             tpsCert.checkValidity();
efcdb2
+
efcdb2
         } catch (CertificateNotYetValidException e) {
efcdb2
             // log that the TPS is not yet valid
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_YET_VALID", getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_NOT_YET_VALID",
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw e;
efcdb2
+
efcdb2
         } catch (CertificateExpiredException e) {
efcdb2
             // log that the TPS is expired
efcdb2
-            logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_EXPIRED", getSelfTestName());
efcdb2
+            String logMessage = CMS.getLogMessage(
efcdb2
+                    "SELFTESTS_TPS_IS_EXPIRED",
efcdb2
+                    getSelfTestName());
efcdb2
             mSelfTestSubsystem.log(logger, logMessage);
efcdb2
-            throw new ESelfTestException(logMessage);
efcdb2
+            throw e;
efcdb2
         }
efcdb2
 
efcdb2
         // log that the TPS is valid
efcdb2
-        logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_VALID", getSelfTestName());
efcdb2
+        String logMessage = CMS.getLogMessage(
efcdb2
+                "SELFTESTS_TPS_IS_VALID",
efcdb2
+                getSelfTestName());
efcdb2
         mSelfTestSubsystem.log(logger, logMessage);
efcdb2
     }
efcdb2
 }
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 9b62371172bbf0868e84e7f1d8d9ab48e5a0afff Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Wed, 24 Jun 2015 16:19:55 -0400
efcdb2
Subject: [PATCH 03/21] Fixed Modutil.is_security_module_registered().
efcdb2
efcdb2
Due to issues with HSM the Modutil.is_security_module_registered()
efcdb2
has been modified to the get the list of all registered modules
efcdb2
and then use it to check if a module is registered.
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/1444
efcdb2
---
efcdb2
 .../python/pki/server/deployment/pkihelper.py      | 90 +++++++++++-----------
efcdb2
 1 file changed, 45 insertions(+), 45 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
efcdb2
index 42ca0d9..5bc4ffa 100644
efcdb2
--- a/base/server/python/pki/server/deployment/pkihelper.py
efcdb2
+++ b/base/server/python/pki/server/deployment/pkihelper.py
efcdb2
@@ -2688,56 +2688,56 @@ class Modutil:
efcdb2
     def __init__(self, deployer):
efcdb2
         self.mdict = deployer.mdict
efcdb2
 
efcdb2
-    def is_security_module_registered(self, path, modulename,
efcdb2
-                                      prefix=None, critical_failure=True):
efcdb2
-        status = False
efcdb2
-        try:
efcdb2
-            # Compose this "modutil" command
efcdb2
-            command = ["modutil"]
efcdb2
-            #   Provide a path to the NSS security databases
efcdb2
-            if path:
efcdb2
-                command.extend(["-dbdir", path])
efcdb2
-            else:
efcdb2
-                config.pki_log.error(
efcdb2
-                    log.PKIHELPER_MODUTIL_MISSING_PATH,
efcdb2
-                    extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-                raise Exception(log.PKIHELPER_MODUTIL_MISSING_PATH)
efcdb2
-            #   Add optional security database prefix
efcdb2
-            if prefix is not None:
efcdb2
-                command.extend(["--dbprefix", prefix])
efcdb2
-            #   Append '-nocertdb' switch
efcdb2
-            command.extend(["-nocertdb"])
efcdb2
-            #   Specify a 'modulename'
efcdb2
-            if modulename:
efcdb2
-                command.extend(["-list", modulename])
efcdb2
-            else:
efcdb2
-                config.pki_log.error(
efcdb2
-                    log.PKIHELPER_MODUTIL_MISSING_MODULENAME,
efcdb2
-                    extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-                raise Exception(log.PKIHELPER_MODUTIL_MISSING_MODULENAME)
efcdb2
-            # Display this "modutil" command
efcdb2
-            config.pki_log.info(
efcdb2
-                log.PKIHELPER_REGISTERED_SECURITY_MODULE_CHECK_1,
efcdb2
-                ' '.join(command),
efcdb2
+    def is_security_module_registered(self, path, modulename, prefix=None):
efcdb2
+
efcdb2
+        if not path:
efcdb2
+            config.pki_log.error(
efcdb2
+                log.PKIHELPER_MODUTIL_MISSING_PATH,
efcdb2
                 extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-            # Execute this "modutil" command
efcdb2
-            subprocess.check_call(command)
efcdb2
-            # 'modulename' is already registered
efcdb2
-            status = True
efcdb2
-            config.pki_log.info(
efcdb2
-                log.PKIHELPER_REGISTERED_SECURITY_MODULE_1, modulename,
efcdb2
+            raise Exception(log.PKIHELPER_MODUTIL_MISSING_PATH)
efcdb2
+
efcdb2
+        if not modulename:
efcdb2
+            config.pki_log.error(
efcdb2
+                log.PKIHELPER_MODUTIL_MISSING_MODULENAME,
efcdb2
                 extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-        except subprocess.CalledProcessError as exc:
efcdb2
-            # 'modulename' is not registered
efcdb2
+            raise Exception(log.PKIHELPER_MODUTIL_MISSING_MODULENAME)
efcdb2
+
efcdb2
+        command = [
efcdb2
+            'modutil',
efcdb2
+            '-list',
efcdb2
+            '-dbdir', path,
efcdb2
+            '-nocertdb']
efcdb2
+
efcdb2
+        if prefix:
efcdb2
+            command.extend(['--dbprefix', prefix])
efcdb2
+
efcdb2
+        config.pki_log.info(
efcdb2
+            log.PKIHELPER_REGISTERED_SECURITY_MODULE_CHECK_1,
efcdb2
+            ' '.join(command),
efcdb2
+            extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
+
efcdb2
+        # execute command
efcdb2
+        p = subprocess.Popen(command, stdout=subprocess.PIPE)
efcdb2
+        output = p.communicate()[0]
efcdb2
+
efcdb2
+        p.wait()
efcdb2
+        # ignore return code due to issues with HSM
efcdb2
+        # https://fedorahosted.org/pki/ticket/1444
efcdb2
+
efcdb2
+        # find modules from lines such as '1. NSS Internal PKCS #11 Module'
efcdb2
+        modules = re.findall(r'^ +\d+\. +(.*)$', output, re.MULTILINE)
efcdb2
+
efcdb2
+        if modulename not in modules:
efcdb2
             config.pki_log.info(
efcdb2
                 log.PKIHELPER_UNREGISTERED_SECURITY_MODULE_1, modulename,
efcdb2
                 extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-        except OSError as exc:
efcdb2
-            config.pki_log.error(log.PKI_OSERROR_1, exc,
efcdb2
-                                 extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
-            if critical_failure:
efcdb2
-                raise
efcdb2
-        return status
efcdb2
+            return False
efcdb2
+
efcdb2
+        config.pki_log.info(
efcdb2
+            log.PKIHELPER_REGISTERED_SECURITY_MODULE_1, modulename,
efcdb2
+            extra=config.PKI_INDENTATION_LEVEL_2)
efcdb2
+        return True
efcdb2
+
efcdb2
 
efcdb2
     def register_security_module(self, path, modulename, libfile,
efcdb2
                                  prefix=None, critical_failure=True):
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From c9180f086971dcf6f183ed5f627510f2183cc61e Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Mon, 29 Jun 2015 15:09:07 -0400
efcdb2
Subject: [PATCH 04/21] Updated pki-cert man page.
efcdb2
efcdb2
The man page for pki-cert has been modified to describe the file
efcdb2
format used to specify the search constraints.
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/995
efcdb2
---
efcdb2
 base/java-tools/man/man1/pki-cert.1 | 67 +++++++++++++++++++++++++++++++++++++
efcdb2
 1 file changed, 67 insertions(+)
efcdb2
efcdb2
diff --git a/base/java-tools/man/man1/pki-cert.1 b/base/java-tools/man/man1/pki-cert.1
efcdb2
index ad2f566..ffa1fea 100644
efcdb2
--- a/base/java-tools/man/man1/pki-cert.1
efcdb2
+++ b/base/java-tools/man/man1/pki-cert.1
efcdb2
@@ -105,6 +105,73 @@ It is also possible to search for and list specific certificates by adding a sea
efcdb2
 
efcdb2
 .B pki ca-cert-find --issuedOnFrom 2012-06-15
efcdb2
 
efcdb2
+To list certificates with search constraints defined in a file:
efcdb2
+
efcdb2
+.B pki ca-cert-find --input <filename>
efcdb2
+
efcdb2
+where the file is in the following format:
efcdb2
+
efcdb2
+.IP
efcdb2
+.nf
efcdb2
+
efcdb2
+<CertSearchRequest>
efcdb2
+
efcdb2
+    <serialNumberRangeInUse>true</serialNumberRangeInUse>
efcdb2
+    <serialFrom></serialFrom>
efcdb2
+    <serialTo></serialTo>
efcdb2
+
efcdb2
+    <subjectInUse>false</subjectInUse>
efcdb2
+    <eMail></eMail>
efcdb2
+    <commonName></commonName>
efcdb2
+    <userID></userID>
efcdb2
+    <orgUnit></orgUnit>
efcdb2
+    <org></org>
efcdb2
+    <locality></locality>
efcdb2
+    <state></state>
efcdb2
+    <country></country>
efcdb2
+
efcdb2
+    <matchExactly>false</matchExactly>
efcdb2
+
efcdb2
+    <status></status>
efcdb2
+
efcdb2
+    <revokedByInUse>false</revokedByInUse>
efcdb2
+    <revokedBy></revokedBy>
efcdb2
+
efcdb2
+    <revokedOnFrom>false</revokedOnFrom>
efcdb2
+    <revokedOnTo></revokedOnTo>
efcdb2
+
efcdb2
+    <revocationReasonInUse>false</revocationReasonInUse>
efcdb2
+    <revocationReason></revocationReason>
efcdb2
+
efcdb2
+    <issuedByInUse>false</issuedByInUse>
efcdb2
+    <issuedBy></issuedBy>
efcdb2
+
efcdb2
+    <issuedOnInUse>false</issuedOnInUse>
efcdb2
+    <issuedOnFrom></issuedOnFrom>
efcdb2
+    <issuedOnTo></issuedOnTo>
efcdb2
+
efcdb2
+    <validNotBeforeInUse>false</validNotBeforeInUse>
efcdb2
+    <validNotBeforeFrom></validNotBeforeFrom>
efcdb2
+    <validNotBeforeTo></validNotBeforeTo>
efcdb2
+
efcdb2
+    <validNotAfterInUse>false</validNotAfterInUse>
efcdb2
+    <validNotAfterFrom></validNotAfterFrom>
efcdb2
+    <validNotAfterTo></validNotAfterTo>
efcdb2
+
efcdb2
+    <validityLengthInUse>false</validityLengthInUse>
efcdb2
+    <validityOperation></validityOperation>
efcdb2
+    <validityCount></validityCount>
efcdb2
+    <validityUnit></validityUnit>
efcdb2
+
efcdb2
+    <certTypeInUse>false</certTypeInUse>
efcdb2
+    <certTypeSubEmailCA></certTypeSubEmailCA>
efcdb2
+    <certTypeSubSSLCA></certTypeSubSSLCA>
efcdb2
+    <certTypeSecureEmail></certTypeSecureEmail>
efcdb2
+
efcdb2
+</CertSearchRequest>
efcdb2
+.fi
efcdb2
+
efcdb2
+.PP
efcdb2
 To view a particular certificate:
efcdb2
 
efcdb2
 .B pki ca-cert-show <certificate ID>
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From b9e461ca8a099b4535aa916886697c6eff01e431 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Mon, 29 Jun 2015 16:04:16 -0400
efcdb2
Subject: [PATCH 05/21] Updated pki man page.
efcdb2
efcdb2
The pki man page has been updated to describe results paging
efcdb2
parameters.
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/1122
efcdb2
---
efcdb2
 base/java-tools/man/man1/pki.1 | 25 +++++++++++++++++++++++++
efcdb2
 1 file changed, 25 insertions(+)
efcdb2
efcdb2
diff --git a/base/java-tools/man/man1/pki.1 b/base/java-tools/man/man1/pki.1
efcdb2
index 9e174e1..41ee3d3 100644
efcdb2
--- a/base/java-tools/man/man1/pki.1
efcdb2
+++ b/base/java-tools/man/man1/pki.1
efcdb2
@@ -220,6 +220,31 @@ Client-side password files generally store a password in an equals-sign-delimite
efcdb2
 .B foobar
efcdb2
    where:  token="internal" (default), password="foobar"
efcdb2
 
efcdb2
+.SS Results Paging
efcdb2
+
efcdb2
+Some commands (e.g. cert-find) may return multiple results. Since the number
efcdb2
+of results may be large, the results are split into multiple pages. By default
efcdb2
+the command will return only the first page (e.g. the first 20 results). To
efcdb2
+retrieve results from another page, additional paging parameters can be
efcdb2
+specified:
efcdb2
+
efcdb2
+.nf
efcdb2
+* start: index of the first result to return (default: 0)
efcdb2
+* size: number of results to return (default: 20)
efcdb2
+.fi
efcdb2
+
efcdb2
+For example, to retrieve the first page (index #0-#19):
efcdb2
+
efcdb2
+.B pki cert-find --start 0 --size 20
efcdb2
+
efcdb2
+To retrieve the second page (index #20-#39):
efcdb2
+
efcdb2
+.B pki cert-find --start 20 --size 20
efcdb2
+
efcdb2
+To retrieve the third page (index #40-#59):
efcdb2
+
efcdb2
+.B pki cert-find --start 40 --size 20
efcdb2
+
efcdb2
 .SH FILES
efcdb2
 .I /usr/bin/pki
efcdb2
 
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From f0637352f12faed2727ee6dcd4661835bf9e2c40 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Mon, 29 Jun 2015 10:00:08 -0400
efcdb2
Subject: [PATCH 06/21] Cleaned up SystemConfigService.validateRequest().
efcdb2
efcdb2
The configure() in SystemConfigService method has been modified to
efcdb2
log only the error message in normal responses but log the full
efcdb2
stack trace when unexpected issues occur.
efcdb2
efcdb2
The validateData() in SystemConfigService has been renamed to
efcdb2
validateRequest() for clarity. The log messages have been modified
efcdb2
to include the invalid values entered in the request.
efcdb2
---
efcdb2
 .../cms/servlet/test/ConfigurationTest.java        |  2 +-
efcdb2
 .../certsrv/system/SystemConfigClient.java         |  2 +-
efcdb2
 .../certsrv/system/SystemConfigResource.java       |  2 +-
efcdb2
 .../dogtagpki/server/rest/SystemConfigService.java | 69 ++++++++++++----------
efcdb2
 4 files changed, 41 insertions(+), 34 deletions(-)
efcdb2
efcdb2
diff --git a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
efcdb2
index bf4dc89..69994fa 100644
efcdb2
--- a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
efcdb2
+++ b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java
efcdb2
@@ -76,7 +76,7 @@ public class ConfigurationTest {
efcdb2
         System.exit(1);
efcdb2
     }
efcdb2
 
efcdb2
-    public static void main(String args[]) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException {
efcdb2
+    public static void main(String args[]) throws Exception {
efcdb2
         String host = null;
efcdb2
         String port = null;
efcdb2
         String cstype = null;
efcdb2
diff --git a/base/common/src/com/netscape/certsrv/system/SystemConfigClient.java b/base/common/src/com/netscape/certsrv/system/SystemConfigClient.java
efcdb2
index 242f005..8208915 100644
efcdb2
--- a/base/common/src/com/netscape/certsrv/system/SystemConfigClient.java
efcdb2
+++ b/base/common/src/com/netscape/certsrv/system/SystemConfigClient.java
efcdb2
@@ -40,7 +40,7 @@ public class SystemConfigClient extends Client {
efcdb2
         configClient = createProxy(SystemConfigResource.class);
efcdb2
     }
efcdb2
 
efcdb2
-    public ConfigurationResponse configure(ConfigurationRequest data) {
efcdb2
+    public ConfigurationResponse configure(ConfigurationRequest data) throws Exception {
efcdb2
         return configClient.configure(data);
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/common/src/com/netscape/certsrv/system/SystemConfigResource.java b/base/common/src/com/netscape/certsrv/system/SystemConfigResource.java
efcdb2
index 0cebb60..9c570eb 100644
efcdb2
--- a/base/common/src/com/netscape/certsrv/system/SystemConfigResource.java
efcdb2
+++ b/base/common/src/com/netscape/certsrv/system/SystemConfigResource.java
efcdb2
@@ -29,5 +29,5 @@ public interface SystemConfigResource {
efcdb2
 
efcdb2
     @POST
efcdb2
     @Path("configure")
efcdb2
-    public ConfigurationResponse configure(ConfigurationRequest data);
efcdb2
+    public ConfigurationResponse configure(ConfigurationRequest data) throws Exception;
efcdb2
 }
efcdb2
diff --git a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
index 2de087b..75e3065 100644
efcdb2
--- a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
@@ -111,28 +111,38 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
      * @see com.netscape.cms.servlet.csadmin.SystemConfigurationResource#configure(com.netscape.cms.servlet.csadmin.data.ConfigurationData)
efcdb2
      */
efcdb2
     @Override
efcdb2
-    public ConfigurationResponse configure(ConfigurationRequest request) {
efcdb2
+    public ConfigurationResponse configure(ConfigurationRequest request) throws Exception {
efcdb2
+
efcdb2
+        CMS.debug("SystemConfigService: configure()");
efcdb2
+
efcdb2
         try {
efcdb2
             ConfigurationResponse response = new ConfigurationResponse();
efcdb2
             configure(request, response);
efcdb2
             return response;
efcdb2
 
efcdb2
-        } catch (Throwable t) {
efcdb2
-            CMS.debug(t);
efcdb2
-            throw t;
efcdb2
+        } catch (PKIException e) { // normal responses
efcdb2
+            CMS.debug(e.getMessage()); // log the response
efcdb2
+            throw e;
efcdb2
+
efcdb2
+        } catch (Exception e) { // unexpected exceptions
efcdb2
+            CMS.debug(e); // show stack trace for troubleshooting
efcdb2
+            throw e;
efcdb2
+
efcdb2
+        } catch (Error e) { // system errors
efcdb2
+            CMS.debug(e); // show stack trace for troubleshooting
efcdb2
+            throw e;
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    public void configure(ConfigurationRequest data, ConfigurationResponse response) {
efcdb2
+    public void configure(ConfigurationRequest data, ConfigurationResponse response) throws Exception {
efcdb2
+
efcdb2
 
efcdb2
         if (csState.equals("1")) {
efcdb2
             throw new BadRequestException("System is already configured");
efcdb2
         }
efcdb2
 
efcdb2
-        CMS.debug("SystemConfigService(): configure() called");
efcdb2
-        CMS.debug(data.toString());
efcdb2
-
efcdb2
-        validateData(data);
efcdb2
+        CMS.debug("SystemConfigService: request: " + data);
efcdb2
+        validateRequest(data);
efcdb2
 
efcdb2
         Collection<String> certList = getCertList(data);
efcdb2
 
efcdb2
@@ -1020,22 +1030,15 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    private void validateData(ConfigurationRequest data) {
efcdb2
-        // get required info from CS.cfg
efcdb2
-        String preopPin;
efcdb2
-        try {
efcdb2
-            preopPin = cs.getString("preop.pin");
efcdb2
-        } catch (Exception e) {
efcdb2
-            CMS.debug("validateData: Failed to get required config form CS.cfg");
efcdb2
-            e.printStackTrace();
efcdb2
-            throw new PKIException("Unable to retrieve required configuration from configuration files");
efcdb2
-        }
efcdb2
+    private void validateRequest(ConfigurationRequest data) throws Exception {
efcdb2
 
efcdb2
-        // get the preop pin and validate it
efcdb2
+        // validate installation pin
efcdb2
         String pin = data.getPin();
efcdb2
         if (pin == null) {
efcdb2
             throw new BadRequestException("No preop pin provided");
efcdb2
         }
efcdb2
+
efcdb2
+        String preopPin = cs.getString("preop.pin");
efcdb2
         if (!preopPin.equals(pin)) {
efcdb2
             throw new BadRequestException("Incorrect pin provided");
efcdb2
         }
efcdb2
@@ -1067,6 +1070,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
             if (data.getSecurityDomainName() == null) {
efcdb2
                 throw new BadRequestException("Security Domain Name is not provided");
efcdb2
             }
efcdb2
+
efcdb2
         } else if (domainType.equals(ConfigurationRequest.EXISTING_DOMAIN) ||
efcdb2
                    domainType.equals(ConfigurationRequest.NEW_SUBDOMAIN)) {
efcdb2
             if (data.getStandAlone()) {
efcdb2
@@ -1079,11 +1083,11 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
             }
efcdb2
 
efcdb2
             try {
efcdb2
-                @SuppressWarnings("unused")
efcdb2
-                URL admin_u = new URL(domainURI);  // check for invalid URL
efcdb2
+                new URL(domainURI);
efcdb2
             } catch (MalformedURLException e) {
efcdb2
-                throw new BadRequestException("Invalid security domain URI");
efcdb2
+                throw new BadRequestException("Invalid security domain URI: " + domainURI, e);
efcdb2
             }
efcdb2
+
efcdb2
             if ((data.getSecurityDomainUser() == null) || (data.getSecurityDomainPassword() == null)) {
efcdb2
                 throw new BadRequestException("Security domain user or password not provided");
efcdb2
             }
efcdb2
@@ -1109,11 +1113,13 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
                 throw new BadRequestException("Clone selected, but no clone URI provided");
efcdb2
             }
efcdb2
             try {
efcdb2
-                @SuppressWarnings("unused")
efcdb2
-                URL url = new URL(cloneUri); // check for invalid URL
efcdb2
+                URL url = new URL(cloneUri);
efcdb2
                 // confirm protocol is https
efcdb2
+                if (!"https".equals(url.getProtocol())) {
efcdb2
+                    throw new BadRequestException("Clone URI must use HTTPS protocol: " + cloneUri);
efcdb2
+                }
efcdb2
             } catch (MalformedURLException e) {
efcdb2
-                throw new BadRequestException("Invalid clone URI");
efcdb2
+                throw new BadRequestException("Invalid clone URI: " + cloneUri, e);
efcdb2
             }
efcdb2
 
efcdb2
             if (data.getToken().equals(ConfigurationRequest.TOKEN_DEFAULT)) {
efcdb2
@@ -1133,6 +1139,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
                     throw new BadRequestException("P12 password should not be provided since HSM clones must share their HSM master's private keys");
efcdb2
                 }
efcdb2
             }
efcdb2
+
efcdb2
         } else {
efcdb2
             data.setClone("false");
efcdb2
         }
efcdb2
@@ -1145,7 +1152,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         try {
efcdb2
             Integer.parseInt(data.getDsPort());  // check for errors
efcdb2
         } catch (NumberFormatException e) {
efcdb2
-            throw new BadRequestException("Internal database port is invalid");
efcdb2
+            throw new BadRequestException("Internal database port is invalid: " + data.getDsPort(), e);
efcdb2
         }
efcdb2
 
efcdb2
         String basedn = data.getBaseDN();
efcdb2
@@ -1173,7 +1180,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
             try {
efcdb2
                 Integer.parseInt(masterReplicationPort); // check for errors
efcdb2
             } catch (NumberFormatException e) {
efcdb2
-                throw new BadRequestException("Master replication port is invalid");
efcdb2
+                throw new BadRequestException("Master replication port is invalid: " + masterReplicationPort, e);
efcdb2
             }
efcdb2
         }
efcdb2
 
efcdb2
@@ -1181,8 +1188,8 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         if (cloneReplicationPort != null && cloneReplicationPort.length() > 0) {
efcdb2
             try {
efcdb2
                 Integer.parseInt(cloneReplicationPort); // check for errors
efcdb2
-            } catch (Exception e) {
efcdb2
-                throw new BadRequestException("Clone replication port is invalid");
efcdb2
+            } catch (NumberFormatException e) {
efcdb2
+                throw new BadRequestException("Clone replication port is invalid: " + cloneReplicationPort, e);
efcdb2
             }
efcdb2
         }
efcdb2
 
efcdb2
@@ -1293,7 +1300,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
             try {
efcdb2
                 Integer.parseInt(data.getAuthdbPort()); // check for errors
efcdb2
             } catch (NumberFormatException e) {
efcdb2
-                throw new BadRequestException("Authdb port is invalid");
efcdb2
+                throw new BadRequestException("Authentication Database port is invalid: " + data.getAuthdbPort(), e);
efcdb2
             }
efcdb2
 
efcdb2
             // TODO check connection with authdb
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 3937d69c1dd5f9ecd7940809b474097d63cb97b3 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Mon, 29 Jun 2015 13:29:41 -0400
efcdb2
Subject: [PATCH 07/21] Cleaned up SystemConfigService.configureClone().
efcdb2
efcdb2
The getCloningData() in SystemConfigService has been renamed to
efcdb2
configureClone(). Redundant try-catch blocks have been removed.
efcdb2
Some exception messages have been modified to include more info.
efcdb2
---
efcdb2
 .../dogtagpki/server/rest/SystemConfigService.java | 72 +++++++---------------
efcdb2
 .../server/tps/rest/TPSInstallerService.java       |  2 +-
efcdb2
 2 files changed, 23 insertions(+), 51 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
index 75e3065..73d24a7 100644
efcdb2
--- a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
@@ -799,7 +799,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    private void getCloningData(ConfigurationRequest data, Collection<String> certList, String token, String domainXML) {
efcdb2
+    private void configureClone(ConfigurationRequest data, Collection<String> certList, String token, String domainXML) throws Exception {
efcdb2
         for (String tag : certList) {
efcdb2
             if (tag.equals("sslserver")) {
efcdb2
                 cs.putBoolean("preop.cert." + tag + ".enable", true);
efcdb2
@@ -809,73 +809,45 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         }
efcdb2
 
efcdb2
         String cloneUri = data.getCloneUri();
efcdb2
-        URL url = null;
efcdb2
-        try {
efcdb2
-            url = new URL(cloneUri);
efcdb2
-        } catch (MalformedURLException e) {
efcdb2
-            // should not reach here as this check is done in validate()
efcdb2
-        }
efcdb2
+        URL url = new URL(cloneUri);
efcdb2
         String masterHost = url.getHost();
efcdb2
         int masterPort = url.getPort();
efcdb2
 
efcdb2
-        // check and store cloneURI information
efcdb2
-        boolean validCloneUri;
efcdb2
-        try {
efcdb2
-            validCloneUri = ConfigurationUtils.isValidCloneURI(domainXML, masterHost, masterPort);
efcdb2
-        } catch (Exception e) {
efcdb2
-            CMS.debug(e);
efcdb2
-            throw new PKIException("Error in determining whether clone URI is valid");
efcdb2
-        }
efcdb2
+        CMS.debug("SystemConfigService: validate clone URI: " + url);
efcdb2
+        boolean validCloneUri = ConfigurationUtils.isValidCloneURI(domainXML, masterHost, masterPort);
efcdb2
 
efcdb2
         if (!validCloneUri) {
efcdb2
             throw new BadRequestException(
efcdb2
-                    "Invalid clone URI provided.  Does not match the available subsystems in the security domain");
efcdb2
+                    "Clone URI does not match available subsystems: " + url);
efcdb2
         }
efcdb2
 
efcdb2
         if (csType.equals("CA")) {
efcdb2
-            try {
efcdb2
-                int masterAdminPort = ConfigurationUtils.getPortFromSecurityDomain(domainXML,
efcdb2
-                        masterHost, masterPort, "CA", "SecurePort", "SecureAdminPort");
efcdb2
-                ConfigurationUtils.importCertChain(masterHost, masterAdminPort, "/ca/admin/ca/getCertChain",
efcdb2
-                        "clone");
efcdb2
-            } catch (Exception e) {
efcdb2
-                CMS.debug(e);
efcdb2
-                throw new PKIException("Failed to import certificate chain from master" + e);
efcdb2
-            }
efcdb2
+            CMS.debug("SystemConfigService: import certificate chain from master");
efcdb2
+            int masterAdminPort = ConfigurationUtils.getPortFromSecurityDomain(domainXML,
efcdb2
+                    masterHost, masterPort, "CA", "SecurePort", "SecureAdminPort");
efcdb2
+            ConfigurationUtils.importCertChain(masterHost, masterAdminPort,
efcdb2
+                    "/ca/admin/ca/getCertChain", "clone");
efcdb2
         }
efcdb2
 
efcdb2
-        try {
efcdb2
-            CMS.debug("SystemConfigService.getCloningData(): get config entries");
efcdb2
-            ConfigurationUtils.getConfigEntriesFromMaster();
efcdb2
-        } catch (Exception e) {
efcdb2
-            CMS.debug(e);
efcdb2
-            throw new PKIException("Failed to obtain configuration entries from the master for cloning " + e);
efcdb2
-        }
efcdb2
+        CMS.debug("SystemConfigService: get configuration entries from master");
efcdb2
+        ConfigurationUtils.getConfigEntriesFromMaster();
efcdb2
 
efcdb2
         if (token.equals(ConfigurationRequest.TOKEN_DEFAULT)) {
efcdb2
-            CMS.debug("SystemConfigService.getCloningData(): restore certs from P12 file");
efcdb2
+            CMS.debug("SystemConfigService: restore certificates from P12 file");
efcdb2
             String p12File = data.getP12File();
efcdb2
             String p12Pass = data.getP12Password();
efcdb2
-            try {
efcdb2
-                ConfigurationUtils.restoreCertsFromP12(p12File, p12Pass);
efcdb2
-            } catch (Exception e) {
efcdb2
-                CMS.debug(e);
efcdb2
-                throw new PKIException("Failed to restore certificates from p12 file" + e);
efcdb2
-            }
efcdb2
+            ConfigurationUtils.restoreCertsFromP12(p12File, p12Pass);
efcdb2
+
efcdb2
         } else {
efcdb2
-            CMS.debug("SystemConfigService.getCloningData(): set permissions for certs stored in hardware");
efcdb2
-            try {
efcdb2
-                ConfigurationUtils.importAndSetCertPermissionsFromHSM();
efcdb2
-            } catch (Exception e) {
efcdb2
-                CMS.debug(e);
efcdb2
-                throw new PKIException("Failed to import certs from HSM and set permissions:" + e);
efcdb2
-            }
efcdb2
+            CMS.debug("SystemConfigService: import certificates from HSM and set permission");
efcdb2
+            ConfigurationUtils.importAndSetCertPermissionsFromHSM();
efcdb2
         }
efcdb2
 
efcdb2
-        CMS.debug("SystemConfigService.getCloningData(): verify certs");
efcdb2
+        CMS.debug("SystemConfigService: verify certificates");
efcdb2
         boolean cloneReady = ConfigurationUtils.isCertdbCloned();
efcdb2
+
efcdb2
         if (!cloneReady) {
efcdb2
-            CMS.debug("clone does not have all the certificates.");
efcdb2
+            CMS.debug("SystemConfigService: clone does not have all the certificates.");
efcdb2
             throw new PKIException("Clone does not have all the required certificates");
efcdb2
         }
efcdb2
     }
efcdb2
@@ -992,7 +964,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
     }
efcdb2
 
efcdb2
     public void configureSubsystem(ConfigurationRequest request,
efcdb2
-            Collection<String> certList, String token, String domainXML) {
efcdb2
+            Collection<String> certList, String token, String domainXML) throws Exception {
efcdb2
 
efcdb2
         cs.putString("preop.subsystem.name", request.getSubsystemName());
efcdb2
 
efcdb2
@@ -1004,7 +976,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         } else {
efcdb2
             cs.putString("preop.subsystem.select", "clone");
efcdb2
             cs.putString("subsystem.select", "Clone");
efcdb2
-            getCloningData(request, certList, token, domainXML);
efcdb2
+            configureClone(request, certList, token, domainXML);
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
efcdb2
index 9c4943b..fe4e124 100644
efcdb2
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
efcdb2
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TPSInstallerService.java
efcdb2
@@ -44,7 +44,7 @@ public class TPSInstallerService extends SystemConfigService  {
efcdb2
 
efcdb2
     @Override
efcdb2
     public void configureSubsystem(ConfigurationRequest request,
efcdb2
-            Collection<String> certList, String token, String domainXML) {
efcdb2
+            Collection<String> certList, String token, String domainXML) throws Exception {
efcdb2
 
efcdb2
         super.configureSubsystem(request, certList, token, domainXML);
efcdb2
 
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 7c1af7f7dac89363c7923802ec759ccb84813bfb Mon Sep 17 00:00:00 2001
efcdb2
From: Christina Fu <cfu@redhat.com>
efcdb2
Date: Mon, 29 Jun 2015 15:34:01 -0700
efcdb2
Subject: [PATCH 08/21] Ticket 1438 pkispawn: SSL_ForceHandshake issue for
efcdb2
 non-CA on HSM on both shared and nonshared tomcat instances
efcdb2
efcdb2
---
efcdb2
 .../python/pki/server/deployment/pkiparser.py      | 107 ++++++++++++++-------
efcdb2
 1 file changed, 72 insertions(+), 35 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
efcdb2
index 7e1813c..4b3dabb 100644
efcdb2
--- a/base/server/python/pki/server/deployment/pkiparser.py
efcdb2
+++ b/base/server/python/pki/server/deployment/pkiparser.py
efcdb2
@@ -921,41 +921,78 @@ class PKIConfigParser:
efcdb2
                 "tls1_0:tls1_2"
efcdb2
             self.mdict['TOMCAT_SSL_VERSION_RANGE_DATAGRAM_SLOT'] = \
efcdb2
                 "tls1_1:tls1_2"
efcdb2
-            self.mdict['TOMCAT_SSL_RANGE_CIPHERS_SLOT'] = \
efcdb2
-                "-TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "-TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_ECDH_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "+TLS_ECDH_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "-TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "+TLS_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "-TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "-TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_DSS_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_DSS_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
-                "+TLS_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
-                "+TLS_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
-                "+TLS_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_DHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_DHE_DSS_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
-                "+TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
-                "+TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
-                "+TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"
efcdb2
+            if self.mdict['pki_ssl_server_key_type'] == "ecc":
efcdb2
+                self.mdict['TOMCAT_SSL_RANGE_CIPHERS_SLOT'] = \
efcdb2
+                    "+TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDH_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDH_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
+                    "-TLS_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "-TLS_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
+                    "-TLS_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_DHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "+TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "+TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "+TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "+TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"
efcdb2
+            else:
efcdb2
+                self.mdict['TOMCAT_SSL_RANGE_CIPHERS_SLOT'] = \
efcdb2
+                    "-TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDH_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDH_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
+                    "+TLS_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "+TLS_RSA_WITH_AES_256_CBC_SHA256," + \
efcdb2
+                    "+TLS_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "+TLS_DHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_DHE_DSS_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256," + \
efcdb2
+                    "-TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + \
efcdb2
+                    "-TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"
efcdb2
             self.mdict['TOMCAT_SSL2_CIPHERS_SLOT'] = \
efcdb2
                 "-SSL2_RC4_128_WITH_MD5," + \
efcdb2
                 "-SSL2_RC4_128_EXPORT40_WITH_MD5," + \
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From b253cad196f57e79a5aede53aceffede1c9edfbe Mon Sep 17 00:00:00 2001
efcdb2
From: Jack Magne <jmagne@localhost.localdomain>
efcdb2
Date: Wed, 1 Jul 2015 15:01:45 -0700
efcdb2
Subject: [PATCH 09/21] Ability to toggle profile usablity in Web vs CLI tools.
efcdb2
efcdb2
Ticket #1442.
efcdb2
efcdb2
This fix gives the command line enrollment commands the ability to enroll a cert against a profile
efcdb2
that has been marked as not visible but "enabled".
efcdb2
efcdb2
With the simple fix the following scenarios tested to work:
efcdb2
efcdb2
The "caUserCert" Profile was marked as not visible, but enabled.
efcdb2
efcdb2
1. pki -c Secret123 client-cert-request --profile caUserCert uid=jmagne
efcdb2
    This is the simplest form of user cert enrollment.
efcdb2
efcdb2
2. pki ca-cert-request-profile-show caUserCert --output testuser.xml
efcdb2
   pki ca-cert-request-submit testuser.xml
efcdb2
efcdb2
    The first command gives us the profile's xml file, which after modification is used to enroll.
efcdb2
efcdb2
3. pki -d ~/.dogtag/pki -c "" -n "PKI Administrator for localdomain" ca-profile-show caUserCert
efcdb2
efcdb2
    This one shows that we can view the contents of a non visible profile. Listing is not allowed.
efcdb2
    We felt this appropiate to allow a command line user to get the details of a non visible profile that
efcdb2
    they know aobut and want to use.
efcdb2
---
efcdb2
 base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java | 5 ++---
efcdb2
 1 file changed, 2 insertions(+), 3 deletions(-)
efcdb2
efcdb2
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
efcdb2
index 969cfd1..a11cb47 100644
efcdb2
--- a/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
efcdb2
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
efcdb2
@@ -336,9 +336,8 @@ public class CertRequestService extends PKIService implements CertRequestResourc
efcdb2
         }
efcdb2
 
efcdb2
         if (! profile.isVisible()) {
efcdb2
-            CMS.debug("getEnrollmentTemplate(): attempt to get enrollment template for non-visible profile");
efcdb2
-            throw new BadRequestException("Cannot provide enrollment template for profile `" + profileId +
efcdb2
-                        "`.  Profile not marked as visible");
efcdb2
+            CMS.debug("getEnrollmentTemplate(): attempt to get enrollment template for non-visible profile. This is ok since command line enrollments should be able to use enabled but non visible profiles.");
efcdb2
+
efcdb2
         }
efcdb2
 
efcdb2
         CertEnrollmentRequest request = new CertEnrollmentRequest();
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 4af223feb262a707b65d4860f6e8552873306209 Mon Sep 17 00:00:00 2001
efcdb2
From: Matthew Harmsen <mharmsen@pki.usersys.redhat.com>
efcdb2
Date: Thu, 2 Jul 2015 11:09:14 -0600
efcdb2
Subject: [PATCH 12/21] Limited Interactive Installation Support
efcdb2
efcdb2
- PKI TRAC Ticket #1441 - Lack of Interactive Installation Support
efcdb2
  (Cloning, Subordinates, Externals, HSMs, ECC)
efcdb2
---
efcdb2
 .../python/pki/server/deployment/pkimessages.py    | 19 ++++++
efcdb2
 base/server/sbin/pkispawn                          | 70 ++++++++++++----------
efcdb2
 2 files changed, 56 insertions(+), 33 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/python/pki/server/deployment/pkimessages.py b/base/server/python/pki/server/deployment/pkimessages.py
efcdb2
index 6528407..ff3d370 100644
efcdb2
--- a/base/server/python/pki/server/deployment/pkimessages.py
efcdb2
+++ b/base/server/python/pki/server/deployment/pkimessages.py
efcdb2
@@ -146,6 +146,25 @@ REMINDER:
efcdb2
     Finally, if an optional '-p <prefix>' is defined, this value WILL NOT
efcdb2
     be prepended in front of the mandatory '-f <configuration_file>'.
efcdb2
 """ + PKI_VERBOSITY
efcdb2
+PKISPAWN_INTERACTIVE_INSTALLATION='''
efcdb2
+IMPORTANT:
efcdb2
+
efcdb2
+    Interactive installation currently only exists for very basic deployments!
efcdb2
+
efcdb2
+    For example, deployments intent upon using advanced features such as:
efcdb2
+
efcdb2
+        * Cloning,
efcdb2
+        * Elliptic Curve Cryptography (ECC),
efcdb2
+        * External CA,
efcdb2
+        * Hardware Security Module (HSM),
efcdb2
+        * Subordinate CA,
efcdb2
+        * etc.,
efcdb2
+
efcdb2
+    must provide the necessary override parameters in a separate
efcdb2
+    configuration file.
efcdb2
+
efcdb2
+    Run 'man pkispawn' for details.
efcdb2
+'''
efcdb2
 
efcdb2
 
efcdb2
 # PKI Deployment "Helper" Messages
efcdb2
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
efcdb2
index 893a22a..bebbf0b 100755
efcdb2
--- a/base/server/sbin/pkispawn
efcdb2
+++ b/base/server/sbin/pkispawn
efcdb2
@@ -125,8 +125,12 @@ def main(argv):
efcdb2
     parser.validate()
efcdb2
     interactive = False
efcdb2
 
efcdb2
-    while True:
efcdb2
+    if config.user_deployment_cfg is None:
efcdb2
+        interactive = True
efcdb2
+        parser.indent = 0
efcdb2
+        print log.PKISPAWN_INTERACTIVE_INSTALLATION
efcdb2
 
efcdb2
+    while True:
efcdb2
         # -s <subsystem>
efcdb2
         if args.pki_subsystem is None:
efcdb2
             interactive = True
efcdb2
@@ -215,38 +219,38 @@ def main(argv):
efcdb2
                              config.pki_subsystem,
efcdb2
                              'pki_client_admin_cert')
efcdb2
 
efcdb2
-            if parser.mdict['pki_hsm_enable'] == 'True':
efcdb2
-                use_hsm = 'Y'
efcdb2
-            else:
efcdb2
-                use_hsm = 'N'
efcdb2
-
efcdb2
-            use_hsm = parser.read_text(
efcdb2
-                'Using hardware security module (HSM) (Yes/No)',
efcdb2
-                default=use_hsm, options=['Yes', 'Y', 'No', 'N'],
efcdb2
-                sign='?', case_sensitive=False).lower()
efcdb2
-
efcdb2
-            if use_hsm == 'y' or use_hsm == 'yes':
efcdb2
-                # XXX:  Suppress interactive HSM installation
efcdb2
-                print "Interactive HSM installation is currently unsupported."
efcdb2
-                sys.exit(0)
efcdb2
-
efcdb2
-                # TBD:  Interactive HSM installation
efcdb2
-                # parser.set_property(config.pki_subsystem,
efcdb2
-                #                     'pki_hsm_enable',
efcdb2
-                #                     'True')
efcdb2
-                # modulename = parser.read_text(
efcdb2
-                #     'HSM Module Name (e. g. - nethsm)', allow_empty=False)
efcdb2
-                # parser.set_property(config.pki_subsystem,
efcdb2
-                #                     'pki_hsm_modulename',
efcdb2
-                #                     modulename)
efcdb2
-                # libfile = parser.read_text(
efcdb2
-                #     'HSM Lib File ' +
efcdb2
-                #     '(e. g. - /opt/nfast/toolkits/pkcs11/libcknfast.so)',
efcdb2
-                #     allow_empty=False)
efcdb2
-                # parser.set_property(config.pki_subsystem,
efcdb2
-                #                     'pki_hsm_libfile',
efcdb2
-                #                     libfile)
efcdb2
-            print
efcdb2
+            # if parser.mdict['pki_hsm_enable'] == 'True':
efcdb2
+            #     use_hsm = 'Y'
efcdb2
+            # else:
efcdb2
+            #     use_hsm = 'N'
efcdb2
+
efcdb2
+            # use_hsm = parser.read_text(
efcdb2
+            #     'Using hardware security module (HSM) (Yes/No)',
efcdb2
+            #     default=use_hsm, options=['Yes', 'Y', 'No', 'N'],
efcdb2
+            #     sign='?', case_sensitive=False).lower()
efcdb2
+
efcdb2
+            # if use_hsm == 'y' or use_hsm == 'yes':
efcdb2
+            #     # XXX:  Suppress interactive HSM installation
efcdb2
+            #     print "Interactive HSM installation is currently unsupported."
efcdb2
+            #     sys.exit(0)
efcdb2
+
efcdb2
+                  # TBD:  Interactive HSM installation
efcdb2
+                  # parser.set_property(config.pki_subsystem,
efcdb2
+                  #                     'pki_hsm_enable',
efcdb2
+                  #                     'True')
efcdb2
+                  # modulename = parser.read_text(
efcdb2
+                  #     'HSM Module Name (e. g. - nethsm)', allow_empty=False)
efcdb2
+                  # parser.set_property(config.pki_subsystem,
efcdb2
+                  #                     'pki_hsm_modulename',
efcdb2
+                  #                     modulename)
efcdb2
+                  # libfile = parser.read_text(
efcdb2
+                  #     'HSM Lib File ' +
efcdb2
+                  #     '(e. g. - /opt/nfast/toolkits/pkcs11/libcknfast.so)',
efcdb2
+                  #     allow_empty=False)
efcdb2
+                  # parser.set_property(config.pki_subsystem,
efcdb2
+                  #                     'pki_hsm_libfile',
efcdb2
+                  #                     libfile)
efcdb2
+            # print
efcdb2
 
efcdb2
             print "Directory Server:"
efcdb2
             while True:
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From bbd2feaa1f0ca4c338ca490f191184f2bd5c1a41 Mon Sep 17 00:00:00 2001
efcdb2
From: Jack Magne <jmagne@localhost.localdomain>
efcdb2
Date: Tue, 30 Jun 2015 17:22:23 -0700
efcdb2
Subject: [PATCH 13/21] Unable to select ECC Curves from EE fix.
efcdb2
efcdb2
Ticket #1446:
efcdb2
efcdb2
Without the crypto object, the user is now presented with a very bared bones
efcdb2
keygen tag powered UI. ONe can only select a key strength and only use RSA.
efcdb2
efcdb2
This fix adds simple UI to make better use of the keygen tag:
efcdb2
efcdb2
1. Allows the use of ECC.
efcdb2
2. Gives simple info on how the key strengths map to RSA key size and
efcdb2
ECC curves.
efcdb2
efcdb2
When the user selects High, they get RSA 2043, and ECC nistp384.
efcdb2
When the user selects Medium, they get RSA 1024, and ECC nistp256.
efcdb2
---
efcdb2
 .../shared/webapps/ca/ee/ca/ProfileSelect.template | 81 +++++++++++++++++++++-
efcdb2
 1 file changed, 80 insertions(+), 1 deletion(-)
efcdb2
efcdb2
diff --git a/base/ca/shared/webapps/ca/ee/ca/ProfileSelect.template b/base/ca/shared/webapps/ca/ee/ca/ProfileSelect.template
efcdb2
index 0e68e36..5075962 100644
efcdb2
--- a/base/ca/shared/webapps/ca/ee/ca/ProfileSelect.template
efcdb2
+++ b/base/ca/shared/webapps/ca/ee/ca/ProfileSelect.template
efcdb2
@@ -47,6 +47,71 @@ var key = new Object();
efcdb2
 key.type = "EC";
efcdb2
 keyList[1] = key;
efcdb2
 
efcdb2
+function getKeyStrengthTableForKeyGen() {
efcdb2
+
efcdb2
+  document.writeln(" <caption> KeyGen Key Strength Info </caption> ");
Key Type High Grade Medium Grade
efcdb2
+  document.writeln(" RSA   2048   1024  ");
efcdb2
+  document.writeln(" ECC   nistp384   nistp256 ");
efcdb2
+  document.writeln("");
efcdb2
+
efcdb2
+}
efcdb2
+
efcdb2
+function getKeyTypesOptionsForKeyGen() {
efcdb2
+    var keyTypesDef = "RSA";
efcdb2
+    var keyTypes = null;
efcdb2
+    for (var i = 0; i < policySetListSet.length; i++) {
efcdb2
+      for (var j = 0; j < policySetListSet[i].policySet.length; j++) {
efcdb2
+        if (typeof(policySetListSet[i].policySet[j].constraintSet) != "undefined") {
efcdb2
+          for (var k = 0; k < policySetListSet[i].policySet[j].constraintSet.length; k++) {
efcdb2
+            if (policySetListSet[i].policySet[j].constraintSet[k].name == "keyType") {
efcdb2
+              if (policySetListSet[i].policySet[j].constraintSet[k].value == "-") {
efcdb2
+                  keyTypes = "RSA,EC";
efcdb2
+              } else {
efcdb2
+                 keyTypes = policySetListSet[i].policySet[j].constraintSet[k].value;
efcdb2
+              }
efcdb2
+            }
efcdb2
+          }
efcdb2
+        }
efcdb2
+      }
efcdb2
+    }
efcdb2
+
efcdb2
+    if(keyTypes == null) {
efcdb2
+      keyTypes = keyTypesDef;
efcdb2
+    }
efcdb2
+
efcdb2
+    var keyTypesRet = keyTypes.split(",");
efcdb2
+    var options = "";
efcdb2
+    var optionLabel = "";
efcdb2
+    var selected = "";
efcdb2
+    for(types= 0 ; types < keyTypesRet.length ; types ++) {
efcdb2
+      if(keyTypesRet[types] == "EC") {
efcdb2
+        optionLabel = "ECC"; 
efcdb2
+      } else {
efcdb2
+        optionLabel = keyTypesRet[types];
efcdb2
+      }
efcdb2
+
efcdb2
+      if( types == 0 ) {
efcdb2
+          selected = "SELECTED";
efcdb2
+      } else {
efcdb2
+          selected = "";
efcdb2
+      }
efcdb2
+ 
efcdb2
+      options += '<OPTION value=' + '\"' + keyTypesRet[types] + '\" ' + selected + ' > ' + optionLabel + ' </OPTION> ';
efcdb2
+    }
efcdb2
+
efcdb2
+    return options;
efcdb2
+}
efcdb2
+
efcdb2
+function keyGenKeyTypeSelected(keygenObj,keyTypeSelectObj) {
efcdb2
+
efcdb2
+    if(keygenObj == null || keyTypeSelectObj == null)
efcdb2
+        return;
efcdb2
+
efcdb2
+    var selectedValue = keyTypeSelectObj.options[keyTypeSelectObj.selectedIndex].value;
efcdb2
+
efcdb2
+     keygenObj.setAttribute("keytype", selectedValue);
efcdb2
+}
efcdb2
+
efcdb2
 function keyTypeOptions (keyPurpose)
efcdb2
 {
efcdb2
   var keyType = "RSA";
efcdb2
@@ -682,7 +747,21 @@ for (var m = 0; m < inputPluginListSet.length; m++) {
efcdb2
         }
efcdb2
         document.writeln('<input type=hidden name=cert_request value="">');
efcdb2
       } else {
efcdb2
-        document.writeln('<KEYGEN name=' + inputListSet[n].inputId + '>');
efcdb2
+
efcdb2
+        getKeyStrengthTableForKeyGen();
efcdb2
+
efcdb2
+        var keyTypesOptions = getKeyTypesOptionsForKeyGen();
efcdb2
+
efcdb2
+        var keygendata = '<KEYGEN id=\"keygentag\" ' + ' name= ' + '\"' + inputListSet[n].inputId + '\" ' + ' KEYTYPE=\"EC\" KEYPARAMS=\"none\"   > '  ;
efcdb2
+        document.writeln(keygendata);
efcdb2
+
efcdb2
+        var keygenObj = document.getElementById("keygentag");
efcdb2
+        var selectKeyTypeData = '<SELECT id=\"keyTypeSelectedId\" name=\"selectKeyType\"  onChange=\"keyGenKeyTypeSelected(keygenObj,this);\"   > '   + keyTypesOptions + '</SELECT> ' ;
efcdb2
+
efcdb2
+        document.writeln(selectKeyTypeData);
efcdb2
+
efcdb2
+        var selectKeyTypeObject = document.getElementById("keyTypeSelectedId");
efcdb2
+        keyGenKeyTypeSelected(keygenObj,selectKeyTypeObject);
efcdb2
       }
efcdb2
     } else if (inputListSet[n].inputSyntax == 'dual_keygen_request_type') {
efcdb2
       keygen_request = 'true';
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 067cbce6c015a50f4a1747f8894b13c9052c2ed9 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Tue, 30 Jun 2015 22:49:11 -0400
efcdb2
Subject: [PATCH 14/21] Fixed pki help CLI.
efcdb2
efcdb2
A new findModules() method has been added to the CLI class to find
efcdb2
the list of modules handling a command. The list will be used by the
efcdb2
pki help CLI to find the proper man page for the specified command.
efcdb2
---
efcdb2
 .../src/com/netscape/cmstools/cert/CertCLI.java    |  5 ++
efcdb2
 .../src/com/netscape/cmstools/cli/CLI.java         | 72 ++++++++++++++++++++++
efcdb2
 .../src/com/netscape/cmstools/cli/HelpCLI.java     | 27 ++++++--
efcdb2
 .../src/com/netscape/cmstools/cli/MainCLI.java     |  5 ++
efcdb2
 .../com/netscape/cmstools/client/ClientCLI.java    |  5 ++
efcdb2
 .../src/com/netscape/cmstools/group/GroupCLI.java  |  5 ++
efcdb2
 .../netscape/cmstools/group/GroupMemberCLI.java    |  5 ++
efcdb2
 .../src/com/netscape/cmstools/key/KeyCLI.java      |  5 ++
efcdb2
 .../com/netscape/cmstools/logging/AuditCLI.java    |  5 ++
efcdb2
 .../com/netscape/cmstools/profile/ProfileCLI.java  |  5 ++
efcdb2
 .../cmstools/system/SecurityDomainCLI.java         |  5 ++
efcdb2
 .../src/com/netscape/cmstools/user/UserCLI.java    |  5 ++
efcdb2
 .../com/netscape/cmstools/user/UserCertCLI.java    |  5 ++
efcdb2
 13 files changed, 148 insertions(+), 6 deletions(-)
efcdb2
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
efcdb2
index 9ffa3ad..e0924d3 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
efcdb2
@@ -67,6 +67,11 @@ public class CertCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-cert";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
efcdb2
index ed01edc..1338749 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
efcdb2
@@ -21,6 +21,7 @@ package com.netscape.cmstools.cli;
efcdb2
 import java.util.ArrayList;
efcdb2
 import java.util.Collection;
efcdb2
 import java.util.LinkedHashMap;
efcdb2
+import java.util.List;
efcdb2
 import java.util.Map;
efcdb2
 
efcdb2
 import org.apache.commons.cli.CommandLineParser;
efcdb2
@@ -113,6 +114,75 @@ public class CLI {
efcdb2
         return modules.remove(name);
efcdb2
     }
efcdb2
 
efcdb2
+    /**
efcdb2
+     * Find the list of modules that handle the specified command.
efcdb2
+     */
efcdb2
+    public List<CLI> findModules(String command) throws Exception {
efcdb2
+
efcdb2
+        List<CLI> results = new ArrayList<CLI>();
efcdb2
+
efcdb2
+        // split command into list of names:
efcdb2
+        // <names[0]>-<names[1]>-<names[2]>-...-<names[n-1]>
efcdb2
+        String[] names = command.split("-");
efcdb2
+
efcdb2
+        CLI current = this;
efcdb2
+        int i = 0;
efcdb2
+
efcdb2
+        // translate all names into modules starting from the beginning
efcdb2
+        while (i < names.length) {
efcdb2
+
efcdb2
+            String moduleName = null;
efcdb2
+            CLI module = null;
efcdb2
+            int j = i;
efcdb2
+
efcdb2
+            // find module that matches the shortest sequence of names
efcdb2
+            while (j < names.length) {
efcdb2
+
efcdb2
+                // construct module name
efcdb2
+                if (moduleName == null) {
efcdb2
+                    moduleName = names[j];
efcdb2
+                } else {
efcdb2
+                    moduleName = moduleName + "-" + names[j];
efcdb2
+                }
efcdb2
+
efcdb2
+                // find module with name <names[i]>-...-<names[j]>
efcdb2
+                module = current.getModule(moduleName);
efcdb2
+
efcdb2
+                if (module != null) {
efcdb2
+                    // module found, stop
efcdb2
+                    break;
efcdb2
+                }
efcdb2
+
efcdb2
+                // try again with longer sequence
efcdb2
+                j++;
efcdb2
+            }
efcdb2
+
efcdb2
+            if (module == null)
efcdb2
+                throw new Error("Invalid module \"" + moduleName + "\".");
efcdb2
+
efcdb2
+            // module found
efcdb2
+            results.add(module);
efcdb2
+
efcdb2
+            // repeat for the remaining parts
efcdb2
+            current = module;
efcdb2
+            i = j + 1;
efcdb2
+        }
efcdb2
+
efcdb2
+        return results;
efcdb2
+    }
efcdb2
+
efcdb2
+    /**
efcdb2
+     * Find the last module that handles the specified command.
efcdb2
+     */
efcdb2
+    public CLI findModule(String command) throws Exception {
efcdb2
+        List<CLI> modules = findModules(command);
efcdb2
+        return modules.get(modules.size() - 1);
efcdb2
+    }
efcdb2
+
efcdb2
+    public String getManPage() {
efcdb2
+        return null;
efcdb2
+    }
efcdb2
+
efcdb2
     public PKIClient getClient() {
efcdb2
         return client;
efcdb2
     }
efcdb2
@@ -182,6 +252,8 @@ public class CLI {
efcdb2
             System.exit(0);
efcdb2
         }
efcdb2
 
efcdb2
+        // TODO: Rewrite using findModules().
efcdb2
+
efcdb2
         // A command consists of parts joined by dashes: <part 1>-<part 2>-...-<part N>.
efcdb2
         // For example: cert-request-find
efcdb2
         String command = args[0];
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/HelpCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/HelpCLI.java
efcdb2
index 6b2a123..b348ffc 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cli/HelpCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cli/HelpCLI.java
efcdb2
@@ -18,6 +18,8 @@
efcdb2
 
efcdb2
 package com.netscape.cmstools.cli;
efcdb2
 
efcdb2
+import java.util.List;
efcdb2
+
efcdb2
 import org.apache.commons.cli.CommandLine;
efcdb2
 
efcdb2
 /**
efcdb2
@@ -51,19 +53,32 @@ public class HelpCLI extends CLI {
efcdb2
 
efcdb2
         String[] cmdArgs = cmd.getArgs();
efcdb2
 
efcdb2
-        String command;
efcdb2
+        String manPage = null;
efcdb2
         if (cmdArgs.length == 0) {
efcdb2
-            command = "pki";
efcdb2
+            // no command specified, show the pki man page
efcdb2
+            manPage = parent.getManPage();
efcdb2
 
efcdb2
         } else {
efcdb2
-            command = "pki-" + cmdArgs[0];
efcdb2
+            // find all modules handling the specified command
efcdb2
+            List<CLI> modules = parent.findModules(cmdArgs[0]);
efcdb2
+
efcdb2
+            // find the module that has a man page starting from the last one
efcdb2
+            for (int i = modules.size() - 1; i >= 0; i--) {
efcdb2
+                CLI module = modules.get(i);
efcdb2
+                manPage = module.getManPage();
efcdb2
+                if (manPage != null) break;
efcdb2
+            }
efcdb2
+
efcdb2
+            // if no module has a man page, show the pki man page
efcdb2
+            if (manPage == null)
efcdb2
+                manPage = parent.getManPage();
efcdb2
         }
efcdb2
 
efcdb2
         while (true) {
efcdb2
             // display man page for the command
efcdb2
             ProcessBuilder pb = new ProcessBuilder(
efcdb2
                     "/bin/man",
efcdb2
-                    command);
efcdb2
+                    manPage);
efcdb2
 
efcdb2
             pb.inheritIO();
efcdb2
             Process p = pb.start();
efcdb2
@@ -71,10 +86,10 @@ public class HelpCLI extends CLI {
efcdb2
 
efcdb2
             if (rc == 16) {
efcdb2
                 // man page not found, find the parent command
efcdb2
-                int i = command.lastIndexOf('-');
efcdb2
+                int i = manPage.lastIndexOf('-');
efcdb2
                 if (i >= 0) {
efcdb2
                     // parent command exists, try again
efcdb2
-                    command = command.substring(0, i);
efcdb2
+                    manPage = manPage.substring(0, i);
efcdb2
                     continue;
efcdb2
 
efcdb2
                 } else {
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
index 1792922..77245ec 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
@@ -89,6 +89,11 @@ public class MainCLI extends CLI {
efcdb2
         return moduleName;
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki";
efcdb2
+    }
efcdb2
+
efcdb2
     public void printVersion() {
efcdb2
         Package pkg = MainCLI.class.getPackage();
efcdb2
         System.out.println("PKI Command-Line Interface "+pkg.getImplementationVersion());
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
efcdb2
index c9c7152..f09ea74 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCLI.java
efcdb2
@@ -50,6 +50,11 @@ public class ClientCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-client";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
efcdb2
index 973e0ba..ca15130 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
efcdb2
@@ -54,6 +54,11 @@ public class GroupCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-group";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberCLI.java
efcdb2
index e21d817..1df404b 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberCLI.java
efcdb2
@@ -40,6 +40,11 @@ public class GroupMemberCLI extends CLI {
efcdb2
         addModule(new GroupMemberRemoveCLI(this));
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-group-member";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
index fb324be..d83bcf2 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
@@ -65,6 +65,11 @@ public class KeyCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-key";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/AuditCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/AuditCLI.java
efcdb2
index 11e5300..531d920 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/logging/AuditCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/logging/AuditCLI.java
efcdb2
@@ -41,6 +41,11 @@ public class AuditCLI extends CLI {
efcdb2
         addModule(new AuditShowCLI(this));
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-audit";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java
efcdb2
index e9e2159..ecfa753 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java
efcdb2
@@ -51,6 +51,11 @@ public class ProfileCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-ca-profile";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
efcdb2
index b1a3597..0c2ed37 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
efcdb2
@@ -47,6 +47,11 @@ public class SecurityDomainCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-securitydomain";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
efcdb2
index 7a03d33..5382c47 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
efcdb2
@@ -57,6 +57,11 @@ public class UserCLI extends CLI {
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-user";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertCLI.java
efcdb2
index ead915a..d8ea917 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCertCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertCLI.java
efcdb2
@@ -40,6 +40,11 @@ public class UserCertCLI extends CLI {
efcdb2
         addModule(new UserCertRemoveCLI(this));
efcdb2
     }
efcdb2
 
efcdb2
+    @Override
efcdb2
+    public String getManPage() {
efcdb2
+        return "pki-user-cert";
efcdb2
+    }
efcdb2
+
efcdb2
     public void execute(String[] args) throws Exception {
efcdb2
 
efcdb2
         client = parent.getClient();
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 433e1dba905f9d45f9eefcbf39e5b11ddfbfbc94 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Thu, 2 Jul 2015 18:33:48 -0400
efcdb2
Subject: [PATCH 15/21] Fixed NPE in key-archive CLI.
efcdb2
efcdb2
The pki CLI has been modified such that if the security database
efcdb2
location (-d) is not specified, the config.certDatabase will be
efcdb2
initialized with the default value (i.e. ~/.dogtag/nssdb). The
efcdb2
config.certDatabase is needed by the CLI to prepare the client
efcdb2
library for key archival operations.
efcdb2
---
efcdb2
 .../src/com/netscape/cmstools/cli/MainCLI.java      | 21 ++++++++-------------
efcdb2
 .../src/com/netscape/cmstools/key/KeyCLI.java       | 10 ++++++++--
efcdb2
 2 files changed, 16 insertions(+), 15 deletions(-)
efcdb2
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
index 77245ec..4d63d9b 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
efcdb2
@@ -330,9 +330,14 @@ public class MainCLI extends CLI {
efcdb2
             }
efcdb2
         }
efcdb2
 
efcdb2
-        // store security database path
efcdb2
-        if (certDatabase != null)
efcdb2
+        if (certDatabase != null) {
efcdb2
+            // store user-provided security database location
efcdb2
             config.setCertDatabase(new File(certDatabase).getAbsolutePath());
efcdb2
+        } else {
efcdb2
+            // store default security database location
efcdb2
+            config.setCertDatabase(System.getProperty("user.home") +
efcdb2
+                    File.separator + ".dogtag" + File.separator + "nssdb");
efcdb2
+        }
efcdb2
 
efcdb2
         // store token name
efcdb2
         config.setTokenName(tokenName);
efcdb2
@@ -395,17 +400,7 @@ public class MainCLI extends CLI {
efcdb2
         list = cmd.getOptionValue("ignore-cert-status");
efcdb2
         convertCertStatusList(list, ignoredCertStatuses);
efcdb2
 
efcdb2
-        if (config.getCertDatabase() == null) {
efcdb2
-            // Use default client security database
efcdb2
-            this.certDatabase = new File(
efcdb2
-                    System.getProperty("user.home") + File.separator +
efcdb2
-                    ".dogtag" + File.separator + "nssdb");
efcdb2
-
efcdb2
-        } else {
efcdb2
-            // Use existing client security database
efcdb2
-            this.certDatabase = new File(config.getCertDatabase());
efcdb2
-        }
efcdb2
-
efcdb2
+        this.certDatabase = new File(config.getCertDatabase());
efcdb2
         if (verbose) System.out.println("Client security database: "+this.certDatabase.getAbsolutePath());
efcdb2
 
efcdb2
         String messageFormat = cmd.getOptionValue("message-format");
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
index d83bcf2..f242ece 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyCLI.java
efcdb2
@@ -81,14 +81,20 @@ public class KeyCLI extends CLI {
efcdb2
 
efcdb2
         // create new key client
efcdb2
         keyClient = new KeyClient(client, subsystem);
efcdb2
-        if (client.getConfig().getCertDatabase() != null && client.getConfig().getCertPassword() != null) {
efcdb2
+
efcdb2
+        // if security database password is specified,
efcdb2
+        // prepare key client for archival/retrieval
efcdb2
+        if (client.getConfig().getCertPassword() != null) {
efcdb2
+            // create crypto provider for key client
efcdb2
             keyClient.setCrypto(new NSSCryptoProvider(client.getConfig()));
efcdb2
 
efcdb2
-            // Set the transport cert for crypto operations
efcdb2
+            // download transport cert
efcdb2
             systemCertClient = new SystemCertClient(client, subsystem);
efcdb2
             String transportCert = systemCertClient.getTransportCert().getEncoded();
efcdb2
             transportCert = transportCert.substring(CertData.HEADER.length(),
efcdb2
                     transportCert.indexOf(CertData.FOOTER));
efcdb2
+
efcdb2
+            // set transport cert for key client
efcdb2
             keyClient.setTransportCert(transportCert);
efcdb2
         }
efcdb2
 
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From cc8f6468bb9f509d16ed526e42d546aaa2ae9ed3 Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Wed, 1 Jul 2015 14:41:51 -0400
efcdb2
Subject: [PATCH 16/21] Fixed fail-over in HttpConnection.
efcdb2
efcdb2
The HttpConnection class has been modified to support fail-over
efcdb2
and timeout more consistently. The targets are parsed into a list
efcdb2
during initialization. All direct calls to HttpClient.connect()
efcdb2
are replaced with a method that will connect to the first available
efcdb2
target. All connections are now created with a timeout (which by
efcdb2
default is 0).
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/891
efcdb2
---
efcdb2
 base/ca/src/com/netscape/ca/CAService.java         |   5 +-
efcdb2
 .../netscape/cmscore/connector/HttpConnection.java | 214 +++++++++++----------
efcdb2
 .../src/com/netscape/cmsutil/http/HttpClient.java  |  40 ++--
efcdb2
 .../netscape/cmsutil/http/JssSSLSocketFactory.java |  27 ++-
efcdb2
 .../com/netscape/cmsutil/net/ISocketFactory.java   |  10 +-
efcdb2
 5 files changed, 154 insertions(+), 142 deletions(-)
efcdb2
efcdb2
diff --git a/base/ca/src/com/netscape/ca/CAService.java b/base/ca/src/com/netscape/ca/CAService.java
efcdb2
index 6edaf2a..36f0bd5 100644
efcdb2
--- a/base/ca/src/com/netscape/ca/CAService.java
efcdb2
+++ b/base/ca/src/com/netscape/ca/CAService.java
efcdb2
@@ -435,9 +435,8 @@ public class CAService implements ICAService, IService {
efcdb2
             // send request to KRA first
efcdb2
             if (type.equals(IRequest.ENROLLMENT_REQUEST) &&
efcdb2
                     isPKIArchiveOptionPresent(request) && mKRAConnector != null) {
efcdb2
-                if (Debug.ON) {
efcdb2
-                    Debug.trace("*** Sending enrollment request to KRA");
efcdb2
-                }
efcdb2
+
efcdb2
+                CMS.debug("CAService: Sending enrollment request to KRA");
efcdb2
                 boolean sendStatus = mKRAConnector.send(request);
efcdb2
 
efcdb2
                 if (mArchivalRequired == true) {
efcdb2
diff --git a/base/server/cmscore/src/com/netscape/cmscore/connector/HttpConnection.java b/base/server/cmscore/src/com/netscape/cmscore/connector/HttpConnection.java
efcdb2
index c179f4b..c480478 100644
efcdb2
--- a/base/server/cmscore/src/com/netscape/cmscore/connector/HttpConnection.java
efcdb2
+++ b/base/server/cmscore/src/com/netscape/cmscore/connector/HttpConnection.java
efcdb2
@@ -18,7 +18,9 @@
efcdb2
 package com.netscape.cmscore.connector;
efcdb2
 
efcdb2
 import java.io.IOException;
efcdb2
-import java.util.StringTokenizer;
efcdb2
+import java.net.InetSocketAddress;
efcdb2
+import java.util.ArrayList;
efcdb2
+import java.util.List;
efcdb2
 
efcdb2
 import com.netscape.certsrv.apps.CMS;
efcdb2
 import com.netscape.certsrv.base.EBaseException;
efcdb2
@@ -33,50 +35,32 @@ import com.netscape.cmsutil.http.HttpResponse;
efcdb2
 import com.netscape.cmsutil.net.ISocketFactory;
efcdb2
 
efcdb2
 public class HttpConnection implements IHttpConnection {
efcdb2
+
efcdb2
     protected IRemoteAuthority mDest = null;
efcdb2
     protected HttpRequest mHttpreq = new HttpRequest();
efcdb2
     protected IRequestEncoder mReqEncoder = null;
efcdb2
     protected HttpClient mHttpClient = null;
efcdb2
 
efcdb2
-    protected boolean Connect(String host, HttpClient client) {
efcdb2
-        StringTokenizer st = new StringTokenizer(host, " ");
efcdb2
-        while (st.hasMoreTokens()) {
efcdb2
-            String hp = st.nextToken(); // host:port
efcdb2
-            StringTokenizer st1 = new StringTokenizer(hp, ":");
efcdb2
-            try {
efcdb2
-                String h = st1.nextToken();
efcdb2
-                int p = Integer.parseInt(st1.nextToken());
efcdb2
-                client.connect(h, p);
efcdb2
-                return true;
efcdb2
-            } catch (Exception e) {
efcdb2
-                // may want to log the failure
efcdb2
-            }
efcdb2
-            try {
efcdb2
-                Thread.sleep(5000); // 5 seconds
efcdb2
-            } catch (Exception e) {
efcdb2
-            }
efcdb2
+    int timeout = 0;
efcdb2
+    List<InetSocketAddress> targets;
efcdb2
 
efcdb2
-        }
efcdb2
-        return false;
efcdb2
-    }
efcdb2
+    public HttpConnection(IRemoteAuthority dest, ISocketFactory factory,
efcdb2
+            int timeout // seconds
efcdb2
+            ) {
efcdb2
 
efcdb2
-    public void setRequestURI(String uri)
efcdb2
-            throws EBaseException {
efcdb2
-        mHttpreq.setURI(uri);
efcdb2
-    }
efcdb2
+        CMS.debug("HttpConnection: Creating HttpConnection with timeout=" + timeout);
efcdb2
 
efcdb2
-    public String getRequestURI() {
efcdb2
-        return mHttpreq.getURI();
efcdb2
-    }
efcdb2
-
efcdb2
-    public HttpConnection(IRemoteAuthority dest, ISocketFactory factory) {
efcdb2
         mDest = dest;
efcdb2
         mReqEncoder = new HttpRequestEncoder();
efcdb2
         mHttpClient = new HttpClient(factory);
efcdb2
-        if (Debug.ON)
efcdb2
-            Debug.trace("Created HttpClient");
efcdb2
+
efcdb2
+        this.timeout = timeout;
efcdb2
+
efcdb2
+        targets = parseTarget(dest.getHost(), dest.getPort());
efcdb2
+
efcdb2
         try {
efcdb2
             mHttpreq.setMethod("POST");
efcdb2
+
efcdb2
             // in case of multi-uri, uri will be set right before send
efcdb2
             //   by calling setRequestURI(uri)
efcdb2
             if (mDest.getURI() != null)
efcdb2
@@ -89,62 +73,85 @@ public class HttpConnection implements IHttpConnection {
efcdb2
             }
efcdb2
 
efcdb2
             mHttpreq.setHeader("Connection", "Keep-Alive");
efcdb2
-            CMS.debug("HttpConnection: connecting to " + dest.getHost() + ":" + dest.getPort());
efcdb2
-            String host = dest.getHost();
efcdb2
-            // we could have a list of host names in the host parameters
efcdb2
-            // the format is, for example,
efcdb2
-            // "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
efcdb2
-            if (host != null && host.indexOf(' ') != -1) {
efcdb2
-                // try to do client-side failover
efcdb2
-                boolean connected = false;
efcdb2
-                do {
efcdb2
-                    connected = Connect(host, mHttpClient);
efcdb2
-                } while (!connected);
efcdb2
-            } else {
efcdb2
-                mHttpClient.connect(host, dest.getPort());
efcdb2
-            }
efcdb2
-            CMS.debug("HttpConnection: connected to " + dest.getHost() + ":" + dest.getPort());
efcdb2
+
efcdb2
+            connect();
efcdb2
+
efcdb2
         } catch (IOException e) {
efcdb2
             // server's probably down. that's fine. try later.
efcdb2
-            //System.out.println(
efcdb2
-            //"Can't connect to server in connection creation");
efcdb2
+            CMS.debug("HttpConnection: Unable to create connection: " + e);
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    /*
efcdb2
-     * @param op operation to determine the receiving servlet (multi-uri support)
efcdb2
-     */
efcdb2
-    public HttpConnection(IRemoteAuthority dest, ISocketFactory factory, int timeout) {
efcdb2
-        mDest = dest;
efcdb2
-        mReqEncoder = new HttpRequestEncoder();
efcdb2
-        mHttpClient = new HttpClient(factory);
efcdb2
-        CMS.debug("HttpConn:Created HttpConnection: factory " + factory + "client " + mHttpClient);
efcdb2
-        try {
efcdb2
-            mHttpreq.setMethod("POST");
efcdb2
-            // in case of multi-uri, uri will be set right before send
efcdb2
-            //   by calling setRequestURI(op)
efcdb2
-            if (mDest.getURI() != null)
efcdb2
-                mHttpreq.setURI(mDest.getURI());
efcdb2
+    public HttpConnection(IRemoteAuthority dest, ISocketFactory factory) {
efcdb2
+        this(dest, factory, 0);
efcdb2
+    }
efcdb2
 
efcdb2
-            String contentType = dest.getContentType();
efcdb2
-            if (contentType != null) {
efcdb2
-                CMS.debug("HttpConnection: setting Content-Type");
efcdb2
-                mHttpreq.setHeader("Content-Type", contentType );
efcdb2
-            }
efcdb2
+    List<InetSocketAddress> parseTarget(String target, int port) {
efcdb2
 
efcdb2
-            mHttpreq.setHeader("Connection", "Keep-Alive");
efcdb2
-            CMS.debug("HttpConnection: connecting to " + dest.getHost() + ":" + dest.getPort() + " timeout:" + timeout);
efcdb2
-            mHttpClient.connect(dest.getHost(), dest.getPort(), timeout);
efcdb2
-            CMS.debug("HttpConnection: connected to " + dest.getHost() + ":" + dest.getPort() + " timeout:" + timeout);
efcdb2
-        } catch (IOException e) {
efcdb2
-            // server's probably down. that's fine. try later.
efcdb2
-            //System.out.println(
efcdb2
-            //"Can't connect to server in connection creation");
efcdb2
-            CMS.debug("CMSConn:IOException in creating HttpConnection " + e.toString());
efcdb2
+        List<InetSocketAddress> results = new ArrayList<InetSocketAddress>();
efcdb2
+
efcdb2
+        if (target == null || target.indexOf(' ') < 0) {
efcdb2
+            // target is a single hostname
efcdb2
+
efcdb2
+            // add hostname and the global port to the results
efcdb2
+            results.add(new InetSocketAddress(target, port));
efcdb2
+            return results;
efcdb2
+        }
efcdb2
+
efcdb2
+        // target is a list of hostname:port, for example:
efcdb2
+        // "server1.example.com:8443 server2.example.com:8443"
efcdb2
+
efcdb2
+        for (String hostnamePort : target.split(" ")) {
efcdb2
+
efcdb2
+            // parse hostname and port, and ignore the global port
efcdb2
+            String[] parts = hostnamePort.split(":");
efcdb2
+            String hostname = parts[0];
efcdb2
+            port = Integer.parseInt(parts[1]);
efcdb2
+
efcdb2
+            // add hostname and port to the results
efcdb2
+            results.add(new InetSocketAddress(hostname, port));
efcdb2
         }
efcdb2
+
efcdb2
+        return results;
efcdb2
     }
efcdb2
 
efcdb2
-    // Insert end
efcdb2
+    void connect() throws IOException {
efcdb2
+
efcdb2
+        IOException exception = null;
efcdb2
+
efcdb2
+        // try all targets
efcdb2
+        for (InetSocketAddress target : targets) {
efcdb2
+
efcdb2
+            String hostname = target.getHostString();
efcdb2
+            int port = target.getPort();
efcdb2
+
efcdb2
+            try {
efcdb2
+                CMS.debug("HttpConnection: Connecting to " + hostname + ":" + port + " with timeout " + timeout + "s");
efcdb2
+
efcdb2
+                mHttpClient.connect(hostname, port, timeout * 1000);
efcdb2
+
efcdb2
+                CMS.debug("HttpConnection: Connected to " + hostname + ":" + port);
efcdb2
+                return;
efcdb2
+
efcdb2
+            } catch (IOException e) {
efcdb2
+                exception = e;
efcdb2
+                CMS.debug("HttpConnection: Unable to connect to " + hostname + ":" + port + ": " + e);
efcdb2
+                // try the next target immediately
efcdb2
+            }
efcdb2
+        }
efcdb2
+
efcdb2
+        // throw the last exception
efcdb2
+        throw exception;
efcdb2
+    }
efcdb2
+
efcdb2
+    public void setRequestURI(String uri)
efcdb2
+            throws EBaseException {
efcdb2
+        mHttpreq.setURI(uri);
efcdb2
+    }
efcdb2
+
efcdb2
+    public String getRequestURI() {
efcdb2
+        return mHttpreq.getURI();
efcdb2
+    }
efcdb2
     /**
efcdb2
      * sends a request to remote RA/CA, returning the result.
efcdb2
      *
efcdb2
@@ -207,16 +214,17 @@ public class HttpConnection implements IHttpConnection {
efcdb2
             CMS.debug("HttpConnection.send: with String content: null or empty");
efcdb2
             throw new EBaseException("HttpConnection.send: with String content: null or empty");
efcdb2
         }
efcdb2
-        // CMS.debug("HttpConnection.send: with String content: " + content);
efcdb2
+
efcdb2
+        CMS.debug("HttpConnection.send: with String content: " + content);
efcdb2
 
efcdb2
         resp = doSend(content);
efcdb2
         return resp;
efcdb2
     }
efcdb2
 
efcdb2
-    private HttpResponse doSend(String content)
efcdb2
-            throws EBaseException {
efcdb2
+    private HttpResponse doSend(String content) throws EBaseException {
efcdb2
+
efcdb2
         HttpResponse resp = null;
efcdb2
-        boolean reconnect = false;
efcdb2
+        boolean reconnected = false;
efcdb2
 
efcdb2
         if (getRequestURI() == null) {
efcdb2
             throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", "URI not set in HttpRequest"));
efcdb2
@@ -229,18 +237,21 @@ public class HttpConnection implements IHttpConnection {
efcdb2
 
efcdb2
         try {
efcdb2
             if (!mHttpClient.connected()) {
efcdb2
-                mHttpClient.connect(mDest.getHost(), mDest.getPort());
efcdb2
-                CMS.debug("HttpConnection.doSend: reconnected to " + mDest.getHost() + ":" + mDest.getPort());
efcdb2
-                reconnect = true;
efcdb2
+                connect();
efcdb2
+                reconnected = true;
efcdb2
             }
efcdb2
+
efcdb2
         } catch (IOException e) {
efcdb2
+
efcdb2
+            CMS.debug(e);
efcdb2
+
efcdb2
             if (e.getMessage().indexOf("Peer's certificate issuer has been marked as not trusted") != -1) {
efcdb2
                 throw new EBaseException(
efcdb2
                         CMS.getUserMessage(
efcdb2
                                 "CMS_BASE_CONN_FAILED",
efcdb2
                                 "(This local authority cannot connect to the remote authority. The local authority's signing certificate must chain to a CA certificate trusted for client authentication in the certificate database. Use the certificate manager, or command line tool such as certutil to verify that the trust permissions of the local authority's issuer cert have 'CT' setting in the SSL client auth field.)"));
efcdb2
             }
efcdb2
-            CMS.debug("HttpConn:Couldn't reconnect " + e);
efcdb2
+
efcdb2
             throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", "Couldn't reconnect " + e));
efcdb2
         }
efcdb2
 
efcdb2
@@ -249,28 +260,35 @@ public class HttpConnection implements IHttpConnection {
efcdb2
             try {
efcdb2
                 CMS.debug("HttpConnection.doSend: sending request");
efcdb2
                 resp = mHttpClient.send(mHttpreq);
efcdb2
+
efcdb2
             } catch (IOException e) {
efcdb2
-                CMS.debug("HttpConn: mHttpClient.send failed " + e.toString());
efcdb2
-                if (reconnect) {
efcdb2
-                    CMS.debug("HttpConnection.doSend:resend failed again. " + e);
efcdb2
-                    throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", "resend failed again. " + e));
efcdb2
+
efcdb2
+                CMS.debug(e);
efcdb2
+
efcdb2
+                if (reconnected) {
efcdb2
+                    CMS.debug("HttpConnection.doSend: resend failed again.");
efcdb2
+                    throw new EBaseException(
efcdb2
+                            CMS.getUserMessage("CMS_BASE_CONN_FAILED", "resend failed again: " + e), e);
efcdb2
                 }
efcdb2
+
efcdb2
                 try {
efcdb2
                     CMS.debug("HttpConnection.doSend: trying a reconnect ");
efcdb2
-                    mHttpClient.connect(mDest.getHost(), mDest.getPort());
efcdb2
+                    connect();
efcdb2
+
efcdb2
                 } catch (IOException ex) {
efcdb2
                     CMS.debug("HttpConnection.doSend: reconnect for resend failed. " + ex);
efcdb2
-                    throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", "reconnect for resend failed."
efcdb2
-                            + ex));
efcdb2
+                    throw new EBaseException(
efcdb2
+                            CMS.getUserMessage("CMS_BASE_CONN_FAILED", "reconnect for resend failed: " + ex), e);
efcdb2
                 }
efcdb2
-                reconnect = true;
efcdb2
+
efcdb2
+                reconnected = true;
efcdb2
             }
efcdb2
         } //while
efcdb2
 
efcdb2
         // got reply; check status
efcdb2
         String statusStr = resp.getStatusCode();
efcdb2
 
efcdb2
-        CMS.debug("HttpConnection.doSend:server returned status " + statusStr);
efcdb2
+        CMS.debug("HttpConnection.doSend: server returned status " + statusStr);
efcdb2
         int statuscode = -1;
efcdb2
 
efcdb2
         try {
efcdb2
@@ -287,16 +305,18 @@ public class HttpConnection implements IHttpConnection {
efcdb2
                 // XXX what to do here.
efcdb2
                 String msg = "request no good " + statuscode + " " + resp.getReasonPhrase();
efcdb2
 
efcdb2
-                CMS.debug(msg);
efcdb2
+                CMS.debug("HttpConnection: " + msg);
efcdb2
                 throw new EBaseException(CMS.getUserMessage("CMS_BASE_AUTHENTICATE_FAILED", msg));
efcdb2
+
efcdb2
             } else {
efcdb2
                 // XXX what to do here.
efcdb2
-                String msg = "HttpConn:request no good " + statuscode + " " + resp.getReasonPhrase();
efcdb2
+                String msg = "HttpConnection: request no good " + statuscode + " " + resp.getReasonPhrase();
efcdb2
 
efcdb2
                 CMS.debug(msg);
efcdb2
                 throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", msg));
efcdb2
             }
efcdb2
         }
efcdb2
+
efcdb2
         return resp;
efcdb2
     }
efcdb2
 }
efcdb2
diff --git a/base/util/src/com/netscape/cmsutil/http/HttpClient.java b/base/util/src/com/netscape/cmsutil/http/HttpClient.java
efcdb2
index 438c70c..db042a7 100644
efcdb2
--- a/base/util/src/com/netscape/cmsutil/http/HttpClient.java
efcdb2
+++ b/base/util/src/com/netscape/cmsutil/http/HttpClient.java
efcdb2
@@ -59,22 +59,24 @@ public class HttpClient {
efcdb2
         mCertApprovalCallback = certApprovalCallback;
efcdb2
     }
efcdb2
 
efcdb2
-    public void connect(String host, int port)
efcdb2
-            throws IOException {
efcdb2
+    public void connect(String host, int port,
efcdb2
+            int timeout // milliseconds
efcdb2
+            ) throws IOException {
efcdb2
+
efcdb2
         if (mFactory != null) {
efcdb2
             if (mCertApprovalCallback == null) {
efcdb2
-                mSocket = mFactory.makeSocket(host, port);
efcdb2
+                mSocket = mFactory.makeSocket(host, port, timeout);
efcdb2
             } else {
efcdb2
-                mSocket = mFactory.makeSocket(host, port, mCertApprovalCallback, null);
efcdb2
+                mSocket = mFactory.makeSocket(host, port, mCertApprovalCallback, null, timeout);
efcdb2
             }
efcdb2
+
efcdb2
         } else {
efcdb2
             mSocket = new Socket(host, port);
efcdb2
+            mSocket.setSoTimeout(timeout);
efcdb2
         }
efcdb2
 
efcdb2
         if (mSocket == null) {
efcdb2
-            IOException e = new IOException("Couldn't make connection");
efcdb2
-
efcdb2
-            throw e;
efcdb2
+            throw new IOException("Couldn't make connection");
efcdb2
         }
efcdb2
 
efcdb2
         mInputStream = mSocket.getInputStream();
efcdb2
@@ -85,30 +87,10 @@ public class HttpClient {
efcdb2
         mConnected = true;
efcdb2
     }
efcdb2
 
efcdb2
-    // Inserted by beomsuk
efcdb2
-    public void connect(String host, int port, int timeout)
efcdb2
-            throws IOException {
efcdb2
-        if (mFactory != null) {
efcdb2
-            mSocket = mFactory.makeSocket(host, port, timeout);
efcdb2
-        } else {
efcdb2
-            mSocket = new Socket(host, port);
efcdb2
-        }
efcdb2
-
efcdb2
-        if (mSocket == null) {
efcdb2
-            IOException e = new IOException("Couldn't make connection");
efcdb2
-
efcdb2
-            throw e;
efcdb2
-        }
efcdb2
-
efcdb2
-        mInputStream = mSocket.getInputStream();
efcdb2
-        mOutputStream = mSocket.getOutputStream();
efcdb2
-        mInputStreamReader = new InputStreamReader(mInputStream, "UTF8");
efcdb2
-        mBufferedReader = new BufferedReader(mInputStreamReader);
efcdb2
-        mOutputStreamWriter = new OutputStreamWriter(mOutputStream, "UTF8");
efcdb2
-        mConnected = true;
efcdb2
+    public void connect(String host, int port) throws IOException {
efcdb2
+        connect(host, port, 0);
efcdb2
     }
efcdb2
 
efcdb2
-    // Insert end
efcdb2
     public boolean connected() {
efcdb2
         return mConnected;
efcdb2
     }
efcdb2
diff --git a/base/util/src/com/netscape/cmsutil/http/JssSSLSocketFactory.java b/base/util/src/com/netscape/cmsutil/http/JssSSLSocketFactory.java
efcdb2
index 166479d..8c70480 100644
efcdb2
--- a/base/util/src/com/netscape/cmsutil/http/JssSSLSocketFactory.java
efcdb2
+++ b/base/util/src/com/netscape/cmsutil/http/JssSSLSocketFactory.java
efcdb2
@@ -48,13 +48,14 @@ public class JssSSLSocketFactory implements ISocketFactory {
efcdb2
 
efcdb2
     public Socket makeSocket(String host, int port)
efcdb2
             throws IOException, UnknownHostException {
efcdb2
-        return makeSocket(host, port, null, null);
efcdb2
+        return makeSocket(host, port, null, null, 0);
efcdb2
     }
efcdb2
 
efcdb2
     public Socket makeSocket(String host, int port,
efcdb2
             SSLCertificateApprovalCallback certApprovalCallback,
efcdb2
-            SSLClientCertificateSelectionCallback clientCertCallback)
efcdb2
-            throws IOException, UnknownHostException {
efcdb2
+            SSLClientCertificateSelectionCallback clientCertCallback,
efcdb2
+            int timeout // milliseconds
efcdb2
+            ) throws IOException, UnknownHostException {
efcdb2
 
efcdb2
         try {
efcdb2
             /*
efcdb2
@@ -63,6 +64,7 @@ public class JssSSLSocketFactory implements ISocketFactory {
efcdb2
             s = new SSLSocket(host, port, null, 0, certApprovalCallback,
efcdb2
                     clientCertCallback);
efcdb2
             s.setUseClientMode(true);
efcdb2
+            s.setSoTimeout(timeout);
efcdb2
 
efcdb2
             SSLHandshakeCompletedListener listener = null;
efcdb2
 
efcdb2
@@ -79,27 +81,34 @@ public class JssSSLSocketFactory implements ISocketFactory {
efcdb2
                 s.setClientCertNickname(mClientAuthCertNickname);
efcdb2
             }
efcdb2
             s.forceHandshake();
efcdb2
+
efcdb2
         } catch (org.mozilla.jss.crypto.ObjectNotFoundException e) {
efcdb2
-            throw new IOException(e.toString());
efcdb2
+            throw new IOException(e.toString(), e);
efcdb2
+
efcdb2
         } catch (org.mozilla.jss.crypto.TokenException e) {
efcdb2
-            throw new IOException(e.toString());
efcdb2
+            throw new IOException(e.toString(), e);
efcdb2
+
efcdb2
         } catch (UnknownHostException e) {
efcdb2
             throw e;
efcdb2
+
efcdb2
         } catch (IOException e) {
efcdb2
             throw e;
efcdb2
+
efcdb2
         } catch (Exception e) {
efcdb2
-            throw new IOException(e.toString());
efcdb2
+            throw new IOException(e.toString(), e);
efcdb2
         }
efcdb2
+
efcdb2
         return s;
efcdb2
     }
efcdb2
 
efcdb2
-    public Socket makeSocket(String host, int port, int timeout)
efcdb2
-            throws IOException, UnknownHostException {
efcdb2
+    public Socket makeSocket(String host, int port,
efcdb2
+            int timeout // milliseconds
efcdb2
+            ) throws IOException, UnknownHostException {
efcdb2
         Thread t = new ConnectAsync(this, host, port);
efcdb2
 
efcdb2
         t.start();
efcdb2
         try {
efcdb2
-            t.join(1000 * timeout);
efcdb2
+            t.join(timeout);
efcdb2
         } catch (InterruptedException e) {
efcdb2
         }
efcdb2
 
efcdb2
diff --git a/base/util/src/com/netscape/cmsutil/net/ISocketFactory.java b/base/util/src/com/netscape/cmsutil/net/ISocketFactory.java
efcdb2
index 18f6cac..0dd6963 100644
efcdb2
--- a/base/util/src/com/netscape/cmsutil/net/ISocketFactory.java
efcdb2
+++ b/base/util/src/com/netscape/cmsutil/net/ISocketFactory.java
efcdb2
@@ -28,11 +28,13 @@ public interface ISocketFactory {
efcdb2
     Socket makeSocket(String host, int port)
efcdb2
             throws IOException, UnknownHostException;
efcdb2
 
efcdb2
-    Socket makeSocket(String host, int port, int timeout)
efcdb2
-            throws IOException, UnknownHostException;
efcdb2
+    Socket makeSocket(String host, int port,
efcdb2
+            int timeout // milliseconds
efcdb2
+            ) throws IOException, UnknownHostException;
efcdb2
 
efcdb2
     Socket makeSocket(String host, int port,
efcdb2
             SSLCertificateApprovalCallback certApprovalCallback,
efcdb2
-            SSLClientCertificateSelectionCallback clientCertCallback)
efcdb2
-            throws IOException, UnknownHostException;
efcdb2
+            SSLClientCertificateSelectionCallback clientCertCallback,
efcdb2
+            int timeout // milliseconds
efcdb2
+            ) throws IOException, UnknownHostException;
efcdb2
 }
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 6db01bd091ce991322b004cdd74bf7c15c57fe8c Mon Sep 17 00:00:00 2001
efcdb2
From: Christina Fu <cfu@redhat.com>
efcdb2
Date: Tue, 30 Jun 2015 18:46:33 -0700
efcdb2
Subject: [PATCH 17/21] Ticket 1447 pkispawn: findCertByNickname fails to find
efcdb2
 cert in creating shared tomcat subsystems on HSM
efcdb2
efcdb2
---
efcdb2
 .../src/org/dogtagpki/server/rest/SystemConfigService.java | 14 +++++++++-----
efcdb2
 1 file changed, 9 insertions(+), 5 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
index 73d24a7..e7a9960 100644
efcdb2
--- a/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
efcdb2
@@ -345,6 +345,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
                     throw new BadRequestException("No data for '" + tag + "' was found!");
efcdb2
                 }
efcdb2
 
efcdb2
+                String tokenName = certData.getToken() != null ? certData.getToken() : token;
efcdb2
                 if (request.getStandAlone() && request.getStepTwo()) {
efcdb2
                     // Stand-alone PKI (Step 2)
efcdb2
                     if (tag.equals("external_signing")) {
efcdb2
@@ -355,7 +356,6 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
 
efcdb2
                             if (request.getIssuingCA().equals("External CA")) {
efcdb2
                                 String nickname = certData.getNickname() != null ? certData.getNickname() : "caSigningCert External CA";
efcdb2
-                                String tokenName = certData.getToken() != null ? certData.getToken() : token;
efcdb2
                                 Cert cert = new Cert(tokenName, nickname, tag);
efcdb2
                                 ConfigurationUtils.setExternalCACert(b64, csSubsystem, cs, cert);
efcdb2
 
efcdb2
@@ -387,7 +387,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
                     updateConfiguration(request, certData, "subsystem");
efcdb2
 
efcdb2
                     // get parameters needed for cloning
efcdb2
-                    updateCloneConfiguration(certData, "subsystem");
efcdb2
+                    updateCloneConfiguration(certData, "subsystem", tokenName);
efcdb2
                     continue;
efcdb2
                 }
efcdb2
 
efcdb2
@@ -439,7 +439,6 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
                     CMS.debug("configure(): step two selected.  keys will not be generated for '" + tag + "'");
efcdb2
                 }
efcdb2
 
efcdb2
-                String tokenName = certData.getToken() != null ? certData.getToken() : token;
efcdb2
                 Cert cert = new Cert(tokenName, nickname, tag);
efcdb2
                 cert.setDN(dn);
efcdb2
                 cert.setSubsystem(cs.getString("preop.cert." + tag + ".subsystem"));
efcdb2
@@ -529,11 +528,16 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    private void updateCloneConfiguration(SystemCertData cdata, String tag) throws NotInitializedException,
efcdb2
+    private void updateCloneConfiguration(SystemCertData cdata, String tag, String tokenName) throws NotInitializedException,
efcdb2
             ObjectNotFoundException, TokenException {
efcdb2
         // TODO - some of these parameters may only be valid for RSA
efcdb2
         CryptoManager cryptoManager = CryptoManager.getInstance();
efcdb2
-        X509Certificate cert = cryptoManager.findCertByNickname(cdata.getNickname());
efcdb2
+        if (!tokenName.isEmpty())
efcdb2
+            CMS.debug("SystemConfigService:updateCloneConfiguration: tokenName=" + tokenName);
efcdb2
+        else
efcdb2
+            CMS.debug("SystemConfigService:updateCloneConfiguration: tokenName empty; using internal");
efcdb2
+
efcdb2
+        X509Certificate cert = cryptoManager.findCertByNickname(!tokenName.isEmpty()? tokenName + ":" + cdata.getNickname() :  cdata.getNickname());
efcdb2
         PublicKey pubk = cert.getPublicKey();
efcdb2
         byte[] exponent = CryptoUtil.getPublicExponent(pubk);
efcdb2
         byte[] modulus = CryptoUtil.getModulus(pubk);
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From a3773d042de25120803154c96763de55bc0bd7c4 Mon Sep 17 00:00:00 2001
efcdb2
From: Matthew Harmsen <mharmsen@redhat.com>
efcdb2
Date: Mon, 6 Jul 2015 15:09:54 -0600
efcdb2
Subject: [PATCH 18/21] Note on overriding pki_client_dir when using an HSM
efcdb2
efcdb2
- PKI TRAC Ticket #1425 - pkispawn CA with HSM - if the config file has
efcdb2
  pki_client related params the dir is not created and the admin cert p12 file
efcdb2
  is stored nowhere
efcdb2
---
efcdb2
 base/server/man/man5/pki_default.cfg.5 | 3 +++
efcdb2
 1 file changed, 3 insertions(+)
efcdb2
efcdb2
diff --git a/base/server/man/man5/pki_default.cfg.5 b/base/server/man/man5/pki_default.cfg.5
efcdb2
index f3db6a8..2c8dbbd 100644
efcdb2
--- a/base/server/man/man5/pki_default.cfg.5
efcdb2
+++ b/base/server/man/man5/pki_default.cfg.5
efcdb2
@@ -152,6 +152,9 @@ Set to True to back up the subsystem certificates and keys to a PKCS #12 file.
efcdb2
 .B pki_client_dir
efcdb2
 .IP
efcdb2
 This is the location where all client data used during the installation is stored.  At the end of the invocation of \fBpkispawn\fP, the administrative user's certificate and keys are stored in a PKCS #12 file in this location.
efcdb2
+.IP
efcdb2
+\fBNote:\fP
efcdb2
+When using an HSM, it is currently recommended to NOT specify a value for \fBpki_client_dir\fP that is different from the default value.
efcdb2
 .TP
efcdb2
 .B pki_client_database_dir,  pki_client_database_password
efcdb2
 .IP
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From 02c50813a2f5054ad1b6b0a42e919e3ae1472fe0 Mon Sep 17 00:00:00 2001
efcdb2
From: Jack Magne <jmagne@localhost.localdomain>
efcdb2
Date: Mon, 6 Jul 2015 14:05:57 -0700
efcdb2
Subject: [PATCH 19/21] Omit OCSP from clone description.
efcdb2
efcdb2
Ticket #1358.
efcdb2
Also note that OCSP cloning is unsupported as of now.
efcdb2
---
efcdb2
 base/server/man/man8/pkispawn.8 | 8 ++++----
efcdb2
 1 file changed, 4 insertions(+), 4 deletions(-)
efcdb2
efcdb2
diff --git a/base/server/man/man8/pkispawn.8 b/base/server/man/man8/pkispawn.8
efcdb2
index 33c36e3..ef1857d 100644
efcdb2
--- a/base/server/man/man8/pkispawn.8
efcdb2
+++ b/base/server/man/man8/pkispawn.8
efcdb2
@@ -277,10 +277,10 @@ A cloned CA is a CA which uses the same signing, OCSP signing, and audit signing
efcdb2
 .PP
efcdb2
 Before the clone can be generated, the Directory Server must be created that is separate from the master CA's Directory Server.  The example assumes that the master CA and cloned CA are on different machines, and that their Directory Servers are on port 389.  In addition, the master's system certs and keys have been stored in a PKCS #12 file that is copied over to the clone subsystem in the location specified in <path_to_pkcs12_file>.  This file is created when the master CA is installed; it can also be generated using \fBPKCS12Export\fP.  The file needs to be readable by the user the Certificate Server runs as (by default, pkiuser) and be given the SELinux context pki_tomcat_cert_t.
efcdb2
 .PP
efcdb2
-.SS Installing a KRA, OCSP, or TKS clone
efcdb2
+.SS Installing a KRA or TKS clone (OCSP unsupported as of now)
efcdb2
 \x'-1'\fBpkispawn \-s <subsystem> \-f myconfig.txt\fR
efcdb2
 .PP
efcdb2
-where subsystem is KRA, OCSP, or TKS, and \fImyconfig.txt\fP contains the following text:
efcdb2
+where subsystem is KRA or TKS and \fImyconfig.txt\fP contains the following text:
efcdb2
 .IP
efcdb2
 .nf
efcdb2
 [DEFAULT]
efcdb2
@@ -302,9 +302,9 @@ pki_clone_uri=https://<master_kra_host>:<master_kra_https_port>
efcdb2
 pki_issuing_ca=https://<ca_hostname>:<ca_https_port>
efcdb2
 .fi
efcdb2
 .PP
efcdb2
-As with a CA clone, a KRA, OCSP, or TKS clone uses the same certificates and basic configuration as the original subsystem. The configuration points to the original subsystem to copy its configuration. This example also assumes that the CA is on a remote machine and specifies the CA and security domain information. 
efcdb2
+As with a CA clone, a KRA or TKS clone uses the same certificates and basic configuration as the original subsystem. The configuration points to the original subsystem to copy its configuration. This example also assumes that the CA is on a remote machine and specifies the CA and security domain information.
efcdb2
 .PP
efcdb2
-The subsystem section is [KRA], [OCSP], or [TKS].
efcdb2
+The subsystem section is [KRA] or [TKS].
efcdb2
 .SS Installing a subordinate CA
efcdb2
 \x'-1'\fBpkispawn \-s CA \-f myconfig.txt\fR
efcdb2
 .PP
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From c48c52703c374c8e7e65c11fdeee9eeda464290f Mon Sep 17 00:00:00 2001
efcdb2
From: Fraser Tweedale <ftweedal@redhat.com>
efcdb2
Date: Sat, 4 Jul 2015 11:00:29 -0400
efcdb2
Subject: [PATCH 20/21] Verify raw profile config before accepting it
efcdb2
efcdb2
Creating or modifying a profile with bad profile data in the "raw"
efcdb2
format succeeds and saves the bad data.  After restart, the profile
efcdb2
cannot be loaded and attempting to use, modify or delete or recreate
efcdb2
the profile will fail.
efcdb2
efcdb2
Verify raw profile data by instantiating a temporary profile and
efcdb2
attempting to initialise it with the received configuration.
efcdb2
efcdb2
Fixes: https://fedorahosted.org/pki/ticket/1462
efcdb2
---
efcdb2
 .../dogtagpki/server/ca/rest/ProfileService.java   | 43 +++++++++++++++++++++-
efcdb2
 1 file changed, 42 insertions(+), 1 deletion(-)
efcdb2
efcdb2
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
efcdb2
index f7d82b0..a1dba80 100644
efcdb2
--- a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
efcdb2
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
efcdb2
@@ -81,6 +81,7 @@ import com.netscape.cms.servlet.base.PKIService;
efcdb2
 import com.netscape.cms.servlet.profile.PolicyConstraintFactory;
efcdb2
 import com.netscape.cms.servlet.profile.PolicyDefaultFactory;
efcdb2
 import com.netscape.cmscore.base.SimpleProperties;
efcdb2
+import com.netscape.cmscore.base.PropConfigStore;
efcdb2
 
efcdb2
 /**
efcdb2
  * @author alee
efcdb2
@@ -583,8 +584,27 @@ public class ProfileService extends PKIService implements ProfileResource {
efcdb2
             auditParams.put("class_id", classId);
efcdb2
 
efcdb2
             IPluginInfo info = registry.getPluginInfo("profile", classId);
efcdb2
+            String className = info.getClassName();
efcdb2
 
efcdb2
-            profile = ps.createProfile(profileId, classId, info.getClassName());
efcdb2
+            // create temporary profile to verify profile configuration
efcdb2
+            IProfile tempProfile;
efcdb2
+            try {
efcdb2
+                tempProfile = (IProfile) Class.forName(className).newInstance();
efcdb2
+            } catch (Exception e) {
efcdb2
+                throw new PKIException(
efcdb2
+                    "Error instantiating profile class: " + className);
efcdb2
+            }
efcdb2
+            tempProfile.setId(profileId);
efcdb2
+            try {
efcdb2
+                PropConfigStore tempConfig = new PropConfigStore(null);
efcdb2
+                tempConfig.load(new ByteArrayInputStream(data));
efcdb2
+                tempProfile.init(ps, tempConfig);
efcdb2
+            } catch (Exception e) {
efcdb2
+                throw new BadRequestException("Invalid profile data", e);
efcdb2
+            }
efcdb2
+
efcdb2
+            // no error thrown, proceed with profile creation
efcdb2
+            profile = ps.createProfile(profileId, classId, className);
efcdb2
             profile.getConfigStore().commit(false);
efcdb2
             profile.getConfigStore().load(new ByteArrayInputStream(data));
efcdb2
             ps.disableProfile(profileId);
efcdb2
@@ -698,6 +718,27 @@ public class ProfileService extends PKIService implements ProfileResource {
efcdb2
             simpleProperties.store(out, null);
efcdb2
             data = out.toByteArray();  // original data sans profileId, classId
efcdb2
 
efcdb2
+            // create temporary profile to verify profile configuration
efcdb2
+            String classId = ps.getProfileClassId(profileId);
efcdb2
+            String className =
efcdb2
+                registry.getPluginInfo("profile", classId).getClassName();
efcdb2
+            IProfile tempProfile;
efcdb2
+            try {
efcdb2
+                tempProfile = (IProfile) Class.forName(className).newInstance();
efcdb2
+            } catch (Exception e) {
efcdb2
+                throw new PKIException(
efcdb2
+                    "Error instantiating profile class: " + className);
efcdb2
+            }
efcdb2
+            tempProfile.setId(profileId);
efcdb2
+            try {
efcdb2
+                PropConfigStore tempConfig = new PropConfigStore(null);
efcdb2
+                tempConfig.load(new ByteArrayInputStream(data));
efcdb2
+                tempProfile.init(ps, tempConfig);
efcdb2
+            } catch (Exception e) {
efcdb2
+                throw new BadRequestException("Invalid profile data", e);
efcdb2
+            }
efcdb2
+
efcdb2
+            // no error thrown, so commit updated profile config
efcdb2
             profile.getConfigStore().load(new ByteArrayInputStream(data));
efcdb2
             ps.disableProfile(profileId);
efcdb2
             profile.getConfigStore().commit(false);
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2
efcdb2
efcdb2
From ac5447a8e0bac5112882be700a17a9274e322adc Mon Sep 17 00:00:00 2001
efcdb2
From: "Endi S. Dewata" <edewata@redhat.com>
efcdb2
Date: Mon, 6 Jul 2015 13:31:22 -0400
efcdb2
Subject: [PATCH 21/21] Fixed default cert-find filter.
efcdb2
efcdb2
To improve the performance the default LDAP filter generated by
efcdb2
cert-find has been changed to (certStatus=*) to match an existing
efcdb2
VLV index.
efcdb2
efcdb2
https://fedorahosted.org/pki/ticket/1449
efcdb2
---
efcdb2
 .../org/dogtagpki/server/ca/rest/CertService.java  |  16 +-
efcdb2
 .../com/netscape/cmstools/cert/CertFindCLI.java    |   1 -
efcdb2
 .../netscape/cms/servlet/cert/FilterBuilder.java   | 248 +++++++++++----------
efcdb2
 3 files changed, 136 insertions(+), 129 deletions(-)
efcdb2
efcdb2
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
efcdb2
index ee974d4..e43909b 100644
efcdb2
--- a/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
efcdb2
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
efcdb2
@@ -367,15 +367,13 @@ public class CertService extends PKIService implements CertResource {
efcdb2
     }
efcdb2
 
efcdb2
     private String createSearchFilter(String status) {
efcdb2
-        String filter = "";
efcdb2
+        String filter;
efcdb2
 
efcdb2
-        if ((status == null)) {
efcdb2
-            filter = "(serialno=*)";
efcdb2
-            return filter;
efcdb2
-        }
efcdb2
+        if (status == null) {
efcdb2
+            filter = "(certstatus=*)"; // allCerts VLV
efcdb2
 
efcdb2
-        if (status != null) {
efcdb2
-            filter += "(certStatus=" + LDAPUtil.escapeFilter(status) + ")";
efcdb2
+        } else  {
efcdb2
+            filter = "(certStatus=" + LDAPUtil.escapeFilter(status) + ")";
efcdb2
         }
efcdb2
 
efcdb2
         return filter;
efcdb2
@@ -398,7 +396,7 @@ public class CertService extends PKIService implements CertResource {
efcdb2
         size       = size == null ? DEFAULT_SIZE : size;
efcdb2
 
efcdb2
         String filter = createSearchFilter(status);
efcdb2
-        CMS.debug("listCerts: filter is " + filter);
efcdb2
+        CMS.debug("CertService.listCerts: filter: " + filter);
efcdb2
 
efcdb2
         CertDataInfos infos = new CertDataInfos();
efcdb2
         try {
efcdb2
@@ -450,7 +448,9 @@ public class CertService extends PKIService implements CertResource {
efcdb2
 
efcdb2
         start = start == null ? 0 : start;
efcdb2
         size = size == null ? DEFAULT_SIZE : size;
efcdb2
+
efcdb2
         String filter = createSearchFilter(data);
efcdb2
+        CMS.debug("CertService.searchCerts: filter: " + filter);
efcdb2
 
efcdb2
         CertDataInfos infos = new CertDataInfos();
efcdb2
         try {
efcdb2
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
efcdb2
index 8c7a4df..cb2d80e 100644
efcdb2
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
efcdb2
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
efcdb2
@@ -254,7 +254,6 @@ public class CertFindCLI extends CLI {
efcdb2
 
efcdb2
         } else {
efcdb2
             searchData = new CertSearchRequest();
efcdb2
-            searchData.setSerialNumberRangeInUse(true);
efcdb2
         }
efcdb2
 
efcdb2
         String s = cmd.getOptionValue("start");
efcdb2
diff --git a/base/server/cms/src/com/netscape/cms/servlet/cert/FilterBuilder.java b/base/server/cms/src/com/netscape/cms/servlet/cert/FilterBuilder.java
efcdb2
index 5c337af..be44c47 100644
efcdb2
--- a/base/server/cms/src/com/netscape/cms/servlet/cert/FilterBuilder.java
efcdb2
+++ b/base/server/cms/src/com/netscape/cms/servlet/cert/FilterBuilder.java
efcdb2
@@ -18,7 +18,9 @@
efcdb2
 
efcdb2
 package com.netscape.cms.servlet.cert;
efcdb2
 
efcdb2
+import java.util.ArrayList;
efcdb2
 import java.util.Calendar;
efcdb2
+import java.util.List;
efcdb2
 import java.util.StringTokenizer;
efcdb2
 
efcdb2
 import com.netscape.certsrv.cert.CertSearchRequest;
efcdb2
@@ -30,210 +32,214 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
efcdb2
  *
efcdb2
  */
efcdb2
 public class FilterBuilder {
efcdb2
-    private final static String MATCH_EXACTLY = "exact";
efcdb2
-    private String searchFilter = null;
efcdb2
-    private CertSearchRequest request = null;
efcdb2
+
efcdb2
+    private List<String> filters = new ArrayList<String>();
efcdb2
+    private CertSearchRequest request;
efcdb2
 
efcdb2
     public FilterBuilder(CertSearchRequest request) {
efcdb2
         this.request = request;
efcdb2
     }
efcdb2
 
efcdb2
     public String buildFilter() {
efcdb2
-        StringBuffer filter = new StringBuffer();
efcdb2
-        buildSerialNumberRangeFilter(filter);
efcdb2
-        buildSubjectFilter(filter);
efcdb2
-        buildStatusFilter(filter);
efcdb2
-        buildRevokedByFilter(filter);
efcdb2
-        buildRevokedOnFilter(filter);
efcdb2
-        buildRevocationReasonFilter(filter);
efcdb2
-        buildIssuedByFilter(filter);
efcdb2
-        buildIssuedOnFilter(filter);
efcdb2
-        buildValidNotBeforeFilter(filter);
efcdb2
-        buildValidNotAfterFilter(filter);
efcdb2
-        buildValidityLengthFilter(filter);
efcdb2
-        buildCertTypeFilter(filter);
efcdb2
-
efcdb2
-        searchFilter = filter.toString();
efcdb2
-
efcdb2
-        if (searchFilter != null && !searchFilter.equals("")) {
efcdb2
-            searchFilter = "(&" + searchFilter + ")";
efcdb2
-        }
efcdb2
 
efcdb2
-        return searchFilter;
efcdb2
+        buildSerialNumberRangeFilter();
efcdb2
+        buildSubjectFilter();
efcdb2
+        buildStatusFilter();
efcdb2
+        buildRevokedByFilter();
efcdb2
+        buildRevokedOnFilter();
efcdb2
+        buildRevocationReasonFilter();
efcdb2
+        buildIssuedByFilter();
efcdb2
+        buildIssuedOnFilter();
efcdb2
+        buildValidNotBeforeFilter();
efcdb2
+        buildValidNotAfterFilter();
efcdb2
+        buildValidityLengthFilter();
efcdb2
+        buildCertTypeFilter();
efcdb2
+
efcdb2
+        if (filters.size() == 0) {
efcdb2
+            return "(certstatus=*)"; // allCerts VLV
efcdb2
+
efcdb2
+        } else if (filters.size() == 1) {
efcdb2
+            return filters.get(0);
efcdb2
+
efcdb2
+        } else {
efcdb2
+            StringBuilder sb = new StringBuilder();
efcdb2
+            for (String filter : filters) {
efcdb2
+                sb.append(filter);
efcdb2
+            }
efcdb2
+            return "(&" + sb + ")";
efcdb2
+        }
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildSerialNumberRangeFilter(StringBuffer filter) {
efcdb2
+    private void buildSerialNumberRangeFilter() {
efcdb2
 
efcdb2
-        if (!request.getSerialNumberRangeInUse()) {
efcdb2
-            return;
efcdb2
-        }
efcdb2
-        boolean changed = false;
efcdb2
         String serialFrom = request.getSerialFrom();
efcdb2
         if (serialFrom != null && !serialFrom.equals("")) {
efcdb2
-            filter.append("(certRecordId>=" + LDAPUtil.escapeFilter(serialFrom) + ")");
efcdb2
-            changed = true;
efcdb2
+            filters.add("(certRecordId>=" + LDAPUtil.escapeFilter(serialFrom) + ")");
efcdb2
         }
efcdb2
+
efcdb2
         String serialTo = request.getSerialTo();
efcdb2
         if (serialTo != null && !serialTo.equals("")) {
efcdb2
-            filter.append("(certRecordId<=" + LDAPUtil.escapeFilter(serialTo) + ")");
efcdb2
-            changed = true;
efcdb2
+            filters.add("(certRecordId<=" + LDAPUtil.escapeFilter(serialTo) + ")");
efcdb2
         }
efcdb2
-        if (!changed) {
efcdb2
-            filter.append("(certRecordId=*)");
efcdb2
-        }
efcdb2
-
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildSubjectFilter(StringBuffer filter) {
efcdb2
+    private void buildSubjectFilter() {
efcdb2
+
efcdb2
         if (!request.getSubjectInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        StringBuffer lf = new StringBuffer();
efcdb2
 
efcdb2
-        String matchStr = null;
efcdb2
+        StringBuffer lf = new StringBuffer();
efcdb2
         boolean match = request.getMatchExactly();
efcdb2
 
efcdb2
-        if (match == true) {
efcdb2
-            matchStr = MATCH_EXACTLY;
efcdb2
-        }
efcdb2
-
efcdb2
-        buildAVAFilter(request.getEmail(), "E", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getCommonName(), "CN", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getUserID(), "UID", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getOrgUnit(), "OU", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getOrg(), "O", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getLocality(), "L", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getState(), "ST", lf, matchStr);
efcdb2
-        buildAVAFilter(request.getCountry(), "C", lf, matchStr);
efcdb2
+        buildAVAFilter(request.getEmail(), "E", lf, match);
efcdb2
+        buildAVAFilter(request.getCommonName(), "CN", lf, match);
efcdb2
+        buildAVAFilter(request.getUserID(), "UID", lf, match);
efcdb2
+        buildAVAFilter(request.getOrgUnit(), "OU", lf, match);
efcdb2
+        buildAVAFilter(request.getOrg(), "O", lf, match);
efcdb2
+        buildAVAFilter(request.getLocality(), "L", lf, match);
efcdb2
+        buildAVAFilter(request.getState(), "ST", lf, match);
efcdb2
+        buildAVAFilter(request.getCountry(), "C", lf, match);
efcdb2
 
efcdb2
         if (lf.length() == 0) {
efcdb2
-            filter.append("("+ICertRecord.ATTR_X509CERT_SUBJECT+"=*)");
efcdb2
-            return;
efcdb2
-        }
efcdb2
-        if (matchStr != null && matchStr.equals(MATCH_EXACTLY)) {
efcdb2
-            filter.append("(&";;
efcdb2
-            filter.append(lf);
efcdb2
-            filter.append(")");
efcdb2
+            filters.add("(" + ICertRecord.ATTR_X509CERT_SUBJECT + "=*)");
efcdb2
+
efcdb2
+        } else if (match) {
efcdb2
+            filters.add("(&" + lf + ")");
efcdb2
+
efcdb2
         } else {
efcdb2
-            filter.append("(|");
efcdb2
-            filter.append(lf);
efcdb2
-            filter.append(")");
efcdb2
+            filters.add("(|" + lf + ")");
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildStatusFilter(StringBuffer filter) {
efcdb2
+    private void buildStatusFilter() {
efcdb2
+
efcdb2
         String status = request.getStatus();
efcdb2
         if (status == null || status.equals("")) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        filter.append("(certStatus=");
efcdb2
-        filter.append(LDAPUtil.escapeFilter(status));
efcdb2
-        filter.append(")");
efcdb2
+
efcdb2
+        filters.add("(certStatus=" + LDAPUtil.escapeFilter(status) + ")");
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildRevokedByFilter(StringBuffer filter) {
efcdb2
+    private void buildRevokedByFilter() {
efcdb2
+
efcdb2
         if (!request.getRevokedByInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
 
efcdb2
         String revokedBy = request.getRevokedBy();
efcdb2
         if (revokedBy == null || revokedBy.equals("")) {
efcdb2
-            filter.append("(certRevokedBy=*)");
efcdb2
+            filters.add("(certRevokedBy=*)");
efcdb2
+
efcdb2
         } else {
efcdb2
-            filter.append("(certRevokedBy=");
efcdb2
-            filter.append(LDAPUtil.escapeFilter(revokedBy));
efcdb2
-            filter.append(")");
efcdb2
+            filters.add("(certRevokedBy=" + LDAPUtil.escapeFilter(revokedBy) + ")");
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
     private void buildDateFilter(String prefix,
efcdb2
-            String outStr, long adjustment,
efcdb2
-            StringBuffer filter) {
efcdb2
+            String outStr, long adjustment) {
efcdb2
+
efcdb2
         if (prefix == null || prefix.length() == 0) return;
efcdb2
+
efcdb2
         long epoch = Long.parseLong(prefix);
efcdb2
         Calendar from = Calendar.getInstance();
efcdb2
         from.setTimeInMillis(epoch);
efcdb2
+
efcdb2
+        StringBuilder filter = new StringBuilder();
efcdb2
         filter.append("(");
efcdb2
         filter.append(LDAPUtil.escapeFilter(outStr));
efcdb2
         filter.append(Long.toString(from.getTimeInMillis() + adjustment));
efcdb2
         filter.append(")");
efcdb2
+
efcdb2
+        filters.add(filter.toString());
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildRevokedOnFilter(StringBuffer filter) {
efcdb2
+    private void buildRevokedOnFilter() {
efcdb2
+
efcdb2
         if (!request.getRevokedOnInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        buildDateFilter(request.getRevokedOnFrom(), "certRevokedOn>=", 0, filter);
efcdb2
-        buildDateFilter(request.getRevokedOnTo(), "certRevokedOn<=", 86399999, filter);
efcdb2
+
efcdb2
+        buildDateFilter(request.getRevokedOnFrom(), "certRevokedOn>=", 0);
efcdb2
+        buildDateFilter(request.getRevokedOnTo(), "certRevokedOn<=", 86399999);
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildRevocationReasonFilter(StringBuffer filter) {
efcdb2
+    private void buildRevocationReasonFilter() {
efcdb2
+
efcdb2
         if (!request.getRevocationReasonInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
+
efcdb2
         String reasons = request.getRevocationReason();
efcdb2
         if (reasons == null) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        String queryCertFilter = null;
efcdb2
+
efcdb2
+        StringBuilder filter = new StringBuilder();
efcdb2
         StringTokenizer st = new StringTokenizer(reasons, ",");
efcdb2
         int count = st.countTokens();
efcdb2
         if (st.hasMoreTokens()) {
efcdb2
-            if (count >=2) filter.append("(|");
efcdb2
+            if (count >= 2) filter.append("(|");
efcdb2
             while (st.hasMoreTokens()) {
efcdb2
                 String token = st.nextToken();
efcdb2
-                if (queryCertFilter == null) {
efcdb2
-                    queryCertFilter = "";
efcdb2
-                }
efcdb2
                 filter.append("(x509cert.certRevoInfo=");
efcdb2
                 filter.append(LDAPUtil.escapeFilter(token));
efcdb2
                 filter.append(")");
efcdb2
             }
efcdb2
             if (count >= 2) filter.append(")");
efcdb2
         }
efcdb2
+
efcdb2
+        filters.add(filter.toString());
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildIssuedByFilter(StringBuffer filter) {
efcdb2
+    private void buildIssuedByFilter() {
efcdb2
+
efcdb2
         if (!request.getIssuedByInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
+
efcdb2
         String issuedBy = request.getIssuedBy();
efcdb2
         if (issuedBy == null || issuedBy.equals("")) {
efcdb2
-            filter.append("(certIssuedBy=*)");
efcdb2
+            filters.add("(certIssuedBy=*)");
efcdb2
         } else {
efcdb2
-            filter.append("(certIssuedBy=");
efcdb2
-            filter.append(LDAPUtil.escapeFilter(issuedBy));
efcdb2
-            filter.append(")");
efcdb2
+            filters.add("(certIssuedBy=" + LDAPUtil.escapeFilter(issuedBy) + ")");
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildIssuedOnFilter(StringBuffer filter) {
efcdb2
+    private void buildIssuedOnFilter() {
efcdb2
+
efcdb2
         if (!request.getIssuedOnInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        buildDateFilter(request.getIssuedOnFrom(), "certCreateTime>=", 0, filter);
efcdb2
-        buildDateFilter(request.getIssuedOnTo(), "certCreateTime<=", 86399999, filter);
efcdb2
+
efcdb2
+        buildDateFilter(request.getIssuedOnFrom(), "certCreateTime>=", 0);
efcdb2
+        buildDateFilter(request.getIssuedOnTo(), "certCreateTime<=", 86399999);
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildValidNotBeforeFilter(StringBuffer filter) {
efcdb2
+    private void buildValidNotBeforeFilter() {
efcdb2
+
efcdb2
         if (!request.getValidNotBeforeInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        buildDateFilter(request.getValidNotBeforeFrom(), ICertRecord.ATTR_X509CERT_NOT_BEFORE+">=", 0, filter);
efcdb2
-        buildDateFilter(request.getValidNotBeforeTo(), ICertRecord.ATTR_X509CERT_NOT_BEFORE+"<=", 86399999, filter);
efcdb2
+
efcdb2
+        buildDateFilter(request.getValidNotBeforeFrom(), ICertRecord.ATTR_X509CERT_NOT_BEFORE+">=", 0);
efcdb2
+        buildDateFilter(request.getValidNotBeforeTo(), ICertRecord.ATTR_X509CERT_NOT_BEFORE+"<=", 86399999);
efcdb2
 
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildValidNotAfterFilter(StringBuffer filter) {
efcdb2
+    private void buildValidNotAfterFilter() {
efcdb2
+
efcdb2
         if (!request.getValidNotAfterInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
-        buildDateFilter(request.getValidNotAfterFrom(), ICertRecord.ATTR_X509CERT_NOT_AFTER+">=", 0, filter);
efcdb2
-        buildDateFilter(request.getValidNotAfterTo(), ICertRecord.ATTR_X509CERT_NOT_AFTER+"<=", 86399999, filter);
efcdb2
+
efcdb2
+        buildDateFilter(request.getValidNotAfterFrom(), ICertRecord.ATTR_X509CERT_NOT_AFTER+">=", 0);
efcdb2
+        buildDateFilter(request.getValidNotAfterTo(), ICertRecord.ATTR_X509CERT_NOT_AFTER+"<=", 86399999);
efcdb2
 
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildValidityLengthFilter(StringBuffer filter) {
efcdb2
+    private void buildValidityLengthFilter() {
efcdb2
         if (!request.getValidityLengthInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
@@ -242,70 +248,72 @@ public class FilterBuilder {
efcdb2
         Integer count = request.getValidityCount();
efcdb2
         Long unit = request.getValidityUnit();
efcdb2
 
efcdb2
+        StringBuilder filter = new StringBuilder();
efcdb2
         filter.append("(");
efcdb2
         filter.append(ICertRecord.ATTR_X509CERT_DURATION);
efcdb2
         filter.append(LDAPUtil.escapeFilter(op));
efcdb2
         filter.append(count * unit);
efcdb2
         filter.append(")");
efcdb2
+
efcdb2
+        filters.add(filter.toString());
efcdb2
     }
efcdb2
 
efcdb2
-    private void buildCertTypeFilter(StringBuffer filter) {
efcdb2
+    private void buildCertTypeFilter() {
efcdb2
+
efcdb2
         if (!request.getCertTypeInUse()) {
efcdb2
             return;
efcdb2
         }
efcdb2
+
efcdb2
         if (isOn(request.getCertTypeSSLClient())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SSLClient=on)");
efcdb2
+            filters.add("(x509cert.nsExtension.SSLClient=on)");
efcdb2
         } else if (isOff(request.getCertTypeSSLClient())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SSLClient=off)");
efcdb2
+            filters.add("(x509cert.nsExtension.SSLClient=off)");
efcdb2
         }
efcdb2
+
efcdb2
         if (isOn(request.getCertTypeSSLServer())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SSLServer=on)");
efcdb2
+            filters.add("(x509cert.nsExtension.SSLServer=on)");
efcdb2
         } else if (isOff(request.getCertTypeSSLServer())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SSLServer=off)");
efcdb2
+            filters.add("(x509cert.nsExtension.SSLServer=off)");
efcdb2
         }
efcdb2
+
efcdb2
         if (isOn(request.getCertTypeSecureEmail())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SecureEmail=on)");
efcdb2
+            filters.add("(x509cert.nsExtension.SecureEmail=on)");
efcdb2
         } else if (isOff(request.getCertTypeSecureEmail())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SecureEmail=off)");
efcdb2
+            filters.add("(x509cert.nsExtension.SecureEmail=off)");
efcdb2
         }
efcdb2
+
efcdb2
         if (isOn(request.getCertTypeSubSSLCA())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SubordinateSSLCA=on)");
efcdb2
+            filters.add("(x509cert.nsExtension.SubordinateSSLCA=on)");
efcdb2
         } else if (isOff(request.getCertTypeSubSSLCA())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SubordinateSSLCA=off)");
efcdb2
+            filters.add("(x509cert.nsExtension.SubordinateSSLCA=off)");
efcdb2
         }
efcdb2
+
efcdb2
         if (isOn(request.getCertTypeSubEmailCA())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SubordinateEmailCA=on)");
efcdb2
+            filters.add("(x509cert.nsExtension.SubordinateEmailCA=on)");
efcdb2
         } else if (isOff(request.getCertTypeSubEmailCA())) {
efcdb2
-            filter.append("(x509cert.nsExtension.SubordinateEmailCA=off)");
efcdb2
+            filters.add("(x509cert.nsExtension.SubordinateEmailCA=off)");
efcdb2
         }
efcdb2
     }
efcdb2
 
efcdb2
     private boolean isOn(String value) {
efcdb2
-        String inUse = value;
efcdb2
-        if (inUse == null) {
efcdb2
-            return false;
efcdb2
-        }
efcdb2
-        if (inUse.equals("on")) {
efcdb2
+        if (value != null && value.equals("on")) {
efcdb2
             return true;
efcdb2
         }
efcdb2
         return false;
efcdb2
     }
efcdb2
 
efcdb2
     private boolean isOff(String value) {
efcdb2
-        String inUse = value;
efcdb2
-        if (inUse == null) {
efcdb2
-            return false;
efcdb2
-        }
efcdb2
-        if (inUse.equals("off")) {
efcdb2
+        if (value != null && value.equals("off")) {
efcdb2
             return true;
efcdb2
         }
efcdb2
         return false;
efcdb2
     }
efcdb2
 
efcdb2
     private void buildAVAFilter(String param,
efcdb2
-            String avaName, StringBuffer lf, String match) {
efcdb2
+            String avaName, StringBuffer lf, boolean match) {
efcdb2
+
efcdb2
         if (param != null && !param.equals("")) {
efcdb2
-            if (match != null && match.equals(MATCH_EXACTLY)) {
efcdb2
+            if (match) {
efcdb2
                 lf.append("(|");
efcdb2
                 lf.append("("+ICertRecord.ATTR_X509CERT_SUBJECT+"=*");
efcdb2
                 lf.append(avaName);
efcdb2
@@ -318,6 +326,7 @@ public class FilterBuilder {
efcdb2
                 lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeRDNValue(param)));
efcdb2
                 lf.append(")");
efcdb2
                 lf.append(")");
efcdb2
+
efcdb2
             } else {
efcdb2
                 lf.append("("+ICertRecord.ATTR_X509CERT_SUBJECT+"=*");
efcdb2
                 lf.append(avaName);
efcdb2
@@ -327,6 +336,5 @@ public class FilterBuilder {
efcdb2
                 lf.append("*)");
efcdb2
             }
efcdb2
         }
efcdb2
-
efcdb2
     }
efcdb2
 }
efcdb2
-- 
efcdb2
1.8.3.1
efcdb2