summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/selftests
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/selftests')
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java194
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java279
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java279
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java270
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java297
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java297
-rw-r--r--pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java270
7 files changed, 1886 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java b/pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java
new file mode 100644
index 000000000..afa9ba320
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java
@@ -0,0 +1,194 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests;
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.selftests.*;
+import java.util.*;
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements an individual self test.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public abstract class ASelfTest
+ implements ISelfTest {
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ //////////////////////////
+ // ISelfTest parameters //
+ //////////////////////////
+
+ // parameter information
+ private static final String SELF_TEST_NAME = "ASelfTest";
+
+ // variables associated with this specific object
+ protected ISelfTestSubsystem mSelfTestSubsystem = null;
+ protected String mInstanceName = null;
+ protected IConfigStore mConfig = null;
+ protected String mPrefix = null;
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ ///////////////////////
+ // ISelfTest methods //
+ ///////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest(ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters)
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException {
+ // store individual self test class values for this instance
+ mSelfTestSubsystem = (ISelfTestSubsystem) subsystem;
+
+ // strip preceding/trailing whitespace
+ // from passed-in String parameters
+ if (instanceName != null) {
+ instanceName = instanceName.trim();
+ } else {
+ mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_PARAMETER_WAS_NULL",
+ SELF_TEST_NAME));
+
+ throw new EMissingSelfTestException();
+ }
+
+ // store additional individual self test class values for this instance
+ mInstanceName = instanceName;
+
+ // compose self test plugin parameter property prefix
+ String pluginPath = PROP_PLUGIN + "." + instanceName;
+
+ mConfig = parameters.getSubStore(pluginPath);
+
+ if ((mConfig != null) &&
+ (mConfig.getName() != null) &&
+ (mConfig.getName() != "")) {
+ mPrefix = mConfig.getName().trim();
+ } else {
+ mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_PARAMETER_WAS_NULL",
+ SELF_TEST_NAME));
+
+ throw new EMissingSelfTestException();
+ }
+
+ return;
+ }
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public abstract void startupSelfTest()
+ throws ESelfTestException;
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public abstract void shutdownSelfTest();
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName() {
+ return mInstanceName;
+ }
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore() {
+ return mConfig;
+ }
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public abstract String getSelfTestDescription(Locale locale);
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public abstract void runSelfTest(ILogEventListener logger)
+ throws ESelfTestException;
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java b/pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java
new file mode 100644
index 000000000..5b2bd7c32
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java
@@ -0,0 +1,279 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.ca;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.ca.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.cert.*;
+import java.util.*;
+import netscape.security.x509.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check for CA presence.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class CAPresence
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////////
+ // CAPresence parameters //
+ ///////////////////////////
+
+ // parameter information
+ public static final String PROP_CA_SUB_ID = "CaSubId";
+ private String mCaSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ ////////////////////////
+ // CAPresence methods //
+ ////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mCaSubId = mConfig.getString( PROP_CA_SUB_ID );
+ if( mCaSubId != null ) {
+ mCaSubId = mCaSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_CA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_CA_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_CA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_CA_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_CA_PRESENCE_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ ICertificateAuthority ca = null;
+ X509CertImpl caCert = null;
+ X509Key caPubKey = null;
+
+ ca = ( ICertificateAuthority ) CMS.getSubsystem( mCaSubId );
+
+ if( ca == null ) {
+ // log that the CA is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the CA certificate
+ caCert = ca.getCACert();
+
+ if( caCert == null ) {
+ // log that the CA is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_CA_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the CA certificate public key
+ try {
+ caPubKey = ( X509Key ) caCert.get( X509CertImpl.PUBLIC_KEY );
+
+ if( caPubKey == null ) {
+ // log that something is seriously wrong with the CA
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_CORRUPT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+ } catch( CertificateParsingException e ) {
+ // log that something is seriously wrong with the CA
+ mSelfTestSubsystem.log( logger,
+ e.toString() );
+
+ throw new ESelfTestException( e.toString() );
+ }
+
+ // log that the CA is present
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java b/pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java
new file mode 100644
index 000000000..a9a29db92
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java
@@ -0,0 +1,279 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.ca;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.ca.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.cert.*;
+import java.util.*;
+import netscape.security.x509.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check the validity of the CA.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class CAValidity
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////////
+ // CAValidity parameters //
+ ///////////////////////////
+
+ // parameter information
+ public static final String PROP_CA_SUB_ID = "CaSubId";
+ private String mCaSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ ////////////////////////
+ // CAValidity methods //
+ ////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mCaSubId = mConfig.getString( PROP_CA_SUB_ID );
+ if( mCaSubId != null ) {
+ mCaSubId = mCaSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_CA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_CA_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_CA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_CA_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_CA_VALIDITY_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ ICertificateAuthority ca = null;
+ X509CertImpl caCert = null;
+
+ ca = ( ICertificateAuthority ) CMS.getSubsystem( mCaSubId );
+
+ if( ca == null ) {
+ // log that the CA is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the CA certificate
+ caCert = ca.getCACert();
+
+ if( caCert == null ) {
+ // log that the CA is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_CA_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the CA validity period
+ try {
+ caCert.checkValidity();
+ } catch( CertificateNotYetValidException e ) {
+ // log that the CA is not yet valid
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_YET_VALID",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } catch( CertificateExpiredException e ) {
+ // log that the CA is expired
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_EXPIRED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // log that the CA is valid
+ logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_VALID",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java b/pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java
new file mode 100644
index 000000000..af4711bed
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java
@@ -0,0 +1,270 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.kra;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.kra.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.*;
+import java.util.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check for KRA presence.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class KRAPresence
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////////
+ // KRAPresence parameters //
+ ///////////////////////////
+
+ // parameter information
+ public static final String PROP_KRA_SUB_ID = "SubId";
+ private String mSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ ////////////////////////
+ // KRAPresence methods //
+ ////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mSubId = mConfig.getString( PROP_KRA_SUB_ID );
+ if( mSubId != null ) {
+ mSubId = mSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_KRA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_KRA_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_KRA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_KRA_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_KRA_PRESENCE_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ IKeyRecoveryAuthority kra = null;
+ org.mozilla.jss.crypto.X509Certificate kraCert = null;
+ PublicKey kraPubKey = null;
+
+ kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( mSubId );
+
+ if( kra == null ) {
+ // log that the KRA is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the KRA certificate
+ kraCert = kra.getTransportCert();
+
+ if( kraCert == null ) {
+ // log that the RA is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_KRA_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the KRA certificate public key
+ kraPubKey = ( PublicKey ) kraCert.getPublicKey();
+
+ if( kraPubKey == null ) {
+ // log that something is seriously wrong with the KRA
+ logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_CORRUPT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // log that the KRA is present
+ logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java
new file mode 100644
index 000000000..41675920d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java
@@ -0,0 +1,297 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.ocsp;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.ocsp.*;
+import com.netscape.certsrv.security.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.cert.*;
+import java.util.*;
+import netscape.security.x509.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check for OCSP presence.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class OCSPPresence
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ /////////////////////////////
+ // OCSPPresence parameters //
+ /////////////////////////////
+
+ // parameter information
+ public static final String PROP_OCSP_SUB_ID = "OcspSubId";
+ private String mOcspSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ //////////////////////////
+ // OCSPPresence methods //
+ //////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mOcspSubId = mConfig.getString( PROP_OCSP_SUB_ID );
+ if( mOcspSubId != null ) {
+ mOcspSubId = mOcspSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_OCSP_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_OCSP_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_OCSP_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_OCSP_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_OCSP_PRESENCE_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ IOCSPAuthority ocsp = null;
+ ISigningUnit ocspSigningUnit = null;
+ X509CertImpl ocspCert = null;
+ X509Key ocspPubKey = null;
+
+ ocsp = ( IOCSPAuthority ) CMS.getSubsystem( mOcspSubId );
+
+ if( ocsp == null ) {
+ // log that the OCSP is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the OCSP signing unit
+ ocspSigningUnit = ocsp.getSigningUnit();
+
+ if( ocspSigningUnit == null ) {
+ // log that the OCSP is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the OCSP certificate
+ ocspCert = ocspSigningUnit.getCertImpl();
+
+ if( ocspCert == null ) {
+ // log that the OCSP is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the OCSP certificate public key
+ try {
+ ocspPubKey = ( X509Key )
+ ocspCert.get( X509CertImpl.PUBLIC_KEY );
+
+ if( ocspPubKey == null ) {
+ // log that something is seriously wrong with the OCSP
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_CORRUPT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+ } catch( CertificateParsingException e ) {
+ // log that something is seriously wrong with the OCSP
+ mSelfTestSubsystem.log( logger,
+ e.toString() );
+
+ throw new ESelfTestException( e.toString() );
+ }
+
+ // log that the OCSP is present
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java
new file mode 100644
index 000000000..7008b5409
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java
@@ -0,0 +1,297 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.ocsp;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.ocsp.*;
+import com.netscape.certsrv.security.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.cert.*;
+import java.util.*;
+import netscape.security.x509.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check the validity of the OCSP.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class OCSPValidity
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ /////////////////////////////
+ // OCSPValidity parameters //
+ /////////////////////////////
+
+ // parameter information
+ public static final String PROP_OCSP_SUB_ID = "OcspSubId";
+ private String mOcspSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ //////////////////////////
+ // OCSPValidity methods //
+ //////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mOcspSubId = mConfig.getString( PROP_OCSP_SUB_ID );
+ if( mOcspSubId != null ) {
+ mOcspSubId = mOcspSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_OCSP_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_OCSP_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_OCSP_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_OCSP_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_OCSP_VALIDITY_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ IOCSPAuthority ocsp = null;
+ ISigningUnit ocspSigningUnit = null;
+ X509CertImpl ocspCert = null;
+
+ ocsp = ( IOCSPAuthority ) CMS.getSubsystem( mOcspSubId );
+
+ if( ocsp == null ) {
+ // log that the OCSP is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the OCSP signing unit
+ ocspSigningUnit = ocsp.getSigningUnit();
+
+ if( ocspSigningUnit == null ) {
+ // log that the OCSP is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the OCSP certificate
+ ocspCert = ocspSigningUnit.getCertImpl();
+
+ if( ocspCert == null ) {
+ // log that the OCSP is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_OCSP_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the OCSP validity period
+ try {
+ ocspCert.checkValidity();
+ } catch( CertificateNotYetValidException e ) {
+ // log that the OCSP is not yet valid
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_OCSP_IS_NOT_YET_VALID",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } catch( CertificateExpiredException e ) {
+ // log that the OCSP is expired
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_EXPIRED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // log that the OCSP is valid
+ logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_VALID",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java b/pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java
new file mode 100644
index 000000000..671f386a1
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java
@@ -0,0 +1,270 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+// package statement //
+///////////////////////
+
+package com.netscape.cms.selftests.ra;
+
+
+
+///////////////////////
+// import statements //
+///////////////////////
+
+import com.netscape.certsrv.apps.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.ra.*;
+import com.netscape.certsrv.selftests.*;
+import com.netscape.cms.selftests.*;
+import java.security.*;
+import java.util.*;
+
+
+
+//////////////////////
+// class definition //
+//////////////////////
+
+/**
+ * This class implements a self test to check for RA presence.
+ * <P>
+ *
+ * @author mharmsen
+ * @author thomask
+ * @version $Revision: 14561 $, $Date: 2007-05-01 10:28:56 -0700 (Tue, 01 May 2007) $
+ */
+public class RAPresence
+extends ASelfTest
+{
+ ////////////////////////
+ // default parameters //
+ ////////////////////////
+
+
+
+ ///////////////////////////
+ // RAPresence parameters //
+ ///////////////////////////
+
+ // parameter information
+ public static final String PROP_RA_SUB_ID = "RaSubId";
+ private String mRaSubId = null;
+
+
+
+ /////////////////////
+ // default methods //
+ /////////////////////
+
+
+
+ ////////////////////////
+ // RAPresence methods //
+ ////////////////////////
+
+ /**
+ * Initializes this subsystem with the configuration store
+ * associated with this instance name.
+ * <P>
+ *
+ * @param subsystem the associated subsystem
+ * @param instanceName the name of this self test instance
+ * @param parameters configuration store (self test parameters)
+ * @exception EDuplicateSelfTestException subsystem has duplicate name/value
+ * @exception EInvalidSelfTestException subsystem has invalid name/value
+ * @exception EMissingSelfTestException subsystem has missing name/value
+ */
+ public void initSelfTest( ISelfTestSubsystem subsystem,
+ String instanceName,
+ IConfigStore parameters )
+ throws EDuplicateSelfTestException,
+ EInvalidSelfTestException,
+ EMissingSelfTestException
+ {
+ super.initSelfTest( subsystem, instanceName, parameters );
+
+ // retrieve mandatory parameter(s)
+ try {
+ mRaSubId = mConfig.getString( PROP_RA_SUB_ID );
+ if( mRaSubId != null ) {
+ mRaSubId = mRaSubId.trim();
+ } else {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_VALUES",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_RA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( PROP_RA_SUB_ID );
+ }
+ } catch( EBaseException e ) {
+ mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(),
+ CMS.getLogMessage(
+ "SELFTESTS_MISSING_NAME",
+ getSelfTestName(),
+ mPrefix
+ + "."
+ + PROP_RA_SUB_ID ) );
+
+ throw new EMissingSelfTestException( mPrefix,
+ PROP_RA_SUB_ID,
+ null );
+ }
+
+ // retrieve optional parameter(s)
+
+ return;
+ }
+
+
+ /**
+ * Notifies this subsystem if it is in execution mode.
+ * <P>
+ *
+ * @exception ESelfTestException failed to start
+ */
+ public void startupSelfTest()
+ throws ESelfTestException
+ {
+ return;
+ }
+
+
+ /**
+ * Stops this subsystem. The subsystem may call shutdownSelfTest
+ * anytime after initialization.
+ * <P>
+ */
+ public void shutdownSelfTest()
+ {
+ return;
+ }
+
+
+ /**
+ * Returns the name associated with this self test. This method may
+ * return null if the self test has not been intialized.
+ * <P>
+ *
+ * @return instanceName of this self test
+ */
+ public String getSelfTestName()
+ {
+ return super.getSelfTestName();
+ }
+
+
+ /**
+ * Returns the root configuration storage (self test parameters)
+ * associated with this subsystem.
+ * <P>
+ *
+ * @return configuration store (self test parameters) of this subsystem
+ */
+ public IConfigStore getSelfTestConfigStore()
+ {
+ return super.getSelfTestConfigStore();
+ }
+
+
+ /**
+ * Retrieves description associated with an individual self test.
+ * This method may return null.
+ * <P>
+ *
+ * @param locale locale of the client that requests the description
+ * @return description of self test
+ */
+ public String getSelfTestDescription( Locale locale )
+ {
+ return CMS.getUserMessage( locale,
+ "CMS_SELFTESTS_RA_PRESENCE_DESCRIPTION" );
+ }
+
+
+ /**
+ * Execute an individual self test.
+ * <P>
+ *
+ * @param logger specifies logging subsystem
+ * @exception ESelfTestException self test exception
+ */
+ public void runSelfTest( ILogEventListener logger )
+ throws ESelfTestException
+ {
+ String logMessage = null;
+ IRegistrationAuthority ra = null;
+ org.mozilla.jss.crypto.X509Certificate raCert = null;
+ PublicKey raPubKey = null;
+
+ ra = ( IRegistrationAuthority ) CMS.getSubsystem( mRaSubId );
+
+ if( ra == null ) {
+ // log that the RA is not installed
+ logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_NOT_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ } else {
+ // Retrieve the RA certificate
+ raCert = ra.getRACert();
+
+ if( raCert == null ) {
+ // log that the RA is not yet initialized
+ logMessage = CMS.getLogMessage(
+ "SELFTESTS_RA_IS_NOT_INITIALIZED",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // Retrieve the RA certificate public key
+ raPubKey = ( PublicKey ) raCert.getPublicKey();
+
+ if( raPubKey == null ) {
+ // log that something is seriously wrong with the RA
+ logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_CORRUPT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+
+ throw new ESelfTestException( logMessage );
+ }
+
+ // log that the RA is present
+ logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_PRESENT",
+ getSelfTestName() );
+
+ mSelfTestSubsystem.log( logger,
+ logMessage );
+ }
+
+ return;
+ }
+}
+