diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/selftests')
9 files changed, 1024 insertions, 668 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 index bc9a5b75c..df7f02bca 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ASelfTest.java @@ -20,6 +20,7 @@ package com.netscape.cms.selftests; + /////////////////////// // import statements // /////////////////////// @@ -36,6 +37,7 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTest; import com.netscape.certsrv.selftests.ISelfTestSubsystem; + ////////////////////// // class definition // ////////////////////// @@ -48,14 +50,17 @@ import com.netscape.certsrv.selftests.ISelfTestSubsystem; * @author thomask * @version $Revision$, $Date$ */ -public abstract class ASelfTest implements ISelfTest { - // ////////////////////// +public abstract class ASelfTest + implements ISelfTest { + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + + - // //////////////////////// + ////////////////////////// // ISelfTest parameters // - // //////////////////////// + ////////////////////////// // parameter information private static final String SELF_TEST_NAME = "ASelfTest"; @@ -66,29 +71,34 @@ public abstract class ASelfTest implements ISelfTest { protected IConfigStore mConfig = null; protected String mPrefix = null; - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// - // ///////////////////// + + + /////////////////////// // ISelfTest methods // - // ///////////////////// + /////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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 { + 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; @@ -97,9 +107,10 @@ public abstract class ASelfTest implements ISelfTest { if (instanceName != null) { instanceName = instanceName.trim(); } else { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_PARAMETER_WAS_NULL", - SELF_TEST_NAME)); + mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage( + "SELFTESTS_PARAMETER_WAS_NULL", + SELF_TEST_NAME)); throw new EMissingSelfTestException(); } @@ -112,13 +123,15 @@ public abstract class ASelfTest implements ISelfTest { mConfig = parameters.getSubStore(pluginPath); - if ((mConfig != null) && (mConfig.getName() != null) - && (mConfig.getName() != "")) { + 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)); + mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage( + "SELFTESTS_PARAMETER_WAS_NULL", + SELF_TEST_NAME)); throw new EMissingSelfTestException(); } @@ -129,23 +142,24 @@ public abstract class ASelfTest implements ISelfTest { /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public abstract void startupSelfTest() throws ESelfTestException; + public abstract void startupSelfTest() + throws ESelfTestException; /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * 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. + * 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() { @@ -153,10 +167,10 @@ public abstract class ASelfTest implements ISelfTest { } /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { @@ -164,10 +178,10 @@ public abstract class ASelfTest implements ISelfTest { } /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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 */ @@ -176,10 +190,11 @@ public abstract class ASelfTest implements ISelfTest { /** * Execute an individual self test. * <P> - * + * * @param logger specifies logging subsystem * @exception ESelfTestException self test exception */ public abstract void runSelfTest(ILogEventListener logger) - throws ESelfTestException; + 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 index edbac11bb..cf3338ef4 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ca/CAPresence.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.ca; + + /////////////////////// // import statements // /////////////////////// @@ -42,6 +44,8 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// @@ -54,63 +58,84 @@ import com.netscape.cms.selftests.ASelfTest; * @author thomask * @version $Revision$, $Date$ */ -public class CAPresence extends ASelfTest { - // ////////////////////// +public class CAPresence +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + - // ///////////////////////// + + /////////////////////////// // CAPresence parameters // - // ///////////////////////// + /////////////////////////// // parameter information public static final String PROP_CA_SUB_ID = "CaSubId"; - private String mCaSubId = null; + private String mCaSubId = null; + + - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + + - // ////////////////////// + //////////////////////// // CAPresence methods // - // ////////////////////// + //////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -118,124 +143,145 @@ public class CAPresence extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + public void runSelfTest( ILogEventListener logger ) + throws ESelfTestException + { String logMessage = null; ICertificateAuthority ca = null; X509CertImpl caCert = null; X509Key caPubKey = null; - ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId); + ca = ( ICertificateAuthority ) CMS.getSubsystem( mCaSubId ); - if (ca == null) { + if( ca == null ) { // log that the CA is not installed - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the CA certificate caCert = ca.getCACert(); - if (caCert == null) { + if( caCert == null ) { // log that the CA is not yet initialized - logMessage = CMS.getLogMessage( - "SELFTESTS_CA_IS_NOT_INITIALIZED", getSelfTestName()); + logMessage = CMS.getLogMessage( + "SELFTESTS_CA_IS_NOT_INITIALIZED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // Retrieve the CA certificate public key try { - caPubKey = (X509Key) caCert.get(X509CertImpl.PUBLIC_KEY); + caPubKey = ( X509Key ) caCert.get( X509CertImpl.PUBLIC_KEY ); - if (caPubKey == null) { + if( caPubKey == null ) { // log that something is seriously wrong with the CA - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_CORRUPT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_CORRUPT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } - } catch (CertificateParsingException e) { + } catch( CertificateParsingException e ) { // log that something is seriously wrong with the CA - mSelfTestSubsystem.log(logger, e.toString()); + mSelfTestSubsystem.log( logger, + e.toString() ); - throw new ESelfTestException(e.toString()); + throw new ESelfTestException( e.toString() ); } // log that the CA is present - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + 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 index c2072dbbb..cff35ce57 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ca/CAValidity.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.ca; + + /////////////////////// // import statements // /////////////////////// @@ -42,75 +44,98 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// /** - * This class implements a self test to check the validity of the CA. + * This class implements a self test to check the validity of the CA. * <P> * * @author mharmsen * @author thomask * @version $Revision$, $Date$ */ -public class CAValidity extends ASelfTest { - // ////////////////////// +public class CAValidity +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + - // ///////////////////////// + + /////////////////////////// // CAValidity parameters // - // ///////////////////////// + /////////////////////////// // parameter information public static final String PROP_CA_SUB_ID = "CaSubId"; - private String mCaSubId = null; + private String mCaSubId = null; + + - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + + - // ////////////////////// + //////////////////////// // CAValidity methods // - // ////////////////////// + //////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -118,124 +143,145 @@ public class CAValidity extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + public void runSelfTest( ILogEventListener logger ) + throws ESelfTestException + { String logMessage = null; ICertificateAuthority ca = null; X509CertImpl caCert = null; - ca = (ICertificateAuthority) CMS.getSubsystem(mCaSubId); + ca = ( ICertificateAuthority ) CMS.getSubsystem( mCaSubId ); - if (ca == null) { + if( ca == null ) { // log that the CA is not installed - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the CA certificate caCert = ca.getCACert(); - if (caCert == null) { + if( caCert == null ) { // log that the CA is not yet initialized - logMessage = CMS.getLogMessage( - "SELFTESTS_CA_IS_NOT_INITIALIZED", getSelfTestName()); + logMessage = CMS.getLogMessage( + "SELFTESTS_CA_IS_NOT_INITIALIZED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // Retrieve the CA validity period try { caCert.checkValidity(); - } catch (CertificateNotYetValidException e) { + } catch( CertificateNotYetValidException e ) { // log that the CA is not yet valid - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_NOT_YET_VALID", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_NOT_YET_VALID", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); - } catch (CertificateExpiredException e) { + throw new ESelfTestException( logMessage ); + } catch( CertificateExpiredException e ) { // log that the CA is expired - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_EXPIRED", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_EXPIRED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // log that the CA is valid - logMessage = CMS.getLogMessage("SELFTESTS_CA_IS_VALID", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_CA_IS_VALID", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); } return; } } + diff --git a/pki/base/common/src/com/netscape/cms/selftests/common/SystemCertsVerification.java b/pki/base/common/src/com/netscape/cms/selftests/common/SystemCertsVerification.java index b0e943c16..b3388d9e1 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/common/SystemCertsVerification.java +++ b/pki/base/common/src/com/netscape/cms/selftests/common/SystemCertsVerification.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.common; + + /////////////////////// // import statements // /////////////////////// @@ -37,74 +39,97 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// /** - * This class implements a self test to check the system certs of the subsystem + * This class implements a self test to check the system certs + * of the subsystem * <P> * - * @version $Revision: $, $Date: $ + * @version $Revision: $, $Date: $ */ -public class SystemCertsVerification extends ASelfTest { - // ////////////////////// +public class SystemCertsVerification +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + - // ///////////////////////// + + /////////////////////////// // SystemCertsVerification parameters // - // ///////////////////////// + /////////////////////////// // parameter information public static final String PROP_SUB_ID = "SubId"; - private String mSubId = null; + private String mSubId = null; + + - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + + - // ////////////////////// + //////////////////////// // SystemCertsVerification methods // - // ////////////////////// + //////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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_SUB_ID); - if (mSubId != null) { + mSubId = mConfig.getString( PROP_SUB_ID ); + if( mSubId != null ) { mSubId = mSubId.trim(); } else { - mSelfTestSubsystem - .log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_MISSING_VALUES", - getSelfTestName(), mPrefix + "." - + PROP_SUB_ID)); - - throw new EMissingSelfTestException(PROP_SUB_ID); + mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage( + "SELFTESTS_MISSING_VALUES", + getSelfTestName(), + mPrefix + + "." + + PROP_SUB_ID ) ); + + throw new EMissingSelfTestException( PROP_SUB_ID ); } - } catch (EBaseException e) { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_MISSING_NAME", getSelfTestName(), - mPrefix + "." + PROP_SUB_ID)); - - throw new EMissingSelfTestException(mPrefix, PROP_SUB_ID, null); + } catch( EBaseException e ) { + mSelfTestSubsystem.log( mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage( + "SELFTESTS_MISSING_NAME", + getSelfTestName(), + mPrefix + + "." + + PROP_SUB_ID ) ); + + throw new EMissingSelfTestException( mPrefix, + PROP_SUB_ID, + null ); } // retrieve optional parameter(s) @@ -112,87 +137,102 @@ public class SystemCertsVerification extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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_SYSTEM_CERTS_VERIFICATION_DESCRIPTION"); + public String getSelfTestDescription( Locale locale ) + { + return CMS.getUserMessage( locale, + "CMS_SELFTESTS_SYSTEM_CERTS_VERIFICATION_DESCRIPTION" ); } + /** * Execute an individual self test. * <P> - * + * * @param logger specifies logging subsystem * @exception ESelfTestException self test exception */ - public void runSelfTest(ILogEventListener logger) throws ESelfTestException { + public void runSelfTest( ILogEventListener logger ) + throws ESelfTestException + { String logMessage = null; boolean rc = false; rc = CMS.verifySystemCerts(); if (rc == true) { - logMessage = CMS.getLogMessage( - "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_SUCCESS", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_SUCCESS", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); } else { - logMessage = CMS.getLogMessage( - "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_FAILURE", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_COMMON_SYSTEM_CERTS_VERIFICATION_FAILURE", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); - throw new ESelfTestException(logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); + throw new ESelfTestException( 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 index e90072c0d..52255e24c 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java +++ b/pki/base/common/src/com/netscape/cms/selftests/kra/KRAPresence.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.kra; + + /////////////////////// // import statements // /////////////////////// @@ -39,6 +41,8 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// @@ -51,63 +55,84 @@ import com.netscape.cms.selftests.ASelfTest; * @author thomask * @version $Revision$, $Date$ */ -public class KRAPresence extends ASelfTest { - // ////////////////////// +public class KRAPresence +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + - // ///////////////////////// + + /////////////////////////// // KRAPresence parameters // - // ///////////////////////// + /////////////////////////// // parameter information public static final String PROP_KRA_SUB_ID = "SubId"; - private String mSubId = null; + private String mSubId = null; + + - // /////////////////// + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + + - // ////////////////////// + //////////////////////// // KRAPresence methods // - // ////////////////////// + //////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -115,117 +140,137 @@ public class KRAPresence extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + 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); + kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( mSubId ); - if (kra == null) { + if( kra == null ) { // log that the KRA is not installed - logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the KRA certificate kraCert = kra.getTransportCert(); - if (kraCert == null) { + if( kraCert == null ) { // log that the RA is not yet initialized - logMessage = CMS.getLogMessage( - "SELFTESTS_KRA_IS_NOT_INITIALIZED", getSelfTestName()); + logMessage = CMS.getLogMessage( + "SELFTESTS_KRA_IS_NOT_INITIALIZED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // Retrieve the KRA certificate public key - kraPubKey = (PublicKey) kraCert.getPublicKey(); + kraPubKey = ( PublicKey ) kraCert.getPublicKey(); - if (kraPubKey == null) { + if( kraPubKey == null ) { // log that something is seriously wrong with the KRA - logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_CORRUPT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_CORRUPT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // log that the KRA is present - logMessage = CMS.getLogMessage("SELFTESTS_KRA_IS_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_KRA_IS_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + 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 index b8f48b4a2..507148bd5 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPPresence.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.ocsp; + + /////////////////////// // import statements // /////////////////////// @@ -43,6 +45,8 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// @@ -55,63 +59,84 @@ import com.netscape.cms.selftests.ASelfTest; * @author thomask * @version $Revision$, $Date$ */ -public class OCSPPresence extends ASelfTest { - // ////////////////////// +public class OCSPPresence +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + + - // /////////////////////////// + ///////////////////////////// // OCSPPresence parameters // - // /////////////////////////// + ///////////////////////////// // parameter information public static final String PROP_OCSP_SUB_ID = "OcspSubId"; - private String mOcspSubId = null; + private String mOcspSubId = null; - // /////////////////// + + + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + - // //////////////////////// + + ////////////////////////// // OCSPPresence methods // - // //////////////////////// + ////////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -119,138 +144,162 @@ public class OCSPPresence extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + 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); + ocsp = ( IOCSPAuthority ) CMS.getSubsystem( mOcspSubId ); - if (ocsp == null) { + if( ocsp == null ) { // log that the OCSP is not installed - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the OCSP signing unit ocspSigningUnit = ocsp.getSigningUnit(); - if (ocspSigningUnit == null) { + 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); + 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) { + 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); + 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); + ocspPubKey = ( X509Key ) + ocspCert.get( X509CertImpl.PUBLIC_KEY ); - if (ocspPubKey == null) { + if( ocspPubKey == null ) { // log that something is seriously wrong with the OCSP - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_CORRUPT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_CORRUPT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } - } catch (CertificateParsingException e) { + } catch( CertificateParsingException e ) { // log that something is seriously wrong with the OCSP - mSelfTestSubsystem.log(logger, e.toString()); + mSelfTestSubsystem.log( logger, + e.toString() ); - throw new ESelfTestException(e.toString()); + throw new ESelfTestException( e.toString() ); } // log that the OCSP is present - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + 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 index 089f2ba32..e6516b2a6 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ocsp/OCSPValidity.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.ocsp; + + /////////////////////// // import statements // /////////////////////// @@ -43,75 +45,98 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// /** - * This class implements a self test to check the validity of the OCSP. + * This class implements a self test to check the validity of the OCSP. * <P> * * @author mharmsen * @author thomask * @version $Revision$, $Date$ */ -public class OCSPValidity extends ASelfTest { - // ////////////////////// +public class OCSPValidity +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// + + - // /////////////////////////// + ///////////////////////////// // OCSPValidity parameters // - // /////////////////////////// + ///////////////////////////// // parameter information public static final String PROP_OCSP_SUB_ID = "OcspSubId"; - private String mOcspSubId = null; + private String mOcspSubId = null; - // /////////////////// + + + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + - // //////////////////////// + + ////////////////////////// // OCSPValidity methods // - // //////////////////////// + ////////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -119,138 +144,162 @@ public class OCSPValidity extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + public void runSelfTest( ILogEventListener logger ) + throws ESelfTestException + { String logMessage = null; IOCSPAuthority ocsp = null; ISigningUnit ocspSigningUnit = null; X509CertImpl ocspCert = null; - ocsp = (IOCSPAuthority) CMS.getSubsystem(mOcspSubId); + ocsp = ( IOCSPAuthority ) CMS.getSubsystem( mOcspSubId ); - if (ocsp == null) { + if( ocsp == null ) { // log that the OCSP is not installed - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the OCSP signing unit ocspSigningUnit = ocsp.getSigningUnit(); - if (ocspSigningUnit == null) { + 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); + 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) { + if( ocspCert == null ) { // log that the OCSP is not yet initialized - logMessage = CMS.getLogMessage( - "SELFTESTS_OCSP_IS_NOT_INITIALIZED", getSelfTestName()); + logMessage = CMS.getLogMessage( + "SELFTESTS_OCSP_IS_NOT_INITIALIZED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // Retrieve the OCSP validity period try { ocspCert.checkValidity(); - } catch (CertificateNotYetValidException e) { + } catch( CertificateNotYetValidException e ) { // log that the OCSP is not yet valid logMessage = CMS.getLogMessage( - "SELFTESTS_OCSP_IS_NOT_YET_VALID", getSelfTestName()); + "SELFTESTS_OCSP_IS_NOT_YET_VALID", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); - } catch (CertificateExpiredException e) { + throw new ESelfTestException( logMessage ); + } catch( CertificateExpiredException e ) { // log that the OCSP is expired - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_EXPIRED", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_EXPIRED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // log that the OCSP is valid - logMessage = CMS.getLogMessage("SELFTESTS_OCSP_IS_VALID", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_OCSP_IS_VALID", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + 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 index 55f921d2d..1a8b4c3e7 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java +++ b/pki/base/common/src/com/netscape/cms/selftests/ra/RAPresence.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.ra; + + /////////////////////// // import statements // /////////////////////// @@ -39,6 +41,8 @@ import com.netscape.certsrv.selftests.ESelfTestException; import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; + + ////////////////////// // class definition // ////////////////////// @@ -46,7 +50,6 @@ import com.netscape.cms.selftests.ASelfTest; /** * This class implements a self test to check for RA presence. * <P> - * * <PRE> * NOTE: This self-test is for Registration Authorities prior to * Netscape Certificate Management System 7.0. It does NOT @@ -61,63 +64,84 @@ import com.netscape.cms.selftests.ASelfTest; * @author thomask * @version $Revision$, $Date$ */ -public class RAPresence extends ASelfTest { - // ////////////////////// +public class RAPresence +extends ASelfTest +{ + //////////////////////// // default parameters // - // ////////////////////// + //////////////////////// - // ///////////////////////// + + + /////////////////////////// // RAPresence parameters // - // ///////////////////////// + /////////////////////////// // parameter information public static final String PROP_RA_SUB_ID = "RaSubId"; - private String mRaSubId = null; + private String mRaSubId = null; + - // /////////////////// + + ///////////////////// // default methods // - // /////////////////// + ///////////////////// + - // ////////////////////// + + //////////////////////// // RAPresence methods // - // ////////////////////// + //////////////////////// /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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); + 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 = 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); + 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); + } 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) @@ -125,117 +149,137 @@ public class RAPresence extends ASelfTest { return; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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"); + 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 { + 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); + ra = ( IRegistrationAuthority ) CMS.getSubsystem( mRaSubId ); - if (ra == null) { + if( ra == null ) { // log that the RA is not installed - logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_NOT_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_NOT_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } else { // Retrieve the RA certificate raCert = ra.getRACert(); - if (raCert == null) { + if( raCert == null ) { // log that the RA is not yet initialized - logMessage = CMS.getLogMessage( - "SELFTESTS_RA_IS_NOT_INITIALIZED", getSelfTestName()); + logMessage = CMS.getLogMessage( + "SELFTESTS_RA_IS_NOT_INITIALIZED", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // Retrieve the RA certificate public key - raPubKey = (PublicKey) raCert.getPublicKey(); + raPubKey = ( PublicKey ) raCert.getPublicKey(); - if (raPubKey == null) { + if( raPubKey == null ) { // log that something is seriously wrong with the RA - logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_CORRUPT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_CORRUPT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); - throw new ESelfTestException(logMessage); + throw new ESelfTestException( logMessage ); } // log that the RA is present - logMessage = CMS.getLogMessage("SELFTESTS_RA_IS_PRESENT", - getSelfTestName()); + logMessage = CMS.getLogMessage( "SELFTESTS_RA_IS_PRESENT", + getSelfTestName() ); - mSelfTestSubsystem.log(logger, logMessage); + mSelfTestSubsystem.log( logger, + logMessage ); } return; } } + diff --git a/pki/base/common/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java b/pki/base/common/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java index ce088045a..ba0ae3cb7 100644 --- a/pki/base/common/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java +++ b/pki/base/common/src/com/netscape/cms/selftests/tks/TKSKnownSessionKey.java @@ -20,6 +20,8 @@ package com.netscape.cms.selftests.tks; + + /////////////////////// // import statements // /////////////////////// @@ -40,6 +42,8 @@ import com.netscape.certsrv.selftests.ISelfTestSubsystem; import com.netscape.cms.selftests.ASelfTest; import com.netscape.symkey.SessionKey; + + ////////////////////// // class definition // ////////////////////// @@ -53,40 +57,47 @@ import com.netscape.symkey.SessionKey; * @author awnuk * @version $Revision$, $Date$ */ -public class TKSKnownSessionKey extends ASelfTest { +public class TKSKnownSessionKey +extends ASelfTest +{ // parameter information public static final String PROP_TKS_SUB_ID = "TksSubId"; - private String mTksSubId = null; - private String mToken = null; - private String mUseSoftToken = null; - private String mKeyName = null; - private byte[] mKeyInfo = null; + private String mTksSubId = null; + private String mToken = null; + private String mUseSoftToken = null; + private String mKeyName = null; + private byte[] mKeyInfo = null; private byte[] mCardChallenge = null; private byte[] mHostChallenge = null; - private byte[] mCUID = null; - private byte[] mMacKey = null; - private byte[] mSessionKey = null; + private byte[] mCUID = null; + private byte[] mMacKey = null; + private byte[] mSessionKey = null; + /** - * Initializes this subsystem with the configuration store associated with - * this instance name. + * 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 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 { + public void initSelfTest (ISelfTestSubsystem subsystem, + String instanceName, + IConfigStore parameters) + throws EDuplicateSelfTestException, + EInvalidSelfTestException, + EMissingSelfTestException + { ISubsystem tks = null; IConfigStore tksConfig = null; String logMessage = null; - super.initSelfTest(subsystem, instanceName, parameters); + super.initSelfTest( subsystem, instanceName, parameters ); mTksSubId = getConfigString(PROP_TKS_SUB_ID); mToken = getConfigString("token"); @@ -105,8 +116,7 @@ public class TKSKnownSessionKey extends ASelfTest { if (tksConfig != null) { try { defKeySetMacKey = tksConfig.getString("defKeySet.mac_key"); - byte defMacKey[] = com.netscape.cmsutil.util.Utils - .SpecialDecode(defKeySetMacKey); + byte defMacKey[] = com.netscape.cmsutil.util.Utils.SpecialDecode(defKeySetMacKey); if (!Arrays.equals(mMacKey, defMacKey)) { defKeySetMacKey = null; } @@ -118,36 +128,34 @@ public class TKSKnownSessionKey extends ASelfTest { if (defKeySetMacKey == null) { CMS.debug("TKSKnownSessionKey: invalid mac key"); CMS.debug("TKSKnownSessionKey self test FAILED"); - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_INVALID_VALUES", - getSelfTestName(), mPrefix + "." + "macKey")); - throw new EInvalidSelfTestException(mPrefix, "macKey", null); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_INVALID_VALUES", + getSelfTestName(), mPrefix + "." + "macKey")); + throw new EInvalidSelfTestException (mPrefix, "macKey", null); } - + try { mSessionKey = getConfigByteArray("sessionKey", 16); } catch (EMissingSelfTestException e) { if (mSessionKey == null) { - mSessionKey = SessionKey.ComputeSessionKey(mToken, mKeyName, - mCardChallenge, mHostChallenge, mKeyInfo, mCUID, - mMacKey, mUseSoftToken, null, null); + mSessionKey = SessionKey.ComputeSessionKey (mToken, mKeyName, + mCardChallenge, mHostChallenge, + mKeyInfo, mCUID, mMacKey, mUseSoftToken, null, null); if (mSessionKey == null || mSessionKey.length != 16) { - mSelfTestSubsystem.log(mSelfTestSubsystem - .getSelfTestLogger(), CMS.getLogMessage( - "SELFTESTS_MISSING_VALUES", getSelfTestName(), - mPrefix + ".sessionKey")); - throw new EMissingSelfTestException("sessionKey"); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_MISSING_VALUES", + getSelfTestName(), mPrefix + ".sessionKey")); + throw new EMissingSelfTestException ("sessionKey"); } String sessionKey = SpecialEncode(mSessionKey); mConfig.putString("sessionKey", sessionKey); try { CMS.getConfigStore().commit(true); } catch (EBaseException be) { - mSelfTestSubsystem.log(mSelfTestSubsystem - .getSelfTestLogger(), CMS.getLogMessage( - "SELFTESTS_MISSING_VALUES", getSelfTestName(), - mPrefix + ".sessionKey")); - throw new EMissingSelfTestException("sessionKey"); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_MISSING_VALUES", + getSelfTestName(), mPrefix + ".sessionKey")); + throw new EMissingSelfTestException ("sessionKey"); } } } @@ -155,7 +163,9 @@ public class TKSKnownSessionKey extends ASelfTest { return; } - private String SpecialEncode(byte data[]) { + + private String SpecialEncode (byte data[]) + { StringBuffer sb = new StringBuffer(); for (int i = 0; i < data.length; i++) { @@ -169,8 +179,9 @@ public class TKSKnownSessionKey extends ASelfTest { return sb.toString(); } - private String getConfigString(String name) - throws EMissingSelfTestException { + + private String getConfigString (String name) throws EMissingSelfTestException + { String value = null; try { @@ -178,126 +189,137 @@ public class TKSKnownSessionKey extends ASelfTest { if (value != null) { value = value.trim(); } else { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), - CMS.getLogMessage("SELFTESTS_MISSING_VALUES", - getSelfTestName(), mPrefix + "." + name)); - throw new EMissingSelfTestException(name); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_MISSING_VALUES", + getSelfTestName(), mPrefix + "." + name)); + throw new EMissingSelfTestException (name); } } catch (EBaseException e) { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_MISSING_NAME", getSelfTestName(), - mPrefix + "." + name)); - throw new EMissingSelfTestException(mPrefix, name, null); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_MISSING_NAME", + getSelfTestName(), mPrefix + "." + name)); + throw new EMissingSelfTestException (mPrefix, name, null); } return value; } - private byte[] getConfigByteArray(String name, int size) - throws EMissingSelfTestException, EInvalidSelfTestException { + + private byte[] getConfigByteArray (String name, int size) throws EMissingSelfTestException, + EInvalidSelfTestException + { String stringValue = getConfigString(name); - byte byteValue[] = com.netscape.cmsutil.util.Utils - .SpecialDecode(stringValue); + byte byteValue[] = com.netscape.cmsutil.util.Utils.SpecialDecode(stringValue); if (byteValue == null) { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_MISSING_NAME", getSelfTestName(), - mPrefix + "." + name)); - throw new EMissingSelfTestException(name); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_MISSING_NAME", + getSelfTestName(), mPrefix + "." + name)); + throw new EMissingSelfTestException (name); } if (byteValue.length != size) { - mSelfTestSubsystem.log(mSelfTestSubsystem.getSelfTestLogger(), CMS - .getLogMessage("SELFTESTS_INVALID_VALUES", - getSelfTestName(), mPrefix + "." + name)); - throw new EInvalidSelfTestException(mPrefix, name, stringValue); + mSelfTestSubsystem.log (mSelfTestSubsystem.getSelfTestLogger(), + CMS.getLogMessage("SELFTESTS_INVALID_VALUES", + getSelfTestName(), mPrefix + "." + name)); + throw new EInvalidSelfTestException (mPrefix, name, stringValue); } return byteValue; } + /** * Notifies this subsystem if it is in execution mode. * <P> - * + * * @exception ESelfTestException failed to start */ - public void startupSelfTest() throws ESelfTestException { + public void startupSelfTest() + throws ESelfTestException + { return; } + /** - * Stops this subsystem. The subsystem may call shutdownSelfTest anytime - * after initialization. + * Stops this subsystem. The subsystem may call shutdownSelfTest + * anytime after initialization. * <P> */ - public void shutdownSelfTest() { + 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. + * 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() { + public String getSelfTestName() + { return super.getSelfTestName(); } + /** - * Returns the root configuration storage (self test parameters) associated - * with this subsystem. + * 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() { + public IConfigStore getSelfTestConfigStore() + { return super.getSelfTestConfigStore(); } + /** - * Retrieves description associated with an individual self test. This - * method may return null. + * 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_TKS_PRESENCE_DESCRIPTION"); + public String getSelfTestDescription( Locale locale ) + { + return CMS.getUserMessage (locale, "CMS_SELFTESTS_TKS_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 { + public void runSelfTest (ILogEventListener logger) + throws ESelfTestException + { String logMessage = null; String keySet = "defKeySet"; - byte[] sessionKey = SessionKey.ComputeSessionKey(mToken, mKeyName, - mCardChallenge, mHostChallenge, mKeyInfo, mCUID, mMacKey, - mUseSoftToken, keySet, null); + byte[] sessionKey = SessionKey.ComputeSessionKey (mToken, mKeyName, + mCardChallenge, mHostChallenge, + mKeyInfo, mCUID, mMacKey, mUseSoftToken, keySet, null); // Now we just see if we can successfully generate a session key. - // For FIPS compliance, the routine now returns a wrapped key, which - // can't be extracted and compared. + // For FIPS compliance, the routine now returns a wrapped key, which can't be extracted and compared. if (sessionKey == null) { CMS.debug("TKSKnownSessionKey: generated no session key"); CMS.debug("TKSKnownSessionKey self test FAILED"); - logMessage = CMS.getLogMessage("SELFTESTS_TKS_FAILED", - getSelfTestName(), getSelfTestName()); - mSelfTestSubsystem.log(logger, logMessage); - throw new ESelfTestException(logMessage); - } else { - logMessage = CMS.getLogMessage("SELFTESTS_TKS_SUCCEEDED", - getSelfTestName(), getSelfTestName()); - mSelfTestSubsystem.log(logger, logMessage); + logMessage = CMS.getLogMessage ("SELFTESTS_TKS_FAILED", getSelfTestName(), getSelfTestName()); + mSelfTestSubsystem.log (logger, logMessage); + throw new ESelfTestException( logMessage ); + } else { + logMessage = CMS.getLogMessage ("SELFTESTS_TKS_SUCCEEDED", getSelfTestName(), getSelfTestName()); + mSelfTestSubsystem.log (logger, logMessage); CMS.debug("TKSKnownSessionKey self test SUCCEEDED"); } |