diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java | 263 |
1 files changed, 131 insertions, 132 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java index e43fa913e..90a6aeb07 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java +++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java @@ -17,6 +17,7 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.servlet.csadmin; + import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -38,19 +39,19 @@ import com.netscape.cms.servlet.wizard.WizardServlet; public class SecurityDomainPanel extends WizardPanelBase { - public SecurityDomainPanel() { - } + public SecurityDomainPanel() {} /** * Initializes this panel. */ - public void init(ServletConfig config, int panelno) throws ServletException { + public void init(ServletConfig config, int panelno) + throws ServletException { setPanelNo(panelno); setName("Security Domain"); } - 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("Security Domain"); setId(id); @@ -71,16 +72,15 @@ public class SecurityDomainPanel extends WizardPanelBase { } else { return true; } - } catch (EBaseException e) { - } + } catch (EBaseException e) {} return false; } public PropertySet getUsage() { PropertySet set = new PropertySet(); - + /* XXX */ - + return set; } @@ -88,7 +88,8 @@ public class SecurityDomainPanel extends WizardPanelBase { * Display the panel. */ public void display(HttpServletRequest request, - HttpServletResponse response, Context context) { + HttpServletResponse response, + Context context) { context.put("title", "Security Domain"); IConfigStore config = CMS.getConfigStore(); String errorString = ""; @@ -98,12 +99,10 @@ public class SecurityDomainPanel extends WizardPanelBase { String systemdService = ""; try { - default_admin_url = config.getString( - "preop.securitydomain.admin_url", ""); + default_admin_url = config.getString("preop.securitydomain.admin_url", ""); name = config.getString("preop.securitydomain.name", ""); cstype = config.getString("cs.type", ""); - systemdService = config.getString("pkicreate.systemd.servicename", - ""); + systemdService = config.getString("pkicreate.systemd.servicename", ""); } catch (Exception e) { CMS.debug(e.toString()); } @@ -137,8 +136,7 @@ public class SecurityDomainPanel extends WizardPanelBase { context.put("https_ee_port", CMS.getEESSLPort()); context.put("https_admin_port", CMS.getAdminPort()); context.put("sdomainAdminURL", default_admin_url); - } catch (EBaseException e) { - } + } catch (EBaseException e) {} context.put("panel", "admin/console/config/securitydomainpanel.vm"); context.put("errorString", errorString); @@ -159,19 +157,18 @@ public class SecurityDomainPanel extends WizardPanelBase { while (st.hasMoreTokens()) { count++; String n = st.nextToken(); - if (first) { // skip the hostname + if (first) { //skip the hostname first = false; continue; } if (count == numTokens) // skip the last element (e.g. com) continue; - sb.append((defaultDomain.length() == 0) ? "" : " "); + sb.append((defaultDomain.length()==0)? "":" "); sb.append(capitalize(n)); } - defaultDomain = sb.toString() + " " + "Domain"; + defaultDomain = sb.toString() + " "+ "Domain"; name = defaultDomain; - CMS.debug("SecurityDomainPanel: defaultDomain generated:" - + name); + CMS.debug("SecurityDomainPanel: defaultDomain generated:"+ name); } catch (MalformedURLException e) { errorString = "Malformed URL"; // not being able to come up with default domain name is ok @@ -179,53 +176,54 @@ public class SecurityDomainPanel extends WizardPanelBase { } context.put("sdomainName", name); - if (default_admin_url != null) { + if( default_admin_url != null ) { String r = null; try { // check to see if "default" security domain exists // on local machine - URL u = new URL(default_admin_url); + URL u = new URL( default_admin_url ); String hostname = u.getHost(); int port = u.getPort(); - ConfigCertApprovalCallback certApprovalCallback = new ConfigCertApprovalCallback(); - r = pingCS(hostname, port, true, certApprovalCallback); + ConfigCertApprovalCallback + certApprovalCallback = new ConfigCertApprovalCallback(); + r = pingCS( hostname, port, true, certApprovalCallback ); } catch (Exception e) { - CMS.debug("SecurityDomainPanel: exception caught: " - + e.toString()); + CMS.debug( "SecurityDomainPanel: exception caught: " + + e.toString() ); } - - if (r != null) { + + if( r != null ) { // "default" security domain exists on local machine; // fill "sdomainURL" in with "default" security domain // as an initial "guess" - CMS.debug("SecurityDomainPanel: pingCS returns: " + r); - context.put("sdomainURL", default_admin_url); + CMS.debug( "SecurityDomainPanel: pingCS returns: "+r ); + context.put( "sdomainURL", default_admin_url ); } else { // "default" security domain does NOT exist on local machine; // leave "sdomainURL" blank - CMS.debug("SecurityDomainPanel: pingCS no successful response"); - context.put("sdomainURL", ""); + CMS.debug( "SecurityDomainPanel: pingCS no successful response" ); + context.put( "sdomainURL", "" ); } } // Information for "existing" Security Domain CAs String initDaemon = "pki-cad"; String instanceId = "<security_domain_instance_name>"; - String os = System.getProperty("os.name"); - if (os.equalsIgnoreCase("Linux")) { - if (!systemdService.equals("")) { - context.put("initCommand", "/usr/bin/pkicontrol"); - context.put("instanceId", "ca " + systemdService); + String os = System.getProperty( "os.name" ); + if( os.equalsIgnoreCase( "Linux" ) ) { + if (! systemdService.equals("")) { + context.put( "initCommand", "/usr/bin/pkicontrol" ); + context.put( "instanceId", "ca " + systemdService ); } else { - context.put("initCommand", "/sbin/service " + initDaemon); - context.put("instanceId", instanceId); + context.put( "initCommand", "/sbin/service " + initDaemon ); + context.put( "instanceId", instanceId ); } } else { - /* default case: e. g. - ( os.equalsIgnoreCase( "SunOS" ) */ - context.put("initCommand", "/etc/init.d/" + initDaemon); - context.put("instanceId", instanceId); + /* default case: e. g. - ( os.equalsIgnoreCase( "SunOS" ) */ + context.put( "initCommand", "/etc/init.d/" + initDaemon ); + context.put( "instanceId", instanceId ); } } @@ -233,7 +231,7 @@ public class SecurityDomainPanel extends WizardPanelBase { if (s.length() == 0) { return s; } else { - return s.substring(0, 1).toUpperCase() + s.substring(1); + return s.substring(0,1).toUpperCase() + s.substring(1); } } @@ -241,59 +239,62 @@ public class SecurityDomainPanel 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 { + String select = HttpInput.getID(request, "choice"); if (select.equals("newdomain")) { - String name = HttpInput.getSecurityDomainName(request, - "sdomainName"); + String name = HttpInput.getSecurityDomainName(request, "sdomainName"); if (name == null || name.equals("")) { initParams(request, context); context.put("updateStatus", "validate-failure"); - throw new IOException( - "Missing name value for the security domain"); + throw new IOException("Missing name value for the security domain"); } } else if (select.equals("existingdomain")) { - CMS.debug("SecurityDomainPanel: validating " - + "SSL Admin HTTPS . . ."); - String admin_url = HttpInput.getURL(request, "sdomainURL"); - if (admin_url == null || admin_url.equals("")) { - initParams(request, context); + CMS.debug( "SecurityDomainPanel: validating " + + "SSL Admin HTTPS . . ." ); + String admin_url = HttpInput.getURL( request, "sdomainURL" ); + if( admin_url == null || admin_url.equals("") ) { + initParams( request, context ); context.put("updateStatus", "validate-failure"); - throw new IOException("Missing SSL Admin HTTPS url value " - + "for the security domain"); + throw new IOException( "Missing SSL Admin HTTPS url value " + + "for the security domain" ); } else { String r = null; try { - URL u = new URL(admin_url); + URL u = new URL( admin_url ); String hostname = u.getHost(); int admin_port = u.getPort(); - ConfigCertApprovalCallback certApprovalCallback = new ConfigCertApprovalCallback(); - r = pingCS(hostname, admin_port, true, certApprovalCallback); - } catch (Exception e) { - CMS.debug("SecurityDomainPanel: exception caught: " - + e.toString()); + ConfigCertApprovalCallback + certApprovalCallback = new ConfigCertApprovalCallback(); + r = pingCS( hostname, admin_port, true, + certApprovalCallback ); + } catch( Exception e ) { + CMS.debug( "SecurityDomainPanel: exception caught: " + + e.toString() ); context.put("updateStatus", "validate-failure"); - throw new IOException("Illegal SSL Admin HTTPS url value " - + "for the security domain"); + throw new IOException( "Illegal SSL Admin HTTPS url value " + + "for the security domain" ); } if (r != null) { - CMS.debug("SecurityDomainPanel: pingAdminCS returns: " + r); - context.put("sdomainURL", admin_url); + CMS.debug("SecurityDomainPanel: pingAdminCS returns: " + + r ); + context.put( "sdomainURL", admin_url ); } else { - CMS.debug("SecurityDomainPanel: pingAdminCS " - + "no successful response for SSL Admin HTTPS"); - context.put("sdomainURL", ""); + CMS.debug( "SecurityDomainPanel: pingAdminCS " + + "no successful response for SSL Admin HTTPS" ); + context.put( "sdomainURL", "" ); } } } } - public void initParams(HttpServletRequest request, Context context) - throws IOException { + public void initParams(HttpServletRequest request, Context context) + throws IOException + { IConfigStore config = CMS.getConfigStore(); try { context.put("cstype", config.getString("cs.type")); @@ -305,7 +306,7 @@ public class SecurityDomainPanel extends WizardPanelBase { context.put("check_newdomain", "checked"); context.put("check_existingdomain", ""); } else if (select.equals("existingdomain")) { - context.put("check_newdomain", ""); + context.put("check_newdomain", ""); context.put("check_existingdomain", "checked"); } @@ -324,7 +325,8 @@ public class SecurityDomainPanel extends WizardPanelBase { * Commit parameter changes */ public void update(HttpServletRequest request, - HttpServletResponse response, Context context) throws IOException { + HttpServletResponse response, + Context context) throws IOException { String errorString = ""; String select = HttpInput.getID(request, "choice"); @@ -338,28 +340,29 @@ public class SecurityDomainPanel extends WizardPanelBase { if (select.equals("newdomain")) { config.putString("preop.securitydomain.select", "new"); config.putString("securitydomain.select", "new"); - config.putString("preop.securitydomain.name", - HttpInput.getDomainName(request, "sdomainName")); - config.putString("securitydomain.name", - HttpInput.getDomainName(request, "sdomainName")); - config.putString("securitydomain.host", CMS.getEENonSSLHost()); - config.putString("securitydomain.httpport", CMS.getEENonSSLPort()); - config.putString("securitydomain.httpsagentport", - CMS.getAgentPort()); - config.putString("securitydomain.httpseeport", CMS.getEESSLPort()); - config.putString("securitydomain.httpsadminport", - CMS.getAdminPort()); - - // make sure the subsystem certificate is issued by the security + config.putString("preop.securitydomain.name", + HttpInput.getDomainName(request, "sdomainName")); + config.putString("securitydomain.name", + HttpInput.getDomainName(request, "sdomainName")); + config.putString("securitydomain.host", + CMS.getEENonSSLHost()); + config.putString("securitydomain.httpport", + CMS.getEENonSSLPort()); + config.putString("securitydomain.httpsagentport", + CMS.getAgentPort()); + config.putString("securitydomain.httpseeport", + CMS.getEESSLPort()); + config.putString("securitydomain.httpsadminport", + CMS.getAdminPort()); + + // make sure the subsystem certificate is issued by the security // domain config.putString("preop.cert.subsystem.type", "local"); - config.putString("preop.cert.subsystem.profile", - "subsystemCert.profile"); - + config.putString("preop.cert.subsystem.profile", "subsystemCert.profile"); + try { config.commit(false); - } catch (EBaseException e) { - } + } catch (EBaseException e) {} String instanceRoot = ""; try { @@ -374,38 +377,37 @@ public class SecurityDomainPanel extends WizardPanelBase { // make sure the subsystem certificate is issued by the security // domain config.putString("preop.cert.subsystem.type", "remote"); - config.putString("preop.cert.subsystem.profile", - "caInternalAuthSubsystemCert"); + config.putString("preop.cert.subsystem.profile", "caInternalAuthSubsystemCert"); String admin_url = HttpInput.getURL(request, "sdomainURL"); String hostname = ""; int admin_port = -1; - if (admin_url != null) { + if( admin_url != null ) { try { - URL admin_u = new URL(admin_url); + URL admin_u = new URL( admin_url ); hostname = admin_u.getHost(); admin_port = admin_u.getPort(); - } catch (MalformedURLException e) { + } catch( MalformedURLException e ) { errorString = "Malformed SSL Admin HTTPS URL"; context.put("updateStatus", "failure"); - throw new IOException(errorString); + throw new IOException( errorString ); } - context.put("sdomainURL", admin_url); - config.putString("securitydomain.host", hostname); - config.putInteger("securitydomain.httpsadminport", admin_port); + context.put( "sdomainURL", admin_url ); + config.putString( "securitydomain.host", hostname ); + config.putInteger( "securitydomain.httpsadminport", + admin_port ); } try { config.commit(false); - } catch (EBaseException e) { - } + } catch (EBaseException e) {} ConfigCertApprovalCallback certApprovalCallback = new ConfigCertApprovalCallback(); - updateCertChain(config, "securitydomain", hostname, admin_port, - true, context, certApprovalCallback); + updateCertChain( config, "securitydomain", hostname, admin_port, + true, context, certApprovalCallback ); } else { CMS.debug("SecurityDomainPanel: invalid choice " + select); errorString = "Invalid choice"; @@ -423,8 +425,7 @@ public class SecurityDomainPanel extends WizardPanelBase { context.put("wizardname", config.getString("preop.wizard.name")); context.put("panelname", "Security Domain Configuration"); context.put("systemname", config.getString("preop.system.name")); - } catch (EBaseException e) { - } + } catch (EBaseException e) {} context.put("errorString", errorString); context.put("updateStatus", "success"); @@ -434,7 +435,8 @@ public class SecurityDomainPanel extends WizardPanelBase { * If validate() returns false, this method will be called. */ public void displayError(HttpServletRequest request, - HttpServletResponse response, Context context) { + HttpServletResponse response, + Context context) { IConfigStore config = CMS.getConfigStore(); String default_admin_url = ""; try { @@ -443,35 +445,33 @@ public class SecurityDomainPanel extends WizardPanelBase { } try { - default_admin_url = config.getString( - "preop.securitydomain.admin_url", ""); - } catch (Exception e) { - } + default_admin_url = config.getString("preop.securitydomain.admin_url", ""); + } catch (Exception e) {} - if (default_admin_url != null) { + if( default_admin_url != null ) { String r = null; try { // check to see if "default" security domain exists // on local machine - URL u = new URL(default_admin_url); + URL u = new URL( default_admin_url ); String hostname = u.getHost(); int port = u.getPort(); - ConfigCertApprovalCallback certApprovalCallback = new ConfigCertApprovalCallback(); - r = pingCS(hostname, port, true, certApprovalCallback); - } catch (Exception e) { - } - - if (r != null) { + ConfigCertApprovalCallback + certApprovalCallback = new ConfigCertApprovalCallback(); + r = pingCS( hostname, port, true, certApprovalCallback ); + } catch (Exception e) {} + + if( r != null ) { // "default" security domain exists on local machine; // refill "sdomainURL" in with "default" security domain // as an initial "guess" - context.put("sdomainURL", default_admin_url); + context.put( "sdomainURL", default_admin_url ); } else { // "default" security domain does NOT exist on local machine; // leave "sdomainURL" blank - context.put("sdomainURL", ""); + context.put( "sdomainURL", "" ); } } @@ -482,21 +482,20 @@ public class SecurityDomainPanel extends WizardPanelBase { context.put("https_ee_port", CMS.getEESSLPort()); context.put("https_admin_port", CMS.getAdminPort()); context.put("sdomainAdminURL", - config.getString("preop.securitydomain.admin_url")); - } catch (EBaseException e) { - } + config.getString("preop.securitydomain.admin_url")); + } catch (EBaseException e) {} // Information for "existing" Security Domain CAs String initDaemon = "pki-cad"; String instanceId = "<security_domain_instance_name>"; - String os = System.getProperty("os.name"); - if (os.equalsIgnoreCase("Linux")) { - context.put("initCommand", "/sbin/service " + initDaemon); - context.put("instanceId", instanceId); + String os = System.getProperty( "os.name" ); + if( os.equalsIgnoreCase( "Linux" ) ) { + context.put( "initCommand", "/sbin/service " + initDaemon ); + context.put( "instanceId", instanceId ); } else { - /* default case: e. g. - ( os.equalsIgnoreCase( "SunOS" ) */ - context.put("initCommand", "/etc/init.d/" + initDaemon); - context.put("instanceId", instanceId); + /* default case: e. g. - ( os.equalsIgnoreCase( "SunOS" ) */ + context.put( "initCommand", "/etc/init.d/" + initDaemon ); + context.put( "instanceId", instanceId ); } context.put("title", "Security Domain"); |