summaryrefslogtreecommitdiffstats
path: root/base/tps/src
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-06-23 12:23:15 -0400
committerEndi S. Dewata <edewata@redhat.com>2015-06-23 17:30:18 -0400
commitcc97f8628b23f8ea75308bb97a31307cb4f162b9 (patch)
tree0e8eb0d56294eb7beedf0041f4ba6f8d9f0cf3fd /base/tps/src
parente1e1e1867c3665def4738530d5c36a1f9801fdb9 (diff)
Fixed selftests log message.
The SelfTestSubsystem has been modified to display a 'successful' message only if all tests have passed. If a test fails, it will log a failure, subsequent tests will not be executed, and the subsystem will shutdown immediately. The runSelfTest() in various tests have been cleaned up to throw the original exception to help troubleshooting. The unused RAPresence test has been removed. https://fedorahosted.org/pki/ticket/1249
Diffstat (limited to 'base/tps/src')
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java38
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java43
2 files changed, 49 insertions, 32 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
index 65ac197e7..665f06855 100644
--- a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
+++ b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSPresence.java
@@ -140,48 +140,60 @@ public class TPSPresence extends ASelfTest {
* <P>
*
* @param logger specifies logging subsystem
- * @exception ESelfTestException self test exception
+ * @exception Exception self test exception
*/
- public void runSelfTest(ILogEventListener logger)
- throws ESelfTestException {
- String logMessage = null;
+ public void runSelfTest(ILogEventListener logger) throws Exception {
+
TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
if (tps == null) {
// log that the TPS is not installed
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_PRESENT", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_PRESENT",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw new Exception(logMessage);
}
// Retrieve the TPS certificate
- org.mozilla.jss.crypto.X509Certificate tpsCert = null;
+ org.mozilla.jss.crypto.X509Certificate tpsCert;
try {
tpsCert = tps.getSubsystemCert();
+
} catch (Exception e) {
- e.printStackTrace();
// cert does not exist or is not yet configured
// tpsCert will remain null
+ // log that the TPS is not yet initialized
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_INITIALIZED",
+ getSelfTestName());
+ mSelfTestSubsystem.log(logger, logMessage);
+ throw e;
}
if (tpsCert == null) {
// log that the TPS is not yet initialized
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_INITIALIZED",
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_INITIALIZED",
getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw new Exception(logMessage);
}
// Retrieve the TPS certificate public key
PublicKey tpsPubKey = tpsCert.getPublicKey();
if (tpsPubKey == null) {
// log that something is seriously wrong with the TPS
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_CORRUPT", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_CORRUPT",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw new Exception(logMessage);
}
// log that the TPS is present
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_PRESENT", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_PRESENT",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
}
}
diff --git a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
index f140d6e7c..28ac38da2 100644
--- a/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
+++ b/base/tps/src/org/dogtagpki/server/tps/selftests/TPSValidity.java
@@ -144,54 +144,59 @@ public class TPSValidity extends ASelfTest {
* <P>
*
* @param logger specifies logging subsystem
- * @exception ESelfTestException self test exception
+ * @exception Exception self test exception
*/
- public void runSelfTest(ILogEventListener logger)
- throws ESelfTestException {
- String logMessage = null;
- TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
+ public void runSelfTest(ILogEventListener logger) throws Exception {
+ TPSSubsystem tps = (TPSSubsystem) CMS.getSubsystem(tpsSubId);
if (tps == null) {
// log that the TPS is not installed
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_PRESENT", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_PRESENT",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw new Exception(logMessage);
}
// Retrieve the TPS subsystem certificate
- X509CertImpl tpsCert = null;
+ X509CertImpl tpsCert;
try {
tpsCert = new X509CertImpl(tps.getSubsystemCert().getEncoded());
} catch (Exception e) {
// certificate is not present or has not been configured
- // tpsCert will remain null
- }
-
- if (tpsCert == null) {
// log that the TPS is not yet initialized
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_INITIALIZED",
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_INITIALIZED",
getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw e;
}
// Check the TPS validity period
try {
tpsCert.checkValidity();
+
} catch (CertificateNotYetValidException e) {
// log that the TPS is not yet valid
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_NOT_YET_VALID", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_NOT_YET_VALID",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw e;
+
} catch (CertificateExpiredException e) {
// log that the TPS is expired
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_EXPIRED", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_EXPIRED",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
- throw new ESelfTestException(logMessage);
+ throw e;
}
// log that the TPS is valid
- logMessage = CMS.getLogMessage("SELFTESTS_TPS_IS_VALID", getSelfTestName());
+ String logMessage = CMS.getLogMessage(
+ "SELFTESTS_TPS_IS_VALID",
+ getSelfTestName());
mSelfTestSubsystem.log(logger, logMessage);
}
}