From f554dc2aa0478aa23f7e986b6779091f7d520bf5 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Sat, 11 Aug 2012 08:37:52 -0500 Subject: Cleaned up REST common class names. The REST common classes have been renamed for better clarity and consistency. Ticket #259 --- .../cms/servlet/csadmin/PKIErrorInterceptor.java | 8 +- .../cms/servlet/csadmin/SystemConfigClient.java | 10 +- .../cms/servlet/csadmin/SystemConfigResource.java | 63 ++ .../cms/servlet/csadmin/SystemConfigService.java | 186 +++--- .../csadmin/SystemConfigurationResource.java | 63 -- .../cms/servlet/csadmin/model/CertData.java | 270 -------- .../servlet/csadmin/model/ConfigurationData.java | 724 --------------------- .../csadmin/model/ConfigurationRequest.java | 724 +++++++++++++++++++++ .../csadmin/model/ConfigurationResponse.java | 121 ++++ .../csadmin/model/ConfigurationResponseData.java | 120 ---- .../cms/servlet/csadmin/model/SystemCertData.java | 270 ++++++++ 11 files changed, 1280 insertions(+), 1279 deletions(-) create mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigResource.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigurationResource.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/CertData.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationData.java create mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationRequest.java create mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponse.java delete mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponseData.java create mode 100644 base/common/src/com/netscape/cms/servlet/csadmin/model/SystemCertData.java (limited to 'base/common/src/com/netscape/cms/servlet/csadmin') diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java b/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java index 166c02eb9..795c0fda3 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java @@ -23,7 +23,7 @@ import javax.ws.rs.core.MultivaluedMap; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.ClientErrorInterceptor; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; public class PKIErrorInterceptor implements ClientErrorInterceptor { @@ -41,15 +41,15 @@ public class PKIErrorInterceptor implements ClientErrorInterceptor { if (contentType == null || !contentType.startsWith(MediaType.APPLICATION_XML)) return; - CMSException exception; + PKIException exception; try { // Requires RESTEasy 2.3.2 // https://issues.jboss.org/browse/RESTEASY-652 - CMSException.Data data = response.getEntity(CMSException.Data.class); + PKIException.Data data = response.getEntity(PKIException.Data.class); Class clazz = Class.forName(data.className); - exception = (CMSException) clazz.getConstructor(CMSException.Data.class).newInstance(data); + exception = (PKIException) clazz.getConstructor(PKIException.Data.class).newInstance(data); } catch (Exception e) { e.printStackTrace(); diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java index 6167b0521..11815a65b 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java @@ -20,8 +20,8 @@ package com.netscape.cms.servlet.csadmin; import java.net.URISyntaxException; import com.netscape.cms.client.cli.ClientConfig; -import com.netscape.cms.servlet.csadmin.model.ConfigurationData; -import com.netscape.cms.servlet.csadmin.model.ConfigurationResponseData; +import com.netscape.cms.servlet.csadmin.model.ConfigurationRequest; +import com.netscape.cms.servlet.csadmin.model.ConfigurationResponse; import com.netscape.cms.servlet.csadmin.model.InstallToken; import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; @@ -32,15 +32,15 @@ import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; */ public class SystemConfigClient extends PKIClient { - private SystemConfigurationResource configClient; + private SystemConfigResource configClient; public SystemConfigClient(ClientConfig config) throws URISyntaxException { super(config); - configClient = createProxy(SystemConfigurationResource.class); + configClient = createProxy(SystemConfigResource.class); } - public ConfigurationResponseData configure(ConfigurationData data) { + public ConfigurationResponse configure(ConfigurationRequest data) { return configClient.configure(data); } diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigResource.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigResource.java new file mode 100644 index 000000000..9cb6791e3 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigResource.java @@ -0,0 +1,63 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.csadmin; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; + +import com.netscape.cms.servlet.csadmin.model.ConfigurationRequest; +import com.netscape.cms.servlet.csadmin.model.ConfigurationResponse; +import com.netscape.cms.servlet.csadmin.model.DomainInfo; +import com.netscape.cms.servlet.csadmin.model.InstallToken; +import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; + +/** + * @author alee + */ +@Path("installer") +public interface SystemConfigResource { + + @POST + @Path("configure") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) + public ConfigurationResponse configure(MultivaluedMap form); + + @POST + @Path("configure") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public ConfigurationResponse configure(ConfigurationRequest data); + + @POST + @Path("installToken") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public InstallToken getInstallToken(InstallTokenRequest data); + + @GET + @Path("domainInfo") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public DomainInfo getDomainInfo(); +} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java index cee8e86e3..b17cf1752 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java @@ -52,14 +52,14 @@ import com.netscape.certsrv.dbs.certdb.ICertificateRepository; import com.netscape.certsrv.ocsp.IOCSPAuthority; import com.netscape.certsrv.usrgrp.IUGSubsystem; import com.netscape.certsrv.usrgrp.IUser; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.base.PKIService; -import com.netscape.cms.servlet.csadmin.model.CertData; -import com.netscape.cms.servlet.csadmin.model.ConfigurationData; -import com.netscape.cms.servlet.csadmin.model.ConfigurationResponseData; +import com.netscape.cms.servlet.csadmin.model.ConfigurationResponse; import com.netscape.cms.servlet.csadmin.model.DomainInfo; import com.netscape.cms.servlet.csadmin.model.InstallToken; import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; +import com.netscape.cms.servlet.csadmin.model.SystemCertData; +import com.netscape.cms.servlet.csadmin.model.ConfigurationRequest; import com.netscape.cmsutil.crypto.CryptoUtil; import com.netscape.cmsutil.util.Utils; @@ -67,7 +67,7 @@ import com.netscape.cmsutil.util.Utils; * @author alee * */ -public class SystemConfigService extends PKIService implements SystemConfigurationResource { +public class SystemConfigService extends PKIService implements SystemConfigResource { IConfigStore cs; String csType; String csState; @@ -95,8 +95,8 @@ public class SystemConfigService extends PKIService implements SystemConfigurati * @see com.netscape.cms.servlet.csadmin.SystemConfigurationResource#configure(javax.ws.rs.core.MultivaluedMap) */ @Override - public ConfigurationResponseData configure(MultivaluedMap form) { - ConfigurationData data = new ConfigurationData(form); + public ConfigurationResponse configure(MultivaluedMap form) { + ConfigurationRequest data = new ConfigurationRequest(form); return configure(data); } @@ -104,9 +104,9 @@ public class SystemConfigService extends PKIService implements SystemConfigurati * @see com.netscape.cms.servlet.csadmin.SystemConfigurationResource#configure(com.netscape.cms.servlet.csadmin.data.ConfigurationData) */ @Override - public ConfigurationResponseData configure(ConfigurationData data){ + public ConfigurationResponse configure(ConfigurationRequest data){ if (csState.equals("1")) { - throw new CMSException(Response.Status.BAD_REQUEST, "System is already configured"); + throw new PKIException(Response.Status.BAD_REQUEST, "System is already configured"); } String certList; @@ -114,34 +114,34 @@ public class SystemConfigService extends PKIService implements SystemConfigurati certList = cs.getString("preop.cert.list"); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Unable to get certList from config file"); + throw new PKIException("Unable to get certList from config file"); } validateData(data); - ConfigurationResponseData response = new ConfigurationResponseData(); + ConfigurationResponse response = new ConfigurationResponse(); // specify module and log into token String token = data.getToken(); if (token == null) { - token = ConfigurationData.TOKEN_DEFAULT; + token = ConfigurationRequest.TOKEN_DEFAULT; } cs.putString("preop.module.token", token); - if (! token.equals(ConfigurationData.TOKEN_DEFAULT)) { + if (! token.equals(ConfigurationRequest.TOKEN_DEFAULT)) { try { CryptoManager cryptoManager = CryptoManager.getInstance(); CryptoToken ctoken = cryptoManager.getTokenByName(token); String tokenpwd = data.getTokenPassword(); ConfigurationUtils.loginToken(ctoken, tokenpwd); } catch (NotInitializedException e) { - throw new CMSException("Token is not initialized"); + throw new PKIException("Token is not initialized"); } catch (NoSuchTokenException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid Token provided. No such token."); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid Token provided. No such token."); } catch (TokenException e) { e.printStackTrace(); - throw new CMSException("Token Exception" + e); + throw new PKIException("Token Exception" + e); } catch (IncorrectPasswordException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Incorrect Password provided for token."); + throw new PKIException(Response.Status.BAD_REQUEST, "Incorrect Password provided for token."); } } @@ -150,7 +150,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati String securityDomainName = data.getSecurityDomainName(); String securityDomainURL = data.getSecurityDomainUri(); String domainXML = null; - if (securityDomainType.equals(ConfigurationData.NEW_DOMAIN)) { + if (securityDomainType.equals(ConfigurationRequest.NEW_DOMAIN)) { cs.putString("preop.securitydomain.select", "new"); cs.putString("securitydomain.select", "new"); cs.putString("preop.securitydomain.name", securityDomainName); @@ -181,7 +181,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.importCertChain(host, port, "/ca/admin/ca/getCertChain", "securitydomain"); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to import certificate chain from security domain master: " + e); + throw new PKIException("Failed to import certificate chain from security domain master: " + e); } // log onto security domain and get token @@ -192,11 +192,11 @@ public class SystemConfigService extends PKIService implements SystemConfigurati installToken = ConfigurationUtils.getInstallToken(host, port, user, pass); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to obtain installation token from security domain: " + e); + throw new PKIException("Failed to obtain installation token from security domain: " + e); } if (installToken == null) { - throw new CMSException("Failed to obtain installation token from security domain"); + throw new PKIException("Failed to obtain installation token from security domain"); } CMS.setConfigSDSessionId(installToken); @@ -205,7 +205,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.getSecurityDomainPorts(domainXML, host, port); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to obtain security domain decriptor from security domain master: " + e); + throw new PKIException("Failed to obtain security domain decriptor from security domain master: " + e); } } @@ -245,11 +245,11 @@ public class SystemConfigService extends PKIService implements SystemConfigurati validCloneUri = ConfigurationUtils.isValidCloneURI(domainXML, masterHost, masterPort); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error in determining whether clone URI is valid"); + throw new PKIException("Error in determining whether clone URI is valid"); } if (!validCloneUri) { - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid clone URI provided. Does not match the available subsystems in the security domain"); } @@ -258,7 +258,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.importCertChain(masterHost, masterPort, "/ca/ee/ca/getCertChain", "clone"); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to import certificate chain from master" + e); + throw new PKIException("Failed to import certificate chain from master" + e); } } @@ -266,25 +266,25 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.getConfigEntriesFromMaster(); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to obtain configuration entries from the master for cloning " + e); + throw new PKIException("Failed to obtain configuration entries from the master for cloning " + e); } // restore certs from P12 file - if (token.equals(ConfigurationData.TOKEN_DEFAULT)) { + if (token.equals(ConfigurationRequest.TOKEN_DEFAULT)) { String p12File = data.getP12File(); String p12Pass = data.getP12Password(); try { ConfigurationUtils.restoreCertsFromP12(p12File, p12Pass); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Failed to restore certificates from p12 file" + e); + throw new PKIException("Failed to restore certificates from p12 file" + e); } } boolean cloneReady = ConfigurationUtils.isCertdbCloned(); if (!cloneReady) { CMS.debug("clone does not have all the certificates."); - throw new CMSException("Clone does not have all the required certificates"); + throw new PKIException("Clone does not have all the required certificates"); } } @@ -299,7 +299,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati cs.putString("preop.hierarchy.select", "join"); cs.putString("hierarchy.select", "Subordinate"); } else { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid hierarchy provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid hierarchy provided"); } } @@ -316,7 +316,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati cs.commit(false); } catch (EBaseException e2) { e2.printStackTrace(); - throw new CMSException("Unable to commit config parameters to file"); + throw new PKIException("Unable to commit config parameters to file"); } if (data.getIsClone().equals("true")) { @@ -333,12 +333,12 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } if (masterhost.equals(realhostname) && masterport.equals(data.getDsPort())) { - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, "Master and clone must not share the same internal database"); } if (!masterbasedn.equals(data.getBaseDN())) { - throw new CMSException(Response.Status.BAD_REQUEST, "Master and clone should have the same base DN"); + throw new PKIException(Response.Status.BAD_REQUEST, "Master and clone should have the same base DN"); } String masterReplicationPort = data.getMasterReplicationPort(); @@ -390,7 +390,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.reInitSubsystem(csType); } } catch (Exception e) { - throw new CMSException("Error in populating database" + e); + throw new PKIException("Error in populating database" + e); } // SizePanel, NamePanel, CertRequestPanel @@ -433,7 +433,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } } } catch (Exception e) { - throw new CMSException("Error in obtaining certificate chain from issuing CA: " + e); + throw new PKIException("Error in obtaining certificate chain from issuing CA: " + e); } boolean hasSigningCert = false; @@ -445,9 +445,9 @@ public class SystemConfigService extends PKIService implements SystemConfigurati boolean enable = cs.getBoolean("preop.cert." + ct + ".enable", true); if (!enable) continue; - Collection certData = data.getSystemCerts(); - Iterator iterator = certData.iterator(); - CertData cdata = null; + Collection certData = data.getSystemCerts(); + Iterator iterator = certData.iterator(); + SystemCertData cdata = null; while (iterator.hasNext()) { cdata = iterator.next(); if (cdata.getTag().equals(ct)) break; @@ -521,7 +521,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati if (cdata.getCertChain() != null) { certObj.setCertChain(cdata.getCertChain()); } else { - throw new CMSException(Response.Status.BAD_REQUEST, "CertChain not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "CertChain not provided"); } } } @@ -533,13 +533,13 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } catch (NumberFormatException e) { // move these validations to validate()? - throw new CMSException(Response.Status.BAD_REQUEST, "Non-integer value for key size"); + throw new PKIException(Response.Status.BAD_REQUEST, "Non-integer value for key size"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid algorithm " + e); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid algorithm " + e); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error in setting certificate names and key sizes: " + e); + throw new PKIException("Error in setting certificate names and key sizes: " + e); } // submitting to external ca @@ -557,10 +557,10 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.setCertPermissions(cert.getCertTag()); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error in confguring system certificates" + e); + throw new PKIException("Error in confguring system certificates" + e); } if (ret != 0) { - throw new CMSException("Error in confguring system certificates"); + throw new PKIException("Error in confguring system certificates"); } } response.setSystemCerts(certs); @@ -571,7 +571,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.backupKeys(data.getBackupPassword(), data.getBackupFile()); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error in creating pkcs12 to backup keys and certs: " + e); + throw new PKIException("Error in creating pkcs12 to backup keys and certs: " + e); } } @@ -617,14 +617,14 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error in creating admin user: " + e); + throw new PKIException("Error in creating admin user: " + e); } } // Done Panel // Create or update security domain try { - if (securityDomainType.equals(ConfigurationData.NEW_DOMAIN)) { + if (securityDomainType.equals(ConfigurationRequest.NEW_DOMAIN)) { ConfigurationUtils.createSecurityDomain(); } else { ConfigurationUtils.updateSecurityDomain(); @@ -634,7 +634,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati cs.commit(false); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Error while updating security domain: " + e); + throw new PKIException("Error while updating security domain: " + e); } // need to push connector information to the CA @@ -653,7 +653,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Errors in pushing KRA connector information to the CA: " + e); + throw new PKIException("Errors in pushing KRA connector information to the CA: " + e); } // import the CA certificate into the OCSP @@ -667,7 +667,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Errors in configuring CA publishing to OCSP: " + e); + throw new PKIException("Errors in configuring CA publishing to OCSP: " + e); } if (!data.getIsClone().equals("true")) { @@ -677,7 +677,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Errors in updating next serial number ranges in DB: " + e); + throw new PKIException("Errors in updating next serial number ranges in DB: " + e); } } @@ -695,12 +695,12 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } } catch (Exception e1) { e1.printStackTrace(); - throw new CMSException("Errors in determining if security domain host is a master CA"); + throw new PKIException("Errors in determining if security domain host is a master CA"); } try { String dbuser = csType + "-" + CMS.getEEHost() + "-" + CMS.getEESSLPort(); - if (! securityDomainType.equals(ConfigurationData.NEW_DOMAIN)) { + if (! securityDomainType.equals(ConfigurationRequest.NEW_DOMAIN)) { ConfigurationUtils.setupDBUser(dbuser); } IUGSubsystem system = (IUGSubsystem) (CMS.getSubsystem(IUGSubsystem.ID)); @@ -708,7 +708,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati system.addCertSubjectDN(user); } catch (Exception e) { e.printStackTrace(); - throw new CMSException("Errors in creating or updating dbuser: " + e); + throw new PKIException("Errors in creating or updating dbuser: " + e); } cs.putInteger("cs.state", 1); @@ -720,7 +720,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati ConfigurationUtils.removePreopConfigEntries(); } catch (EBaseException e) { e.printStackTrace(); - throw new CMSException("Errors when removing preop config entries: " + e); + throw new PKIException("Errors when removing preop config entries: " + e); } // Create an empty file that designates the fact that although @@ -734,7 +734,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati return response; } - private void validateData(ConfigurationData data) { + private void validateData(ConfigurationRequest data) { // get required info from CS.cfg String preopPin; try { @@ -742,35 +742,35 @@ public class SystemConfigService extends PKIService implements SystemConfigurati } catch (Exception e) { CMS.debug("validateData: Failed to get required config form CS.cfg"); e.printStackTrace(); - throw new CMSException("Unable to retrieve required configuration from configuration files"); + throw new PKIException("Unable to retrieve required configuration from configuration files"); } // get the preop pin and validate it String pin = data.getPin(); if (pin == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "No preop pin provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "No preop pin provided"); } if (!preopPin.equals(pin)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Incorrect pin provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Incorrect pin provided"); } // validate security domain settings String domainType = data.getSecurityDomainType(); if (domainType == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "Security Domain Type not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Security Domain Type not provided"); } - if (domainType.equals(ConfigurationData.NEW_DOMAIN)) { + if (domainType.equals(ConfigurationRequest.NEW_DOMAIN)) { if (!csType.equals("CA")) { - throw new CMSException(Response.Status.BAD_REQUEST, "New Domain is only valid for CA subsytems"); + throw new PKIException(Response.Status.BAD_REQUEST, "New Domain is only valid for CA subsytems"); } if (data.getSecurityDomainName() == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "Security Domain Name is not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Security Domain Name is not provided"); } - } else if (domainType.equals(ConfigurationData.EXISTING_DOMAIN)) { + } else if (domainType.equals(ConfigurationRequest.EXISTING_DOMAIN)) { String domainURI = data.getSecurityDomainUri(); if (domainURI == null) { - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, "Existing security domain requested, but no security domain URI provided"); } @@ -778,40 +778,40 @@ public class SystemConfigService extends PKIService implements SystemConfigurati @SuppressWarnings("unused") URL admin_u = new URL(domainURI); // check for invalid URL } catch (MalformedURLException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid security domain URI"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid security domain URI"); } if ((data.getSecurityDomainUser() == null) || (data.getSecurityDomainPassword() == null)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Security domain user or password not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Security domain user or password not provided"); } } else { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid security domain URI provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid security domain URI provided"); } if ((data.getSubsystemName() == null) || (data.getSubsystemName().length() ==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid or no subsystem name provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid or no subsystem name provided"); } if ((data.getIsClone() != null) && (data.getIsClone().equals("true"))) { String cloneUri = data.getCloneUri(); if (cloneUri == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "Clone selected, but no clone URI provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Clone selected, but no clone URI provided"); } try { @SuppressWarnings("unused") URL url = new URL(cloneUri); // check for invalid URL // confirm protocol is https } catch (MalformedURLException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid clone URI"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid clone URI"); } - if (data.getToken().equals(ConfigurationData.TOKEN_DEFAULT)) { + if (data.getToken().equals(ConfigurationRequest.TOKEN_DEFAULT)) { if (data.getP12File() == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "P12 filename not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "P12 filename not provided"); } if (data.getP12Password() == null) { - throw new CMSException(Response.Status.BAD_REQUEST, "P12 password not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "P12 password not provided"); } } } else { @@ -820,33 +820,33 @@ public class SystemConfigService extends PKIService implements SystemConfigurati String dsHost = data.getDsHost(); if (dsHost == null || dsHost.length() == 0) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database host not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database host not provided"); } try { Integer.parseInt(data.getDsPort()); // check for errors } catch (NumberFormatException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database port is invalid"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database port is invalid"); } String basedn = data.getBaseDN(); if (basedn == null || basedn.length() == 0) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database basedn not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database basedn not provided"); } String binddn = data.getBindDN(); if (binddn == null || binddn.length() == 0) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database basedn not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database basedn not provided"); } String database = data.getDatabase(); if (database == null || database.length() == 0) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database database name not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database database name not provided"); } String bindpwd = data.getBindpwd(); if (bindpwd == null || bindpwd.length() == 0) { - throw new CMSException(Response.Status.BAD_REQUEST, "Internal database database name not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Internal database database name not provided"); } String masterReplicationPort = data.getMasterReplicationPort(); @@ -854,7 +854,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati try { Integer.parseInt(masterReplicationPort); // check for errors } catch (NumberFormatException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Master replication port is invalid"); + throw new PKIException(Response.Status.BAD_REQUEST, "Master replication port is invalid"); } } @@ -863,48 +863,48 @@ public class SystemConfigService extends PKIService implements SystemConfigurati try { Integer.parseInt(cloneReplicationPort); // check for errors } catch (Exception e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Clone replication port is invalid"); + throw new PKIException(Response.Status.BAD_REQUEST, "Clone replication port is invalid"); } } if ((data.getBackupKeys() != null) && data.getBackupKeys().equals("true")) { if ((data.getBackupFile() == null) || (data.getBackupFile().length()<=0)) { //TODO: also check for valid path, perhaps by touching file there - throw new CMSException(Response.Status.BAD_REQUEST, "Invalid key backup file name"); + throw new PKIException(Response.Status.BAD_REQUEST, "Invalid key backup file name"); } if ((data.getBackupPassword() == null) || (data.getBackupPassword().length()<8)) { - throw new CMSException(Response.Status.BAD_REQUEST, "key backup password must be at least 8 characters"); + throw new PKIException(Response.Status.BAD_REQUEST, "key backup password must be at least 8 characters"); } } else { data.setBackupKeys("false"); } if (csType.equals("CA") && (data.getHierarchy() == null)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Hierarchy is requred for CA, not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Hierarchy is requred for CA, not provided"); } if (data.getIsClone().equals("false")) { if ((data.getAdminUID() == null) || (data.getAdminUID().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin UID not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin UID not provided"); } if ((data.getAdminPassword() == null) || (data.getAdminPassword().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin Password not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin Password not provided"); } if ((data.getAdminEmail() == null) || (data.getAdminEmail().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin UID not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin UID not provided"); } if ((data.getAdminName() == null) || (data.getAdminName().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin name not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin name not provided"); } if ((data.getAdminCertRequest() == null) || (data.getAdminCertRequest().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin cert request not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin cert request not provided"); } if ((data.getAdminCertRequestType() == null) || (data.getAdminCertRequestType().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin cert request type not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin cert request type not provided"); } if ((data.getAdminSubjectDN() == null) || (data.getAdminSubjectDN().length()==0)) { - throw new CMSException(Response.Status.BAD_REQUEST, "Admin subjectDN not provided"); + throw new PKIException(Response.Status.BAD_REQUEST, "Admin subjectDN not provided"); } } @@ -928,7 +928,7 @@ public class SystemConfigService extends PKIService implements SystemConfigurati try { ip = InetAddress.getByName(host).toString(); } catch (UnknownHostException e) { - throw new CMSException(Response.Status.BAD_REQUEST, "Unable to resolve host " + host + + throw new PKIException(Response.Status.BAD_REQUEST, "Unable to resolve host " + host + "to an IP address: " + e); } int index = ip.indexOf("/"); diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigurationResource.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigurationResource.java deleted file mode 100644 index 2918842c9..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigurationResource.java +++ /dev/null @@ -1,63 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2012 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; - -import com.netscape.cms.servlet.csadmin.model.ConfigurationData; -import com.netscape.cms.servlet.csadmin.model.ConfigurationResponseData; -import com.netscape.cms.servlet.csadmin.model.DomainInfo; -import com.netscape.cms.servlet.csadmin.model.InstallToken; -import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; - -/** - * @author alee - */ -@Path("installer") -public interface SystemConfigurationResource { - - @POST - @Path("configure") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) - public ConfigurationResponseData configure(MultivaluedMap form); - - @POST - @Path("configure") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public ConfigurationResponseData configure(ConfigurationData data); - - @POST - @Path("installToken") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public InstallToken getInstallToken(InstallTokenRequest data); - - @GET - @Path("domainInfo") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public DomainInfo getDomainInfo(); -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/CertData.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/CertData.java deleted file mode 100644 index d9e5e8005..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/model/CertData.java +++ /dev/null @@ -1,270 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2012 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -package com.netscape.cms.servlet.csadmin.model; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author alee - * - */ -@XmlRootElement(name="CertData") -@XmlAccessorType(XmlAccessType.FIELD) -public class CertData { - public static final String TAG = "tag"; - public static final String NICKNAME = "nickname"; - public static final String TOKEN = "token"; - public static final String KEY_TYPE = "keyType"; - public static final String KEY_ALGORITHM = "keyAlgorithm"; - public static final String SIGNING_ALGORITHM = "signingAlgorithm"; - public static final String KEY_SIZE = "keySize"; - public static final String KEY_CURVENAME = "keyCurveName"; - public static final String REQUEST = "request"; - public static final String SUBJECT_DN = "subjectDN"; - public static final String CERT = "cert"; - public static final String CERT_CHAIN = "certChain"; - - @XmlElement - protected String tag; - - @XmlElement - protected String nickname; - - @XmlElement - protected String token; - - @XmlElement - protected String keyType; - - @XmlElement - protected String keyAlgorithm; - - @XmlElement - protected String signingAlgorithm; - - @XmlElement - protected String keySize; - - @XmlElement - protected String keyCurveName; - - @XmlElement - protected String request; - - @XmlElement - protected String subjectDN; - - @XmlElement - protected String cert; - - @XmlElement - protected String certChain; - - public CertData() { - // required for JAXB - } - - public CertData(MultivaluedMap form) { - tag = form.getFirst(TAG); - nickname = form.getFirst(NICKNAME); - token = form.getFirst(TOKEN); - keyType = form.getFirst(KEY_TYPE); - keyAlgorithm = form.getFirst(KEY_ALGORITHM); - signingAlgorithm = form.getFirst(SIGNING_ALGORITHM); - keySize = form.getFirst(KEY_SIZE); - keyCurveName = form.getFirst(KEY_CURVENAME); - request = form.getFirst(REQUEST); - subjectDN = form.getFirst(SUBJECT_DN); - cert = form.getFirst(CERT); - certChain = form.getFirst(CERT_CHAIN); - } - - /** - * @return the tag - */ - public String getTag() { - return tag; - } - - /** - * @param tag the tag to set - */ - public void setTag(String tag) { - this.tag = tag; - } - - /** - * @return the nickname - */ - public String getNickname() { - return nickname; - } - - /** - * @param nickname the nickname to set - */ - public void setNickname(String nickname) { - this.nickname = nickname; - } - - /** - * @return the token - */ - public String getToken() { - return token; - } - - /** - * @param token the token to set - */ - public void setToken(String token) { - this.token = token; - } - - /** - * @return the keyType - */ - public String getKeyType() { - return keyType; - } - - /** - * @param keyType the keyType to set - */ - public void setKeyType(String keyType) { - this.keyType = keyType; - } - - /** - * @return the keyAlgorithm - */ - public String getKeyAlgorithm() { - return keyAlgorithm; - } - - /** - * @param keyAlgorithm the keyAlgorithm to set - */ - public void setKeyAlgorithm(String keyAlgorithm) { - this.keyAlgorithm = keyAlgorithm; - } - - /** - * @return the signingAlgorithm - */ - public String getSigningAlgorithm() { - return signingAlgorithm; - } - - /** - * @param signingAlgorithm the signingAlgorithm to set - */ - public void setSigningAlgorithm(String signingAlgorithm) { - this.signingAlgorithm = signingAlgorithm; - } - - /** - * @return the keySize - */ - public String getKeySize() { - return keySize; - } - - /** - * @param keySize the keySize to set - */ - public void setKeySize(String keySize) { - this.keySize = keySize; - } - - /** - * @return the keyCurveName - */ - public String getKeyCurveName() { - return keyCurveName; - } - - /** - * @param keyCurveName the keyCurveName to set - */ - public void setKeyCurveName(String keyCurveName) { - this.keyCurveName = keyCurveName; - } - - /** - * @return the request - */ - public String getRequest() { - return request; - } - - /** - * @param request the request to set - */ - public void setRequest(String request) { - this.request = request; - } - - /** - * @return the subjectDN - */ - public String getSubjectDN() { - return subjectDN; - } - - /** - * @param subjectDN the subjectDN to set - */ - public void setSubjectDN(String subjectDN) { - this.subjectDN = subjectDN; - } - - /** - * @return the cert - */ - public String getCert() { - return cert; - } - - /** - * @param cert the cert to set - */ - public void setCert(String cert) { - this.cert = cert; - } - - /** - * @return the certChain - */ - public String getCertChain() { - return certChain; - } - - /** - * @param certChain the certChain to set - */ - public void setCertChain(String certChain) { - this.certChain = certChain; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationData.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationData.java deleted file mode 100644 index 3c1bea86b..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationData.java +++ /dev/null @@ -1,724 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2012 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin.model; - -import java.util.Collection; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author alee - * - */ -@XmlRootElement(name="ConfigurationData") -@XmlAccessorType(XmlAccessType.FIELD) -public class ConfigurationData { - private static final String PIN = "pin"; - private static final String TOKEN = "token"; - private static final String TOKEN_PASSWORD = "tokenPassword"; - private static final String SECURITY_DOMAIN_TYPE = "securityDomainType"; - private static final String SECURITY_DOMAIN_URI = "securityDomainUri"; - private static final String SECURITY_DOMAIN_NAME = "securityDomainName"; - private static final String SECURITY_DOMAIN_USER = "securityDomainUser"; - private static final String SECURITY_DOMAIN_PASSWORD = "securityDomainPassword"; - private static final String IS_CLONE = "isClone"; - private static final String CLONE_URI = "cloneUri"; - private static final String SUBSYSTEM_NAME = "subsystemName"; - private static final String P12_FILE = "p12File"; - private static final String P12_PASSWORD = "p12Password"; - private static final String HIERARCHY = "hierarchy"; - private static final String DSHOST = "dsHost"; - private static final String DSPORT = "dsPort"; - private static final String BASEDN = "basedn"; - private static final String BINDDN = "binddn"; - private static final String DATABASE = "database"; - private static final String SECURECONN = "secureConn"; - private static final String REMOVEDATA = "removeData"; - private static final String MASTER_REPLICATION_PORT = "masterReplicationPort"; - private static final String CLONE_REPLICATION_PORT = "cloneReplicationPort"; - private static final String REPLICATION_SECURITY = "replicationSecurity"; - private static final String ISSUING_CA = "issuingCa"; - private static final String BACKUP_KEYS = "backupKeys"; - private static final String BACKUP_FILE = "backupFile"; - private static final String BACKUP_PASSWORD = "backupPassword"; - private static final String ADMIN_UID = "adminUid"; - private static final String ADMIN_EMAIL = "adminEmail"; - private static final String ADMIN_PASSWORD = "adminPassword"; - private static final String ADMIN_CERT_REQUEST = "adminCertRequest"; - private static final String ADMIN_CERT_REQUEST_TYPE = "adminCertRequestType"; - private static final String ADMIN_SUBJECT_DN = "adminSubjectDN"; - private static final String ADMIN_NAME = "adminName"; - private static final String ADMIN_PROFILE_ID = "adminProfileID"; - private static final String STEP_TWO = "stepTwo"; - - //defaults - public static final String TOKEN_DEFAULT = "Internal Key Storage Token"; - public static final String NEW_DOMAIN = "newdomain"; - public static final String EXISTING_DOMAIN = "existingdomain"; - - @XmlElement - protected String pin; - - @XmlElement(defaultValue=TOKEN_DEFAULT) - protected String token; - - @XmlElement - protected String tokenPassword; - - @XmlElement - protected String securityDomainType; - - @XmlElement - protected String securityDomainUri; - - @XmlElement - protected String securityDomainName; - - @XmlElement - protected String securityDomainUser; - - @XmlElement - protected String securityDomainPassword; - - @XmlElement(defaultValue="false") - protected String isClone; - - @XmlElement - protected String cloneUri; - - @XmlElement - protected String subsystemName; - - @XmlElement - protected String p12File; - - @XmlElement - protected String p12Password; - - @XmlElement - protected String hierarchy; - - @XmlElement - protected String dsHost; - - @XmlElement - protected String dsPort; - - @XmlElement - protected String baseDN; - - @XmlElement - protected String bindDN; - - @XmlElement - protected String bindpwd; - - @XmlElement - protected String database; - - @XmlElement(defaultValue = "off") - protected String secureConn; - - @XmlElement - protected String removeData; - - @XmlElement - protected String masterReplicationPort; - - @XmlElement - protected String cloneReplicationPort; - - @XmlElement - protected String replicationSecurity; - - @XmlElementRef - protected Collection systemCerts; - - @XmlElement - protected String issuingCA; - - @XmlElement - protected String backupKeys; - - @XmlElement - protected String backupPassword; - - @XmlElement - protected String backupFile; - - @XmlElement - protected String adminUID; - - @XmlElement - protected String adminPassword; - - @XmlElement - protected String adminEmail; - - @XmlElement - protected String adminCertRequest; - - @XmlElement - protected String adminCertRequestType; - - @XmlElement - protected String adminSubjectDN; - - @XmlElement - protected String adminName; - - @XmlElement - protected String adminProfileID; - - @XmlElement - protected String stepTwo; - - public ConfigurationData() { - // required for JAXB - } - - public ConfigurationData(MultivaluedMap form) { - pin = form.getFirst(PIN); - token = form.getFirst(TOKEN); - tokenPassword = form.getFirst(TOKEN_PASSWORD); - securityDomainType = form.getFirst(SECURITY_DOMAIN_TYPE); - securityDomainUri = form.getFirst(SECURITY_DOMAIN_URI); - securityDomainName = form.getFirst(SECURITY_DOMAIN_NAME); - securityDomainUser = form.getFirst(SECURITY_DOMAIN_USER); - securityDomainPassword = form.getFirst(SECURITY_DOMAIN_PASSWORD); - isClone = form.getFirst(IS_CLONE); - cloneUri = form.getFirst(CLONE_URI); - subsystemName = form.getFirst(SUBSYSTEM_NAME); - p12File = form.getFirst(P12_FILE); - p12Password = form.getFirst(P12_PASSWORD); - hierarchy = form.getFirst(HIERARCHY); - dsHost = form.getFirst(DSHOST); - dsPort = form.getFirst(DSPORT); - baseDN = form.getFirst(BASEDN); - bindDN = form.getFirst(BINDDN); - database = form.getFirst(DATABASE); - secureConn = form.getFirst(SECURECONN); - removeData = form.getFirst(REMOVEDATA); - masterReplicationPort = form.getFirst(MASTER_REPLICATION_PORT); - cloneReplicationPort = form.getFirst(CLONE_REPLICATION_PORT); - replicationSecurity = form.getFirst(REPLICATION_SECURITY); - //TODO - figure out how to get the cert requests - issuingCA = form.getFirst(ISSUING_CA); - backupFile = form.getFirst(BACKUP_FILE); - backupPassword = form.getFirst(BACKUP_PASSWORD); - backupKeys = form.getFirst(BACKUP_KEYS); - adminUID = form.getFirst(ADMIN_UID); - adminEmail = form.getFirst(ADMIN_EMAIL); - adminPassword = form.getFirst(ADMIN_PASSWORD); - adminCertRequest = form.getFirst(ADMIN_CERT_REQUEST); - adminCertRequestType = form.getFirst(ADMIN_CERT_REQUEST_TYPE); - adminSubjectDN = form.getFirst(ADMIN_SUBJECT_DN); - adminName = form.getFirst(ADMIN_NAME); - adminProfileID = form.getFirst(ADMIN_PROFILE_ID); - stepTwo = form.getFirst(STEP_TWO); - } - - - public String getSubsystemName() { - return subsystemName; - } - - public void setSubsystemName(String subsystemName) { - this.subsystemName = subsystemName; - } - - public String getPin() { - return pin; - } - - public void setPin(String pin) { - this.pin = pin; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getSecurityDomainType() { - return securityDomainType; - } - - public void setSecurityDomainType(String securityDomainType) { - this.securityDomainType = securityDomainType; - } - - public String getSecurityDomainUri() { - return securityDomainUri; - } - - public void setSecurityDomainUri(String securityDomainUri) { - this.securityDomainUri = securityDomainUri; - } - - public String getSecurityDomainName() { - return securityDomainName; - } - - public void setSecurityDomainName(String securityDomainName) { - this.securityDomainName = securityDomainName; - } - - public String getSecurityDomainUser() { - return securityDomainUser; - } - - public void setSecurityDomainUser(String securityDomainUser) { - this.securityDomainUser = securityDomainUser; - } - - public String getSecurityDomainPassword() { - return securityDomainPassword; - } - - public void setSecurityDomainPassword(String securityDomainPassword) { - this.securityDomainPassword = securityDomainPassword; - } - - public String getIsClone() { - return isClone; - } - - public void setIsClone(String isClone) { - this.isClone = isClone; - } - - public String getCloneUri() { - return cloneUri; - } - - public void setCloneUri(String cloneUri) { - this.cloneUri = cloneUri; - } - - /** - * @return the p12File - */ - public String getP12File() { - return p12File; - } - - /** - * @param p12File the p12File to set - */ - public void setP12File(String p12File) { - this.p12File = p12File; - } - - /** - * @return the p12Password - */ - public String getP12Password() { - return p12Password; - } - - /** - * @param p12Password the p12Password to set - */ - public void setP12Password(String p12Password) { - this.p12Password = p12Password; - } - - /** - * @return the tokenPassword - */ - public String getTokenPassword() { - return tokenPassword; - } - - /** - * @param tokenPassword the tokenPassword to set - */ - public void setTokenPassword(String tokenPassword) { - this.tokenPassword = tokenPassword; - } - - /** - * @return the hierarchy - */ - public String getHierarchy() { - return hierarchy; - } - - /** - * @param hierarchy the hierarchy to set - */ - public void setHierarchy(String hierarchy) { - this.hierarchy = hierarchy; - } - - /** - * @return the dsHost - */ - public String getDsHost() { - return dsHost; - } - - /** - * @param dsHost the dsHost to set - */ - public void setDsHost(String dsHost) { - this.dsHost = dsHost; - } - - /** - * @return the dsPort - */ - public String getDsPort() { - return dsPort; - } - - /** - * @param dsPort the dsPort to set - */ - public void setDsPort(String dsPort) { - this.dsPort = dsPort; - } - - /** - * @return the baseDN - */ - public String getBaseDN() { - return baseDN; - } - - /** - * @param baseDN the baseDN to set - */ - public void setBaseDN(String baseDN) { - this.baseDN = baseDN; - } - - /** - * @return the bindDN - */ - public String getBindDN() { - return bindDN; - } - - /** - * @param bindDN the bindDN to set - */ - public void setBindDN(String bindDN) { - this.bindDN = bindDN; - } - - /** - * @return the bindpwd - */ - public String getBindpwd() { - return bindpwd; - } - - /** - * @param bindpwd the bindpwd to set - */ - public void setBindpwd(String bindpwd) { - this.bindpwd = bindpwd; - } - - /** - * @return the secureConn - */ - public String getSecureConn() { - return secureConn; - } - - /** - * @param secureConn the secureConn to set - */ - public void setSecureConn(String secureConn) { - this.secureConn = secureConn; - } - - /** - * @return the removeData - */ - public String getRemoveData() { - return removeData; - } - - /** - * @param removeData the removeData to set - */ - public void setRemoveData(String removeData) { - this.removeData = removeData; - } - - /** - * @return the masterReplicationPort - */ - public String getMasterReplicationPort() { - return masterReplicationPort; - } - - /** - * @param masterReplicationPort the masterReplicationPort to set - */ - public void setMasterReplicationPort(String masterReplicationPort) { - this.masterReplicationPort = masterReplicationPort; - } - - /** - * @return the cloneReplicationPort - */ - public String getCloneReplicationPort() { - return cloneReplicationPort; - } - - /** - * @param cloneReplicationPort the cloneReplicationPort to set - */ - public void setCloneReplicationPort(String cloneReplicationPort) { - this.cloneReplicationPort = cloneReplicationPort; - } - - /** - * @return the replicationSecurity - */ - public String getReplicationSecurity() { - return replicationSecurity; - } - - /** - * @param replicationSecurity the replicationSecurity to set - */ - public void setReplicationSecurity(String replicationSecurity) { - this.replicationSecurity = replicationSecurity; - } - - /** - * @return the database - */ - public String getDatabase() { - return database; - } - - /** - * @param database the database to set - */ - public void setDatabase(String database) { - this.database = database; - } - - /** - * - * @return systemCerts - */ - public Collection getSystemCerts() { - return systemCerts; - } - - /** - * - * @param systemCerts - */ - public void setSystemCerts(Collection systemCerts) { - this.systemCerts = systemCerts; - } - - /** - * @return the issuingCA - */ - public String getIssuingCA() { - return issuingCA; - } - - /** - * @param issuingCA the issuingCA to set - */ - public void setIssuingCA(String issuingCA) { - this.issuingCA = issuingCA; - } - - /** - * @return the backupKeys - */ - public String getBackupKeys() { - return backupKeys; - } - - /** - * @param backupKeys the backupKeys to set - */ - public void setBackupKeys(String backupKeys) { - this.backupKeys = backupKeys; - } - - /** - * @return the backupFile - */ - public String getBackupFile() { - return backupFile; - } - - /** - * @param backupFile the backupFile to set - */ - public void setBackupFile(String backupFile) { - this.backupFile = backupFile; - } - - /** - * @return the backupPassword - */ - public String getBackupPassword() { - return backupPassword; - } - - /** - * @param backupPassword the backupPassword to set - */ - public void setBackupPassword(String backupPassword) { - this.backupPassword = backupPassword; - } - - /** - * @return the adminUID - */ - public String getAdminUID() { - return adminUID; - } - - /** - * @param adminUID the adminUID to set - */ - public void setAdminUID(String adminUID) { - this.adminUID = adminUID; - } - - /** - * @return the adminPassword - */ - public String getAdminPassword() { - return adminPassword; - } - - /** - * @param adminPassword the adminPassword to set - */ - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - /** - * @return the adminEmail - */ - public String getAdminEmail() { - return adminEmail; - } - - /** - * @param adminEmail the adminEmail to set - */ - public void setAdminEmail(String adminEmail) { - this.adminEmail = adminEmail; - } - - /** - * @return the adminCertRequest - */ - public String getAdminCertRequest() { - return adminCertRequest; - } - - /** - * @param adminCertRequest the adminCertRequest to set - */ - public void setAdminCertRequest(String adminCertRequest) { - this.adminCertRequest = adminCertRequest; - } - - /** - * @return the adminCertRequestType - */ - public String getAdminCertRequestType() { - return adminCertRequestType; - } - - /** - * @param adminCertRequestType the adminCertRequestType to set - */ - public void setAdminCertRequestType(String adminCertRequestType) { - this.adminCertRequestType = adminCertRequestType; - } - - /** - * @return the adminSubjectDN - */ - public String getAdminSubjectDN() { - return adminSubjectDN; - } - - /** - * @param adminSubjectDN the adminSubjectDN to set - */ - public void setAdminSubjectDN(String adminSubjectDN) { - this.adminSubjectDN = adminSubjectDN; - } - - /** - * @return the adminName - */ - public String getAdminName() { - return adminName; - } - - /** - * @param adminName the adminName to set - */ - public void setAdminName(String adminName) { - this.adminName = adminName; - } - - /** - * @return the adminProfileID - */ - public String getAdminProfileID() { - return adminProfileID; - } - - /** - * @param adminProfileID the adminProfileID to set - */ - public void setAdminProfileID(String adminProfileID) { - this.adminProfileID = adminProfileID; - } - - public String getStepTwo() { - return stepTwo; - } - - public void setStepTwo(String stepTwo) { - this.stepTwo = stepTwo; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationRequest.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationRequest.java new file mode 100644 index 000000000..b42403f4e --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationRequest.java @@ -0,0 +1,724 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.csadmin.model; + +import java.util.Collection; + +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author alee + * + */ +@XmlRootElement(name="ConfigurationRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class ConfigurationRequest { + private static final String PIN = "pin"; + private static final String TOKEN = "token"; + private static final String TOKEN_PASSWORD = "tokenPassword"; + private static final String SECURITY_DOMAIN_TYPE = "securityDomainType"; + private static final String SECURITY_DOMAIN_URI = "securityDomainUri"; + private static final String SECURITY_DOMAIN_NAME = "securityDomainName"; + private static final String SECURITY_DOMAIN_USER = "securityDomainUser"; + private static final String SECURITY_DOMAIN_PASSWORD = "securityDomainPassword"; + private static final String IS_CLONE = "isClone"; + private static final String CLONE_URI = "cloneUri"; + private static final String SUBSYSTEM_NAME = "subsystemName"; + private static final String P12_FILE = "p12File"; + private static final String P12_PASSWORD = "p12Password"; + private static final String HIERARCHY = "hierarchy"; + private static final String DSHOST = "dsHost"; + private static final String DSPORT = "dsPort"; + private static final String BASEDN = "basedn"; + private static final String BINDDN = "binddn"; + private static final String DATABASE = "database"; + private static final String SECURECONN = "secureConn"; + private static final String REMOVEDATA = "removeData"; + private static final String MASTER_REPLICATION_PORT = "masterReplicationPort"; + private static final String CLONE_REPLICATION_PORT = "cloneReplicationPort"; + private static final String REPLICATION_SECURITY = "replicationSecurity"; + private static final String ISSUING_CA = "issuingCa"; + private static final String BACKUP_KEYS = "backupKeys"; + private static final String BACKUP_FILE = "backupFile"; + private static final String BACKUP_PASSWORD = "backupPassword"; + private static final String ADMIN_UID = "adminUid"; + private static final String ADMIN_EMAIL = "adminEmail"; + private static final String ADMIN_PASSWORD = "adminPassword"; + private static final String ADMIN_CERT_REQUEST = "adminCertRequest"; + private static final String ADMIN_CERT_REQUEST_TYPE = "adminCertRequestType"; + private static final String ADMIN_SUBJECT_DN = "adminSubjectDN"; + private static final String ADMIN_NAME = "adminName"; + private static final String ADMIN_PROFILE_ID = "adminProfileID"; + private static final String STEP_TWO = "stepTwo"; + + //defaults + public static final String TOKEN_DEFAULT = "Internal Key Storage Token"; + public static final String NEW_DOMAIN = "newdomain"; + public static final String EXISTING_DOMAIN = "existingdomain"; + + @XmlElement + protected String pin; + + @XmlElement(defaultValue=TOKEN_DEFAULT) + protected String token; + + @XmlElement + protected String tokenPassword; + + @XmlElement + protected String securityDomainType; + + @XmlElement + protected String securityDomainUri; + + @XmlElement + protected String securityDomainName; + + @XmlElement + protected String securityDomainUser; + + @XmlElement + protected String securityDomainPassword; + + @XmlElement(defaultValue="false") + protected String isClone; + + @XmlElement + protected String cloneUri; + + @XmlElement + protected String subsystemName; + + @XmlElement + protected String p12File; + + @XmlElement + protected String p12Password; + + @XmlElement + protected String hierarchy; + + @XmlElement + protected String dsHost; + + @XmlElement + protected String dsPort; + + @XmlElement + protected String baseDN; + + @XmlElement + protected String bindDN; + + @XmlElement + protected String bindpwd; + + @XmlElement + protected String database; + + @XmlElement(defaultValue = "off") + protected String secureConn; + + @XmlElement + protected String removeData; + + @XmlElement + protected String masterReplicationPort; + + @XmlElement + protected String cloneReplicationPort; + + @XmlElement + protected String replicationSecurity; + + @XmlElementRef + protected Collection systemCerts; + + @XmlElement + protected String issuingCA; + + @XmlElement + protected String backupKeys; + + @XmlElement + protected String backupPassword; + + @XmlElement + protected String backupFile; + + @XmlElement + protected String adminUID; + + @XmlElement + protected String adminPassword; + + @XmlElement + protected String adminEmail; + + @XmlElement + protected String adminCertRequest; + + @XmlElement + protected String adminCertRequestType; + + @XmlElement + protected String adminSubjectDN; + + @XmlElement + protected String adminName; + + @XmlElement + protected String adminProfileID; + + @XmlElement + protected String stepTwo; + + public ConfigurationRequest() { + // required for JAXB + } + + public ConfigurationRequest(MultivaluedMap form) { + pin = form.getFirst(PIN); + token = form.getFirst(TOKEN); + tokenPassword = form.getFirst(TOKEN_PASSWORD); + securityDomainType = form.getFirst(SECURITY_DOMAIN_TYPE); + securityDomainUri = form.getFirst(SECURITY_DOMAIN_URI); + securityDomainName = form.getFirst(SECURITY_DOMAIN_NAME); + securityDomainUser = form.getFirst(SECURITY_DOMAIN_USER); + securityDomainPassword = form.getFirst(SECURITY_DOMAIN_PASSWORD); + isClone = form.getFirst(IS_CLONE); + cloneUri = form.getFirst(CLONE_URI); + subsystemName = form.getFirst(SUBSYSTEM_NAME); + p12File = form.getFirst(P12_FILE); + p12Password = form.getFirst(P12_PASSWORD); + hierarchy = form.getFirst(HIERARCHY); + dsHost = form.getFirst(DSHOST); + dsPort = form.getFirst(DSPORT); + baseDN = form.getFirst(BASEDN); + bindDN = form.getFirst(BINDDN); + database = form.getFirst(DATABASE); + secureConn = form.getFirst(SECURECONN); + removeData = form.getFirst(REMOVEDATA); + masterReplicationPort = form.getFirst(MASTER_REPLICATION_PORT); + cloneReplicationPort = form.getFirst(CLONE_REPLICATION_PORT); + replicationSecurity = form.getFirst(REPLICATION_SECURITY); + //TODO - figure out how to get the cert requests + issuingCA = form.getFirst(ISSUING_CA); + backupFile = form.getFirst(BACKUP_FILE); + backupPassword = form.getFirst(BACKUP_PASSWORD); + backupKeys = form.getFirst(BACKUP_KEYS); + adminUID = form.getFirst(ADMIN_UID); + adminEmail = form.getFirst(ADMIN_EMAIL); + adminPassword = form.getFirst(ADMIN_PASSWORD); + adminCertRequest = form.getFirst(ADMIN_CERT_REQUEST); + adminCertRequestType = form.getFirst(ADMIN_CERT_REQUEST_TYPE); + adminSubjectDN = form.getFirst(ADMIN_SUBJECT_DN); + adminName = form.getFirst(ADMIN_NAME); + adminProfileID = form.getFirst(ADMIN_PROFILE_ID); + stepTwo = form.getFirst(STEP_TWO); + } + + + public String getSubsystemName() { + return subsystemName; + } + + public void setSubsystemName(String subsystemName) { + this.subsystemName = subsystemName; + } + + public String getPin() { + return pin; + } + + public void setPin(String pin) { + this.pin = pin; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getSecurityDomainType() { + return securityDomainType; + } + + public void setSecurityDomainType(String securityDomainType) { + this.securityDomainType = securityDomainType; + } + + public String getSecurityDomainUri() { + return securityDomainUri; + } + + public void setSecurityDomainUri(String securityDomainUri) { + this.securityDomainUri = securityDomainUri; + } + + public String getSecurityDomainName() { + return securityDomainName; + } + + public void setSecurityDomainName(String securityDomainName) { + this.securityDomainName = securityDomainName; + } + + public String getSecurityDomainUser() { + return securityDomainUser; + } + + public void setSecurityDomainUser(String securityDomainUser) { + this.securityDomainUser = securityDomainUser; + } + + public String getSecurityDomainPassword() { + return securityDomainPassword; + } + + public void setSecurityDomainPassword(String securityDomainPassword) { + this.securityDomainPassword = securityDomainPassword; + } + + public String getIsClone() { + return isClone; + } + + public void setIsClone(String isClone) { + this.isClone = isClone; + } + + public String getCloneUri() { + return cloneUri; + } + + public void setCloneUri(String cloneUri) { + this.cloneUri = cloneUri; + } + + /** + * @return the p12File + */ + public String getP12File() { + return p12File; + } + + /** + * @param p12File the p12File to set + */ + public void setP12File(String p12File) { + this.p12File = p12File; + } + + /** + * @return the p12Password + */ + public String getP12Password() { + return p12Password; + } + + /** + * @param p12Password the p12Password to set + */ + public void setP12Password(String p12Password) { + this.p12Password = p12Password; + } + + /** + * @return the tokenPassword + */ + public String getTokenPassword() { + return tokenPassword; + } + + /** + * @param tokenPassword the tokenPassword to set + */ + public void setTokenPassword(String tokenPassword) { + this.tokenPassword = tokenPassword; + } + + /** + * @return the hierarchy + */ + public String getHierarchy() { + return hierarchy; + } + + /** + * @param hierarchy the hierarchy to set + */ + public void setHierarchy(String hierarchy) { + this.hierarchy = hierarchy; + } + + /** + * @return the dsHost + */ + public String getDsHost() { + return dsHost; + } + + /** + * @param dsHost the dsHost to set + */ + public void setDsHost(String dsHost) { + this.dsHost = dsHost; + } + + /** + * @return the dsPort + */ + public String getDsPort() { + return dsPort; + } + + /** + * @param dsPort the dsPort to set + */ + public void setDsPort(String dsPort) { + this.dsPort = dsPort; + } + + /** + * @return the baseDN + */ + public String getBaseDN() { + return baseDN; + } + + /** + * @param baseDN the baseDN to set + */ + public void setBaseDN(String baseDN) { + this.baseDN = baseDN; + } + + /** + * @return the bindDN + */ + public String getBindDN() { + return bindDN; + } + + /** + * @param bindDN the bindDN to set + */ + public void setBindDN(String bindDN) { + this.bindDN = bindDN; + } + + /** + * @return the bindpwd + */ + public String getBindpwd() { + return bindpwd; + } + + /** + * @param bindpwd the bindpwd to set + */ + public void setBindpwd(String bindpwd) { + this.bindpwd = bindpwd; + } + + /** + * @return the secureConn + */ + public String getSecureConn() { + return secureConn; + } + + /** + * @param secureConn the secureConn to set + */ + public void setSecureConn(String secureConn) { + this.secureConn = secureConn; + } + + /** + * @return the removeData + */ + public String getRemoveData() { + return removeData; + } + + /** + * @param removeData the removeData to set + */ + public void setRemoveData(String removeData) { + this.removeData = removeData; + } + + /** + * @return the masterReplicationPort + */ + public String getMasterReplicationPort() { + return masterReplicationPort; + } + + /** + * @param masterReplicationPort the masterReplicationPort to set + */ + public void setMasterReplicationPort(String masterReplicationPort) { + this.masterReplicationPort = masterReplicationPort; + } + + /** + * @return the cloneReplicationPort + */ + public String getCloneReplicationPort() { + return cloneReplicationPort; + } + + /** + * @param cloneReplicationPort the cloneReplicationPort to set + */ + public void setCloneReplicationPort(String cloneReplicationPort) { + this.cloneReplicationPort = cloneReplicationPort; + } + + /** + * @return the replicationSecurity + */ + public String getReplicationSecurity() { + return replicationSecurity; + } + + /** + * @param replicationSecurity the replicationSecurity to set + */ + public void setReplicationSecurity(String replicationSecurity) { + this.replicationSecurity = replicationSecurity; + } + + /** + * @return the database + */ + public String getDatabase() { + return database; + } + + /** + * @param database the database to set + */ + public void setDatabase(String database) { + this.database = database; + } + + /** + * + * @return systemCerts + */ + public Collection getSystemCerts() { + return systemCerts; + } + + /** + * + * @param systemCerts + */ + public void setSystemCerts(Collection systemCerts) { + this.systemCerts = systemCerts; + } + + /** + * @return the issuingCA + */ + public String getIssuingCA() { + return issuingCA; + } + + /** + * @param issuingCA the issuingCA to set + */ + public void setIssuingCA(String issuingCA) { + this.issuingCA = issuingCA; + } + + /** + * @return the backupKeys + */ + public String getBackupKeys() { + return backupKeys; + } + + /** + * @param backupKeys the backupKeys to set + */ + public void setBackupKeys(String backupKeys) { + this.backupKeys = backupKeys; + } + + /** + * @return the backupFile + */ + public String getBackupFile() { + return backupFile; + } + + /** + * @param backupFile the backupFile to set + */ + public void setBackupFile(String backupFile) { + this.backupFile = backupFile; + } + + /** + * @return the backupPassword + */ + public String getBackupPassword() { + return backupPassword; + } + + /** + * @param backupPassword the backupPassword to set + */ + public void setBackupPassword(String backupPassword) { + this.backupPassword = backupPassword; + } + + /** + * @return the adminUID + */ + public String getAdminUID() { + return adminUID; + } + + /** + * @param adminUID the adminUID to set + */ + public void setAdminUID(String adminUID) { + this.adminUID = adminUID; + } + + /** + * @return the adminPassword + */ + public String getAdminPassword() { + return adminPassword; + } + + /** + * @param adminPassword the adminPassword to set + */ + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + /** + * @return the adminEmail + */ + public String getAdminEmail() { + return adminEmail; + } + + /** + * @param adminEmail the adminEmail to set + */ + public void setAdminEmail(String adminEmail) { + this.adminEmail = adminEmail; + } + + /** + * @return the adminCertRequest + */ + public String getAdminCertRequest() { + return adminCertRequest; + } + + /** + * @param adminCertRequest the adminCertRequest to set + */ + public void setAdminCertRequest(String adminCertRequest) { + this.adminCertRequest = adminCertRequest; + } + + /** + * @return the adminCertRequestType + */ + public String getAdminCertRequestType() { + return adminCertRequestType; + } + + /** + * @param adminCertRequestType the adminCertRequestType to set + */ + public void setAdminCertRequestType(String adminCertRequestType) { + this.adminCertRequestType = adminCertRequestType; + } + + /** + * @return the adminSubjectDN + */ + public String getAdminSubjectDN() { + return adminSubjectDN; + } + + /** + * @param adminSubjectDN the adminSubjectDN to set + */ + public void setAdminSubjectDN(String adminSubjectDN) { + this.adminSubjectDN = adminSubjectDN; + } + + /** + * @return the adminName + */ + public String getAdminName() { + return adminName; + } + + /** + * @param adminName the adminName to set + */ + public void setAdminName(String adminName) { + this.adminName = adminName; + } + + /** + * @return the adminProfileID + */ + public String getAdminProfileID() { + return adminProfileID; + } + + /** + * @param adminProfileID the adminProfileID to set + */ + public void setAdminProfileID(String adminProfileID) { + this.adminProfileID = adminProfileID; + } + + public String getStepTwo() { + return stepTwo; + } + + public void setStepTwo(String stepTwo) { + this.stepTwo = stepTwo; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponse.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponse.java new file mode 100644 index 000000000..2fcd37d9d --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponse.java @@ -0,0 +1,121 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.csadmin.model; + +import java.security.cert.CertificateEncodingException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Vector; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; + +import netscape.security.x509.X509CertImpl; + +import com.netscape.certsrv.apps.CMS; +import com.netscape.cms.servlet.csadmin.Cert; + +/** + * @author alee + * + */ +@XmlRootElement(name="ConfigurationResponse") +@XmlAccessorType(XmlAccessType.FIELD) +public class ConfigurationResponse { + + @XmlElementRef + protected Collection systemCerts; + + @XmlElement + protected SystemCertData adminCert; + + @XmlElement + protected String status; + + public ConfigurationResponse() { + systemCerts = new ArrayList(); + adminCert = new SystemCertData(); + } + + public void setSystemCerts(Vector certs) { + systemCerts.clear(); + Enumeration e = certs.elements(); + while (e.hasMoreElements()) { + Cert cert = e.nextElement(); + SystemCertData cdata = new SystemCertData(); + cdata.setCert(cert.getCert()); + cdata.setRequest(cert.getRequest()); + cdata.setTag(cert.getCertTag()); + cdata.setCertChain(cert.getCertChain()); + systemCerts.add(cdata); + } + } + + /** + * @return the systemCerts + */ + public Collection getSystemCerts() { + return systemCerts; + } + + /** + * @param systemCerts the systemCerts to set + */ + public void setSystemCerts(Collection systemCerts) { + this.systemCerts = systemCerts; + } + + /** + * @return the adminCert + */ + public SystemCertData getAdminCert() { + return adminCert; + } + + /** + * @param adminCert the adminCert to set + */ + public void setAdminCert(SystemCertData adminCert) { + this.adminCert = adminCert; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @param status the status to set + */ + public void setStatus(String status) { + this.status = status; + } + + + + public void setAdminCert(X509CertImpl x509CertImpl) throws CertificateEncodingException { + adminCert.setCert(CMS.BtoA(x509CertImpl.getEncoded())); + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponseData.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponseData.java deleted file mode 100644 index d1656fdda..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/model/ConfigurationResponseData.java +++ /dev/null @@ -1,120 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2012 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.csadmin.model; - -import java.security.cert.CertificateEncodingException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Vector; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlRootElement; - -import netscape.security.x509.X509CertImpl; - -import com.netscape.certsrv.apps.CMS; -import com.netscape.cms.servlet.csadmin.Cert; - -/** - * @author alee - * - */ -@XmlRootElement(name="ConfigurationResponseData") -@XmlAccessorType(XmlAccessType.FIELD) -public class ConfigurationResponseData { - - @XmlElementRef - protected Collection systemCerts; - - @XmlElement - protected CertData adminCert; - - @XmlElement - protected String status; - - public ConfigurationResponseData() { - systemCerts = new ArrayList(); - adminCert = new CertData(); - } - - public void setSystemCerts(Vector certs) { - systemCerts.clear(); - Enumeration e = certs.elements(); - while (e.hasMoreElements()) { - Cert cert = e.nextElement(); - CertData cdata = new CertData(); - cdata.setCert(cert.getCert()); - cdata.setRequest(cert.getRequest()); - cdata.setTag(cert.getCertTag()); - cdata.setCertChain(cert.getCertChain()); - systemCerts.add(cdata); - } - } - - /** - * @return the systemCerts - */ - public Collection getSystemCerts() { - return systemCerts; - } - - /** - * @param systemCerts the systemCerts to set - */ - public void setSystemCerts(Collection systemCerts) { - this.systemCerts = systemCerts; - } - - /** - * @return the adminCert - */ - public CertData getAdminCert() { - return adminCert; - } - - /** - * @param adminCert the adminCert to set - */ - public void setAdminCert(CertData adminCert) { - this.adminCert = adminCert; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @param status the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - - - public void setAdminCert(X509CertImpl x509CertImpl) throws CertificateEncodingException { - adminCert.setCert(CMS.BtoA(x509CertImpl.getEncoded())); - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/model/SystemCertData.java b/base/common/src/com/netscape/cms/servlet/csadmin/model/SystemCertData.java new file mode 100644 index 000000000..bd98fe95c --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/csadmin/model/SystemCertData.java @@ -0,0 +1,270 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +package com.netscape.cms.servlet.csadmin.model; + +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author alee + * + */ +@XmlRootElement(name="SystemCertData") +@XmlAccessorType(XmlAccessType.FIELD) +public class SystemCertData { + public static final String TAG = "tag"; + public static final String NICKNAME = "nickname"; + public static final String TOKEN = "token"; + public static final String KEY_TYPE = "keyType"; + public static final String KEY_ALGORITHM = "keyAlgorithm"; + public static final String SIGNING_ALGORITHM = "signingAlgorithm"; + public static final String KEY_SIZE = "keySize"; + public static final String KEY_CURVENAME = "keyCurveName"; + public static final String REQUEST = "request"; + public static final String SUBJECT_DN = "subjectDN"; + public static final String CERT = "cert"; + public static final String CERT_CHAIN = "certChain"; + + @XmlElement + protected String tag; + + @XmlElement + protected String nickname; + + @XmlElement + protected String token; + + @XmlElement + protected String keyType; + + @XmlElement + protected String keyAlgorithm; + + @XmlElement + protected String signingAlgorithm; + + @XmlElement + protected String keySize; + + @XmlElement + protected String keyCurveName; + + @XmlElement + protected String request; + + @XmlElement + protected String subjectDN; + + @XmlElement + protected String cert; + + @XmlElement + protected String certChain; + + public SystemCertData() { + // required for JAXB + } + + public SystemCertData(MultivaluedMap form) { + tag = form.getFirst(TAG); + nickname = form.getFirst(NICKNAME); + token = form.getFirst(TOKEN); + keyType = form.getFirst(KEY_TYPE); + keyAlgorithm = form.getFirst(KEY_ALGORITHM); + signingAlgorithm = form.getFirst(SIGNING_ALGORITHM); + keySize = form.getFirst(KEY_SIZE); + keyCurveName = form.getFirst(KEY_CURVENAME); + request = form.getFirst(REQUEST); + subjectDN = form.getFirst(SUBJECT_DN); + cert = form.getFirst(CERT); + certChain = form.getFirst(CERT_CHAIN); + } + + /** + * @return the tag + */ + public String getTag() { + return tag; + } + + /** + * @param tag the tag to set + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * @return the nickname + */ + public String getNickname() { + return nickname; + } + + /** + * @param nickname the nickname to set + */ + public void setNickname(String nickname) { + this.nickname = nickname; + } + + /** + * @return the token + */ + public String getToken() { + return token; + } + + /** + * @param token the token to set + */ + public void setToken(String token) { + this.token = token; + } + + /** + * @return the keyType + */ + public String getKeyType() { + return keyType; + } + + /** + * @param keyType the keyType to set + */ + public void setKeyType(String keyType) { + this.keyType = keyType; + } + + /** + * @return the keyAlgorithm + */ + public String getKeyAlgorithm() { + return keyAlgorithm; + } + + /** + * @param keyAlgorithm the keyAlgorithm to set + */ + public void setKeyAlgorithm(String keyAlgorithm) { + this.keyAlgorithm = keyAlgorithm; + } + + /** + * @return the signingAlgorithm + */ + public String getSigningAlgorithm() { + return signingAlgorithm; + } + + /** + * @param signingAlgorithm the signingAlgorithm to set + */ + public void setSigningAlgorithm(String signingAlgorithm) { + this.signingAlgorithm = signingAlgorithm; + } + + /** + * @return the keySize + */ + public String getKeySize() { + return keySize; + } + + /** + * @param keySize the keySize to set + */ + public void setKeySize(String keySize) { + this.keySize = keySize; + } + + /** + * @return the keyCurveName + */ + public String getKeyCurveName() { + return keyCurveName; + } + + /** + * @param keyCurveName the keyCurveName to set + */ + public void setKeyCurveName(String keyCurveName) { + this.keyCurveName = keyCurveName; + } + + /** + * @return the request + */ + public String getRequest() { + return request; + } + + /** + * @param request the request to set + */ + public void setRequest(String request) { + this.request = request; + } + + /** + * @return the subjectDN + */ + public String getSubjectDN() { + return subjectDN; + } + + /** + * @param subjectDN the subjectDN to set + */ + public void setSubjectDN(String subjectDN) { + this.subjectDN = subjectDN; + } + + /** + * @return the cert + */ + public String getCert() { + return cert; + } + + /** + * @param cert the cert to set + */ + public void setCert(String cert) { + this.cert = cert; + } + + /** + * @return the certChain + */ + public String getCertChain() { + return certChain; + } + + /** + * @param certChain the certChain to set + */ + public void setCertChain(String certChain) { + this.certChain = certChain; + } + +} -- cgit