From 29f10d8050e2e401780ec4642f9ea1a4837b4a2d Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Mon, 30 Apr 2012 13:30:34 -0400 Subject: Removed obsolete installation servlets --- base/common/src/CMakeLists.txt | 16 - .../servlet/csadmin/AdminAuthenticatePanel.java | 330 --------------------- .../servlet/csadmin/AgentAuthenticatePanel.java | 229 -------------- .../netscape/cms/servlet/csadmin/CAInfoPanel.java | 320 -------------------- .../cms/servlet/csadmin/CertPrettyPrintPanel.java | 210 ------------- .../cms/servlet/csadmin/ConfigBaseServlet.java | 121 -------- .../cms/servlet/csadmin/ConfigCertReqServlet.java | 50 ---- .../cms/servlet/csadmin/ConfigCloneServlet.java | 50 ---- .../cms/servlet/csadmin/ConfigDatabaseServlet.java | 196 ------------ .../cms/servlet/csadmin/ConfigHSMServlet.java | 298 ------------------- .../servlet/csadmin/ConfigImportCertServlet.java | 50 ---- .../cms/servlet/csadmin/ConfigJoinServlet.java | 182 ------------ .../cms/servlet/csadmin/ConfigRootCAServlet.java | 145 --------- .../cms/servlet/csadmin/ConfigurationUtils.java | 37 +++ .../cms/servlet/csadmin/DatabaseServlet.java | 49 --- .../cms/servlet/csadmin/DisplayServlet.java | 49 --- .../cms/servlet/csadmin/ModuleServlet.java | 90 ------ .../netscape/cms/servlet/csadmin/NamePanel.java | 2 +- .../cms/servlet/csadmin/WelcomeServlet.java | 49 --- .../cms/servlet/csadmin/WizardPanelBase.java | 269 +---------------- 20 files changed, 39 insertions(+), 2703 deletions(-) delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/AdminAuthenticatePanel.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/AgentAuthenticatePanel.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/CAInfoPanel.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/CertPrettyPrintPanel.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigBaseServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigCertReqServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigCloneServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigDatabaseServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigImportCertServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigJoinServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ConfigRootCAServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/DatabaseServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/DisplayServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/ModuleServlet.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/WelcomeServlet.java (limited to 'base') diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt index 3cfd3ba01..5cd55365d 100644 --- a/base/common/src/CMakeLists.txt +++ b/base/common/src/CMakeLists.txt @@ -592,7 +592,6 @@ set(pki-cms_java_SRCS com/netscape/cms/servlet/base/DisplayHtmlServlet.java com/netscape/cms/servlet/base/model/Link.java com/netscape/cms/servlet/csadmin/BaseServlet.java - com/netscape/cms/servlet/csadmin/ConfigCertReqServlet.java com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java com/netscape/cms/servlet/csadmin/SizePanel.java @@ -604,17 +603,10 @@ set(pki-cms_java_SRCS com/netscape/cms/servlet/csadmin/CheckIdentity.java com/netscape/cms/servlet/csadmin/UpdateNumberRange.java com/netscape/cms/servlet/csadmin/ConfigCertApprovalCallback.java - com/netscape/cms/servlet/csadmin/AgentAuthenticatePanel.java - com/netscape/cms/servlet/csadmin/ConfigRootCAServlet.java - com/netscape/cms/servlet/csadmin/ConfigJoinServlet.java com/netscape/cms/servlet/csadmin/AuthenticatePanel.java - com/netscape/cms/servlet/csadmin/ConfigCloneServlet.java com/netscape/cms/servlet/csadmin/ImportCAChainPanel.java - com/netscape/cms/servlet/csadmin/DisplayServlet.java com/netscape/cms/servlet/csadmin/DatabasePanel.java com/netscape/cms/servlet/csadmin/WelcomePanel.java - com/netscape/cms/servlet/csadmin/DatabaseServlet.java - com/netscape/cms/servlet/csadmin/CAInfoPanel.java com/netscape/cms/servlet/csadmin/GetTransportCert.java com/netscape/cms/servlet/csadmin/ImportTransportCert.java com/netscape/cms/servlet/csadmin/SessionTimer.java @@ -625,11 +617,8 @@ set(pki-cms_java_SRCS com/netscape/cms/servlet/csadmin/BackupKeyCertPanel.java com/netscape/cms/servlet/csadmin/TokenAuthenticate.java com/netscape/cms/servlet/csadmin/SecurityDomainLogin.java - com/netscape/cms/servlet/csadmin/ConfigDatabaseServlet.java - com/netscape/cms/servlet/csadmin/ConfigBaseServlet.java com/netscape/cms/servlet/csadmin/CertUtil.java com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java - com/netscape/cms/servlet/csadmin/ConfigImportCertServlet.java com/netscape/cms/servlet/csadmin/SecurityDomainSessionTable.java com/netscape/cms/servlet/csadmin/GetCertChain.java com/netscape/cms/servlet/csadmin/CreateSubsystemPanel.java @@ -637,18 +626,13 @@ set(pki-cms_java_SRCS com/netscape/cms/servlet/csadmin/UpdateOCSPConfig.java com/netscape/cms/servlet/csadmin/GetDomainXML.java com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java - com/netscape/cms/servlet/csadmin/AdminAuthenticatePanel.java - com/netscape/cms/servlet/csadmin/ModuleServlet.java com/netscape/cms/servlet/csadmin/GetCookie.java com/netscape/cms/servlet/csadmin/CertRequestPanel.java com/netscape/cms/servlet/csadmin/RegisterUser.java com/netscape/cms/servlet/csadmin/GetSubsystemCert.java - com/netscape/cms/servlet/csadmin/CertPrettyPrintPanel.java - com/netscape/cms/servlet/csadmin/WelcomeServlet.java com/netscape/cms/servlet/csadmin/LoginServlet.java com/netscape/cms/servlet/csadmin/AdminPanel.java com/netscape/cms/servlet/csadmin/RestoreKeyCertPanel.java - com/netscape/cms/servlet/csadmin/ConfigHSMServlet.java com/netscape/cms/servlet/csadmin/MainPageServlet.java com/netscape/cms/servlet/csadmin/HierarchyPanel.java com/netscape/cms/servlet/csadmin/DownloadPKCS12.java diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/AdminAuthenticatePanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/AdminAuthenticatePanel.java deleted file mode 100644 index 7921fc114..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/AdminAuthenticatePanel.java +++ /dev/null @@ -1,330 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.io.IOException; -import java.util.StringTokenizer; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.context.Context; -import org.mozilla.jss.CryptoManager; -import org.mozilla.jss.crypto.X509Certificate; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.certsrv.property.PropertySet; -import com.netscape.certsrv.util.HttpInput; -import com.netscape.cms.servlet.wizard.WizardServlet; - -public class AdminAuthenticatePanel extends WizardPanelBase { - - public AdminAuthenticatePanel() { - } - - /** - * Initializes this panel. - */ - public void init(ServletConfig config, int panelno) - throws ServletException { - setPanelNo(panelno); - setName("Admin Authentication"); - } - - public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) - throws ServletException { - setPanelNo(panelno); - setName("Admin Authentication"); - setId(id); - } - - public boolean isSubPanel() { - return true; - } - - /** - * Should we skip this panel for the configuration. - */ - public boolean shouldSkip() { - CMS.debug("AdminAuthenticatePanel: should skip"); - - IConfigStore cs = CMS.getConfigStore(); - // if we are root, no need to get the certificate chain. - - try { - String select = cs.getString("preop.subsystem.select", ""); - if (select.equals("new")) { - return true; - } - } catch (EBaseException e) { - } - - return false; - } - - public void cleanUp() throws IOException { - IConfigStore cs = CMS.getConfigStore(); - /* clean up if necessary */ - try { - @SuppressWarnings("unused") - boolean done = cs.getBoolean("preop.AdminAuthenticate.done"); // check for errors - cs.putBoolean("preop.AdminAuthenticate.done", false); - cs.commit(false); - } catch (Exception e) { - } - } - - public boolean isPanelDone() { - IConfigStore cs = CMS.getConfigStore(); - try { - String s = cs.getString("preop.AdminAuthenticate.done", ""); - if (s == null || s.equals("")) { - return false; - } else { - return true; - } - } catch (EBaseException e) { - } - return false; - } - - public PropertySet getUsage() { - PropertySet set = new PropertySet(); - - /* XXX */ - - return set; - } - - /** - * Display the panel. - */ - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - context.put("title", "Admin Authentication"); - IConfigStore config = CMS.getConfigStore(); - - if (isPanelDone()) { - - try { - String s = config.getString("preop.master.admin.uid", ""); - String type = config.getString("preop.subsystem.select", ""); - if (type.equals("clone")) - context.put("uid", s); - else - context.put("uid", ""); - } catch (Exception e) { - CMS.debug(e.toString()); - } - } else { - context.put("uid", ""); - } - - context.put("password", ""); - context.put("panel", "admin/console/config/adminauthenticatepanel.vm"); - context.put("errorString", ""); - } - - /** - * Checks if the given parameters are valid. - */ - public void validate(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - } - - /** - * Commit parameter changes - */ - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - IConfigStore config = CMS.getConfigStore(); - String subsystemtype = ""; - String cstype = ""; - try { - subsystemtype = config.getString("preop.subsystem.select", ""); - cstype = config.getString("cs.type", ""); - } catch (Exception e) { - } - cstype = cstype.toLowerCase(); - - if (subsystemtype.equals("clone")) { - CMS.debug("AdminAuthenticatePanel: this is the clone subsystem"); - String uid = HttpInput.getUID(request, "uid"); - if (uid == null) { - context.put("errorString", "Uid is empty"); - throw new IOException("Uid is empty"); - } - context.put("uid", uid); - String pwd = HttpInput.getPassword(request, "__password"); - config.putString("preop.master.admin.uid", uid); - config.putString("preop.master.admin.pwd", pwd); - String host = ""; - int httpsport = -1; - try { - host = config.getString("preop.master.hostname"); - } catch (Exception e) { - CMS.debug("AdminAuthenticatePanel update: " + e.toString()); - context.put("errorString", "Missing hostname for master"); - throw new IOException("Missing hostname"); - } - - try { - httpsport = config.getInteger("preop.master.httpsadminport"); - } catch (Exception e) { - CMS.debug("AdminAuthenticatePanel update: " + e.toString()); - context.put("errorString", "Missing port for master"); - throw new IOException("Missing port"); - } - - String list = ""; - try { - list = config.getString("preop.cert.list", ""); - } catch (Exception e) { - } - - StringBuffer c1 = new StringBuffer(); - StringBuffer s1 = new StringBuffer(); - - StringTokenizer tok = new StringTokenizer(list, ","); - while (tok.hasMoreTokens()) { - String t1 = tok.nextToken(); - c1.append(","); - c1.append("cloning."); - c1.append(t1); - c1.append(".nickname,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".dn,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".keytype,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".keyalgorithm,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".privkey.id,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".pubkey.exponent,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".pubkey.modulus,"); - c1.append("cloning."); - c1.append(t1); - c1.append(".pubkey.encoded"); - - if (s1.length() != 0) - s1.append(","); - - s1.append(cstype); - s1.append("."); - s1.append(t1); - } - - if (!cstype.equals("ca")) { - c1.append(",preop.ca.hostname,preop.ca.httpport,preop.ca.httpsport,preop.ca.list,preop.ca.pkcs7,preop.ca.type"); - } - s1.append(",internaldb,internaldb.ldapauth,internaldb.ldapconn"); - String content = - "uid=" + uid - + "&pwd=" + pwd - + "&op=get&names=cloning.module.token,instanceId," - + "internaldb.ldapauth.password,internaldb.replication.password" - + c1.toString() + "&substores=" + s1.toString(); - - boolean success = updateConfigEntries(host, httpsport, true, - "/" + cstype + "/admin/" + cstype + "/getConfigEntries", content, config, - response); - - try { - config.commit(false); - } catch (Exception ee) { - } - - if (!success) { - context.put("errorString", "Failed to get configuration entries from the master"); - throw new IOException("Failed to get configuration entries from the master"); - } else { - boolean cloneReady = isCertdbCloned(request, context); - if (!cloneReady) { - CMS.debug("AdminAuthenticatePanel update: clone does not have all the certificates."); - context.put("errorString", "Make sure you have copied the certificate database over to the clone"); - throw new IOException("Clone is not ready"); - } - } - } else { - CMS.debug("AdminAuthentication update: no authentication is required."); - } - - config.putBoolean("preop.AdminAuthenticate.done", true); - try { - config.commit(false); - } catch (EBaseException e) { - } - } - - /** - * If validiate() returns false, this method will be called. - */ - public void displayError(HttpServletRequest request, - HttpServletResponse response, - Context context) { - context.put("title", "Admin Authentication"); - context.put("password", ""); - context.put("panel", "admin/console/config/adminauthenticatepanel.vm"); - } - - private boolean isCertdbCloned(HttpServletRequest request, - Context context) { - IConfigStore config = CMS.getConfigStore(); - String certList = ""; - try { - CryptoManager cm = CryptoManager.getInstance(); - certList = config.getString("preop.cert.list"); - StringTokenizer st = new StringTokenizer(certList, ","); - while (st.hasMoreTokens()) { - String token = st.nextToken(); - String tokenname = config.getString("preop.module.token", ""); - cm.getTokenByName(tokenname); // throw exception on error - String name1 = "preop.master." + token + ".nickname"; - String nickname = config.getString(name1, ""); - if (!tokenname.equals("Internal Key Storage Token") && - !tokenname.equals("internal")) - nickname = tokenname + ":" + nickname; - - CMS.debug("AdminAuthenticatePanel isCertdbCloned: " + nickname); - X509Certificate cert = cm.findCertByNickname(nickname); - if (cert == null) - return false; - } - } catch (Exception e) { - context.put("errorString", "Check your CS.cfg for cloning"); - return false; - } - - return true; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/AgentAuthenticatePanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/AgentAuthenticatePanel.java deleted file mode 100644 index c1e6bffd1..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/AgentAuthenticatePanel.java +++ /dev/null @@ -1,229 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.io.IOException; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.certsrv.property.PropertySet; -import com.netscape.certsrv.util.HttpInput; -import com.netscape.cms.servlet.wizard.WizardServlet; - -public class AgentAuthenticatePanel extends WizardPanelBase { - - public AgentAuthenticatePanel() { - } - - /** - * Initializes this panel. - */ - public void init(ServletConfig config, int panelno) - throws ServletException { - setPanelNo(panelno); - setName("Agent Authentication"); - } - - public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) - throws ServletException { - setPanelNo(panelno); - setName("Agent Authentication"); - setId(id); - } - - public boolean isSubPanel() { - return true; - } - - /** - * Should we skip this panel for the configuration. - */ - public boolean shouldSkip() { - CMS.debug("DisplayCertChainPanel: should skip"); - - IConfigStore cs = CMS.getConfigStore(); - // if we are root, no need to get the certificate chain. - - try { - String select = cs.getString("securitydomain.select", ""); - if (select.equals("new")) { - return true; - } - - String catype = cs.getString("preop.ca.type", ""); - if (catype.equals("otherca")) - return true; - } catch (EBaseException e) { - } - - return false; - } - - public void cleanUp() throws IOException { - IConfigStore cs = CMS.getConfigStore(); - cs.putString("preop.ca.agent.uid", ""); - } - - public boolean isPanelDone() { - IConfigStore cs = CMS.getConfigStore(); - try { - String s = cs.getString("preop.ca.agent.uid", ""); - if (s == null || s.equals("")) { - return false; - } else { - return true; - } - } catch (EBaseException e) { - } - return false; - } - - public PropertySet getUsage() { - PropertySet set = new PropertySet(); - - /* XXX */ - - return set; - } - - /** - * Display the panel. - */ - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - context.put("title", "Agent Authentication"); - IConfigStore config = CMS.getConfigStore(); - - if (isPanelDone()) { - - try { - String s = config.getString("preop.ca.agent.uid", ""); - String type = config.getString("preop.hierarchy.select", ""); - if (type.equals("root")) - context.put("uid", ""); - else - context.put("uid", s); - } catch (Exception e) { - CMS.debug(e.toString()); - } - } else { - context.put("uid", ""); - } - - context.put("password", ""); - context.put("panel", "admin/console/config/agentauthenticatepanel.vm"); - context.put("errorString", ""); - } - - /** - * Checks if the given parameters are valid. - */ - public void validate(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - } - - /** - * Commit parameter changes - */ - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - IConfigStore config = CMS.getConfigStore(); - context.put("panel", "admin/console/config/agentauthenticatepanel.vm"); - context.put("title", "Agent Authentication"); - String type = ""; - String catype = ""; - try { - type = config.getString("preop.hierarchy.select", ""); - catype = config.getString("preop.ca.type", ""); - } catch (Exception e) { - } - - if (type.equals("root")) { - CMS.debug("AgentAuthenticatePanel: This is root, no need for authentication"); - } else if (catype.equals("sdca")) { - CMS.debug("AgentAuthenticatePanel: This is not external CA"); - String uid = HttpInput.getUID(request, "uid"); - if (uid == null) { - context.put("errorString", "Uid is empty"); - throw new IOException("Uid is empty"); - } - context.put("uid", uid); - String pwd = HttpInput.getPassword(request, "__password"); - config.putString("preop.ca.agent.uid", uid); - config.putString("preop.ca.agent.pwd", pwd); - - /* - String host = ""; - int httpsport = -1; - - try { - host = config.getString("preop.ca.hostname"); - } catch (Exception e) { - CMS.debug("AgentAuthenticatePanel update: " + e.toString()); - context.put("errorString", "Missing hostname"); - throw new IOException("Missing hostname"); - } - - try { - httpsport = config.getInteger("preop.ca.httpsport"); - } catch (Exception e) { - CMS.debug("AgentAuthenticatePanel update: " + e.toString()); - context.put("errorString", "Missing port"); - throw new IOException("Missing port"); - } - - // Bugzilla Bug #583825 - CC: Obsolete servlets to be removed from - // web.xml as part of CC interface review - boolean authenticated = authenticate(host, httpsport, true, - "/ca/ee/ca/checkIdentity", "uid="+uid+"&pwd="+pwd); - - if (!authenticated) { - context.put("errorString", "Wrong user id or password"); - throw new IOException("Wrong user id or password"); - } - */ - - try { - config.commit(false); - } catch (EBaseException e) { - } - } - } - - /** - * If validiate() returns false, this method will be called. - */ - public void displayError(HttpServletRequest request, - HttpServletResponse response, - Context context) { - context.put("password", ""); - context.put("title", "Agent Authentication"); - context.put("panel", "admin/console/config/agentauthenticatepanel.vm"); - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/CAInfoPanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/CAInfoPanel.java deleted file mode 100644 index ab284f3c6..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/CAInfoPanel.java +++ /dev/null @@ -1,320 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.io.IOException; -import java.net.URL; -import java.security.cert.CertificateEncodingException; -import java.util.StringTokenizer; -import java.util.Vector; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.certsrv.base.ISubsystem; -import com.netscape.certsrv.ca.ICertificateAuthority; -import com.netscape.certsrv.property.PropertySet; -import com.netscape.cms.servlet.wizard.WizardServlet; - -public class CAInfoPanel extends WizardPanelBase { - - public CAInfoPanel() { - } - - /** - * Initializes this panel. - */ - public void init(ServletConfig config, int panelno) - throws ServletException { - setPanelNo(panelno); - setName("CA Information"); - } - - public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) - throws ServletException { - setPanelNo(panelno); - setName("CA Information"); - setId(id); - } - - public void cleanUp() throws IOException { - IConfigStore cs = CMS.getConfigStore(); - cs.putString("preop.ca.type", ""); - } - - public boolean shouldSkip() { - IConfigStore cs = CMS.getConfigStore(); - try { - String s = cs.getString("preop.subsystem.select", ""); - if (s.equals("clone")) - return true; - } catch (Exception e) { - } - return false; - } - - public boolean isPanelDone() { - IConfigStore cs = CMS.getConfigStore(); - try { - String s = cs.getString("preop.ca.type", ""); - if (s == null || s.equals("")) { - return false; - } else { - return true; - } - } catch (Exception e) { - } - - return false; - } - - public PropertySet getUsage() { - PropertySet set = new PropertySet(); - - return set; - } - - /** - * Display the panel. - */ - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - CMS.debug("CAInfoPanel: display"); - - IConfigStore cs = CMS.getConfigStore(); - String hostname = ""; - String httpport = ""; - String httpsport = ""; - - if (isPanelDone()) { - String type = "sdca"; - - try { - type = cs.getString("preop.ca.type"); - } catch (Exception e) { - CMS.debug("CAInfoPanel exception: " + e.toString()); - return; - } - - try { - hostname = cs.getString("preop.ca.hostname"); - } catch (Exception e) { - } - - try { - httpport = cs.getString("preop.ca.httpport"); - } catch (Exception e) { - } - - try { - httpsport = cs.getString("preop.ca.httpsport"); - } catch (Exception e) { - } - - if (type.equals("sdca")) { - context.put("check_sdca", "checked"); - context.put("check_otherca", ""); - } else if (type.equals("otherca")) { - context.put("check_sdca", ""); - context.put("check_otherca", "checked"); - } - } else { - context.put("check_sdca", "checked"); - context.put("check_otherca", ""); - } - - String cstype = "CA"; - String portType = "SecurePort"; - - CMS.debug("CAInfoPanel: Ready to get url"); - Vector v = null; - try { - v = ConfigurationUtils.getUrlListFromSecurityDomain(cs, cstype, portType); - } catch (Exception e) { - CMS.debug("CAInfoPanel display(): errors in getting URL list from security domain" + e); - e.printStackTrace(); - } - if (v == null) { - v = new Vector(); - } - - v.addElement("External CA"); - StringBuffer list = new StringBuffer(); - int size = v.size(); - - for (int i = 0; i < size; i++) { - if (i == size - 1) { - list.append(v.elementAt(i)); - } else { - list.append(v.elementAt(i)); - list.append(","); - } - } - - try { - cs.putString("preop.ca.list", list.toString()); - cs.commit(false); - } catch (Exception e) { - } - - context.put("urls", v); - - context.put("sdcaHostname", hostname); - context.put("sdcaHttpPort", httpport); - context.put("sdcaHttpsPort", httpsport); - context.put("title", "CA Information"); - context.put("panel", "admin/console/config/cainfopanel.vm"); - context.put("errorString", ""); - } - - /** - * Checks if the given parameters are valid. - */ - public void validate(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - } - - /** - * Commit parameter changes - */ - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - IConfigStore config = CMS.getConfigStore(); - - try { - String subsystemselect = config.getString("preop.subsystem.select", ""); - if (subsystemselect.equals("clone")) - return; - - String select = null; - String index = request.getParameter("urls"); - String url = ""; - if (index.startsWith("http")) { - // user may submit url directly - url = index; - } else { - int x = Integer.parseInt(index); - String list = config.getString("preop.ca.list", ""); - StringTokenizer tokenizer = new StringTokenizer(list, ","); - int counter = 0; - - while (tokenizer.hasMoreTokens()) { - url = tokenizer.nextToken(); - if (counter == x) { - break; - } - counter++; - } - } - - URL urlx = null; - - if (url.equals("External CA")) { - select = "otherca"; - config.putString("preop.ca.pkcs7", ""); - config.putInteger("preop.ca.certchain.size", 0); - } else { - select = "sdca"; - - // parse URL (CA1 - https://...) - url = url.substring(url.indexOf("https")); - urlx = new URL(url); - } - - ISubsystem subsystem = CMS.getSubsystem(ICertificateAuthority.ID); - - if (select.equals("sdca")) { - config.putString("preop.ca.type", "sdca"); - CMS.debug("CAInfoPanel update: this is the CA in the security domain."); - context.put("check_sdca", "checked"); - sdca(request, context, urlx.getHost(), - Integer.toString(urlx.getPort())); - if (subsystem != null) { - config.putString(PCERT_PREFIX + "signing.type", "remote"); - config.putString(PCERT_PREFIX + "signing.profile", - "caInstallCACert"); - } - } else if (select.equals("otherca")) { - config.putString("preop.ca.type", "otherca"); - context.put("check_otherca", "checked"); - if (subsystem != null) { - config.putString(PCERT_PREFIX + "signing.type", "remote"); - } - CMS.debug("CAInfoPanel update: this is the other CA."); - } - - config.commit(false); - } catch (Exception e) { - CMS.debug("CAInfoPanel update(): Exception thrown " + e); - e.printStackTrace(); - context.put("updateStatus", "failure"); - } - context.put("updateStatus", "success"); - } - - private void sdca(HttpServletRequest request, Context context, String hostname, String httpsPortStr) - throws IOException, CertificateEncodingException, EBaseException { - CMS.debug("CAInfoPanel update: this is the CA in the security domain."); - IConfigStore config = CMS.getConfigStore(); - - context.put("sdcaHostname", hostname); - context.put("sdcaHttpsPort", httpsPortStr); - - if (hostname == null || hostname.length() == 0) { - context.put("errorString", "Hostname is null"); - throw new IOException("Hostname is null"); - } - - int httpsport = -1; - try { - httpsport = Integer.parseInt(httpsPortStr); - } catch (Exception e) { - CMS.debug("CAInfoPanel update: Https port is not valid. Exception: " + e.toString()); - throw new IOException("Http Port is not valid."); - } - - config.putString("preop.ca.hostname", hostname); - config.putString("preop.ca.httpsport", httpsPortStr); - ConfigCertApprovalCallback certApprovalCallback = new ConfigCertApprovalCallback(); - updateCertChainUsingSecureEEPort(config, "ca", hostname, - httpsport, true, context, - certApprovalCallback); - } - - /** - * If validate() returns false, this method will be called. - */ - public void displayError(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - /* This should never be called */ - context.put("title", "CA Information"); - context.put("panel", "admin/console/config/cainfopanel.vm"); - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/CertPrettyPrintPanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/CertPrettyPrintPanel.java deleted file mode 100644 index 9c4315c05..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/CertPrettyPrintPanel.java +++ /dev/null @@ -1,210 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.io.IOException; -import java.util.Locale; -import java.util.StringTokenizer; -import java.util.Vector; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import netscape.security.util.CertPrettyPrint; - -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.certsrv.property.PropertySet; -import com.netscape.cms.servlet.wizard.WizardServlet; -import com.netscape.cmsutil.crypto.CryptoUtil; - -public class CertPrettyPrintPanel extends WizardPanelBase { - private Vector mCerts = null; - - public CertPrettyPrintPanel() { - } - - /** - * Initializes this panel. - */ - public void init(ServletConfig config, int panelno) - throws ServletException { - setPanelNo(panelno); - setName("Certificates"); - } - - public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) - throws ServletException { - setPanelNo(panelno); - setName("Certificates"); - setId(id); - } - - public PropertySet getUsage() { - // expects no input from client - PropertySet set = new PropertySet(); - - return set; - } - - public void cleanUp() throws IOException { - IConfigStore cs = CMS.getConfigStore(); - cs.putBoolean("preop.CertPrettyPrintPanel.done", false); - } - - public boolean isPanelDone() { - IConfigStore cs = CMS.getConfigStore(); - try { - boolean s = cs.getBoolean("preop.CertPrettyPrintPanel.done", - false); - - if (s != true) { - return false; - } else { - return true; - } - } catch (EBaseException e) { - } - - return false; - } - - public void getCert(HttpServletRequest req, IConfigStore config, - Context context, String certTag, Cert cert) { - CMS.debug("CertPrettyPrintPanel: in getCert()"); - try { - // String cert = config.getString(CONF_CA_CERT); - String subsystem = config.getString(PCERT_PREFIX + certTag + ".subsystem"); - String certs = config.getString(subsystem + "." + certTag + ".cert"); - byte[] certb = CryptoUtil.base64Decode(certs); - - if (cert != null) { - CertPrettyPrint pp = new CertPrettyPrint(certb); - cert.setCertpp(pp.toString(Locale.getDefault())); - String certf = CryptoUtil.certFormat(certs); - - // String canickname = config.getString(CONF_CA_CERTNICKNAME); - // context.put("cert", certf); - // context.put("nickname", nickname); - cert.setCert(certf); - } - } catch (Exception e) { - CMS.debug("CertPrettyPrintPanel:getCert" + e.toString()); - } // try - } - - /** - * Display the panel. - */ - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - CMS.debug("CertPrettyPrintPanel: display()"); - context.put("title", "Certificates Pretty Print"); - - try { - mCerts = new Vector(); - - IConfigStore config = CMS.getConfigStore(); - - String certTags = config.getString("preop.cert.list"); - StringTokenizer st = new StringTokenizer(certTags, ","); - - while (st.hasMoreTokens()) { - String certTag = st.nextToken(); - - try { - String subsystem = config.getString( - PCERT_PREFIX + certTag + ".subsystem"); - - String nickname = config.getString( - subsystem + "." + certTag + ".nickname"); - String tokenname = config.getString( - subsystem + "." + certTag + ".tokenname"); - Cert c = new Cert(tokenname, nickname, certTag); - - String type = config.getString( - PCERT_PREFIX + certTag + ".type"); - - c.setType(type); - getCert(request, config, context, certTag, c); - - mCerts.addElement(c); - } catch (Exception e) { - CMS.debug( - "CertPrettyPrintPanel: display() certTag " + certTag - + " Exception caught: " + e.toString()); - } - } - } catch (Exception e) { - CMS.debug( - "CertPrettyPrintPanel:display() Exception caught: " - + e.toString()); - System.err.println("Exception caught: " + e.toString()); - - } // try - - context.put("ppcerts", mCerts); - context.put("status", "display"); - // context.put("status_token", "None"); - context.put("panel", "admin/console/config/certprettyprintpanel.vm"); - - } - - /** - * Checks if the given parameters are valid. - */ - public void validate(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - } - - /** - * Commit parameter changes - */ - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) throws IOException { - CMS.debug("CertPrettyPrintPanel: in update()"); - IConfigStore config = CMS.getConfigStore(); - config.putBoolean("preop.CertPrettyPrintPanel.done", true); - try { - config.commit(false); - } catch (EBaseException e) { - CMS.debug( - "CertPrettyPrintPanel: update() Exception caught at config commit: " - + e.toString()); - } - } - - /** - * If validiate() returns false, this method will be called. - */ - public void displayError(HttpServletRequest request, - HttpServletResponse response, - Context context) { - context.put("title", "Certificates Pretty Print"); - context.put("panel", "admin/console/config/certprettyprintpanel.vm"); - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigBaseServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigBaseServlet.java deleted file mode 100644 index 41249fa97..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigBaseServlet.java +++ /dev/null @@ -1,121 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.util.Enumeration; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; - -public abstract class ConfigBaseServlet extends BaseServlet { - /** - * - */ - private static final long serialVersionUID = 7692352201878710530L; - - public boolean isDisplayMode(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String display = request.getParameter("display"); - - if (display == null) { - return true; - } else { - return false; - } - } - - public abstract void display(HttpServletRequest request, - HttpServletResponse response, Context context); - - public abstract void update(HttpServletRequest request, - HttpServletResponse response, Context context); - - public abstract Template getTemplate(HttpServletRequest request, - HttpServletResponse response, - Context context); - - public void outputHttpParameters(HttpServletRequest httpReq) { - CMS.debug("ConfigBaseServlet:service() uri = " + httpReq.getRequestURI()); - @SuppressWarnings("unchecked") - Enumeration paramNames = httpReq.getParameterNames(); - - while (paramNames.hasMoreElements()) { - String pn = paramNames.nextElement(); - // added this facility so that password can be hidden, - // all sensitive parameters should be prefixed with - // __ (double underscores); however, in the event that - // a security parameter slips through, we perform multiple - // additional checks to insure that it is NOT displayed - if (pn.startsWith("__") || - pn.endsWith("password") || - pn.endsWith("passwd") || - pn.endsWith("pwd") || - pn.equalsIgnoreCase("admin_password_again") || - pn.equalsIgnoreCase("directoryManagerPwd") || - pn.equalsIgnoreCase("bindpassword") || - pn.equalsIgnoreCase("bindpwd") || - pn.equalsIgnoreCase("passwd") || - pn.equalsIgnoreCase("password") || - pn.equalsIgnoreCase("pin") || - pn.equalsIgnoreCase("pwd") || - pn.equalsIgnoreCase("pwdagain") || - pn.equalsIgnoreCase("uPasswd")) { - CMS.debug("ConfigBaseServlet::service() param name='" + pn + - "' value='(sensitive)'"); - } else { - CMS.debug("ConfigBaseServlet::service() param name='" + pn + - "' value='" + httpReq.getParameter(pn) + "'"); - } - } - } - - /** - * Processes request. - */ - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - if (CMS.debugOn()) { - outputHttpParameters(request); - } - - if (isDisplayMode(request, response, context)) { - display(request, response, context); - } else { - update(request, response, context); - } - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = getTemplate(request, response, context); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCertReqServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCertReqServlet.java deleted file mode 100644 index b04de4144..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCertReqServlet.java +++ /dev/null @@ -1,50 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class ConfigCertReqServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = 4489288758636916446L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = Velocity.getTemplate( - "admin/console/config/config_certreq.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCloneServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCloneServlet.java deleted file mode 100644 index ed1d9cc07..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigCloneServlet.java +++ /dev/null @@ -1,50 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class ConfigCloneServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = -9065299591659111350L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = Velocity.getTemplate( - "admin/console/config/config_clone.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigDatabaseServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigDatabaseServlet.java deleted file mode 100644 index 2b4a82a08..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigDatabaseServlet.java +++ /dev/null @@ -1,196 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.IConfigStore; - -public class ConfigDatabaseServlet extends ConfigBaseServlet { - - /** - * - */ - private static final long serialVersionUID = 2625626176089893989L; - private static final String HOST = "localhost"; - private static final String PORT = "389"; - private static final String BASEDN = "o=netscapeCertificateServer"; - private static final String BINDDN = "cn=Directory Manager"; - private static final String DATABASE = "userRoot"; - - public boolean isPanelModified() { - IConfigStore cs = CMS.getConfigStore(); - String modified = ""; - - try { - modified = cs.getString("preop.configDatabase.modified", ""); - } catch (Exception e) { - } - - if (modified.equals("true")) { - return true; - } else { - return false; - } - } - - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String hostname = null; - String portStr = null; - String basedn = null; - String binddn = null; - String bindpwd = ""; - String database = null; - - IConfigStore cs = CMS.getConfigStore(); - - if (isPanelModified()) { - try { - hostname = cs.getString("internaldb.ldapconn.host", ""); - portStr = cs.getString("internaldb.ldapconn.port", ""); - basedn = cs.getString("internaldb.basedn", ""); - binddn = cs.getString("internaldb.ldapauth.bindDN", ""); - database = cs.getString("internaldb.database", ""); - } catch (Exception e) { - } - } else { - hostname = HOST; - portStr = PORT; - basedn = BASEDN; - binddn = BINDDN; - database = DATABASE; - } - - context.put("hostname", hostname); - context.put("portStr", portStr); - context.put("basedn", basedn); - context.put("binddn", binddn); - context.put("bindpwd", bindpwd); - context.put("database", database); - context.put("displayStr", "initial"); - context.put("errorString", ""); - } - - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) { - IConfigStore cs = CMS.getConfigStore(); - String errorString = ""; - String hostname = request.getParameter("host"); - - if (hostname != null && hostname.length() > 0) { - cs.putString("internaldb.ldapconn.host", hostname); - } else { - errorString = "Host is empty string"; - } - - String portStr = request.getParameter("port"); - - if (portStr != null && portStr.length() > 0) { - int port = -1; - - try { - port = Integer.parseInt(portStr); - cs.putInteger("internaldb.ldapconn.port", port); - } catch (Exception e) { - errorString = "Port is invalid"; - } - } else { - errorString = "Port is empty string"; - } - - String basedn = request.getParameter("basedn"); - - if (basedn != null && basedn.length() > 0) { - cs.putString("internaldb.basedn", basedn); - } else { - errorString = "Base DN is empty string"; - } - - String binddn = request.getParameter("binddn"); - - if (binddn != null && binddn.length() > 0) { - cs.putString("internaldb.ldapauth.bindDN", binddn); - } else { - errorString = "Bind DN is empty string"; - } - - String database = request.getParameter("database"); - - if (database != null && database.length() > 0) { - cs.putString("internaldb.database", database); - } else { - errorString = "Database is empty string"; - } - - String bindpwd = request.getParameter("__bindpwd"); - IConfigStore psStore = null; - - if (bindpwd != null && bindpwd.length() > 0) { - String passwordFile = null; - - try { - passwordFile = cs.getString("passwordFile"); - psStore = CMS.createFileConfigStore(passwordFile); - } catch (Exception e) { - CMS.debug("ConfigDatabaseServlet update: " + e.toString()); - return; - } - psStore.putString("internaldb", bindpwd); - } else { - errorString = "Bind password is empty string"; - } - - cs.putString("preop.configDatabase.modified", "true"); - if (errorString.equals("")) { - try { - psStore.commit(false); - cs.commit(false); - } catch (Exception e) { - CMS.debug("ConfigDatabaseServlet update: " + e.toString()); - } - } - - context.put("hostname", hostname); - context.put("portStr", portStr); - context.put("basedn", basedn); - context.put("binddn", binddn); - context.put("bindpwd", bindpwd); - context.put("database", database); - context.put("displayStr", "loaded"); - context.put("errorString", errorString); - } - - public Template getTemplate(HttpServletRequest request, - HttpServletResponse response, - Context context) { - try { - return Velocity.getTemplate("admin/console/config/config_db.vm"); - } catch (Exception e) { - } - return null; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMServlet.java deleted file mode 100644 index 4854abc56..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMServlet.java +++ /dev/null @@ -1,298 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; -import org.mozilla.jss.CryptoManager; -import org.mozilla.jss.crypto.CryptoToken; -import org.mozilla.jss.crypto.TokenException; -import org.mozilla.jss.pkcs11.PK11Module; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.cmsutil.crypto.Module; - -public class ConfigHSMServlet extends ConfigBaseServlet { - /** - * - */ - private static final long serialVersionUID = -330521231753992202L; - private CryptoManager mCryptoManager = null; - private Vector mSupportedModules = null; - private Vector mOtherModules = null; - private String mDefaultTok = null; - private Hashtable mCurrModTable = new Hashtable(); - - @SuppressWarnings("deprecation") - public void init(ServletConfig config) throws ServletException { - super.init(config); - } - - public void loadCurrModTable() { - try { - // getting existing modules - mCryptoManager = CryptoManager.getInstance(); - @SuppressWarnings("unchecked") - Enumeration modules = mCryptoManager.getModules(); - - while (modules.hasMoreElements()) { - PK11Module mod = modules.nextElement(); - - CMS.debug("ConfigHSMServlet: got module " + mod.getName()); - mCurrModTable.put(mod.getName(), mod); - } // while - } catch (Exception e) { - CMS.debug( - "ConfigHSMServlet: Exception caught in loadCurrModTable: " - + e.toString()); - System.err.println("Exception caught: " + e.toString()); - } - } - - /* - * Modules not listed as supported modules - */ - public void loadOtherModules() { - Enumeration m = mCurrModTable.elements(); - - mOtherModules = new Vector(); - while (m.hasMoreElements()) { - PK11Module mod = m.nextElement(); - Enumeration s = mSupportedModules.elements(); - boolean found = false; - - while (s.hasMoreElements()) { - Module sm = s.nextElement(); - - if (mod.getName().equals(sm.getCommonName())) { - found = true; - break; - } else { - found = false; - } - }// while - if (!found) { - // unsupported, use common name as user friendly name - Module module = new Module(mod.getName(), mod.getName()); - - loadModTokens(module, mod); - module.setFound(true); - mOtherModules.addElement(module); - break; - } - }// while - } - - /* - * find all tokens belonging to a module and load the Module - */ - public void loadModTokens(Module module, PK11Module mod) { - @SuppressWarnings("unchecked") - Enumeration tokens = mod.getTokens(); - - while (tokens.hasMoreElements()) { - try { - CryptoToken token = tokens.nextElement(); - - CMS.debug("ConfigHSMServlet: token nick name=" + token.getName()); - CMS.debug( - "ConfigHSMServlet: token logged in?" - + token.isLoggedIn()); - CMS.debug( - "ConfigHSMServlet: token is present?" - + token.isPresent()); - if (!token.getName().equals("Internal Crypto Services Token")) { - module.addToken(token); - } else { - CMS.debug( - "ConfigHSMServlet: token " + token.getName() - + " not to be added"); - } - - } catch (TokenException ex) { - CMS.debug("ConfigHSMServlet:" + ex.toString()); - } - } - } - - /* - * Modules unsupported by the system will not be included - */ - public void loadSupportedModules() { - - // getting supported security modules - // a Vectgor of Modules - mSupportedModules = new Vector(); - // read from conf store all supported modules - try { - int count = CMS.getConfigStore().getInteger( - "preop.configModules.count"); - - CMS.debug("ConfigHSMServlet: supported modules count= " + count); - for (int i = 0; i < count; i++) { - String cn = CMS.getConfigStore().getString( - "preop.configModules.module" + i + ".commonName"); - String pn = CMS.getConfigStore().getString( - "preop.configModules.module" + i + ".userFriendlyName"); - String img = CMS.getConfigStore().getString( - "preop.configModules.module" + i + ".imagePath"); - - if ((cn == null) || (cn.equals(""))) { - break; - } - - CMS.debug("ConfigHSMServlet: got from config module: " + cn); - // create a Module object - Module module = new Module(cn, pn, img); - - if (mCurrModTable.containsKey(cn)) { - CMS.debug("ConfigHSMServlet: module found: " + cn); - module.setFound(true); - // add token info to module vector - PK11Module m = mCurrModTable.get(cn); - - loadModTokens(module, m); - } - - CMS.debug("ConfigHSMServlet: adding module " + cn); - // add module to set - if (!mSupportedModules.contains(module)) { - mSupportedModules.addElement(module); - } - }// for - - } catch (Exception e) { - CMS.debug( - "ConfigHSMServlet: Exception caught in loadSupportedModules(): " - + e.toString()); - System.err.println("Exception caught: " + e.toString()); - } - } - - public boolean isDisplayMode(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String choice = request.getParameter("choice"); - - if (choice == null) { - return true; - } else { - return false; - } - } - - public boolean isPanelModified(IConfigStore cs) { - String modified = ""; - - try { - modified = cs.getString("preop.configModules.modified", ""); - } catch (Exception e) { - return false; - } - - if (modified.equals("true")) { - return true; - } else { - return false; - } - } - - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - CMS.debug("ConfigHSMServlet: in display()"); - - loadCurrModTable(); - loadSupportedModules(); - loadOtherModules(); - // getting default token selection - try { - mDefaultTok = CMS.getConfigStore().getString( - "preop.configModules.defaultTok", - "Internal Key Storage Token"); - } catch (Exception e) { - CMS.debug("ConfigHSMServlet: Exception caught: " + e.toString()); - System.err.println("Exception caught: " + e.toString()); - } - if (mSupportedModules == null) { - CMS.debug("ConfigHSMServlet: mSupportedModules not loaded"); - } else { - CMS.debug("ConfigHSMServlet: mSupportedModules loaded"); - } - - context.put("status", "display"); - context.put("oms", mOtherModules); - context.put("sms", mSupportedModules); - context.put("defTok", mDefaultTok); - } - - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - IConfigStore cs = CMS.getConfigStore(); - - CMS.debug("ConfigHSMServlet: in update()"); - - if (mSupportedModules == null) { - CMS.debug("ConfigHSMServlet: mSupportedModules not loaded"); - } else { - CMS.debug("ConfigHSMServlet: mSupportedModules loaded"); - } - - String select = request.getParameter("choice"); - - if (select == null) { - CMS.debug("ConfigHSMServlet: choice not found"); - // throw new IOException("choice not found"); - } - - try { - CMS.debug("ConfigHSMServlet: choice =" + select); - cs.putString("preop.configModules.defaultTok", select); - cs.commit(false); - } catch (Exception e) { - CMS.debug("ConfigHSMServlet: Exception caught: " + e.toString()); - System.err.println("Exception caught: " + e.toString()); - } - context.put("status", "update"); - context.put("error", ""); - - } - - public Template getTemplate(HttpServletRequest request, - HttpServletResponse response, - Context context) { - try { - return Velocity.getTemplate("admin/console/config/config_hsm.vm"); - } catch (Exception e) { - } - return null; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigImportCertServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigImportCertServlet.java deleted file mode 100644 index c65e559df..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigImportCertServlet.java +++ /dev/null @@ -1,50 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class ConfigImportCertServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = 1907102921734394118L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = Velocity.getTemplate( - "admin/console/config/config_importcert.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigJoinServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigJoinServlet.java deleted file mode 100644 index 5d50193cb..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigJoinServlet.java +++ /dev/null @@ -1,182 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.cmsutil.crypto.CryptoUtil; - -public class ConfigJoinServlet extends ConfigBaseServlet { - - /** - * - */ - private static final long serialVersionUID = -5848083581083497909L; - - public boolean isDisplayMode(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String cert = request.getParameter("cert"); - - if (cert == null) { - return true; - } else { - return false; - } - } - - public boolean isPanelModified() { - IConfigStore config = CMS.getConfigStore(); - - String cert = null; - - try { - cert = config.getString("preop.join.cert", null); - } catch (EBaseException e) { - } - if (cert == null || cert.equals("")) { - return false; - } else { - return true; - } - } - - /** - * Displays panel. - */ - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - IConfigStore config = CMS.getConfigStore(); - - try { - String pubKeyModulus = config.getString( - "preop.keysize.pubKeyModulus"); - String pubKeyPublicExponent = config.getString( - "preop.keysize.pubKeyPublicExponent"); - String dn = config.getString("preop.name.dn"); - String priKeyID = config.getString("preop.keysize.priKeyID"); - String pkcs10 = CryptoUtil.getPKCS10FromKey(dn, - CryptoUtil.string2byte(pubKeyModulus), - CryptoUtil.string2byte(pubKeyPublicExponent), - CryptoUtil.string2byte(priKeyID)); - context.put("certreq", pkcs10); - } catch (Exception e) { - } - - String select = "auto"; - boolean select_manual = true; - - if (isPanelModified()) { - try { - select = config.getString("preop.join.select", null); - } catch (EBaseException e) { - CMS.debug("ConfigJoinServlet::display() - " - + "Exception=" + e.toString()); - return; - } - if (select.equals("auto")) { - - /* automated enrollment */ - select_manual = false; - } else { - try { - - /* manual enrollment */ - String cert = config.getString("preop.join.cert", ""); - - context.put("cert", cert); - } catch (EBaseException e) { - } - } - } else { - context.put("cert", ""); - } - if (select_manual) { - context.put("check_manual", "checked"); - context.put("check_auto", ""); - } else { - context.put("check_manual", ""); - context.put("check_auto", "checked"); - } - context.put("status", "display"); - } - - /** - * Updates panel. - */ - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) { - CMS.debug("JoinServlet: update"); - IConfigStore config = CMS.getConfigStore(); - String select = request.getParameter("choice"); - - try { - if (select.equals("manual")) { - - /* manual enrollment */ - CMS.debug("JoinServlet: manual"); - String certchain = request.getParameter("cert"); - - config.putString("preop.join.cert", certchain); - } else if (select.equals("auto")) { - CMS.debug("JoinServlet: auto"); - - /* automated enrollment */ - String url = request.getParameter("url"); - String uid = request.getParameter("uid"); - String pwd = request.getParameter("__pwd"); - - config.putString("preop.join.url", url); - config.putString("preop.join.uid", uid); - config.putString("preop.join.pwd", pwd); - - /* XXX - submit request to the CA, and import it automatically */ - config.putString( - "preop.join.cert", ""); /* store the chain */ - } - config.putString("preop.join.select", select); - config.commit(false); - } catch (Exception e) { - } - } - - public Template getTemplate(HttpServletRequest request, - HttpServletResponse response, - Context context) { - Template template = null; - - try { - template = Velocity.getTemplate( - "admin/console/config/config_join.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigRootCAServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigRootCAServlet.java deleted file mode 100644 index c9618db19..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigRootCAServlet.java +++ /dev/null @@ -1,145 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import java.util.Vector; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.IConfigStore; -import com.netscape.certsrv.profile.CertInfoProfile; - -public class ConfigRootCAServlet extends ConfigBaseServlet { - - /** - * - */ - private static final long serialVersionUID = 1128630821163059659L; - - public boolean isDisplayMode(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String profile = request.getParameter("profile"); - - if (profile == null) { - return true; - } else { - return false; - } - } - - public boolean isPanelModified() { - IConfigStore config = CMS.getConfigStore(); - - String profile = null; - - try { - profile = config.getString("preop.hierarchy.profile", null); - } catch (EBaseException e) { - } - if (profile == null || profile.equals("")) { - return false; - } else { - return true; - } - } - - public Vector getProfiles() { - IConfigStore config = CMS.getConfigStore(); - String instancePath = ""; - - try { - instancePath = config.getString("instanceRoot"); - } catch (EBaseException e) { - } - String p[] = { "caCert.profile" }; - Vector profiles = new Vector(); - - for (int i = 0; i < p.length; i++) { - try { - profiles.addElement( - new CertInfoProfile(instancePath + "/conf/" + p[i])); - } catch (Exception e) { - } - } - return profiles; - } - - public void display(HttpServletRequest request, - HttpServletResponse response, - Context context) { - IConfigStore config = CMS.getConfigStore(); - String profile = null; - - if (isPanelModified()) { - try { - profile = config.getString("preop.hierarchy.profile", null); - } catch (EBaseException e) { - } - } - if (profile == null) { - profile = "caCert.profile"; - } - Vector profiles = getProfiles(); - - context.put("status", "display"); - context.put("profiles", profiles); - context.put("selected_profile_id", profile); - } - - public void update(HttpServletRequest request, - HttpServletResponse response, - Context context) { - String profile = request.getParameter("profile"); - IConfigStore config = CMS.getConfigStore(); - - config.putString("preop.hierarchy.profile", profile); - try { - config.commit(false); - } catch (Exception e) { - } - context.put("status", "update"); - context.put("error", ""); - Vector profiles = getProfiles(); - - context.put("profiles", profiles); - context.put("selected_profile_id", profile); - } - - public Template getTemplate(HttpServletRequest request, - HttpServletResponse response, - Context context) { - Template template = null; - - try { - template = Velocity.getTemplate( - "admin/console/config/config_rootca.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java index 490911353..d491da07c 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java @@ -121,6 +121,7 @@ import org.mozilla.jss.ssl.SSLCertificateApprovalCallback; import org.mozilla.jss.util.IncorrectPasswordException; import org.mozilla.jss.util.Password; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -1944,6 +1945,42 @@ public class ConfigurationUtils { } } + public static int getSubsystemCount(String hostname, int https_admin_port, + boolean https, String type) throws IOException, SAXException, ParserConfigurationException { + CMS.debug("getSubsystemCount start"); + String c = getDomainXML(hostname, https_admin_port, true); + if (c != null) { + ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); + XMLObject obj = new XMLObject(bis); + String containerName = type + "List"; + Node n = obj.getContainer(containerName); + NodeList nlist = n.getChildNodes(); + String countS = ""; + for (int i = 0; i < nlist.getLength(); i++) { + Element nn = (Element) nlist.item(i); + String tagname = nn.getTagName(); + if (tagname.equals("SubsystemCount")) { + NodeList nlist1 = nn.getChildNodes(); + Node nn1 = nlist1.item(0); + countS = nn1.getNodeValue(); + break; + } + } + CMS.debug("getSubsystemCount: SubsystemCount=" + countS); + int num = 0; + + if (countS != null && !countS.equals("")) { + try { + num = Integer.parseInt(countS); + } catch (Exception ee) { + } + } + + return num; + } + return -1; + } + public static void configCert(HttpServletRequest request, HttpServletResponse response, Context context, Cert certObj, WizardPanelBase panel) throws IOException { diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/DatabaseServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/DatabaseServlet.java deleted file mode 100644 index c44f61130..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/DatabaseServlet.java +++ /dev/null @@ -1,49 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class DatabaseServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = 6474664942834474385L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = Velocity.getTemplate("admin/console/config/database.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/DisplayServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/DisplayServlet.java deleted file mode 100644 index 3bb8c73c8..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/DisplayServlet.java +++ /dev/null @@ -1,49 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class DisplayServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = -8753831516572779596L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - Template template = null; - - try { - String tmpl = request.getParameter("t"); - - template = Velocity.getTemplate(tmpl); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ModuleServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/ModuleServlet.java deleted file mode 100644 index 7732a9a3c..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ModuleServlet.java +++ /dev/null @@ -1,90 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -import com.netscape.certsrv.apps.CMS; - -public class ModuleServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = 6518965840466227888L; - - /** - * Collect information on where keys are to be generated. - * Once collected, write to CS.cfg: - * "preop.module=soft" - * or - * "preop.module=hard" - * - *
    - *
  • http.param selection "soft" or "hard" for software token or hardware token - *
- */ - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - CMS.debug("ModuleServlet: in ModuleServlet"); - try { - - // get the value of the selection - String selection = request.getParameter("selection"); - - if (selection != null) { - - if (selection.equals("soft")) { - CMS.debug("ModuleServlet: user selected software"); - // XXX - CMS.getConfigStore().putString("preop.module", "soft"); - CMS.getConfigStore().commit(false); - response.sendRedirect("size"); - } else if (selection.equals("hard")) { - CMS.debug("ModuleServlet: user selected hardware"); - // YYY - CMS.getConfigStore().putString("preop.module", "hard"); - CMS.getConfigStore().commit(false); - response.sendRedirect("size"); - } else { - CMS.debug("ModuleServlet: illegal selection: " + selection); - context.put("error", "failed selection"); - } - - } else { - CMS.debug("ModuleServlet: no selection"); - } - - template = Velocity.getTemplate("admin/console/config/module.vm"); - } catch (Exception e) { - CMS.debug("ModuleServlet: Exception caught: " + e.toString()); - System.err.println("Exception caught: " + e.toString()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java b/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java index 8d69997bb..070e17e7c 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java @@ -199,7 +199,7 @@ public class NamePanel extends WizardPanelBase { if (domaintype.equals("existing")) { host = config.getString("securitydomain.host", ""); sd_admin_port = config.getInteger("securitydomain.httpsadminport", -1); - count = getSubsystemCount(host, sd_admin_port, true, cstype); + count = ConfigurationUtils.getSubsystemCount(host, sd_admin_port, true, cstype); } while (st.hasMoreTokens()) { diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/WelcomeServlet.java b/base/common/src/com/netscape/cms/servlet/csadmin/WelcomeServlet.java deleted file mode 100644 index f5a96bc8a..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/WelcomeServlet.java +++ /dev/null @@ -1,49 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.context.Context; - -public class WelcomeServlet extends BaseServlet { - - /** - * - */ - private static final long serialVersionUID = 1179761802633506502L; - - public Template process(HttpServletRequest request, - HttpServletResponse response, - Context context) { - - Template template = null; - - try { - context.put("name", "Velocity Test"); - template = Velocity.getTemplate("admin/console/config/welcome.vm"); - } catch (Exception e) { - System.err.println("Exception caught: " + e.getMessage()); - } - - return template; - } -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java b/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java index 273e33173..4fe641240 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java @@ -20,31 +20,22 @@ package com.netscape.cms.servlet.csadmin; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.URLEncoder; -import java.security.cert.CertificateEncodingException; import java.util.Locale; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.xml.parsers.ParserConfigurationException; import org.apache.velocity.context.Context; import org.mozilla.jss.ssl.SSLCertificateApprovalCallback; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; import com.netscape.certsrv.apps.CMS; -import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.property.PropertySet; import com.netscape.cms.servlet.base.UserInfo; import com.netscape.cms.servlet.wizard.IWizardPanel; import com.netscape.cms.servlet.wizard.WizardServlet; -import com.netscape.cmsutil.crypto.CryptoUtil; import com.netscape.cmsutil.xml.XMLObject; public class WizardPanelBase implements IWizardPanel { @@ -214,239 +205,6 @@ public class WizardPanelBase implements IWizardPanel { return locale; } - public int getSubsystemCount(String hostname, int https_admin_port, - boolean https, String type) throws IOException, SAXException, ParserConfigurationException { - CMS.debug("WizardPanelBase getSubsystemCount start"); - String c = ConfigurationUtils.getDomainXML(hostname, https_admin_port, true); - if (c != null) { - ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); - XMLObject obj = new XMLObject(bis); - String containerName = type + "List"; - Node n = obj.getContainer(containerName); - NodeList nlist = n.getChildNodes(); - String countS = ""; - for (int i = 0; i < nlist.getLength(); i++) { - Element nn = (Element) nlist.item(i); - String tagname = nn.getTagName(); - if (tagname.equals("SubsystemCount")) { - NodeList nlist1 = nn.getChildNodes(); - Node nn1 = nlist1.item(0); - countS = nn1.getNodeValue(); - break; - } - } - CMS.debug("WizardPanelBase getSubsystemCount: SubsystemCount=" + countS); - int num = 0; - - if (countS != null && !countS.equals("")) { - try { - num = Integer.parseInt(countS); - } catch (Exception ee) { - } - } - - return num; - } - return -1; - } - - public String getCertChainUsingSecureEEPort(String hostname, - int https_ee_port, - boolean https, - ConfigCertApprovalCallback - certApprovalCallback) - throws IOException { - CMS.debug("WizardPanelBase getCertChainUsingSecureEEPort start"); - String c = ConfigurationUtils.getHttpResponse(hostname, https_ee_port, https, - "/ca/ee/ca/getCertChain", null, null, - certApprovalCallback); - - if (c != null) { - try { - ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); - XMLObject parser = null; - - try { - parser = new XMLObject(bis); - } catch (Exception e) { - CMS.debug("WizardPanelBase::getCertChainUsingSecureEEPort() - " - + "Exception=" + e.toString()); - throw new IOException(e.toString()); - } - - String status = parser.getValue("Status"); - - CMS.debug("WizardPanelBase getCertChainUsingSecureEEPort: status=" + status); - - if (status.equals(SUCCESS)) { - String certchain = parser.getValue("ChainBase64"); - - certchain = CryptoUtil.normalizeCertStr(certchain); - CMS.debug( - "WizardPanelBase getCertChainUsingSecureEEPort: certchain=" - + certchain); - return certchain; - } else { - String error = parser.getValue("Error"); - - throw new IOException(error); - } - } catch (IOException e) { - CMS.debug("WizardPanelBase: getCertChainUsingSecureEEPort: " + e.toString()); - throw e; - } catch (Exception e) { - CMS.debug("WizardPanelBase: getCertChainUsingSecureEEPort: " + e.toString()); - throw new IOException(e.toString()); - } - } - - return null; - } - - public boolean updateConfigEntries(String hostname, int port, boolean https, - String servlet, String uri, IConfigStore config, - HttpServletResponse response) throws IOException { - CMS.debug("WizardPanelBase updateConfigEntries start"); - String c = ConfigurationUtils.getHttpResponse(hostname, port, https, servlet, uri, null); - - if (c != null) { - try { - ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); - XMLObject parser = null; - - try { - parser = new XMLObject(bis); - } catch (Exception e) { - CMS.debug("WizardPanelBase::updateConfigEntries() - " - + "Exception=" + e.toString()); - throw new IOException(e.toString()); - } - - String status = parser.getValue("Status"); - - CMS.debug("WizardPanelBase updateConfigEntries: status=" + status); - - if (status.equals(SUCCESS)) { - String cstype = ""; - try { - cstype = config.getString("cs.type", ""); - } catch (Exception e) { - CMS.debug("WizardPanelBase::updateConfigEntries() - unable to get cs.type: " + e.toString()); - } - - Document doc = parser.getDocument(); - NodeList list = doc.getElementsByTagName("name"); - int len = list.getLength(); - for (int i = 0; i < len; i++) { - Node n = list.item(i); - NodeList nn = n.getChildNodes(); - String name = nn.item(0).getNodeValue(); - Node parent = n.getParentNode(); - nn = parent.getChildNodes(); - int len1 = nn.getLength(); - String v = ""; - for (int j = 0; j < len1; j++) { - Node nv = nn.item(j); - String val = nv.getNodeName(); - if (val.equals("value")) { - NodeList n2 = nv.getChildNodes(); - if (n2.getLength() > 0) - v = n2.item(0).getNodeValue(); - break; - } - } - - if (name.equals("internaldb.basedn")) { - config.putString(name, v); - config.putString("preop.internaldb.master.basedn", v); - } else if (name.startsWith("internaldb")) { - config.putString(name.replaceFirst("internaldb", "preop.internaldb.master"), v); - } else if (name.equals("instanceId")) { - config.putString("preop.master.instanceId", v); - } else if (name.equals("cloning.cert.signing.nickname")) { - config.putString("preop.master.signing.nickname", v); - config.putString("preop.cert.signing.nickname", v); - } else if (name.equals("cloning.ocsp_signing.nickname")) { - config.putString("preop.master.ocsp_signing.nickname", v); - config.putString("preop.cert.ocsp_signing.nickname", v); - } else if (name.equals("cloning.subsystem.nickname")) { - config.putString("preop.master.subsystem.nickname", v); - config.putString("preop.cert.subsystem.nickname", v); - } else if (name.equals("cloning.transport.nickname")) { - config.putString("preop.master.transport.nickname", v); - config.putString("kra.transportUnit.nickName", v); - config.putString("preop.cert.transport.nickname", v); - } else if (name.equals("cloning.storage.nickname")) { - config.putString("preop.master.storage.nickname", v); - config.putString("kra.storageUnit.nickName", v); - config.putString("preop.cert.storage.nickname", v); - } else if (name.equals("cloning.audit_signing.nickname")) { - config.putString("preop.master.audit_signing.nickname", v); - config.putString("preop.cert.audit_signing.nickname", v); - config.putString(name, v); - } else if (name.startsWith("cloning.ca")) { - config.putString(name.replaceFirst("cloning", "preop"), v); - } else if (name.equals("cloning.signing.keyalgorithm")) { - config.putString(name.replaceFirst("cloning", "preop.cert"), v); - if (cstype.equals("CA")) { - config.putString("ca.crl.MasterCRL.signingAlgorithm", v); - config.putString("ca.signing.defaultSigningAlgorithm", v); - } else if (cstype.equals("OCSP")) { - config.putString("ocsp.signing.defaultSigningAlgorithm", v); - } - } else if (name.equals("cloning.transport.keyalgorithm")) { - config.putString(name.replaceFirst("cloning", "preop.cert"), v); - config.putString("kra.transportUnit.signingAlgorithm", v); - } else if (name.equals("cloning.ocsp_signing.keyalgorithm")) { - config.putString(name.replaceFirst("cloning", "preop.cert"), v); - if (cstype.equals("CA")) { - config.putString("ca.ocsp_signing.defaultSigningAlgorithm", v); - } - } else if (name.startsWith("cloning")) { - config.putString(name.replaceFirst("cloning", "preop.cert"), v); - } else { - config.putString(name, v); - } - } - - // set master ldap password (if it exists) temporarily in password store - // in case it is needed for replication. Not stored in password.conf. - try { - String master_pwd = config.getString("preop.internaldb.master.ldapauth.password", ""); - if (!master_pwd.equals("")) { - config.putString("preop.internaldb.master.ldapauth.bindPWPrompt", "master_internaldb"); - String passwordFile = config.getString("passwordFile"); - IConfigStore psStore = CMS.createFileConfigStore(passwordFile); - psStore.putString("master_internaldb", master_pwd); - psStore.commit(false); - } - } catch (Exception e) { - CMS.debug("updateConfigEntries: Failed to temporarily store master bindpwd: " + e.toString()); - e.printStackTrace(); - throw new IOException(e.toString()); - } - - return true; - } else if (status.equals(AUTH_FAILURE)) { - reloginSecurityDomain(response); - return false; - } else { - String error = parser.getValue("Error"); - - throw new IOException(error); - } - } catch (IOException e) { - CMS.debug("WizardPanelBase: updateConfigEntries: " + e.toString()); - throw e; - } catch (Exception e) { - CMS.debug("WizardPanelBase: updateConfigEntries: " + e.toString()); - throw new IOException(e.toString()); - } - } - - return false; - } - public boolean authenticate(String hostname, int port, boolean https, String servlet, String uri) throws IOException { CMS.debug("WizardPanelBase authenticate start"); @@ -497,8 +255,7 @@ public class WizardPanelBase implements IWizardPanel { if (c != null) { try { - ByteArrayInputStream bis = new - ByteArrayInputStream(c.getBytes()); + ByteArrayInputStream bis = new ByteArrayInputStream(c.getBytes()); XMLObject parser = null; String state = null; @@ -526,30 +283,6 @@ public class WizardPanelBase implements IWizardPanel { return null; } - public void updateCertChainUsingSecureEEPort(IConfigStore config, String name, String host, - int https_ee_port, boolean https, Context context, ConfigCertApprovalCallback certApprovalCallback) - throws IOException, CertificateEncodingException, EBaseException { - String certchain = getCertChainUsingSecureEEPort(host, https_ee_port, https, certApprovalCallback); - config.putString("preop." + name + ".pkcs7", certchain); - - byte[] decoded = CryptoUtil.base64Decode(certchain); - java.security.cert.X509Certificate[] b_certchain = CryptoUtil.getX509CertificateFromPKCS7(decoded); - - int size = 0; - if (b_certchain != null) { - size = b_certchain.length; - } - config.putInteger("preop." + name + ".certchain.size", size); - - for (int i = 0; i < size; i++) { - byte[] bb = b_certchain[i].getEncoded(); - config.putString("preop." + name + ".certchain." + i, - CryptoUtil.normalizeCertStr(CryptoUtil.base64Encode(bb))); - } - - config.commit(false); - } - public void reloginSecurityDomain(HttpServletResponse response) { IConfigStore cs = CMS.getConfigStore(); try { -- cgit