From a3488415bb76cacdcdb18518b203ae023b5c1132 Mon Sep 17 00:00:00 2001 From: vakwetu Date: Tue, 25 Jan 2011 19:06:41 +0000 Subject: Bugzilla Bug 670337 - CA Clone configuration throws TCP connection error - fix for kra cloning git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1770 c9f7a03b-bd48-0410-a16d-cbbf54688b0b --- .../cms/servlet/csadmin/CreateSubsystemPanel.java | 3 +- .../csadmin/LDAPSecurityDomainSessionTable.java | 8 ++++ .../netscape/cms/servlet/csadmin/NamePanel.java | 43 +++++++++++++++++++++- .../cms/servlet/csadmin/WizardPanelBase.java | 5 ++- 4 files changed, 54 insertions(+), 5 deletions(-) (limited to 'pki/base/common') diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/CreateSubsystemPanel.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/CreateSubsystemPanel.java index 1130e50f7..464abf955 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/CreateSubsystemPanel.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/CreateSubsystemPanel.java @@ -258,7 +258,8 @@ public class CreateSubsystemPanel extends WizardPanelBase { String https_admin_port = getSecurityDomainAdminPort( config, host, - String.valueOf(https_ee_port) ); + String.valueOf(https_ee_port), + cstype ); config.putString("preop.master.hostname", host); config.putInteger("preop.master.httpsport", https_ee_port); diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java index 55d39886e..65b98a4ae 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/LDAPSecurityDomainSessionTable.java @@ -169,6 +169,14 @@ public class LDAPSecurityDomainSessionTable LDAPEntry entry = res.next(); ret.add(entry.getAttribute("cn").getStringValueArray()[0]); } + } catch (LDAPException e) { + switch (e.getLDAPResultCode()) { + case LDAPException.NO_SUCH_OBJECT: + CMS.debug("SecurityDomainSessionTable: getSessionIds(): no sessions have been created"); + break; + default: + CMS.debug("SecurityDomainSessionTable: unable to query sessionIds due to ldap exception: " + e); + } } catch(Exception e) { CMS.debug("SecurityDomainSessionTable: unable to query sessionIds: " + e); } diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java index 31d5f4623..1ab7c03a4 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/NamePanel.java @@ -745,9 +745,14 @@ public class NamePanel extends WizardPanelBase { configCertWithTag(request, response, context, "sslserver"); String url = getURL(request, config); if (url != null && !url.equals("External CA")) { - // preop.ca.url is required for setting KRA connector + // preop.ca.url and admin port are required for setting KRA connector url = url.substring(url.indexOf("https")); config.putString("preop.ca.url", url); + + URL urlx = new URL(url); + updateCloneSDCAInfo(request, context, urlx.getHost(), + Integer.toString(urlx.getPort())); + } updateCloneConfig(config); CMS.debug("NamePanel: clone configuration done"); @@ -869,6 +874,39 @@ public class NamePanel extends WizardPanelBase { CMS.debug("NamePanel: update() done"); } + private void updateCloneSDCAInfo(HttpServletRequest request, Context context, String hostname, String httpsPortStr) throws IOException { + CMS.debug("NamePanel updateCloneSDCAInfo: selected CA hostname=" + hostname + " port=" + httpsPortStr); + String https_admin_port = ""; + IConfigStore config = CMS.getConfigStore(); + + if (hostname == null || hostname.length() == 0) { + context.put("errorString", "Hostname is null"); + throw new IOException("Hostname is null"); + } + + // Retrieve the associated HTTPS Admin port so that it + // may be stored for use with ImportAdminCertPanel + https_admin_port = getSecurityDomainAdminPort( config, + hostname, + httpsPortStr, + "CA" ); + + int httpsport = -1; + + try { + httpsport = Integer.parseInt(httpsPortStr); + } catch (Exception e) { + CMS.debug( + "NamePanel update: Https port is not valid. Exception: " + + e.toString()); + throw new IOException("Https Port is not valid."); + } + + config.putString("preop.ca.hostname", hostname); + config.putString("preop.ca.httpsport", httpsPortStr); + config.putString("preop.ca.httpsadminport", https_admin_port); + } + private void sdca(HttpServletRequest request, Context context, String hostname, String httpsPortStr) throws IOException { CMS.debug("NamePanel update: this is the CA in the security domain."); CMS.debug("NamePanel update: selected CA hostname=" + hostname + " port=" + httpsPortStr); @@ -887,7 +925,8 @@ public class NamePanel extends WizardPanelBase { // may be stored for use with ImportAdminCertPanel https_admin_port = getSecurityDomainAdminPort( config, hostname, - httpsPortStr ); + httpsPortStr, + "CA" ); int httpsport = -1; diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java index 862a269cd..c34adc408 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/WizardPanelBase.java @@ -1140,7 +1140,8 @@ public class WizardPanelBase implements IWizardPanel { // retrieve the associated HTTPS Admin port public String getSecurityDomainAdminPort( IConfigStore config, String hostname, - String https_ee_port ) { + String https_ee_port, + String cstype ) { String https_admin_port = new String(); try { @@ -1157,7 +1158,7 @@ public class WizardPanelBase implements IWizardPanel { ByteArrayInputStream bis = new ByteArrayInputStream( c.getBytes() ); XMLObject parser = new XMLObject( bis ); Document doc = parser.getDocument(); - NodeList nodeList = doc.getElementsByTagName( "CA" ); + NodeList nodeList = doc.getElementsByTagName( cstype.toUpperCase() ); int len = nodeList.getLength(); for( int i = 0; i < len; i++ ) { -- cgit