From 2df750de798fb8ea6f6e72079fa6c44f40b8ad35 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 6 Apr 2016 20:15:21 +0200 Subject: Fixed error handling in ConfigurationUtils.updateDomainXML(). https://fedorahosted.org/pki/ticket/1695 --- .../cms/servlet/csadmin/ConfigurationUtils.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java') diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java index 0ca8c0222..69682d51e 100644 --- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java +++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java @@ -31,7 +31,6 @@ import java.math.BigInteger; import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; -import java.security.DigestException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyPair; @@ -57,6 +56,7 @@ import java.util.Vector; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.NotFoundException; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -3816,15 +3816,19 @@ public class ConfigurationUtils { content.putSingle("httpport", CMS.getEENonSSLPort()); try { + // Use new interface String session_id = CMS.getConfigSDSessionId(); content.putSingle("sessionID", session_id); updateDomainXML(sd_host, sd_admin_port, true, url, content, false); - } catch (Exception e) { - CMS.debug("updateSecurityDomain: failed to update security domain using admin port " - + sd_admin_port + ": " + e); - CMS.debug("updateSecurityDomain: now trying agent port with client auth"); + } catch (NotFoundException e) { + CMS.debug("updateSecurityDomain: admin interface not found: " + + "https://" + sd_host + ":" + sd_admin_port + url); + + // Use legacy interface url = "/ca/agent/ca/updateDomainXML"; + CMS.debug("updateSecurityDomain: now trying agent interface: " + + "https://" + sd_host + ":" + sd_admin_port + url); updateDomainXML(sd_host, sd_agent_port, true, url, content, true); } @@ -3896,13 +3900,17 @@ public class ConfigurationUtils { if (status.equals(SUCCESS)) { return; + + } else if (status.equals(AUTH_FAILURE)) { + throw new PKIException("Unable to update security domain info: authentication failure"); + } else { String error = obj.getValue("Error"); - throw new IOException(error); + throw new PKIException("Unable to update security domain info: " + error); } } else { - throw new IOException("Failed to get response when updating security domain"); + throw new PKIException("Unable to update security domain info: no response"); } } -- cgit