diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java index ce5e9795..d4f93a9b 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/ImportAdminCertPanel.java @@ -17,6 +17,7 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.servlet.csadmin; + import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; @@ -46,19 +47,19 @@ import com.netscape.cmsutil.crypto.CryptoUtil; public class ImportAdminCertPanel extends WizardPanelBase { - public ImportAdminCertPanel() { - } + public ImportAdminCertPanel() {} /** * Initializes this panel. */ - public void init(ServletConfig config, int panelno) throws ServletException { + public void init(ServletConfig config, int panelno) + throws ServletException { setPanelNo(panelno); setName("Import Administrator's Certificate"); } - public void init(WizardServlet servlet, ServletConfig config, int panelno, - String id) throws ServletException { + public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) + throws ServletException { setPanelNo(panelno); setName("Import Administrator's Certificate"); setId(id); @@ -85,7 +86,8 @@ public class ImportAdminCertPanel extends WizardPanelBase { * Display the panel. */ public void display(HttpServletRequest request, - HttpServletResponse response, Context context) { + HttpServletResponse response, + Context context) { CMS.debug("ImportAdminCertPanel: display"); context.put("errorString", ""); context.put("title", "Import Administrator's Certificate"); @@ -100,12 +102,11 @@ public class ImportAdminCertPanel extends WizardPanelBase { try { type = cs.getString("preop.ca.type", ""); subsystemtype = cs.getString("cs.type", ""); - } catch (Exception e) { - } + } catch (Exception e) {} try { String serialno = cs.getString("preop.admincert.serialno.0"); - + context.put("serialNumber", serialno); } catch (Exception e) { context.put("errorString", "Failed to get serial number."); @@ -128,26 +129,21 @@ public class ImportAdminCertPanel extends WizardPanelBase { if (ca == null) { if (type.equals("otherca")) { try { - // this is a non-CA system that has elected to have its - // certificates + // this is a non-CA system that has elected to have its certificates // signed by a CA outside of the security domain. - // in this case, we submitted the cert request for the admin - // cert to + // in this case, we submitted the cert request for the admin cert to // to security domain host. caHost = cs.getString("securitydomain.host", ""); caPort = cs.getString("securitydomain.httpsadminport", ""); - } catch (Exception e) { - } + } catch (Exception e) {} } else if (type.equals("sdca")) { try { // this is a non-CA system that submitted its certs to a CA - // within the security domain. In this case, we submitted - // the cert + // within the security domain. In this case, we submitted the cert // request for the admin cert to this CA caHost = cs.getString("preop.ca.hostname", ""); caPort = cs.getString("preop.ca.httpsadminport", ""); - } catch (Exception e) { - } + } catch (Exception e) {} } } else { // for CAs, we always generate our own admin certs @@ -155,8 +151,7 @@ public class ImportAdminCertPanel extends WizardPanelBase { try { caHost = cs.getString("service.machineName", ""); caPort = cs.getString("pkicreate.admin_secure_port", ""); - } catch (Exception e) { - } + } catch (Exception e) {} } String pkcs7 = ""; @@ -175,14 +170,16 @@ public class ImportAdminCertPanel extends WizardPanelBase { * Checks if the given parameters are valid. */ public void validate(HttpServletRequest request, - HttpServletResponse response, Context context) throws IOException { + HttpServletResponse response, + Context context) throws IOException { } /** * Commit parameter changes */ public void update(HttpServletRequest request, - HttpServletResponse response, Context context) throws IOException { + HttpServletResponse response, + Context context) throws IOException { IConfigStore cs = CMS.getConfigStore(); String type = ""; @@ -195,13 +192,12 @@ public class ImportAdminCertPanel extends WizardPanelBase { subsystemtype = cs.getString("cs.type", ""); security_domain_type = cs.getString("securitydomain.select", ""); selected_hierarchy = cs.getString("preop.hierarchy.select", ""); - } catch (Exception e) { - } + } catch (Exception e) {} - ICertificateAuthority ca = (ICertificateAuthority) CMS - .getSubsystem(ICertificateAuthority.ID); + ICertificateAuthority ca = (ICertificateAuthority) CMS.getSubsystem( + ICertificateAuthority.ID); - if (ca == null) { + if (ca == null) { context.put("ca", "false"); } else { context.put("ca", "true"); @@ -210,23 +206,25 @@ public class ImportAdminCertPanel extends WizardPanelBase { X509CertImpl certs[] = new X509CertImpl[1]; - // REMINDER: This panel is NOT used by "clones" - if (ca != null) { + // REMINDER: This panel is NOT used by "clones" + if( ca != null ) { String serialno = null; - if (selected_hierarchy.equals("root")) { - CMS.debug("ImportAdminCertPanel update: " - + "Root CA subsystem - " + "(new Security Domain)"); + if( selected_hierarchy.equals( "root" ) ) { + CMS.debug( "ImportAdminCertPanel update: " + + "Root CA subsystem - " + + "(new Security Domain)" ); } else { - CMS.debug("ImportAdminCertPanel update: " - + "Subordinate CA subsystem - " - + "(new Security Domain)"); + CMS.debug( "ImportAdminCertPanel update: " + + "Subordinate CA subsystem - " + + "(new Security Domain)" ); } try { serialno = cs.getString("preop.admincert.serialno.0"); } catch (Exception e) { - CMS.debug("ImportAdminCertPanel update: Failed to get request id."); + CMS.debug( + "ImportAdminCertPanel update: Failed to get request id."); context.put("updateStatus", "failure"); throw new IOException("Failed to get request id."); } @@ -234,37 +232,37 @@ public class ImportAdminCertPanel extends WizardPanelBase { ICertificateRepository repost = ca.getCertificateRepository(); try { - certs[0] = repost.getX509Certificate(new BigInteger(serialno, - 16)); - } catch (Exception ee) { - } + certs[0] = repost.getX509Certificate( + new BigInteger(serialno, 16)); + } catch (Exception ee) {} } else { String dir = null; - // REMINDER: This panel is NOT used by "clones" - if (subsystemtype.equals("CA")) { - if (selected_hierarchy.equals("root")) { - CMS.debug("ImportAdminCertPanel update: " - + "Root CA subsystem - " - + "(existing Security Domain)"); + // REMINDER: This panel is NOT used by "clones" + if( subsystemtype.equals( "CA" ) ) { + if( selected_hierarchy.equals( "root" ) ) { + CMS.debug( "ImportAdminCertPanel update: " + + "Root CA subsystem - " + + "(existing Security Domain)" ); } else { - CMS.debug("ImportAdminCertPanel update: " - + "Subordinate CA subsystem - " - + "(existing Security Domain)"); + CMS.debug( "ImportAdminCertPanel update: " + + "Subordinate CA subsystem - " + + "(existing Security Domain)" ); } } else { - CMS.debug("ImportAdminCertPanel update: " + subsystemtype - + " subsystem"); + CMS.debug( "ImportAdminCertPanel update: " + + subsystemtype + + " subsystem" ); } try { - dir = cs.getString("preop.admincert.b64", ""); + dir = cs.getString("preop.admincert.b64", ""); CMS.debug("ImportAdminCertPanel update: dir=" + dir); - } catch (Exception ee) { - } + } catch (Exception ee) {} try { - BufferedReader reader = new BufferedReader(new FileReader(dir)); + BufferedReader reader = new BufferedReader( + new FileReader(dir)); String b64 = ""; StringBuffer sb = new StringBuffer(); @@ -291,15 +289,15 @@ public class ImportAdminCertPanel extends WizardPanelBase { user.setX509Certificates(certs); ug.addUserCert(user); } catch (LDAPException e) { - CMS.debug("ImportAdminCertPanel update: failed to add certificate to the internal database. Exception: " - + e.toString()); + CMS.debug("ImportAdminCertPanel update: failed to add certificate to the internal database. Exception: "+e.toString()); if (e.getLDAPResultCode() != LDAPException.ATTRIBUTE_OR_VALUE_EXISTS) { context.put("updateStatus", "failure"); throw new IOException(e.toString()); } } catch (Exception e) { - CMS.debug("ImportAdminCertPanel update: failed to add certificate. Exception: " - + e.toString()); + CMS.debug( + "ImportAdminCertPanel update: failed to add certificate. Exception: " + + e.toString()); context.put("updateStatus", "failure"); throw new IOException(e.toString()); } @@ -314,7 +312,7 @@ public class ImportAdminCertPanel extends WizardPanelBase { public boolean shouldSkip() { try { IConfigStore c = CMS.getConfigStore(); - String s = c.getString("preop.subsystem.select", null); + String s = c.getString("preop.subsystem.select",null); if (s != null && s.equals("clone")) { return true; } @@ -324,11 +322,13 @@ public class ImportAdminCertPanel extends WizardPanelBase { return false; } + /** * If validiate() returns false, this method will be called. */ public void displayError(HttpServletRequest request, - HttpServletResponse response, Context context) { + HttpServletResponse response, + Context context) { /* This should never be called */ context.put("title", "Import Administrator Certificate"); |