summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java130
1 files changed, 78 insertions, 52 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java
index f9e6c70e..b3d9470d 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/GetDomainXML.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.csadmin;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
@@ -48,7 +47,6 @@ import com.netscape.cms.servlet.common.CMSRequest;
import com.netscape.cms.servlet.common.ICMSTemplateFiller;
import com.netscape.cmsutil.xml.XMLObject;
-
public class GetDomainXML extends CMSServlet {
/**
@@ -64,6 +62,7 @@ public class GetDomainXML extends CMSServlet {
/**
* initialize the servlet.
+ *
* @param sc servlet configuration, read from the web.xml file
*/
public void init(ServletConfig sc) throws ServletException {
@@ -73,11 +72,13 @@ public class GetDomainXML extends CMSServlet {
}
/**
- * Process the HTTP request.
+ * Process the HTTP request.
* <ul>
* <li>http.param op 'downloadBIN' - return the binary certificate chain
- * <li>http.param op 'displayIND' - display pretty-print of certificate chain components
+ * <li>http.param op 'displayIND' - display pretty-print of certificate
+ * chain components
* </ul>
+ *
* @param cmsReq the object holding the request and response information
*/
protected void process(CMSRequest cmsReq) throws EBaseException {
@@ -95,8 +96,7 @@ public class GetDomainXML extends CMSServlet {
try {
secstore = cs.getString("securitydomain.store");
basedn = cs.getString("internaldb.basedn");
- }
- catch (Exception e) {
+ } catch (Exception e) {
CMS.debug("Unable to determine the security domain name or internal basedn. Please run the domaininfo migration script");
}
@@ -104,7 +104,8 @@ public class GetDomainXML extends CMSServlet {
XMLObject response = new XMLObject();
Node root = response.createRoot("XMLResponse");
- if ((secstore != null) && (basedn != null) && (secstore.equals("ldap"))) {
+ if ((secstore != null) && (basedn != null)
+ && (secstore.equals("ldap"))) {
ILdapConnFactory connFactory = null;
LDAPConnection conn = null;
try {
@@ -120,64 +121,77 @@ public class GetDomainXML extends CMSServlet {
connFactory.init(ldapConfig);
conn = connFactory.getConn();
- // get the security domain name
- String secdomain = (String) conn.read(dn).getAttribute("name").getStringValues().nextElement();
+ // get the security domain name
+ String secdomain = (String) conn.read(dn)
+ .getAttribute("name").getStringValues()
+ .nextElement();
XMLObject xmlObj = new XMLObject();
Node domainInfo = xmlObj.createRoot("DomainInfo");
xmlObj.addItemToContainer(domainInfo, "Name", secdomain);
- // this should return CAList, KRAList etc.
- LDAPSearchResults res = conn.search(dn, LDAPConnection.SCOPE_ONE, filter,
- attrs, true, cons);
+ // this should return CAList, KRAList etc.
+ LDAPSearchResults res = conn
+ .search(dn, LDAPConnection.SCOPE_ONE, filter,
+ attrs, true, cons);
while (res.hasMoreElements()) {
int count = 0;
dn = res.next().getDN();
String listName = dn.substring(3, dn.indexOf(","));
- String subType = listName.substring(0, listName.indexOf("List"));
- Node listNode = xmlObj.createContainer(domainInfo, listName);
-
+ String subType = listName.substring(0,
+ listName.indexOf("List"));
+ Node listNode = xmlObj.createContainer(domainInfo,
+ listName);
+
filter = "objectclass=pkiSubsystem";
- LDAPSearchResults res2 = conn.search(dn, LDAPConnection.SCOPE_ONE, filter,
- attrs, false, cons);
+ LDAPSearchResults res2 = conn.search(dn,
+ LDAPConnection.SCOPE_ONE, filter, attrs, false,
+ cons);
while (res2.hasMoreElements()) {
- Node node = xmlObj.createContainer(listNode, subType);
+ Node node = xmlObj.createContainer(listNode,
+ subType);
LDAPEntry entry = res2.next();
- LDAPAttributeSet entryAttrs = entry.getAttributeSet();
+ LDAPAttributeSet entryAttrs = entry
+ .getAttributeSet();
Enumeration attrsInSet = entryAttrs.getAttributes();
while (attrsInSet.hasMoreElements()) {
- LDAPAttribute nextAttr = (LDAPAttribute) attrsInSet.nextElement();
+ LDAPAttribute nextAttr = (LDAPAttribute) attrsInSet
+ .nextElement();
String attrName = nextAttr.getName();
- if ((! attrName.equals("cn")) && (! attrName.equals("objectClass"))) {
- String attrValue = (String) nextAttr.getStringValues().nextElement();
- xmlObj.addItemToContainer(node, securityDomainLDAPtoXML(attrName), attrValue);
+ if ((!attrName.equals("cn"))
+ && (!attrName.equals("objectClass"))) {
+ String attrValue = (String) nextAttr
+ .getStringValues().nextElement();
+ xmlObj.addItemToContainer(node,
+ securityDomainLDAPtoXML(attrName),
+ attrValue);
}
}
- count ++;
- }
- xmlObj.addItemToContainer(listNode, "SubsystemCount", Integer.toString(count));
+ count++;
+ }
+ xmlObj.addItemToContainer(listNode, "SubsystemCount",
+ Integer.toString(count));
}
// Add new xml object as string to response.
- response.addItemToContainer(root, "DomainInfo", xmlObj.toXMLString());
- }
- catch (Exception e) {
- CMS.debug("GetDomainXML: Failed to read domain.xml from ldap " + e.toString());
+ response.addItemToContainer(root, "DomainInfo",
+ xmlObj.toXMLString());
+ } catch (Exception e) {
+ CMS.debug("GetDomainXML: Failed to read domain.xml from ldap "
+ + e.toString());
status = FAILED;
- }
- finally {
- if ((conn != null) && (connFactory!= null)) {
+ } finally {
+ if ((conn != null) && (connFactory != null)) {
CMS.debug("Releasing ldap connection");
connFactory.returnConn(conn);
}
}
- }
- else {
- // get data from file store
+ } else {
+ // get data from file store
- String path = CMS.getConfigStore().getString("instanceRoot", "")
- + "/conf/domain.xml";
+ String path = CMS.getConfigStore()
+ .getString("instanceRoot", "") + "/conf/domain.xml";
CMS.debug("GetDomainXML: got path=" + path);
@@ -193,11 +207,12 @@ public class GetDomainXML extends CMSServlet {
fis.close();
CMS.debug("GetDomainXML: Done Reading domain.xml...");
- response.addItemToContainer(root, "DomainInfo", new String(buf));
- }
- catch (Exception e) {
- CMS.debug("Failed to read domain.xml from file" + e.toString());
- status = FAILED;
+ response.addItemToContainer(root, "DomainInfo", new String(
+ buf));
+ } catch (Exception e) {
+ CMS.debug("Failed to read domain.xml from file"
+ + e.toString());
+ status = FAILED;
}
}
@@ -206,23 +221,34 @@ public class GetDomainXML extends CMSServlet {
outputResult(httpResp, "application/xml", cb);
} catch (Exception e) {
- CMS.debug("GetDomainXML: Failed to send the XML output" + e.toString());
+ CMS.debug("GetDomainXML: Failed to send the XML output"
+ + e.toString());
}
}
protected String securityDomainLDAPtoXML(String attribute) {
- if (attribute.equals("host")) return "Host";
- else return attribute;
+ if (attribute.equals("host"))
+ return "Host";
+ else
+ return attribute;
}
- protected void setDefaultTemplates(ServletConfig sc) {}
+ protected void setDefaultTemplates(ServletConfig sc) {
+ }
- protected void renderTemplate(
- CMSRequest cmsReq, String templateName, ICMSTemplateFiller filler)
- throws IOException {// do nothing
- }
+ protected void renderTemplate(CMSRequest cmsReq, String templateName,
+ ICMSTemplateFiller filler) throws IOException {// do nothing
+ }
- protected void renderResult(CMSRequest cmsReq) throws IOException {// do nothing, ie, it will not return the default javascript.
+ protected void renderResult(CMSRequest cmsReq) throws IOException {// do
+ // nothing,
+ // ie, it
+ // will
+ // not
+ // return
+ // the
+ // default
+ // javascript.
}
/**