summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java592
1 files changed, 295 insertions, 297 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java b/pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
index 2c17d088d..352dd8415 100644
--- a/pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
+++ b/pki/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.apps;
-
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -183,10 +182,10 @@ public class CMSEngine implements ICMSEngine {
public static final SubsystemRegistry mSSReg = SubsystemRegistry.getInstance();
- public static String instanceDir; /* path to instance <server-root>/cert-<instance-name> */
-
- private IConfigStore mConfig = null;
- private ISubsystem mOwner = null;
+ public static String instanceDir; /* path to instance <server-root>/cert-<instance-name> */
+
+ private IConfigStore mConfig = null;
+ private ISubsystem mOwner = null;
private long mStartupTime = 0;
private boolean isStarted = false;
private StringBuffer mWarning = new StringBuffer();
@@ -201,27 +200,27 @@ public class CMSEngine implements ICMSEngine {
// static subsystems - must be singletons
private static SubsystemInfo[] mStaticSubsystems = {
new SubsystemInfo(
- Debug.ID, Debug.getInstance()),
- new SubsystemInfo(LogSubsystem.ID,
- LogSubsystem.getInstance()),
- new SubsystemInfo(
- OsSubsystem.ID, OsSubsystem.getInstance()),
- new SubsystemInfo(
- JssSubsystem.ID, JssSubsystem.getInstance()),
- new SubsystemInfo(
- DBSubsystem.ID, DBSubsystem.getInstance()),
- new SubsystemInfo(
- UGSubsystem.ID, UGSubsystem.getInstance()),
+ Debug.ID, Debug.getInstance()),
+ new SubsystemInfo(LogSubsystem.ID,
+ LogSubsystem.getInstance()),
+ new SubsystemInfo(
+ OsSubsystem.ID, OsSubsystem.getInstance()),
+ new SubsystemInfo(
+ JssSubsystem.ID, JssSubsystem.getInstance()),
+ new SubsystemInfo(
+ DBSubsystem.ID, DBSubsystem.getInstance()),
+ new SubsystemInfo(
+ UGSubsystem.ID, UGSubsystem.getInstance()),
new SubsystemInfo(
- PluginRegistry.ID, new PluginRegistry()),
+ PluginRegistry.ID, new PluginRegistry()),
new SubsystemInfo(
- OidLoaderSubsystem.ID, OidLoaderSubsystem.getInstance()),
+ OidLoaderSubsystem.ID, OidLoaderSubsystem.getInstance()),
new SubsystemInfo(
- X500NameSubsystem.ID, X500NameSubsystem.getInstance()),
+ X500NameSubsystem.ID, X500NameSubsystem.getInstance()),
// skip TP subsystem;
// problem in needing dbsubsystem in constructor. and it's not used.
new SubsystemInfo(
- RequestSubsystem.ID, RequestSubsystem.getInstance()),
+ RequestSubsystem.ID, RequestSubsystem.getInstance()),
};
// dynamic subsystems are loaded at init time, not neccessarily singletons.
@@ -229,12 +228,12 @@ public class CMSEngine implements ICMSEngine {
// final static subsystems - must be singletons.
private static SubsystemInfo[] mFinalSubsystems = {
- new SubsystemInfo(
- AuthSubsystem.ID, AuthSubsystem.getInstance()),
- new SubsystemInfo(
- AuthzSubsystem.ID, AuthzSubsystem.getInstance()),
new SubsystemInfo(
- JobsScheduler.ID, JobsScheduler.getInstance()),
+ AuthSubsystem.ID, AuthSubsystem.getInstance()),
+ new SubsystemInfo(
+ AuthzSubsystem.ID, AuthzSubsystem.getInstance()),
+ new SubsystemInfo(
+ JobsScheduler.ID, JobsScheduler.getInstance()),
};
private static final int IP = 0;
@@ -246,12 +245,12 @@ public class CMSEngine implements ICMSEngine {
private static final int EE_NON_SSL = 3;
private static final int EE_CLIENT_AUTH_SSL = 4;
private static String mServerCertNickname = null;
- private static String info[][] = { {null, null, null},//agent
- {null, null, null},//admin
- {null, null, null},//sslEE
- {null, null, null},//non_sslEE
- {null, null, null} //ssl_clientauth_EE
- };
+ private static String info[][] = { { null, null, null },//agent
+ { null, null, null },//admin
+ { null, null, null },//sslEE
+ { null, null, null },//non_sslEE
+ { null, null, null } //ssl_clientauth_EE
+ };
/**
* private constructor.
@@ -260,14 +259,14 @@ public class CMSEngine implements ICMSEngine {
}
/**
- * gets this ID
+ * gets this ID
*/
public String getId() {
return ID;
}
/**
- * should never be called. returns error.
+ * should never be called. returns error.
*/
public void setId(String id) throws EBaseException {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_OPERATION"));
@@ -282,42 +281,43 @@ public class CMSEngine implements ICMSEngine {
public synchronized IPasswordStore getPasswordStore() {
// initialize the PasswordReader and PasswordWriter
- try {
- String pwdPath = mConfig.getString("passwordFile");
- if (mPasswordStore == null) {
- CMS.debug("CMSEngine: getPasswordStore(): password store not initialized before.");
- String pwdClass = mConfig.getString("passwordClass");
+ try {
+ String pwdPath = mConfig.getString("passwordFile");
+ if (mPasswordStore == null) {
+ CMS.debug("CMSEngine: getPasswordStore(): password store not initialized before.");
+ String pwdClass = mConfig.getString("passwordClass");
- if (pwdClass != null) {
- try {
- mPasswordStore = (IPasswordStore)Class.forName(pwdClass).newInstance();
- } catch (Exception e) {
- CMS.debug("CMSEngine: getPasswordStore(): password store initialization failure:" + e.toString());
+ if (pwdClass != null) {
+ try {
+ mPasswordStore = (IPasswordStore) Class.forName(pwdClass).newInstance();
+ } catch (Exception e) {
+ CMS.debug("CMSEngine: getPasswordStore(): password store initialization failure:" + e.toString());
+ }
+ }
+ } else {
+ CMS.debug("CMSEngine: getPasswordStore(): password store initialized before.");
}
- }
- } else {
- CMS.debug("CMSEngine: getPasswordStore(): password store initialized before.");
- }
- // have to initialize it because other places don't always
- mPasswordStore.init(pwdPath);
- CMS.debug("CMSEngine: getPasswordStore(): password store initialized.");
- } catch (Exception e) {
- CMS.debug("CMSEngine: getPasswordStore(): failure:" + e.toString());
- }
+ // have to initialize it because other places don't always
+ mPasswordStore.init(pwdPath);
+ CMS.debug("CMSEngine: getPasswordStore(): password store initialized.");
+ } catch (Exception e) {
+ CMS.debug("CMSEngine: getPasswordStore(): failure:" + e.toString());
+ }
- return mPasswordStore;
+ return mPasswordStore;
}
/**
* initialize all static, dynamic and final static subsystems.
+ *
* @param owner null
* @param config main config store.
- * @exception EBaseException if any error occur in subsystems during
- * initialization.
+ * @exception EBaseException if any error occur in subsystems during
+ * initialization.
*/
- public void init(ISubsystem owner, IConfigStore config)
- throws EBaseException {
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException {
mOwner = owner;
mConfig = config;
int state = mConfig.getInteger("cs.state");
@@ -362,10 +362,10 @@ public class CMSEngine implements ICMSEngine {
loadDynSubsystems();
java.security.Security.addProvider(
- new netscape.security.provider.CMS());
+ new netscape.security.provider.CMS());
mSSReg.put(ID, this);
- initSubsystems(mStaticSubsystems, false);
+ initSubsystems(mStaticSubsystems, false);
// Once the log subsystem is initialized, we
// want to register a listener to catch
@@ -378,7 +378,7 @@ public class CMSEngine implements ICMSEngine {
initSubsystems(mDynSubsystems, true);
initSubsystems(mFinalSubsystems, false);
- CMS.debug("Java version=" + (String)System.getProperty("java.version"));
+ CMS.debug("Java version=" + (String) System.getProperty("java.version"));
java.security.Provider ps[] = java.security.Security.getProviders();
if (ps == null || ps.length <= 0) {
@@ -394,8 +394,10 @@ public class CMSEngine implements ICMSEngine {
/**
* Parse ACL resource attributes
+ *
* @param resACLs same format as the resourceACLs attribute:
- * <PRE>
+ *
+ * <PRE>
* <resource name>:<permission1,permission2,...permissionn>:
* <allow|deny> (<subset of the permission set>) <evaluator expression>
* </PRE>
@@ -419,7 +421,7 @@ public class CMSEngine implements ICMSEngine {
if (resource == null) {
String infoMsg = "resource not specified in resourceACLS attribute:" +
- resACLs;
+ resACLs;
String[] params = new String[2];
@@ -437,7 +439,7 @@ public class CMSEngine implements ICMSEngine {
rightsString = st.substring(0, idx2);
else {
String infoMsg =
- "rights not specified in resourceACLS attribute:" + resACLs;
+ "rights not specified in resourceACLS attribute:" + resACLs;
String[] params = new String[2];
params[0] = resACLs;
@@ -486,7 +488,7 @@ public class CMSEngine implements ICMSEngine {
// fine
String infoMsg = "acls not specified in resourceACLS attribute:" +
- resACLs;
+ resACLs;
String[] params = new String[2];
@@ -510,24 +512,24 @@ public class CMSEngine implements ICMSEngine {
private void parseServerXML() {
try {
String instanceRoot = mConfig.getString("instanceRoot");
- String path = instanceRoot+File.separator+"conf"+File.separator+SERVER_XML;
+ String path = instanceRoot + File.separator + "conf" + File.separator + SERVER_XML;
DOMParser parser = new DOMParser();
parser.parse(path);
NodeList nodes = parser.getDocument().getElementsByTagName("Connector");
- String parentName="";
- String name="";
- String port="";
- for (int i=0; i<nodes.getLength(); i++) {
- Element n = (Element)nodes.item(i);
+ String parentName = "";
+ String name = "";
+ String port = "";
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Element n = (Element) nodes.item(i);
parentName = "";
Element p = (Element) n.getParentNode();
- if(p != null) {
- parentName = p.getAttribute("name");
+ if (p != null) {
+ parentName = p.getAttribute("name");
}
name = n.getAttribute("name");
port = n.getAttribute("port");
-
+
// The "server.xml" file is parsed from top-to-bottom, and
// supports BOTH "Port Separation" (the new default method)
// as well as "Shared Ports" (the old legacy method). Since
@@ -573,37 +575,37 @@ public class CMSEngine implements ICMSEngine {
// ...
// </Catalina>
//
- if ( parentName.equals("Catalina")) {
- if( name.equals( "Unsecure" ) ) {
+ if (parentName.equals("Catalina")) {
+ if (name.equals("Unsecure")) {
// Port Separation: Unsecure Port
// OR
// Shared Ports: Unsecure Port
info[EE_NON_SSL][PORT] = port;
- } else if( name.equals( "Agent" ) ) {
+ } else if (name.equals("Agent")) {
// Port Separation: Agent Secure Port
info[AGENT][PORT] = port;
- } else if( name.equals( "Admin" ) ) {
+ } else if (name.equals("Admin")) {
// Port Separation: Admin Secure Port
info[ADMIN][PORT] = port;
- } else if( name.equals( "EE" ) ) {
+ } else if (name.equals("EE")) {
// Port Separation: EE Secure Port
info[EE_SSL][PORT] = port;
- } else if( name.equals( "EEClientAuth" ) ) {
+ } else if (name.equals("EEClientAuth")) {
// Port Separation: EE Client Auth Secure Port
- info[EE_CLIENT_AUTH_SSL][PORT] = port;
- } else if( name.equals( "Secure" ) ) {
+ info[EE_CLIENT_AUTH_SSL][PORT] = port;
+ } else if (name.equals("Secure")) {
// Shared Ports: Agent, EE, and Admin Secure Port
info[AGENT][PORT] = port;
info[ADMIN][PORT] = port;
info[EE_SSL][PORT] = port;
info[EE_CLIENT_AUTH_SSL][PORT] = port;
}
- }
- }
-
- } catch (Exception e) {
- CMS.debug("CMSEngine: parseServerXML exception: " + e.toString());
- }
+ }
+ }
+
+ } catch (Exception e) {
+ CMS.debug("CMSEngine: parseServerXML exception: " + e.toString());
+ }
}
private void fixProxyPorts() throws EBaseException {
@@ -623,24 +625,22 @@ public class CMSEngine implements ICMSEngine {
} catch (EBaseException e) {
CMS.debug("CMSEngine: fixProxyPorts exception: " + e.toString());
throw e;
- }
+ }
}
-
public IConfigStore createFileConfigStore(String path) throws EBaseException {
try {
- /* if the file is not there, create one */
- File f = new File(path);
- if (!f.exists()) {
- f.createNewFile();
- }
+ /* if the file is not there, create one */
+ File f = new File(path);
+ if (!f.exists()) {
+ f.createNewFile();
+ }
} catch (Exception e) {
}
-
return new FileConfigStore(path);
}
-
+
public IArgBlock createArgBlock() {
return new ArgBlock();
}
@@ -683,7 +683,7 @@ public class CMSEngine implements ICMSEngine {
}
public ICRLIssuingPointRecord createCRLIssuingPointRecord(String
- id, BigInteger crlNumber, Long crlSize, Date thisUpdate, Date nextUpdate) {
+ id, BigInteger crlNumber, Long crlSize, Date thisUpdate, Date nextUpdate) {
return new CRLIssuingPointRecord(id, crlNumber, crlSize, thisUpdate, nextUpdate);
}
@@ -777,17 +777,17 @@ public class CMSEngine implements ICMSEngine {
}
public IHttpConnection getHttpConnection(IRemoteAuthority authority,
- ISocketFactory factory) {
+ ISocketFactory factory) {
return new HttpConnection(authority, factory);
}
public IHttpConnection getHttpConnection(IRemoteAuthority authority,
- ISocketFactory factory, int timeout) {
+ ISocketFactory factory, int timeout) {
return new HttpConnection(authority, factory, timeout);
}
public IResender getResender(IAuthority authority, String nickname,
- IRemoteAuthority remote, int interval) {
+ IRemoteAuthority remote, int interval) {
return new Resender(authority, nickname, remote, interval);
}
@@ -795,31 +795,31 @@ public class CMSEngine implements ICMSEngine {
return new HttpPKIMessage();
}
- public ILdapConnInfo getLdapConnInfo(IConfigStore config)
- throws EBaseException, ELdapException {
+ public ILdapConnInfo getLdapConnInfo(IConfigStore config)
+ throws EBaseException, ELdapException {
return new LdapConnInfo(config);
}
- public LDAPSSLSocketFactoryExt getLdapJssSSLSocketFactory(
- String certNickname) {
+ public LDAPSSLSocketFactoryExt getLdapJssSSLSocketFactory(
+ String certNickname) {
return new LdapJssSSLSocketFactory(certNickname);
}
- public LDAPSSLSocketFactoryExt getLdapJssSSLSocketFactory() {
+ public LDAPSSLSocketFactoryExt getLdapJssSSLSocketFactory() {
return new LdapJssSSLSocketFactory();
}
- public ILdapAuthInfo getLdapAuthInfo() {
+ public ILdapAuthInfo getLdapAuthInfo() {
return new LdapAuthInfo();
}
- public ILdapConnFactory getLdapBoundConnFactory()
- throws ELdapException {
+ public ILdapConnFactory getLdapBoundConnFactory()
+ throws ELdapException {
return new LdapBoundConnFactory();
}
- public ILdapConnFactory getLdapAnonConnFactory()
- throws ELdapException {
+ public ILdapConnFactory getLdapAnonConnFactory()
+ throws ELdapException {
return new LdapAnonConnFactory();
}
@@ -843,8 +843,8 @@ public class CMSEngine implements ICMSEngine {
* initialize an array of subsystem info.
*/
private void initSubsystems(SubsystemInfo[] sslist, boolean doSetId)
- throws EBaseException {
- if (sslist == null)
+ throws EBaseException {
+ if (sslist == null)
return;
for (int i = 0; i < sslist.length; i++) {
initSubsystem(sslist[i], doSetId);
@@ -855,7 +855,7 @@ public class CMSEngine implements ICMSEngine {
* load dynamic subsystems
*/
private void loadDynSubsystems()
- throws EBaseException {
+ throws EBaseException {
IConfigStore ssconfig = mConfig.getSubStore(PROP_SUBSYSTEM);
// count number of dyn loaded subsystems.
@@ -863,26 +863,26 @@ public class CMSEngine implements ICMSEngine {
int nsubsystems = 0;
for (nsubsystems = 0; ssnames.hasMoreElements(); nsubsystems++)
- ssnames.nextElement();
+ ssnames.nextElement();
if (Debug.ON) {
Debug.trace(nsubsystems + " dyn subsystems loading..");
}
- if (nsubsystems == 0)
+ if (nsubsystems == 0)
return;
- // load dyn subsystems.
+ // load dyn subsystems.
mDynSubsystems = new SubsystemInfo[nsubsystems];
ssnames = ssconfig.getSubStoreNames();
for (int i = 0; i < mDynSubsystems.length; i++) {
- IConfigStore config =
- ssconfig.getSubStore(String.valueOf(i));
+ IConfigStore config =
+ ssconfig.getSubStore(String.valueOf(i));
String id = config.getString(PROP_ID);
String classname = config.getString(PROP_CLASS);
ISubsystem ss = null;
try {
ss = (ISubsystem) Class.forName(classname).newInstance();
- } catch (InstantiationException e) {
+ } catch (InstantiationException e) {
throw new EBaseException(
CMS.getUserMessage("CMS_BASE_LOAD_FAILED_1", id, e.toString()));
} catch (IllegalAccessException e) {
@@ -899,23 +899,22 @@ public class CMSEngine implements ICMSEngine {
public LDAPConnection getBoundConnection(String host, int port,
int version, LDAPSSLSocketFactoryExt fac, String bindDN,
- String bindPW) throws LDAPException
- {
- return new LdapBoundConnection(host, port, version, fac,
- bindDN, bindPW);
+ String bindPW) throws LDAPException {
+ return new LdapBoundConnection(host, port, version, fac,
+ bindDN, bindPW);
}
/**
- * initialize a subsystem
+ * initialize a subsystem
*/
- private void initSubsystem(SubsystemInfo ssinfo, boolean doSetId)
- throws EBaseException {
+ private void initSubsystem(SubsystemInfo ssinfo, boolean doSetId)
+ throws EBaseException {
String id = ssinfo.mId;
ISubsystem ss = ssinfo.mInstance;
IConfigStore ssConfig = mConfig.getSubStore(id);
CMS.debug("CMSEngine: initSubsystem id=" + id);
- if (doSetId)
+ if (doSetId)
ss.setId(id);
CMS.debug("CMSEngine: ready to init id=" + id);
ss.init(this, ssConfig);
@@ -924,8 +923,8 @@ public class CMSEngine implements ICMSEngine {
mSSReg.put(id, ss);
CMS.debug("CMSEngine: initialized " + id);
- if(id.equals("ca") || id.equals("ocsp") ||
- id.equals("kra") || id.equals("tks")) {
+ if (id.equals("ca") || id.equals("ocsp") ||
+ id.equals("kra") || id.equals("tks")) {
CMS.debug("CMSEngine::initSubsystem " + id + " Java subsytem about to calculate serverCertNickname. ");
// get SSL server nickname
IConfigStore serverCertStore = mConfig.getSubStore(id + "." + "sslserver");
@@ -933,12 +932,12 @@ public class CMSEngine implements ICMSEngine {
String nickName = serverCertStore.getString("nickname");
String tokenName = serverCertStore.getString("tokenname");
if (tokenName != null && tokenName.length() > 0 &&
- nickName != null && nickName.length() > 0) {
+ nickName != null && nickName.length() > 0) {
CMS.setServerCertNickname(tokenName, nickName);
- CMS.debug("Subsystem " + id + " init sslserver: tokenName:"+tokenName+" nickName:"+nickName);
+ CMS.debug("Subsystem " + id + " init sslserver: tokenName:" + tokenName + " nickName:" + nickName);
} else if (nickName != null && nickName.length() > 0) {
CMS.setServerCertNickname(nickName);
- CMS.debug("Subsystem " + id + " init sslserver: nickName:"+nickName);
+ CMS.debug("Subsystem " + id + " init sslserver: nickName:" + nickName);
} else {
CMS.debug("Subsystem " + id + " init error: SSL server certificate nickname is not available.");
}
@@ -954,6 +953,7 @@ public class CMSEngine implements ICMSEngine {
/**
* Starts up all subsystems. subsystems must be initialized.
+ *
* @exception EBaseException if any subsystem fails to startup.
*/
public void startup() throws EBaseException {
@@ -980,7 +980,7 @@ public class CMSEngine implements ICMSEngine {
CMS.debug("CMSEngine: checking certificate serial number ranges");
ca.getCertificateRepository().checkRanges();
- }
+ }
IKeyRecoveryAuthority kra = (IKeyRecoveryAuthority) getSubsystem("kra");
if ((kra != null) && !isPreOpMode()) {
@@ -997,10 +997,10 @@ public class CMSEngine implements ICMSEngine {
* @reason all subsystems are initialized and started.
*/
Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
- ILogger.LL_INFO, CMS.getLogMessage("SERVER_STARTUP"));
+ ILogger.LL_INFO, CMS.getLogMessage("SERVER_STARTUP"));
System.out.println(Constants.SERVER_STARTUP_MESSAGE);
isStarted = true;
-
+
}
public boolean isInRunningState() {
@@ -1010,31 +1010,31 @@ public class CMSEngine implements ICMSEngine {
public byte[] getPKCS7(Locale locale, IRequest req) {
try {
X509CertImpl cert = req.getExtDataInCert(
- IEnrollProfile.REQUEST_ISSUED_CERT);
+ IEnrollProfile.REQUEST_ISSUED_CERT);
if (cert == null)
return null;
-
+
ICertificateAuthority ca = (ICertificateAuthority)
- CMS.getSubsystem("ca");
+ CMS.getSubsystem("ca");
CertificateChain cachain = ca.getCACertChain();
X509Certificate[] cacerts = cachain.getChain();
X509CertImpl[] userChain = new X509CertImpl[cacerts.length + 1];
int m = 1, n = 0;
-
+
for (; n < cacerts.length; m++, n++) {
userChain[m] = (X509CertImpl) cacerts[n];
}
userChain[0] = cert;
PKCS7 p7 = new PKCS7(new AlgorithmId[0],
- new ContentInfo(new byte[0]),
- userChain,
- new SignerInfo[0]);
+ new ContentInfo(new byte[0]),
+ userChain,
+ new SignerInfo[0]);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
p7.encodeSignedData(bos);
- return bos.toByteArray();
+ return bos.toByteArray();
} catch (Exception e) {
return null;
}
@@ -1045,11 +1045,11 @@ public class CMSEngine implements ICMSEngine {
}
public void setServerCertNickname(String tokenName, String
- nickName) {
+ nickName) {
String newName = null;
if (tokenName.equals(Constants.PR_INTERNAL_TOKEN_NAME) ||
- tokenName.equalsIgnoreCase("Internal Key Storage Token"))
+ tokenName.equalsIgnoreCase("Internal Key Storage Token"))
newName = nickName;
else {
if (tokenName.equals("") && nickName.equals(""))
@@ -1062,83 +1062,83 @@ public class CMSEngine implements ICMSEngine {
public void setServerCertNickname(String newName) {
// modify server.xml
-/*
- String filePrefix = instanceDir + File.separator +
- "config" + File.separator;
- String orig = filePrefix + "server.xml";
- String dest = filePrefix + "server.xml.bak";
- String newF = filePrefix + "server.xml.new";
-
- // save the old copy
- Utils.copy(orig, dest);
-
- BufferedReader in1 = null;
- PrintWriter out1 = null;
+ /*
+ String filePrefix = instanceDir + File.separator +
+ "config" + File.separator;
+ String orig = filePrefix + "server.xml";
+ String dest = filePrefix + "server.xml.bak";
+ String newF = filePrefix + "server.xml.new";
+
+ // save the old copy
+ Utils.copy(orig, dest);
+
+ BufferedReader in1 = null;
+ PrintWriter out1 = null;
+
+ try {
+ in1 = new BufferedReader(new FileReader(dest));
+ out1 = new PrintWriter(
+ new BufferedWriter(new FileWriter(newF)));
+ String line = "";
+
+ while (in1.ready()) {
+ line = in1.readLine();
+ if (line != null)
+ out1.println(lineParsing(line, newName));
+ }
- try {
- in1 = new BufferedReader(new FileReader(dest));
- out1 = new PrintWriter(
- new BufferedWriter(new FileWriter(newF)));
- String line = "";
-
- while (in1.ready()) {
- line = in1.readLine();
- if (line != null)
- out1.println(lineParsing(line, newName));
- }
+ out1.close();
+ in1.close();
+ } catch (Exception eee) {
+ Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
+ ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", eee.toString()));
+ }
- out1.close();
- in1.close();
- } catch (Exception eee) {
- Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
- ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", eee.toString()));
- }
+ File file = new File(newF);
+ File nfile = new File(orig);
- File file = new File(newF);
- File nfile = new File(orig);
+ try {
+ boolean success = file.renameTo(nfile);
- try {
- boolean success = file.renameTo(nfile);
-
- if (!success) {
- if (Utils.isNT()) {
- // NT is very picky on the path
- Utils.exec("copy " +
- file.getAbsolutePath().replace('/', '\\') + " " +
- nfile.getAbsolutePath().replace('/', '\\'));
- } else {
- Utils.exec("cp " + file.getAbsolutePath() + " " +
- nfile.getAbsolutePath());
+ if (!success) {
+ if (Utils.isNT()) {
+ // NT is very picky on the path
+ Utils.exec("copy " +
+ file.getAbsolutePath().replace('/', '\\') + " " +
+ nfile.getAbsolutePath().replace('/', '\\'));
+ } else {
+ Utils.exec("cp " + file.getAbsolutePath() + " " +
+ nfile.getAbsolutePath());
+ }
+ }
+ } catch (Exception exx) {
+ Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
+ ILogger.LL_FAILURE, "CMSEngine: Error " + exx.toString());
}
- }
- } catch (Exception exx) {
- Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
- ILogger.LL_FAILURE, "CMSEngine: Error " + exx.toString());
- }
- // update "cache" for CMS.getServerCertNickname()
-*/
+ // update "cache" for CMS.getServerCertNickname()
+ */
mServerCertNickname = newName;
}
public String getFingerPrint(Certificate cert)
- throws CertificateEncodingException, NoSuchAlgorithmException {
+ throws CertificateEncodingException, NoSuchAlgorithmException {
return CertUtils.getFingerPrint(cert);
}
public String getFingerPrints(Certificate cert)
- throws NoSuchAlgorithmException, CertificateEncodingException {
+ throws NoSuchAlgorithmException, CertificateEncodingException {
return CertUtils.getFingerPrints(cert);
}
public String getFingerPrints(byte[] certDer)
- throws NoSuchAlgorithmException {
+ throws NoSuchAlgorithmException {
return CertUtils.getFingerPrints(certDer);
}
public String getUserMessage(Locale locale, String msgID, String params[]) {
// if locale is null, try to get it out from session context
if (locale == null) {
- SessionContext sc = SessionContext.getExistingContext();
+ SessionContext sc = SessionContext.getExistingContext();
if (sc != null)
locale = (Locale) sc.get(SessionContext.LOCALE);
@@ -1177,8 +1177,8 @@ public class CMSEngine implements ICMSEngine {
return getUserMessage(locale, msgID, params);
}
- public String getUserMessage(Locale locale, String msgID,
- String p1, String p2, String p3) {
+ public String getUserMessage(Locale locale, String msgID,
+ String p1, String p2, String p3) {
String params[] = { p1, p2, p3 };
return getUserMessage(locale, msgID, params);
@@ -1197,7 +1197,7 @@ public class CMSEngine implements ICMSEngine {
}
public void debug(byte data[]) {
- if (!debugOn()) {
+ if (!debugOn()) {
// this helps to not saving stuff to file when debug
// is disable
return;
@@ -1206,7 +1206,7 @@ public class CMSEngine implements ICMSEngine {
}
public void debug(int level, String msg) {
- if (!debugOn()) {
+ if (!debugOn()) {
// this helps to not saving stuff to file when debug
// is disable
return;
@@ -1215,7 +1215,7 @@ public class CMSEngine implements ICMSEngine {
}
public void debug(String msg) {
- if (!debugOn()) {
+ if (!debugOn()) {
// this helps to not saving stuff to file when debug
// is disable
return;
@@ -1224,7 +1224,7 @@ public class CMSEngine implements ICMSEngine {
}
public void debug(Throwable e) {
- if (!debugOn()) {
+ if (!debugOn()) {
// this helps to not saving stuff to file when debug
// is disable
return;
@@ -1243,14 +1243,15 @@ public class CMSEngine implements ICMSEngine {
public void traceHashKey(String type, String key) {
Debug.traceHashKey(type, key);
}
+
public void traceHashKey(String type, String key, String val) {
Debug.traceHashKey(type, key, val);
}
+
public void traceHashKey(String type, String key, String val, String def) {
Debug.traceHashKey(type, key, val, def);
}
-
public String getLogMessage(String msgID) {
return getLogMessage(msgID, (String[]) null);
}
@@ -1309,67 +1310,67 @@ public class CMSEngine implements ICMSEngine {
return getLogMessage(msgID, params);
}
- public void getSubjAltNameConfigDefaultParams(String name,
- Vector<String> params) {
+ public void getSubjAltNameConfigDefaultParams(String name,
+ Vector<String> params) {
GeneralNameUtil.SubjAltNameGN.getDefaultParams(name, params);
}
- public void getSubjAltNameConfigExtendedPluginInfo(String name,
- Vector<String> params) {
+ public void getSubjAltNameConfigExtendedPluginInfo(String name,
+ Vector<String> params) {
GeneralNameUtil.SubjAltNameGN.getExtendedPluginInfo(name, params);
}
- public ISubjAltNameConfig createSubjAltNameConfig(String name, IConfigStore config, boolean isValueConfigured) throws EBaseException {
+ public ISubjAltNameConfig createSubjAltNameConfig(String name, IConfigStore config, boolean isValueConfigured) throws EBaseException {
return new GeneralNameUtil.SubjAltNameGN(name, config, isValueConfigured);
}
- public GeneralName form_GeneralNameAsConstraints(String generalNameChoice, String value) throws EBaseException {
+ public GeneralName form_GeneralNameAsConstraints(String generalNameChoice, String value) throws EBaseException {
return GeneralNameUtil.form_GeneralNameAsConstraints(generalNameChoice, value);
}
- public GeneralName form_GeneralName(String generalNameChoice,
- String value) throws EBaseException {
+ public GeneralName form_GeneralName(String generalNameChoice,
+ String value) throws EBaseException {
return GeneralNameUtil.form_GeneralName(generalNameChoice, value);
}
- public void getGeneralNameConfigDefaultParams(String name,
- boolean isValueConfigured, Vector<String> params) {
+ public void getGeneralNameConfigDefaultParams(String name,
+ boolean isValueConfigured, Vector<String> params) {
GeneralNameUtil.GeneralNameConfig.getDefaultParams(name, isValueConfigured, params);
}
- public void getGeneralNamesConfigDefaultParams(String name,
- boolean isValueConfigured, Vector<String> params) {
+ public void getGeneralNamesConfigDefaultParams(String name,
+ boolean isValueConfigured, Vector<String> params) {
GeneralNameUtil.GeneralNamesConfig.getDefaultParams(name, isValueConfigured, params);
}
- public void getGeneralNameConfigExtendedPluginInfo(String name,
- boolean isValueConfigured, Vector<String> info) {
+ public void getGeneralNameConfigExtendedPluginInfo(String name,
+ boolean isValueConfigured, Vector<String> info) {
GeneralNameUtil.GeneralNameConfig.getExtendedPluginInfo(name, isValueConfigured, info);
}
- public void getGeneralNamesConfigExtendedPluginInfo(String name,
- boolean isValueConfigured, Vector<String> info) {
+ public void getGeneralNamesConfigExtendedPluginInfo(String name,
+ boolean isValueConfigured, Vector<String> info) {
GeneralNameUtil.GeneralNamesConfig.getExtendedPluginInfo(name, isValueConfigured, info);
}
- public IGeneralNamesConfig createGeneralNamesConfig(String name,
- IConfigStore config, boolean isValueConfigured,
- boolean isPolicyEnabled) throws EBaseException {
+ public IGeneralNamesConfig createGeneralNamesConfig(String name,
+ IConfigStore config, boolean isValueConfigured,
+ boolean isPolicyEnabled) throws EBaseException {
return new GeneralNameUtil.GeneralNamesConfig(name, config, isValueConfigured, isPolicyEnabled);
}
- public IGeneralNameAsConstraintsConfig createGeneralNameAsConstraintsConfig(String name, IConfigStore config, boolean isValueConfigured,
- boolean isPolicyEnabled) throws EBaseException {
+ public IGeneralNameAsConstraintsConfig createGeneralNameAsConstraintsConfig(String name, IConfigStore config, boolean isValueConfigured,
+ boolean isPolicyEnabled) throws EBaseException {
return new GeneralNameUtil.GeneralNameAsConstraintsConfig(name, config, isValueConfigured, isPolicyEnabled);
}
- public IGeneralNamesAsConstraintsConfig createGeneralNamesAsConstraintsConfig(String name, IConfigStore config, boolean isValueConfigured,
- boolean isPolicyEnabled) throws EBaseException {
+ public IGeneralNamesAsConstraintsConfig createGeneralNamesAsConstraintsConfig(String name, IConfigStore config, boolean isValueConfigured,
+ boolean isPolicyEnabled) throws EBaseException {
return new GeneralNameUtil.GeneralNamesAsConstraintsConfig(name, config, isValueConfigured, isPolicyEnabled);
}
public ObjectIdentifier checkOID(String attrName, String value)
- throws EBaseException {
+ throws EBaseException {
return CertUtils.checkOID(attrName, value);
}
@@ -1383,10 +1384,9 @@ public class CMSEngine implements ICMSEngine {
public String getEncodedCert(X509Certificate cert) {
try {
- return
- "-----BEGIN CERTIFICATE-----\n" +
- CMS.BtoA(cert.getEncoded()) +
- "\n-----END CERTIFICATE-----\n";
+ return "-----BEGIN CERTIFICATE-----\n" +
+ CMS.BtoA(cert.getEncoded()) +
+ "\n-----END CERTIFICATE-----\n";
} catch (Exception e) {
return null;
}
@@ -1438,10 +1438,10 @@ public class CMSEngine implements ICMSEngine {
public IMailNotification getMailNotification() {
try {
- String className = mConfig.getString("notificationClassName",
+ String className = mConfig.getString("notificationClassName",
"com.netscape.cms.notification.MailNotification");
IMailNotification notification = (IMailNotification)
- Class.forName(className).newInstance();
+ Class.forName(className).newInstance();
return notification;
} catch (Exception e) {
@@ -1474,7 +1474,7 @@ public class CMSEngine implements ICMSEngine {
String className = mConfig.getString("passwordCheckerClass",
"com.netscape.cms.password.PasswordChecker");
IPasswordCheck check = (IPasswordCheck)
- Class.forName(className).newInstance();
+ Class.forName(className).newInstance();
return check;
} catch (Exception e) {
@@ -1493,8 +1493,8 @@ public class CMSEngine implements ICMSEngine {
/**
* starts up subsystems in a subsystem list..
*/
- private void startupSubsystems(SubsystemInfo[] sslist)
- throws EBaseException {
+ private void startupSubsystems(SubsystemInfo[] sslist)
+ throws EBaseException {
ISubsystem ss = null;
for (int i = 0; i < sslist.length; i++) {
@@ -1515,10 +1515,10 @@ public class CMSEngine implements ICMSEngine {
public void terminateRequests() {
Enumeration e = CommandQueue.mCommandQueue.keys();
-
+
while (e.hasMoreElements()) {
Object thisRequest = e.nextElement();
-
+
HttpServlet thisServlet = (HttpServlet) CommandQueue.mCommandQueue.get(thisRequest);
if (thisServlet != null) {
@@ -1527,6 +1527,7 @@ public class CMSEngine implements ICMSEngine {
}
}
}
+
public static boolean isNT() {
return (File.separator.equals("\\"));
}
@@ -1541,17 +1542,16 @@ public class CMSEngine implements ICMSEngine {
cmds = new String[3];
cmds[0] = "cmd";
cmds[1] = "/c";
- cmds[2] = instanceDir +"\\" + cmd;
+ cmds[2] = instanceDir + "\\" + cmd;
} else {
// UNIX
cmds = new String[3];
cmds[0] = "/bin/sh";
cmds[1] = "-c";
- cmds[2] = instanceDir +"/" +cmd;
+ cmds[2] = instanceDir + "/" + cmd;
}
- Process process = Runtime.getRuntime().exec(cmds);
-
+ Process process = Runtime.getRuntime().exec(cmds);
process.waitFor();
@@ -1561,38 +1561,39 @@ public class CMSEngine implements ICMSEngine {
}
} // end shutdownHttpServer
+
/**
- * Shuts down subsystems in backwards order
+ * Shuts down subsystems in backwards order
* exceptions are ignored. process exists at end to force exit.
*/
public void shutdown() {
Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
- ILogger.LL_INFO, Constants.SERVER_SHUTDOWN_MESSAGE);
+ ILogger.LL_INFO, Constants.SERVER_SHUTDOWN_MESSAGE);
CMS.debug("CMSEngine.shutdown()");
-
-/*
- CommandQueue commandQueue = new CommandQueue();
- Thread t1 = new Thread(commandQueue);
- t1.setDaemon(true);
- t1.start();
-
- // wait for command queue to emptied before proceeding to shutting down subsystems
- Date time = new Date();
- long startTime = time.getTime();
- long timeOut = time.getTime();
+ /*
+ CommandQueue commandQueue = new CommandQueue();
+ Thread t1 = new Thread(commandQueue);
- while (t1.isAlive() && ((timeOut - startTime) < (60 * 1000))) //wait for 1 minute
- {
- try {
- Thread.currentThread().sleep(5000); // sleep for 5 sec
- }catch (java.lang.InterruptedException e) {
- }
- timeOut = time.getTime();
- }
- terminateRequests();
-*/
+ t1.setDaemon(true);
+ t1.start();
+
+ // wait for command queue to emptied before proceeding to shutting down subsystems
+ Date time = new Date();
+ long startTime = time.getTime();
+ long timeOut = time.getTime();
+
+ while (t1.isAlive() && ((timeOut - startTime) < (60 * 1000))) //wait for 1 minute
+ {
+ try {
+ Thread.currentThread().sleep(5000); // sleep for 5 sec
+ }catch (java.lang.InterruptedException e) {
+ }
+ timeOut = time.getTime();
+ }
+ terminateRequests();
+ */
shutdownSubsystems(mFinalSubsystems);
shutdownSubsystems(mDynSubsystems);
@@ -1610,7 +1611,7 @@ public class CMSEngine implements ICMSEngine {
public void forceShutdown() {
Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_ADMIN,
- ILogger.LL_INFO, Constants.SERVER_SHUTDOWN_MESSAGE);
+ ILogger.LL_INFO, Constants.SERVER_SHUTDOWN_MESSAGE);
CMS.debug("CMSEngine.forceShutdown()");
@@ -1628,8 +1629,8 @@ public class CMSEngine implements ICMSEngine {
while (t1.isAlive() && ((timeOut - startTime) < (60 * 1000))) //wait for 1 minute
{
try {
- Thread.sleep(5000); // sleep for 5 sec
- }catch (java.lang.InterruptedException e) {
+ Thread.sleep(5000); // sleep for 5 sec
+ } catch (java.lang.InterruptedException e) {
}
timeOut = time.getTime();
}
@@ -1646,12 +1647,11 @@ public class CMSEngine implements ICMSEngine {
* shuts down a subsystem list in reverse order.
*/
private void shutdownSubsystems(SubsystemInfo[] sslist) {
- if (sslist == null)
+ if (sslist == null)
return;
for (int i = sslist.length - 1; i >= 0; i--) {
- if (sslist[i] != null && sslist[i].mInstance != null)
- {
+ if (sslist[i] != null && sslist[i].mInstance != null) {
sslist[i].mInstance.shutdown();
}
}
@@ -1678,7 +1678,7 @@ public class CMSEngine implements ICMSEngine {
} catch (EBaseException e) {
// intercept this for now -- don't want to change the callers
Logger.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SDR_ADD_ERROR", e.toString()));
+ ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SDR_ADD_ERROR", e.toString()));
}
}
@@ -1706,22 +1706,22 @@ public class CMSEngine implements ICMSEngine {
}
public static void upgradeConfig(IConfigStore c)
- throws EBaseException {
+ throws EBaseException {
String version = c.getString("cms.version", "pre4.2");
if (version.equals("4.22")) {
Upgrade.perform422to45(c);
- }else if (version.equals("4.2")) {
+ } else if (version.equals("4.2")) {
// SUPPORT UPGRADE FROM 4.2 to 4.2 (SP2)
Upgrade.perform42to422(c);
Upgrade.perform422to45(c);
} else {
// ONLY SUPPORT UPGRADE FROM 4.2 to 4.2 (SP2)
/**
- if (!version.equals("pre4.2"))
- return;
-
- Upgrade.perform(c);
+ * if (!version.equals("pre4.2"))
+ * return;
+ *
+ * Upgrade.perform(c);
**/
}
}
@@ -1752,10 +1752,10 @@ public class CMSEngine implements ICMSEngine {
try {
IRegistrationAuthority ra = (IRegistrationAuthority)
- SubsystemRegistry.getInstance().get("ra");
+ SubsystemRegistry.getInstance().get("ra");
if (ra != null) {
- queue = ra.getRequestQueue();
+ queue = ra.getRequestQueue();
}
} catch (Exception e) {
@@ -1787,8 +1787,8 @@ public class CMSEngine implements ICMSEngine {
result = mVCList.check(cert);
}
if (result != VerifiedCert.REVOKED &&
- result != VerifiedCert.NOT_REVOKED &&
- result != VerifiedCert.CHECKED) {
+ result != VerifiedCert.NOT_REVOKED &&
+ result != VerifiedCert.CHECKED) {
CertificateRepository certDB = (CertificateRepository) getCertDB();
@@ -1814,9 +1814,9 @@ public class CMSEngine implements ICMSEngine {
try {
checkRevReq = queue.newRequest(CertRequestConstants.GETREVOCATIONINFO_REQUEST);
checkRevReq.setExtData(IRequest.REQ_TYPE,
- CertRequestConstants.GETREVOCATIONINFO_REQUEST);
+ CertRequestConstants.GETREVOCATIONINFO_REQUEST);
checkRevReq.setExtData(IRequest.REQUESTOR_TYPE,
- IRequest.REQUESTOR_RA);
+ IRequest.REQUESTOR_RA);
X509CertImpl agentCerts[] = new X509CertImpl[certificates.length];
@@ -1864,12 +1864,11 @@ public class CMSEngine implements ICMSEngine {
}
private void log(int level, String msg) {
- Logger.getLogger().log(ILogger.EV_SYSTEM, null,
- ILogger.S_AUTHENTICATION, level, msg);
+ Logger.getLogger().log(ILogger.EV_SYSTEM, null,
+ ILogger.S_AUTHENTICATION, level, msg);
}
}
-
class WarningListener implements ILogEventListener {
private StringBuffer mSB = null;
@@ -1902,8 +1901,8 @@ class WarningListener implements ILogEventListener {
return null;
}
- public void init(ISubsystem owner, IConfigStore config)
- throws EBaseException {
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException {
}
public void startup() {
@@ -1911,7 +1910,7 @@ class WarningListener implements ILogEventListener {
/**
* Retrieve last "maxLine" number of system log with log lever >"level"
- * and from source "source". If the parameter is omitted. All entries
+ * and from source "source". If the parameter is omitted. All entries
* are sent back.
*/
public synchronized NameValuePairs retrieveLogContent(Hashtable req) throws ServletException,
@@ -1948,14 +1947,13 @@ class WarningListener implements ILogEventListener {
}
}
-
class SubsystemInfo {
public final String mId;
public final ISubsystem mInstance;
+
public SubsystemInfo(String id, ISubsystem ssInstance) {
mId = id;
mInstance = ssInstance;
}
-
-}
+}