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 --- .../com/netscape/cms/servlet/test/CAClient.java | 28 +- .../src/com/netscape/cms/servlet/test/CATest.java | 42 +- .../ca/CertificateAuthorityApplication.java | 4 +- .../cms/servlet/test/ConfigurationTest.java | 162 ++-- .../src/com/netscape/cms/client/cert/CertCLI.java | 4 +- .../com/netscape/cms/client/cert/CertClient.java | 18 +- .../com/netscape/cms/client/cert/CertFindCLI.java | 14 +- .../com/netscape/cms/client/cert/CertHoldCLI.java | 6 +- .../cms/client/cert/CertReleaseHoldCLI.java | 6 +- .../cms/client/cert/CertRequestApproveCLI.java | 12 +- .../cms/client/cert/CertRequestReviewCLI.java | 10 +- .../cms/client/cert/CertRequestSubmitCLI.java | 12 +- .../netscape/cms/client/cert/CertRevokeCLI.java | 6 +- .../com/netscape/cms/client/cert/CertShowCLI.java | 4 +- .../cms/servlet/admin/GroupMemberService.java | 36 +- .../netscape/cms/servlet/admin/GroupService.java | 34 +- .../cms/servlet/admin/SystemCertService.java | 4 +- .../servlet/admin/SystemCertificateResource.java | 4 +- .../cms/servlet/admin/UserCertService.java | 56 +- .../netscape/cms/servlet/admin/UserService.java | 50 +- .../cms/servlet/base/BadRequestException.java | 2 +- .../netscape/cms/servlet/base/CMSException.java | 182 ----- .../netscape/cms/servlet/base/PKIException.java | 182 +++++ .../com/netscape/cms/servlet/base/PKIService.java | 6 +- .../cms/servlet/base/UnauthorizedException.java | 2 +- .../cms/servlet/cert/CertNotFoundException.java | 4 +- .../netscape/cms/servlet/cert/CertProcessor.java | 6 +- .../netscape/cms/servlet/cert/CertResource.java | 8 +- .../com/netscape/cms/servlet/cert/CertService.java | 50 +- .../com/netscape/cms/servlet/cert/DoRevoke.java | 4 +- .../com/netscape/cms/servlet/cert/DoUnrevoke.java | 4 +- .../cms/servlet/cert/EnrollmentProcessor.java | 8 +- .../cms/servlet/cert/RenewalProcessor.java | 6 +- .../cms/servlet/cert/RequestProcessor.java | 14 +- .../netscape/cms/servlet/cert/model/CertData.java | 283 +++++++ .../cms/servlet/cert/model/CertSearchData.java | 862 --------------------- .../cms/servlet/cert/model/CertSearchRequest.java | 862 +++++++++++++++++++++ .../cms/servlet/cert/model/CertificateData.java | 283 ------- .../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 +++++++ .../com/netscape/cms/servlet/key/KeyResource.java | 4 +- .../com/netscape/cms/servlet/key/KeyService.java | 10 +- .../servlet/profile/ProfileNotFoundException.java | 4 +- .../cms/servlet/profile/ProfileProcessServlet.java | 4 +- .../cms/servlet/request/CertRequestResource.java | 22 +- .../cms/servlet/request/CertRequestService.java | 58 +- .../cms/servlet/request/KeyRequestResource.java | 8 +- .../cms/servlet/request/KeyRequestService.java | 16 +- .../servlet/request/RequestNotFoundException.java | 4 +- .../request/model/AgentEnrollmentRequestData.java | 252 ------ .../servlet/request/model/ArchivalRequestData.java | 123 --- .../request/model/CertEnrollmentRequest.java | 321 ++++++++ .../model/CertEnrollmentRequestFactory.java | 4 +- .../cms/servlet/request/model/CertRequestDAO.java | 10 +- .../request/model/CertRetrievalRequest.java | 78 ++ .../request/model/CertRetrievalRequestData.java | 78 -- .../servlet/request/model/CertReviewResponse.java | 252 ++++++ .../request/model/CertReviewResponseFactory.java | 8 +- .../request/model/EnrollmentRequestData.java | 321 -------- .../servlet/request/model/KeyArchivalRequest.java | 123 +++ .../servlet/request/model/KeyRecoveryRequest.java | 155 ++++ .../cms/servlet/request/model/KeyRequestDAO.java | 4 +- .../request/model/ProfileRetrievalRequest.java | 67 ++ .../request/model/ProfileRetrievalRequestData.java | 67 -- .../servlet/request/model/RecoveryRequestData.java | 155 ---- base/deploy/src/scriptlets/pkijython.py | 32 +- .../com/netscape/cms/servlet/test/DRMClient.java | 16 +- .../kra/KeyRecoveryAuthorityApplication.java | 4 +- .../src/com/netscape/ocsp/OCSPApplication.java | 4 +- base/tks/src/com/netscape/tks/TKSApplication.java | 4 +- 79 files changed, 4024 insertions(+), 4023 deletions(-) delete mode 100644 base/common/src/com/netscape/cms/servlet/base/CMSException.java create mode 100644 base/common/src/com/netscape/cms/servlet/base/PKIException.java create mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertData.java delete mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertSearchData.java create mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertSearchRequest.java delete mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java 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 delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/AgentEnrollmentRequestData.java delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequest.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequest.java delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponse.java delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/KeyArchivalRequest.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/KeyRecoveryRequest.java create mode 100644 base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequest.java delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java delete mode 100644 base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java index cc6aa19d5..24c53b137 100644 --- a/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java +++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java @@ -25,17 +25,17 @@ import com.netscape.certsrv.request.RequestId; import com.netscape.cms.client.cli.ClientConfig; import com.netscape.cms.servlet.cert.CertResource; import com.netscape.cms.servlet.cert.model.CertDataInfos; -import com.netscape.cms.servlet.cert.model.CertSearchData; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.csadmin.PKIClient; import com.netscape.cms.servlet.profile.ProfileResource; import com.netscape.cms.servlet.profile.model.ProfileData; import com.netscape.cms.servlet.profile.model.ProfileDataInfos; import com.netscape.cms.servlet.request.CertRequestResource; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; public class CAClient extends PKIClient { @@ -65,7 +65,7 @@ public class CAClient extends PKIClient { return certClient.listCerts(status, 100, 10); } - public CertDataInfos searchCerts(CertSearchData data) { + public CertDataInfos searchCerts(CertSearchRequest data) { return certClient.searchCerts(data, 100, 10); } @@ -82,7 +82,7 @@ public class CAClient extends PKIClient { return profileClient.retrieveProfile(id); } - public CertificateData getCertData(CertId id) { + public CertData getCertData(CertId id) { if (id == null) { return null; @@ -92,7 +92,7 @@ public class CAClient extends PKIClient { } - public CertRequestInfos enrollCertificate(EnrollmentRequestData data) { + public CertRequestInfos enrollCertificate(CertEnrollmentRequest data) { if (data == null) { return null; } @@ -107,34 +107,34 @@ public class CAClient extends PKIClient { return certRequestClient.getRequestInfo(id); } - public AgentEnrollmentRequestData reviewRequest(RequestId id) { + public CertReviewResponse reviewRequest(RequestId id) { if (id == null) { return null; } return certRequestClient.reviewRequest(id); } - public void approveRequest(RequestId id, AgentEnrollmentRequestData data) { + public void approveRequest(RequestId id, CertReviewResponse data) { certRequestClient.approveRequest(id, data); } - public void rejectRequest(RequestId id, AgentEnrollmentRequestData data) { + public void rejectRequest(RequestId id, CertReviewResponse data) { certRequestClient.rejectRequest(id, data); } - public void cancelRequest(RequestId id, AgentEnrollmentRequestData data) { + public void cancelRequest(RequestId id, CertReviewResponse data) { certRequestClient.cancelRequest(id, data); } - public void updateRequest(RequestId id, AgentEnrollmentRequestData data) { + public void updateRequest(RequestId id, CertReviewResponse data) { certRequestClient.updateRequest(id, data); } - public void validateRequest(RequestId id, AgentEnrollmentRequestData data) { + public void validateRequest(RequestId id, CertReviewResponse data) { certRequestClient.validateRequest(id, data); } - public void unassignRequest(RequestId id, AgentEnrollmentRequestData data) { + public void unassignRequest(RequestId id, CertReviewResponse data) { certRequestClient.unassignRequest(id, data); } diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java index 185f01f24..8e67f5d5f 100644 --- a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java +++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java @@ -39,17 +39,17 @@ import com.netscape.cms.client.cli.ClientConfig; import com.netscape.cms.servlet.cert.CertNotFoundException; import com.netscape.cms.servlet.cert.model.CertDataInfo; import com.netscape.cms.servlet.cert.model.CertDataInfos; -import com.netscape.cms.servlet.cert.model.CertSearchData; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.profile.model.ProfileData; import com.netscape.cms.servlet.profile.model.ProfileDataInfo; import com.netscape.cms.servlet.profile.model.ProfileDataInfos; import com.netscape.cms.servlet.profile.model.ProfileInput; import com.netscape.cms.servlet.request.RequestNotFoundException; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; public class CATest { @@ -172,7 +172,7 @@ public class CATest { //Get a CertInfo int certIdToPrint = 1; CertId id = new CertId(certIdToPrint); - CertificateData certData = null; + CertData certData = null; try { certData = client.getCertData(id); } catch (CertNotFoundException e) { @@ -186,7 +186,7 @@ public class CATest { //Get a CertInfo int certIdBadToPrint = 9999999; CertId certIdBad = new CertId(certIdBadToPrint); - CertificateData certDataBad = null; + CertData certDataBad = null; try { certDataBad = client.getCertData(certIdBad); } catch (CertNotFoundException e) { @@ -209,15 +209,15 @@ public class CATest { //Initiate a Certificate Enrollment - EnrollmentRequestData data = createUserCertEnrollment(); + CertEnrollmentRequest data = createUserCertEnrollment(); enrollAndApproveCertRequest(client, data); // submit a RA authenticated user cert request - EnrollmentRequestData rdata = createRAUserCertEnrollment(); + CertEnrollmentRequest rdata = createRAUserCertEnrollment(); enrollCertRequest(client, rdata); // now try a manually approved server cert - EnrollmentRequestData serverData = createServerCertEnrollment(); + CertEnrollmentRequest serverData = createServerCertEnrollment(); enrollAndApproveCertRequest(client,serverData); // submit using an agent approval profile @@ -226,7 +226,7 @@ public class CATest { //Perform a sample certificate search with advanced search terms - CertSearchData searchData = new CertSearchData(); + CertSearchRequest searchData = new CertSearchRequest(); searchData.setSerialNumberRangeInUse(true); searchData.setSerialFrom("9999"); searchData.setSerialTo("99990"); @@ -252,7 +252,7 @@ public class CATest { //Perform another sample certificate search with advanced search terms - searchData = new CertSearchData(); + searchData = new CertSearchRequest(); searchData.setSubjectInUse(true); searchData.setEmail("jmagne@redhat.com"); searchData.setMatchExactly(true); @@ -275,7 +275,7 @@ public class CATest { } - private static void enrollAndApproveCertRequest(CAClient client, EnrollmentRequestData data) { + private static void enrollAndApproveCertRequest(CAClient client, CertEnrollmentRequest data) { CertRequestInfos reqInfo = null; try { reqInfo = client.enrollCertificate(data); @@ -287,7 +287,7 @@ public class CATest { for (CertRequestInfo info : reqInfo.getRequests()) { printRequestInfo(info); - AgentEnrollmentRequestData reviewData = client.reviewRequest(info.getRequestId()); + CertReviewResponse reviewData = client.reviewRequest(info.getRequestId()); log(reviewData.toString()); reviewData.setRequestNotes("This is an approval message"); @@ -295,7 +295,7 @@ public class CATest { } } - private static void enrollCertRequest(CAClient client, EnrollmentRequestData data) { + private static void enrollCertRequest(CAClient client, CertEnrollmentRequest data) { CertRequestInfos reqInfo = null; try { reqInfo = client.enrollCertificate(data); @@ -309,8 +309,8 @@ public class CATest { } } - private static EnrollmentRequestData createUserCertEnrollment() { - EnrollmentRequestData data = new EnrollmentRequestData(); + private static CertEnrollmentRequest createUserCertEnrollment() { + CertEnrollmentRequest data = new CertEnrollmentRequest(); data.setProfileId("caUserCert"); data.setIsRenewal(false); @@ -340,8 +340,8 @@ public class CATest { return data; } - private static EnrollmentRequestData createRAUserCertEnrollment() { - EnrollmentRequestData data = new EnrollmentRequestData(); + private static CertEnrollmentRequest createRAUserCertEnrollment() { + CertEnrollmentRequest data = new CertEnrollmentRequest(); data.setProfileId("caDualRAuserCert"); data.setIsRenewal(false); @@ -365,8 +365,8 @@ public class CATest { return data; } - private static EnrollmentRequestData createServerCertEnrollment() { - EnrollmentRequestData data = new EnrollmentRequestData(); + private static CertEnrollmentRequest createServerCertEnrollment() { + CertEnrollmentRequest data = new CertEnrollmentRequest(); data.setProfileId("caServerCert"); data.setIsRenewal(false); @@ -505,7 +505,7 @@ public class CATest { } - private static void printCertificate(CertificateData info) { + private static void printCertificate(CertData info) { if (info == null) { log("No CertificateData: "); diff --git a/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java b/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java index fe08e299b..6a426bd09 100644 --- a/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java +++ b/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java @@ -10,7 +10,7 @@ import com.netscape.cms.servlet.admin.GroupService; import com.netscape.cms.servlet.admin.SystemCertService; import com.netscape.cms.servlet.admin.UserCertService; import com.netscape.cms.servlet.admin.UserService; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.cert.CertService; import com.netscape.cms.servlet.csadmin.SystemConfigService; import com.netscape.cms.servlet.profile.ProfileService; @@ -41,7 +41,7 @@ public class CertificateAuthorityApplication extends Application { classes.add(SystemCertService.class); // exception mapper - classes.add(CMSException.Mapper.class); + classes.add(PKIException.Mapper.class); } public Set> getClasses() { diff --git a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java index dfa79c650..fd951d9f8 100644 --- a/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java +++ b/base/common/functional/src/com/netscape/cms/servlet/test/ConfigurationTest.java @@ -58,9 +58,9 @@ import org.mozilla.jss.util.Password; import com.netscape.cms.client.cli.ClientConfig; import com.netscape.cms.servlet.csadmin.SystemConfigClient; -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.SystemCertData; +import com.netscape.cms.servlet.csadmin.model.ConfigurationRequest; +import com.netscape.cms.servlet.csadmin.model.ConfigurationResponse; import com.netscape.cmsutil.util.Utils; /** @@ -195,7 +195,7 @@ public class ConfigurationTest { System.exit(1); } - ConfigurationData data = null; + ConfigurationRequest data = null; switch (testnum) { case 1: data = constructCAData(host, port, pin, db_dir, token_pwd, token); @@ -226,14 +226,14 @@ public class ConfigurationTest { System.exit(1); } - ConfigurationResponseData response = client.configure(data); + ConfigurationResponse response = client.configure(data); System.out.println("status: " + response.getStatus()); System.out.println("adminCert: " + response.getAdminCert().getCert()); - Collection certs = response.getSystemCerts(); - Iterator iterator = certs.iterator(); + Collection certs = response.getSystemCerts(); + Iterator iterator = certs.iterator(); while (iterator.hasNext()) { - CertData cdata = iterator.next(); + SystemCertData cdata = iterator.next(); System.out.println("tag: " + cdata.getTag()); System.out.println("cert: " + cdata.getCert()); System.out.println("request: " + cdata.getRequest()); @@ -241,16 +241,16 @@ public class ConfigurationTest { } - private static ConfigurationData constructCAData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructCAData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.NEW_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.NEW_DOMAIN); data.setSecurityDomainName("Testca2 security domain"); data.setIsClone("false"); data.setHierarchy("root"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test ca subsystem"); data.setDsHost(host); @@ -279,8 +279,8 @@ public class ConfigurationTest { data.setAdminCertRequestType("crmf"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("signing"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -292,7 +292,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert2 = new CertData(); + SystemCertData cert2 = new SystemCertData(); cert2.setTag("ocsp_signing"); cert2.setKeyAlgorithm("SHA256withRSA"); cert2.setKeySize("2048"); @@ -303,7 +303,7 @@ public class ConfigurationTest { cert2.setToken("Internal Key Storage Token"); systemCerts.add(cert2); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -313,7 +313,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -323,7 +323,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -339,20 +339,20 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructSubCAData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructSubCAData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.EXISTING_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.EXISTING_DOMAIN); data.setSecurityDomainUri("https://" + host + ":9225"); data.setSecurityDomainUser("admin"); data.setSecurityDomainPassword("redhat123"); data.setIsClone("false"); data.setHierarchy("join"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test subca subsystem"); data.setDsHost(host); @@ -383,8 +383,8 @@ public class ConfigurationTest { data.setIssuingCA("https://" + host + ":9224"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("signing"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -396,7 +396,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert2 = new CertData(); + SystemCertData cert2 = new SystemCertData(); cert2.setTag("ocsp_signing"); cert2.setKeyAlgorithm("SHA256withRSA"); cert2.setKeySize("2048"); @@ -407,7 +407,7 @@ public class ConfigurationTest { cert2.setToken("Internal Key Storage Token"); systemCerts.add(cert2); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -417,7 +417,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -427,7 +427,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -443,18 +443,18 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructExternalCADataPart1(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructExternalCADataPart1(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.NEW_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.NEW_DOMAIN); data.setSecurityDomainName("External CA security domain"); data.setIsClone("false"); data.setHierarchy("join"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test external ca subsystem"); data.setDsHost(host); @@ -485,8 +485,8 @@ public class ConfigurationTest { data.setIssuingCA("External CA"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("signing"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -498,7 +498,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert2 = new CertData(); + SystemCertData cert2 = new SystemCertData(); cert2.setTag("ocsp_signing"); cert2.setKeyAlgorithm("SHA256withRSA"); cert2.setKeySize("2048"); @@ -509,7 +509,7 @@ public class ConfigurationTest { cert2.setToken("Internal Key Storage Token"); systemCerts.add(cert2); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -519,7 +519,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -529,7 +529,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -545,18 +545,18 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructExternalCADataPart2(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructExternalCADataPart2(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token, String extCertFile, String extChainFile) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.NEW_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.NEW_DOMAIN); data.setSecurityDomainName("External CA security domain"); data.setIsClone("false"); data.setHierarchy("join"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test external ca subsystem"); data.setDsHost(host); @@ -588,8 +588,8 @@ public class ConfigurationTest { data.setStepTwo("true"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("signing"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -617,7 +617,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert2 = new CertData(); + SystemCertData cert2 = new SystemCertData(); cert2.setTag("ocsp_signing"); cert2.setKeyAlgorithm("SHA256withRSA"); cert2.setKeySize("2048"); @@ -628,7 +628,7 @@ public class ConfigurationTest { cert2.setToken("Internal Key Storage Token"); systemCerts.add(cert2); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -638,7 +638,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -648,7 +648,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -664,12 +664,12 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructCloneCAData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructCloneCAData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.EXISTING_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.EXISTING_DOMAIN); data.setSecurityDomainUri("https://" + host + ":9225"); data.setSecurityDomainUser("admin"); data.setSecurityDomainPassword("redhat123"); @@ -680,7 +680,7 @@ public class ConfigurationTest { data.setP12Password("redhat123"); data.setHierarchy("root"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test clone ca subsystem"); data.setDsHost(host); @@ -695,8 +695,8 @@ public class ConfigurationTest { data.setBackupKeys("false"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert3 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -711,19 +711,19 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructKRAData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructKRAData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.EXISTING_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.EXISTING_DOMAIN); data.setSecurityDomainUri("https://" + host + ":9225"); data.setSecurityDomainUser("admin"); data.setSecurityDomainPassword("redhat123"); data.setIsClone("false"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test kra subsystem"); data.setDsHost(host); @@ -754,8 +754,8 @@ public class ConfigurationTest { data.setIssuingCA("https://" + host + ":9224"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("transport"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -767,7 +767,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert2 = new CertData(); + SystemCertData cert2 = new SystemCertData(); cert2.setTag("storage"); cert2.setKeyAlgorithm("SHA256withRSA"); cert2.setKeySize("2048"); @@ -778,7 +778,7 @@ public class ConfigurationTest { cert2.setToken("Internal Key Storage Token"); systemCerts.add(cert2); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -788,7 +788,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -798,7 +798,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -814,19 +814,19 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructOCSPData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructOCSPData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.EXISTING_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.EXISTING_DOMAIN); data.setSecurityDomainUri("https://" + host + ":9225"); data.setSecurityDomainUser("admin"); data.setSecurityDomainPassword("redhat123"); data.setIsClone("false"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test ocsp subsystem"); data.setDsHost(host); @@ -857,8 +857,8 @@ public class ConfigurationTest { data.setIssuingCA("https://" + host + ":9224"); // create system certs - Collection systemCerts = new ArrayList(); - CertData cert1 = new CertData(); + Collection systemCerts = new ArrayList(); + SystemCertData cert1 = new SystemCertData(); cert1.setTag("signing"); cert1.setKeyAlgorithm("SHA256withRSA"); cert1.setKeySize("2048"); @@ -870,7 +870,7 @@ public class ConfigurationTest { systemCerts.add(cert1); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -880,7 +880,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -890,7 +890,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); @@ -906,19 +906,19 @@ public class ConfigurationTest { return data; } - private static ConfigurationData constructTKSData(String host, String port, String pin, String db_dir, + private static ConfigurationRequest constructTKSData(String host, String port, String pin, String db_dir, String token_pwd, CryptoToken token) throws NoSuchAlgorithmException, TokenException, IOException, InvalidBERException { - ConfigurationData data = new ConfigurationData(); + ConfigurationRequest data = new ConfigurationRequest(); data.setPin(pin); - data.setSecurityDomainType(ConfigurationData.EXISTING_DOMAIN); + data.setSecurityDomainType(ConfigurationRequest.EXISTING_DOMAIN); data.setSecurityDomainUri("https://" + host + ":9225"); data.setSecurityDomainUser("admin"); data.setSecurityDomainPassword("redhat123"); data.setIsClone("false"); - data.setToken(ConfigurationData.TOKEN_DEFAULT); + data.setToken(ConfigurationRequest.TOKEN_DEFAULT); data.setSubsystemName("test tks subsystem"); data.setDsHost(host); @@ -949,9 +949,9 @@ public class ConfigurationTest { data.setIssuingCA("https://" + host + ":9224"); // create system certs - Collection systemCerts = new ArrayList(); + Collection systemCerts = new ArrayList(); - CertData cert3 = new CertData(); + SystemCertData cert3 = new SystemCertData(); cert3.setTag("sslserver"); cert3.setKeyAlgorithm("SHA256withRSA"); cert3.setKeySize("2048"); @@ -961,7 +961,7 @@ public class ConfigurationTest { cert3.setToken("Internal Key Storage Token"); systemCerts.add(cert3); - CertData cert4 = new CertData(); + SystemCertData cert4 = new SystemCertData(); cert4.setTag("subsystem"); cert4.setKeyAlgorithm("SHA256withRSA"); cert4.setKeySize("2048"); @@ -971,7 +971,7 @@ public class ConfigurationTest { cert4.setToken("Internal Key Storage Token"); systemCerts.add(cert4); - CertData cert5 = new CertData(); + SystemCertData cert5 = new SystemCertData(); cert5.setTag("audit_signing"); cert5.setKeyAlgorithm("SHA256withRSA"); cert5.setKeySize("2048"); diff --git a/base/common/src/com/netscape/cms/client/cert/CertCLI.java b/base/common/src/com/netscape/cms/client/cert/CertCLI.java index 2f7ab668e..ced2560ec 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertCLI.java @@ -26,7 +26,7 @@ import org.jboss.resteasy.plugins.providers.atom.Link; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; import com.netscape.cms.servlet.cert.model.CertDataInfo; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.request.model.CertRequestInfo; /** @@ -114,7 +114,7 @@ public class CertCLI extends CLI { } public static void printCertData( - CertificateData certData, + CertData certData, boolean showPrettyPrint, boolean showEncoded) { diff --git a/base/common/src/com/netscape/cms/client/cert/CertClient.java b/base/common/src/com/netscape/cms/client/cert/CertClient.java index b8fdde703..fb2f61c75 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertClient.java +++ b/base/common/src/com/netscape/cms/client/cert/CertClient.java @@ -25,15 +25,15 @@ import com.netscape.cms.client.cli.ClientConfig; import com.netscape.cms.servlet.cert.CertResource; import com.netscape.cms.servlet.cert.model.CertDataInfos; import com.netscape.cms.servlet.cert.model.CertRevokeRequest; -import com.netscape.cms.servlet.cert.model.CertSearchData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.csadmin.PKIClient; import com.netscape.cms.servlet.request.CertRequestResource; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; /** * @author Endi S. Dewata @@ -50,11 +50,11 @@ public class CertClient extends PKIClient { certRequestResource = createProxy(CertRequestResource.class); } - public CertificateData getCert(CertId id) { + public CertData getCert(CertId id) { return certClient.getCert(id); } - public CertDataInfos findCerts(CertSearchData data, Integer start, Integer size) { + public CertDataInfos findCerts(CertSearchRequest data, Integer start, Integer size) { return certClient.searchCerts(data, start, size); } @@ -70,15 +70,15 @@ public class CertClient extends PKIClient { return certClient.unrevokeCert(id, request); } - public CertRequestInfos enrollRequest(EnrollmentRequestData data){ + public CertRequestInfos enrollRequest(CertEnrollmentRequest data){ return certRequestResource.enrollCert(data); } - public AgentEnrollmentRequestData reviewRequest(RequestId id){ + public CertReviewResponse reviewRequest(RequestId id){ return certRequestResource.reviewRequest(id); } - public void approveRequest(RequestId id, AgentEnrollmentRequestData data) { + public void approveRequest(RequestId id, CertReviewResponse data) { certRequestResource.approveRequest(id, data); } } diff --git a/base/common/src/com/netscape/cms/client/cert/CertFindCLI.java b/base/common/src/com/netscape/cms/client/cert/CertFindCLI.java index ea88c46cd..e67276ac3 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertFindCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertFindCLI.java @@ -30,10 +30,10 @@ import org.apache.commons.cli.ParseException; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.cert.model.CertDataInfo; import com.netscape.cms.servlet.cert.model.CertDataInfos; -import com.netscape.cms.servlet.cert.model.CertSearchData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; /** * @author Endi S. Dewata @@ -56,7 +56,7 @@ public class CertFindCLI extends CLI { addOptions(); CommandLine cmd = null; - CertSearchData searchData = null; + CertSearchRequest searchData = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { @@ -84,7 +84,7 @@ public class CertFindCLI extends CLI { FileReader reader = null; try { reader = new FileReader(fileName); - searchData = CertSearchData.valueOf(reader); + searchData = CertSearchRequest.valueOf(reader); } catch (FileNotFoundException e) { System.err.println("Error: " + e.getMessage()); System.exit(-1); @@ -100,7 +100,7 @@ public class CertFindCLI extends CLI { } } } else { - searchData = new CertSearchData(); + searchData = new CertSearchRequest(); searchData.setSerialNumberRangeInUse(true); } String s = cmd.getOptionValue("start"); @@ -113,7 +113,7 @@ public class CertFindCLI extends CLI { CertDataInfos certs = null; try { certs = parent.client.findCerts(searchData, start, size); - } catch (CMSException e) { + } catch (PKIException e) { System.err.println("Error: Cannot list certificates. " + e.getMessage()); System.exit(-1); } @@ -267,7 +267,7 @@ public class CertFindCLI extends CLI { options.addOption(option); } - public void addSearchAttribute(CommandLine cmd, CertSearchData csd) { + public void addSearchAttribute(CommandLine cmd, CertSearchRequest csd) { if (cmd.hasOption("minSerialNumber")) { csd.setSerialNumberRangeInUse(true); csd.setSerialFrom(cmd.getOptionValue("minSerialNumber")); diff --git a/base/common/src/com/netscape/cms/client/cert/CertHoldCLI.java b/base/common/src/com/netscape/cms/client/cert/CertHoldCLI.java index 598c1e664..1e283b722 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertHoldCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertHoldCLI.java @@ -31,7 +31,7 @@ import com.netscape.certsrv.request.RequestStatus; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; import com.netscape.cms.servlet.cert.model.CertRevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.request.model.CertRequestInfo; /** @@ -80,7 +80,7 @@ public class CertHoldCLI extends CLI { if (!cmd.hasOption("force")) { - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); System.out.println("Placing certificate on-hold:"); @@ -108,7 +108,7 @@ public class CertHoldCLI extends CLI { if (certRequestInfo.getRequestStatus() == RequestStatus.COMPLETE) { MainCLI.printMessage("Placed certificate \"" + certID.toHexString() + "\" on-hold"); - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); CertCLI.printCertData(certData, false, false); } else { diff --git a/base/common/src/com/netscape/cms/client/cert/CertReleaseHoldCLI.java b/base/common/src/com/netscape/cms/client/cert/CertReleaseHoldCLI.java index 0d39aff88..920c642e5 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertReleaseHoldCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertReleaseHoldCLI.java @@ -28,7 +28,7 @@ import com.netscape.certsrv.request.RequestStatus; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.request.model.CertRequestInfo; /** @@ -73,7 +73,7 @@ public class CertReleaseHoldCLI extends CLI { if (!cmd.hasOption("force")) { - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); System.out.println("Placing certificate off-hold:"); @@ -99,7 +99,7 @@ public class CertReleaseHoldCLI extends CLI { if (certRequestInfo.getRequestStatus() == RequestStatus.COMPLETE) { MainCLI.printMessage("Placed certificate \"" + certID.toHexString() + "\" off-hold"); - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); CertCLI.printCertData(certData, false, false); } else { diff --git a/base/common/src/com/netscape/cms/client/cert/CertRequestApproveCLI.java b/base/common/src/com/netscape/cms/client/cert/CertRequestApproveCLI.java index 3d729424f..91cb26e14 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertRequestApproveCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertRequestApproveCLI.java @@ -12,8 +12,8 @@ import org.apache.commons.cli.ParseException; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.base.PKIException; +import com.netscape.cms.servlet.request.model.CertReviewResponse; public class CertRequestApproveCLI extends CLI { CertCLI parent; @@ -42,14 +42,14 @@ public class CertRequestApproveCLI extends CLI { printHelp(); System.exit(-1); } - AgentEnrollmentRequestData reviewInfo = null; + CertReviewResponse reviewInfo = null; try { - JAXBContext context = JAXBContext.newInstance(AgentEnrollmentRequestData.class); + JAXBContext context = JAXBContext.newInstance(CertReviewResponse.class); Unmarshaller unmarshaller = context.createUnmarshaller(); FileInputStream fis = new FileInputStream(cLineArgs[0].trim()); - reviewInfo = (AgentEnrollmentRequestData) unmarshaller.unmarshal(fis); + reviewInfo = (CertReviewResponse) unmarshaller.unmarshal(fis); parent.client.approveRequest(reviewInfo.getRequestId(), reviewInfo); - } catch (CMSException e) { + } catch (PKIException e) { System.err.println(e.getMessage()); System.exit(-1); } catch (JAXBException e) { diff --git a/base/common/src/com/netscape/cms/client/cert/CertRequestReviewCLI.java b/base/common/src/com/netscape/cms/client/cert/CertRequestReviewCLI.java index 10c0e40fc..61c8506e7 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertRequestReviewCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertRequestReviewCLI.java @@ -14,8 +14,8 @@ import org.apache.commons.cli.ParseException; import com.netscape.certsrv.request.RequestId; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; -import com.netscape.cms.servlet.base.CMSException; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.base.PKIException; +import com.netscape.cms.servlet.request.model.CertReviewResponse; public class CertRequestReviewCLI extends CLI { @@ -71,16 +71,16 @@ public class CertRequestReviewCLI extends CLI { System.exit(-1); } - AgentEnrollmentRequestData reviewInfo = null; + CertReviewResponse reviewInfo = null; try { reviewInfo = parent.client.reviewRequest(reqId); - } catch (CMSException e) { + } catch (PKIException e) { System.err.println(e.getMessage()); System.exit(-1); } try { - JAXBContext context = JAXBContext.newInstance(AgentEnrollmentRequestData.class); + JAXBContext context = JAXBContext.newInstance(CertReviewResponse.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); diff --git a/base/common/src/com/netscape/cms/client/cert/CertRequestSubmitCLI.java b/base/common/src/com/netscape/cms/client/cert/CertRequestSubmitCLI.java index e09f8be5b..021400f75 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertRequestSubmitCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertRequestSubmitCLI.java @@ -15,7 +15,7 @@ import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; public class CertRequestSubmitCLI extends CLI { @@ -46,7 +46,7 @@ public class CertRequestSubmitCLI extends CLI { System.exit(-1); } - EnrollmentRequestData erd = null; + CertEnrollmentRequest erd = null; try { erd = getEnrollmentRequest(cLineArgs[0]); @@ -62,12 +62,12 @@ public class CertRequestSubmitCLI extends CLI { } } - private EnrollmentRequestData getEnrollmentRequest(String fileName) throws JAXBException, FileNotFoundException { - EnrollmentRequestData erd = null; - JAXBContext context = JAXBContext.newInstance(EnrollmentRequestData.class); + private CertEnrollmentRequest getEnrollmentRequest(String fileName) throws JAXBException, FileNotFoundException { + CertEnrollmentRequest erd = null; + JAXBContext context = JAXBContext.newInstance(CertEnrollmentRequest.class); Unmarshaller unmarshaller = context.createUnmarshaller(); FileInputStream fis = new FileInputStream(fileName); - erd = (EnrollmentRequestData) unmarshaller.unmarshal(fis); + erd = (CertEnrollmentRequest) unmarshaller.unmarshal(fis); return erd; } diff --git a/base/common/src/com/netscape/cms/client/cert/CertRevokeCLI.java b/base/common/src/com/netscape/cms/client/cert/CertRevokeCLI.java index ad3276c52..611e50c37 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertRevokeCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertRevokeCLI.java @@ -31,7 +31,7 @@ import com.netscape.certsrv.request.RequestStatus; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; import com.netscape.cms.servlet.cert.model.CertRevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.request.model.CertRequestInfo; /** @@ -107,7 +107,7 @@ public class CertRevokeCLI extends CLI { if (!cmd.hasOption("force")) { - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); if (reason == RevocationReason.CERTIFICATE_HOLD) { System.out.println("Placing certificate on-hold:"); @@ -154,7 +154,7 @@ public class CertRevokeCLI extends CLI { MainCLI.printMessage("Revoked certificate \"" + certID.toHexString() + "\""); } - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); CertCLI.printCertData(certData, false, false); } else { diff --git a/base/common/src/com/netscape/cms/client/cert/CertShowCLI.java b/base/common/src/com/netscape/cms/client/cert/CertShowCLI.java index 1389a0a42..a16e36f3f 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertShowCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertShowCLI.java @@ -27,7 +27,7 @@ import org.apache.commons.cli.Option; import com.netscape.certsrv.dbs.certdb.CertId; import com.netscape.cms.client.cli.CLI; import com.netscape.cms.client.cli.MainCLI; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; /** * @author Endi S. Dewata @@ -78,7 +78,7 @@ public class CertShowCLI extends CLI { CertId certID = new CertId(cmdArgs[0]); String file = cmd.getOptionValue("output"); - CertificateData certData = parent.client.getCert(certID); + CertData certData = parent.client.getCert(certID); String encoded = certData.getEncoded(); if (encoded != null && file != null) { diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java index 2a7419d33..7b4ccf323 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java @@ -43,7 +43,7 @@ import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.user.UserResource; import com.netscape.certsrv.usrgrp.IGroup; import com.netscape.certsrv.usrgrp.IUGSubsystem; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.base.PKIService; /** @@ -81,13 +81,13 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } GroupMemberCollection response = new GroupMemberCollection(); @@ -120,12 +120,12 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc return response; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { CMS.debug(e); - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -141,13 +141,13 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } String memberID = groupMemberData.getID(); @@ -199,14 +199,14 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc .type(MediaType.APPLICATION_XML) .build(); - } catch (CMSException e) { + } catch (PKIException e) { auditAddGroupMember(groupID, groupMemberData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditAddGroupMember(groupID, groupMemberData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } @@ -289,13 +289,13 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } Enumeration e = group.getMemberNames(); @@ -307,14 +307,14 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc return groupMemberData; } - throw new CMSException("Group member not found"); + throw new PKIException("Group member not found"); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -329,13 +329,13 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } String member = groupMemberData.getID(); @@ -351,14 +351,14 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc auditDeleteGroupMember(groupID, groupMemberData, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteGroupMember(groupID, groupMemberData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditDeleteGroupMember(groupID, groupMemberData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java index 868f142c8..9f2e32cd1 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/GroupService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java @@ -40,7 +40,7 @@ import com.netscape.certsrv.logging.IAuditor; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.usrgrp.IGroup; import com.netscape.certsrv.usrgrp.IUGSubsystem; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.base.PKIService; import com.netscape.cmsutil.ldap.LDAPUtil; @@ -115,7 +115,7 @@ public class GroupService extends PKIService implements GroupResource { return response; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -131,22 +131,22 @@ public class GroupService extends PKIService implements GroupResource { try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); if (group == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_GROUP_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_GROUP_NOT_EXIST")); } return createGroupData(group); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -173,7 +173,7 @@ public class GroupService extends PKIService implements GroupResource { try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.createGroup(groupID); @@ -201,16 +201,16 @@ public class GroupService extends PKIService implements GroupResource { .build(); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditAddGroup(groupID, groupData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditAddGroup(groupID, groupData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -237,7 +237,7 @@ public class GroupService extends PKIService implements GroupResource { try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IGroup group = userGroupManager.getGroupFromName(groupID); @@ -261,16 +261,16 @@ public class GroupService extends PKIService implements GroupResource { } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditModifyGroup(groupID, groupData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditModifyGroup(groupID, groupData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -295,7 +295,7 @@ public class GroupService extends PKIService implements GroupResource { try { if (groupID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } // if fails, let the exception fall through @@ -303,13 +303,13 @@ public class GroupService extends PKIService implements GroupResource { auditDeleteGroup(groupID, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteGroup(groupID, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditDeleteGroup(groupID, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java index 2d86d71ea..fe6016056 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java @@ -27,7 +27,7 @@ import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.kra.IKeyRecoveryAuthority; import com.netscape.certsrv.security.ITransportKeyUnit; import com.netscape.cms.servlet.base.PKIService; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; /** * This is the class used to list, retrieve and modify system certificates for all Java subsystems. @@ -41,7 +41,7 @@ public class SystemCertService extends PKIService implements SystemCertificateRe * Used to retrieve the transport certificate */ public Response getTransportCert() { - CertificateData cert = null; + CertData cert = null; IKeyRecoveryAuthority kra = null; // auth and authz diff --git a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java b/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java index aaf3fa129..16b3b5b5d 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java +++ b/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java @@ -8,7 +8,7 @@ import javax.ws.rs.core.Response; import org.jboss.resteasy.annotations.ClientResponseType; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; @Path("config/cert") public interface SystemCertificateResource { @@ -18,7 +18,7 @@ public interface SystemCertificateResource { */ @GET @Path("transport") - @ClientResponseType(entityType=CertificateData.class) + @ClientResponseType(entityType=CertData.class) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response getTransportCert(); diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java index 4f2304a97..c2d4d6cfa 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java @@ -50,7 +50,7 @@ import com.netscape.certsrv.user.UserCertData; import com.netscape.certsrv.user.UserCertResource; 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.cmsutil.util.Cert; import com.netscape.cmsutil.util.Utils; @@ -96,7 +96,7 @@ public class UserCertService extends PKIService implements UserCertResource { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = null; @@ -104,12 +104,12 @@ public class UserCertService extends PKIService implements UserCertResource { try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } UserCertCollection response = new UserCertCollection(); @@ -134,11 +134,11 @@ public class UserCertService extends PKIService implements UserCertResource { return response; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -148,7 +148,7 @@ public class UserCertService extends PKIService implements UserCertResource { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = null; @@ -156,24 +156,24 @@ public class UserCertService extends PKIService implements UserCertResource { try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } X509Certificate[] certs = user.getX509Certificates(); if (certs == null) { - throw new CMSException("Certificate not found"); + throw new PKIException("Certificate not found"); } try { certID = URLDecoder.decode(certID, "UTF-8"); } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } for (X509Certificate cert : certs) { @@ -192,13 +192,13 @@ public class UserCertService extends PKIService implements UserCertResource { return userCertData; } - throw new CMSException("Certificate not found"); + throw new PKIException("Certificate not found"); - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -223,7 +223,7 @@ public class UserCertService extends PKIService implements UserCertResource { try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -266,7 +266,7 @@ public class UserCertService extends PKIService implements UserCertResource { X509Certificate p7certs[] = pkcs7.getCertificates(); if (p7certs.length == 0) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } // fix for 370099 - cert ordering can not be assumed @@ -292,7 +292,7 @@ public class UserCertService extends PKIService implements UserCertResource { } else { // not a chain, or in random order CMS.debug("UserCertResourceService: " + CMS.getLogMessage("ADMIN_SRVLT_CERT_BAD_CHAIN")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } CMS.debug("UserCertResourceService: " @@ -343,7 +343,7 @@ public class UserCertService extends PKIService implements UserCertResource { */ } catch (Exception e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_ERROR", e.toString())); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR")); } } @@ -375,29 +375,29 @@ public class UserCertService extends PKIService implements UserCertResource { } catch (CertificateExpiredException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_CERT_EXPIRED", String.valueOf(cert.getSubjectDN()))); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED")); } catch (CertificateNotYetValidException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_NOT_YET_VALID", String.valueOf(cert.getSubjectDN()))); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID")); } catch (LDAPException e) { if (e.getLDAPResultCode() == LDAPException.ATTRIBUTE_OR_VALUE_EXISTS) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS")); } else { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } - } catch (CMSException e) { + } catch (PKIException e) { auditAddUserCert(userID, userCertData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditAddUserCert(userID, userCertData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } @@ -423,7 +423,7 @@ public class UserCertService extends PKIService implements UserCertResource { try { certID = URLDecoder.decode(certID, "UTF-8"); } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } UserCertData userCertData = new UserCertData(); @@ -438,7 +438,7 @@ public class UserCertService extends PKIService implements UserCertResource { try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -456,14 +456,14 @@ public class UserCertService extends PKIService implements UserCertResource { auditDeleteUserCert(userID, userCertData, ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteUserCert(userID, userCertData, ILogger.FAILURE); throw e; } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); auditDeleteUserCert(userID, userCertData, ILogger.FAILURE); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } } diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserService.java b/base/common/src/com/netscape/cms/servlet/admin/UserService.java index 1128e09e7..687619722 100644 --- a/base/common/src/com/netscape/cms/servlet/admin/UserService.java +++ b/base/common/src/com/netscape/cms/servlet/admin/UserService.java @@ -45,7 +45,7 @@ import com.netscape.certsrv.usrgrp.EUsrGrpException; import com.netscape.certsrv.usrgrp.IGroup; 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.cmsutil.ldap.LDAPUtil; @@ -123,7 +123,7 @@ public class UserService extends PKIService implements UserResource { return response; } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } } @@ -142,7 +142,7 @@ public class UserService extends PKIService implements UserResource { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user; @@ -150,13 +150,13 @@ public class UserService extends PKIService implements UserResource { try { user = userGroupManager.getUser(userID); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } if (user == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_USER_NOT_EXIST")); - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST")); } UserData userData = createUserData(user); @@ -175,11 +175,11 @@ public class UserService extends PKIService implements UserResource { return userData; - } catch (CMSException e) { + } catch (PKIException e) { throw e; } catch (Exception e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -207,19 +207,19 @@ public class UserService extends PKIService implements UserResource { try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } if (userID.indexOf(BACK_SLASH) != -1) { // backslashes (BS) are not allowed log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_RS_ID_BS")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS")); } if (userID.equals(SYSTEM_USER)) { // backslashes (BS) are not allowed log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_SPECIAL_ID", userID)); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", userID)); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", userID)); } IUser user = userGroupManager.createUser(userID); @@ -229,7 +229,7 @@ public class UserService extends PKIService implements UserResource { String msg = getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "full name"); log(ILogger.LL_FAILURE, msg); - throw new CMSException(msg); + throw new PKIException(msg); } else { user.setFullName(fname); @@ -292,27 +292,27 @@ public class UserService extends PKIService implements UserResource { log(ILogger.LL_FAILURE, e.toString()); if (user.getUserID() == null) { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid")); } else { - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } } catch (LDAPException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_USER_FAIL", e.toString())); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditAddUser(userID, userData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditAddUser(userID, userData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -337,7 +337,7 @@ public class UserService extends PKIService implements UserResource { try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } IUser user = userGroupManager.createUser(userID); @@ -388,16 +388,16 @@ public class UserService extends PKIService implements UserResource { } catch (Exception e) { log(ILogger.LL_FAILURE, e.toString()); - throw new CMSException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); + throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED")); } - } catch (CMSException e) { + } catch (PKIException e) { auditModifyUser(userID, userData, ILogger.FAILURE); throw e; } catch (EBaseException e) { auditModifyUser(userID, userData, ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -425,7 +425,7 @@ public class UserService extends PKIService implements UserResource { try { if (userID == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID")); - throw new CMSException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); + throw new PKIException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID")); } // get list of groups, and see if uid belongs to any @@ -435,7 +435,7 @@ public class UserService extends PKIService implements UserResource { groups = userGroupManager.findGroups("*"); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_INTERNAL_ERROR")); + throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR")); } try { @@ -452,10 +452,10 @@ public class UserService extends PKIService implements UserResource { auditDeleteUser(userID, ILogger.SUCCESS); } catch (Exception e) { - throw new CMSException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV")); + throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV")); } - } catch (CMSException e) { + } catch (PKIException e) { auditDeleteUser(userID, ILogger.FAILURE); throw e; } diff --git a/base/common/src/com/netscape/cms/servlet/base/BadRequestException.java b/base/common/src/com/netscape/cms/servlet/base/BadRequestException.java index b5c5e0b12..cefa26985 100644 --- a/base/common/src/com/netscape/cms/servlet/base/BadRequestException.java +++ b/base/common/src/com/netscape/cms/servlet/base/BadRequestException.java @@ -18,7 +18,7 @@ package com.netscape.cms.servlet.base; import javax.ws.rs.core.Response; -public class BadRequestException extends CMSException { +public class BadRequestException extends PKIException { private static final long serialVersionUID = -4784839378360933483L; diff --git a/base/common/src/com/netscape/cms/servlet/base/CMSException.java b/base/common/src/com/netscape/cms/servlet/base/CMSException.java deleted file mode 100644 index 5ceb30ee1..000000000 --- a/base/common/src/com/netscape/cms/servlet/base/CMSException.java +++ /dev/null @@ -1,182 +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) 2007 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.cms.servlet.base; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -public class CMSException extends RuntimeException { - - private static final long serialVersionUID = 6000910362260369923L; - - public int code; - - public CMSException(String message) { - super(message); - code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - } - - public CMSException(int code, String message) { - super(message); - this.code = code; - } - - public CMSException(Response.Status status, String message) { - super(message); - code = status.getStatusCode(); - } - - public CMSException(String message, Throwable cause) { - super(message, cause); - code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - } - - public CMSException(int code, String message, Throwable cause) { - super(message, cause); - this.code = code; - } - - public CMSException(Response.Status status, String message, Throwable cause) { - super(message, cause); - code = status.getStatusCode(); - } - - public CMSException(Data data) { - super(data.message); - code = data.code; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public Data getData() { - Data data = new Data(); - data.className = getClass().getName(); - data.code = code; - data.message = getMessage(); - return data; - } - - @XmlRootElement(name="CMSException") - public static class Data { - - @XmlElement(name="ClassName") - public String className; - - @XmlElement(name="Code") - public int code; - - @XmlElement(name="Message") - public String message; - - @XmlElement(name="Attributes") - @XmlJavaTypeAdapter(MapAdapter.class) - public Map attributes = new LinkedHashMap(); - - public String getAttribute(String name) { - return attributes.get(name); - } - - public void setAttribute(String name, String value) { - attributes.put(name, value); - } - } - - public static class MapAdapter extends XmlAdapter> { - - public AttributeList marshal(Map map) { - AttributeList list = new AttributeList(); - for (Map.Entry entry : map.entrySet()) { - Attribute attribute = new Attribute(); - attribute.name = entry.getKey(); - attribute.value = entry.getValue(); - list.attributes.add(attribute); - } - return list; - } - - public Map unmarshal(AttributeList list) { - Map map = new LinkedHashMap(); - for (Attribute attribute : list.attributes) { - map.put(attribute.name, attribute.value); - } - return map; - } - } - - public static class AttributeList { - @XmlElement(name="Attribute") - public List attributes = new ArrayList(); - } - - public static class Attribute { - - @XmlAttribute - public String name; - - @XmlValue - public String value; - } - - @Provider - public static class Mapper implements ExceptionMapper { - - public Response toResponse(CMSException exception) { - // convert CMSException into HTTP response with XML content - return Response - .status(exception.getCode()) - .entity(exception.getData()) - .type(MediaType.APPLICATION_XML) - .build(); - } - } - - public static void main(String args[]) throws Exception { - Data data = new Data(); - data.className = CMSException.class.getName(); - data.code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - data.message = "An error has occured"; - data.setAttribute("attr1", "value1"); - data.setAttribute("attr2", "value2"); - - JAXBContext context = JAXBContext.newInstance(Data.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshaller.marshal(data, System.out); - } -} diff --git a/base/common/src/com/netscape/cms/servlet/base/PKIException.java b/base/common/src/com/netscape/cms/servlet/base/PKIException.java new file mode 100644 index 000000000..be2629e17 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/base/PKIException.java @@ -0,0 +1,182 @@ +// --- 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) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cms.servlet.base; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +public class PKIException extends RuntimeException { + + private static final long serialVersionUID = 6000910362260369923L; + + public int code; + + public PKIException(String message) { + super(message); + code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + } + + public PKIException(int code, String message) { + super(message); + this.code = code; + } + + public PKIException(Response.Status status, String message) { + super(message); + code = status.getStatusCode(); + } + + public PKIException(String message, Throwable cause) { + super(message, cause); + code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + } + + public PKIException(int code, String message, Throwable cause) { + super(message, cause); + this.code = code; + } + + public PKIException(Response.Status status, String message, Throwable cause) { + super(message, cause); + code = status.getStatusCode(); + } + + public PKIException(Data data) { + super(data.message); + code = data.code; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public Data getData() { + Data data = new Data(); + data.className = getClass().getName(); + data.code = code; + data.message = getMessage(); + return data; + } + + @XmlRootElement(name="PKIException") + public static class Data { + + @XmlElement(name="ClassName") + public String className; + + @XmlElement(name="Code") + public int code; + + @XmlElement(name="Message") + public String message; + + @XmlElement(name="Attributes") + @XmlJavaTypeAdapter(MapAdapter.class) + public Map attributes = new LinkedHashMap(); + + public String getAttribute(String name) { + return attributes.get(name); + } + + public void setAttribute(String name, String value) { + attributes.put(name, value); + } + } + + public static class MapAdapter extends XmlAdapter> { + + public AttributeList marshal(Map map) { + AttributeList list = new AttributeList(); + for (Map.Entry entry : map.entrySet()) { + Attribute attribute = new Attribute(); + attribute.name = entry.getKey(); + attribute.value = entry.getValue(); + list.attributes.add(attribute); + } + return list; + } + + public Map unmarshal(AttributeList list) { + Map map = new LinkedHashMap(); + for (Attribute attribute : list.attributes) { + map.put(attribute.name, attribute.value); + } + return map; + } + } + + public static class AttributeList { + @XmlElement(name="Attribute") + public List attributes = new ArrayList(); + } + + public static class Attribute { + + @XmlAttribute + public String name; + + @XmlValue + public String value; + } + + @Provider + public static class Mapper implements ExceptionMapper { + + public Response toResponse(PKIException exception) { + // convert PKIException into HTTP response with XML content + return Response + .status(exception.getCode()) + .entity(exception.getData()) + .type(MediaType.APPLICATION_XML) + .build(); + } + } + + public static void main(String args[]) throws Exception { + Data data = new Data(); + data.className = PKIException.class.getName(); + data.code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); + data.message = "An error has occured"; + data.setAttribute("attr1", "value1"); + data.setAttribute("attr2", "value2"); + + JAXBContext context = JAXBContext.newInstance(Data.class); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.marshal(data, System.out); + } +} diff --git a/base/common/src/com/netscape/cms/servlet/base/PKIService.java b/base/common/src/com/netscape/cms/servlet/base/PKIService.java index de92d290a..a77846c68 100644 --- a/base/common/src/com/netscape/cms/servlet/base/PKIService.java +++ b/base/common/src/com/netscape/cms/servlet/base/PKIService.java @@ -38,7 +38,7 @@ import javax.ws.rs.core.UriInfo; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.logging.IAuditor; import com.netscape.certsrv.logging.ILogger; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; /** * Base class for CMS RESTful resources @@ -90,9 +90,9 @@ public class PKIService { return builder.build(); } - public CertificateData createCertificateData(org.mozilla.jss.crypto.X509Certificate cert) + public CertData createCertificateData(org.mozilla.jss.crypto.X509Certificate cert) throws CertificateEncodingException { - CertificateData data = new CertificateData(); + CertData data = new CertData(); String b64 = HEADER + CMS.BtoA(cert.getEncoded()) + TRAILER; data.setEncoded(b64); return data; diff --git a/base/common/src/com/netscape/cms/servlet/base/UnauthorizedException.java b/base/common/src/com/netscape/cms/servlet/base/UnauthorizedException.java index 7dfa3d6d4..83803601c 100644 --- a/base/common/src/com/netscape/cms/servlet/base/UnauthorizedException.java +++ b/base/common/src/com/netscape/cms/servlet/base/UnauthorizedException.java @@ -23,7 +23,7 @@ import javax.ws.rs.core.Response; /** * @author Endi S. Dewata */ -public class UnauthorizedException extends CMSException { +public class UnauthorizedException extends PKIException { private static final long serialVersionUID = -2025082875126996556L; diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertNotFoundException.java b/base/common/src/com/netscape/cms/servlet/cert/CertNotFoundException.java index 11948ee39..bcfc18aaf 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/CertNotFoundException.java +++ b/base/common/src/com/netscape/cms/servlet/cert/CertNotFoundException.java @@ -20,9 +20,9 @@ package com.netscape.cms.servlet.cert; import javax.ws.rs.core.Response; import com.netscape.certsrv.dbs.certdb.CertId; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; -public class CertNotFoundException extends CMSException { +public class CertNotFoundException extends PKIException { private static final long serialVersionUID = -4784839378360933483L; diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/CertProcessor.java index 13b0072b4..2254a0458 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/CertProcessor.java +++ b/base/common/src/com/netscape/cms/servlet/cert/CertProcessor.java @@ -42,7 +42,7 @@ import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.RequestStatus; import com.netscape.cms.servlet.processors.Processor; import com.netscape.cms.servlet.profile.model.ProfileInput; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; public class CertProcessor extends Processor { @@ -73,7 +73,7 @@ public class CertProcessor extends Processor { } } - private void setInputsIntoRequest(EnrollmentRequestData data, IProfile profile, IRequest req) { + private void setInputsIntoRequest(CertEnrollmentRequest data, IProfile profile, IRequest req) { // put profile inputs into a local map HashMap dataInputs = new HashMap(); for (ProfileInput input : data.getInputs()) { @@ -269,7 +269,7 @@ public class CertProcessor extends Processor { return errorCode; } - protected void populateRequests(EnrollmentRequestData data, boolean isRenewal, + protected void populateRequests(CertEnrollmentRequest data, boolean isRenewal, Locale locale, Date origNotAfter, String origSubjectDN, IRequest origReq, String profileId, IProfile profile, IProfileContext ctx, IProfileAuthenticator authenticator, IAuthToken authToken, IRequest[] reqs) throws EBaseException { diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertResource.java b/base/common/src/com/netscape/cms/servlet/cert/CertResource.java index f3a9d4129..e937b2816 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/CertResource.java +++ b/base/common/src/com/netscape/cms/servlet/cert/CertResource.java @@ -13,9 +13,9 @@ import javax.ws.rs.core.MediaType; import com.netscape.certsrv.dbs.certdb.CertId; import com.netscape.cms.servlet.cert.model.CertDataInfos; import com.netscape.cms.servlet.cert.model.CertRevokeRequest; -import com.netscape.cms.servlet.cert.model.CertSearchData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.request.model.CertRequestInfo; @Path("") @@ -37,14 +37,14 @@ public interface CertResource { @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CertDataInfos searchCerts( - CertSearchData data, + CertSearchRequest data, @QueryParam("start") Integer start, @QueryParam("size") Integer size); @GET @Path("certs/{id}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public CertificateData getCert(@PathParam("id") CertId id); + public CertData getCert(@PathParam("id") CertId id); @POST @Path("agent/certs/{id}/revoke-ca") diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertService.java b/base/common/src/com/netscape/cms/servlet/cert/CertService.java index 08a621529..365e89977 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/CertService.java +++ b/base/common/src/com/netscape/cms/servlet/cert/CertService.java @@ -54,19 +54,19 @@ import com.netscape.certsrv.logging.AuditFormat; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.request.IRequest; import com.netscape.cms.servlet.base.BadRequestException; -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.base.UnauthorizedException; import com.netscape.cms.servlet.cert.model.CertDataInfo; import com.netscape.cms.servlet.cert.model.CertDataInfos; import com.netscape.cms.servlet.cert.model.CertRevokeRequest; -import com.netscape.cms.servlet.cert.model.CertSearchData; +import com.netscape.cms.servlet.cert.model.CertSearchRequest; import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.processors.Processor; import com.netscape.cms.servlet.request.model.CertRequestDAO; import com.netscape.cms.servlet.request.model.CertRequestInfo; -import com.netscape.cms.servlet.request.model.CertRetrievalRequestData; +import com.netscape.cms.servlet.request.model.CertRetrievalRequest; import com.netscape.cmsutil.ldap.LDAPUtil; import com.netscape.cmsutil.util.Utils; @@ -93,22 +93,22 @@ public class CertService extends PKIService implements CertResource { } @Override - public CertificateData getCert(CertId id) { + public CertData getCert(CertId id) { validateRequest(id); - CertRetrievalRequestData data = new CertRetrievalRequestData(); + CertRetrievalRequest data = new CertRetrievalRequest(); data.setCertId(id); - CertificateData certData = null; + CertData certData = null; try { certData = getCert(data); } catch (EDBRecordNotFoundException e) { throw new CertNotFoundException(id); } catch (EBaseException e) { - throw new CMSException("Problem returning certificate: " + id); + throw new PKIException("Problem returning certificate: " + id); } catch (CertificateEncodingException e) { - throw new CMSException("Problem encoding certificate searched for: " + id); + throw new PKIException("Problem encoding certificate searched for: " + id); } return certData; @@ -152,7 +152,7 @@ public class CertService extends PKIService implements CertResource { processor.setAuthority(authority); } catch (EBaseException e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } try { @@ -190,7 +190,7 @@ public class CertService extends PKIService implements CertResource { processor.auditChangeRequest(ILogger.SUCCESS); - } catch (CMSException e) { + } catch (PKIException e) { processor.log(ILogger.LL_FAILURE, e.getMessage()); processor.auditChangeRequest(ILogger.FAILURE); throw e; @@ -199,13 +199,13 @@ public class CertService extends PKIService implements CertResource { processor.log(ILogger.LL_FAILURE, "Error " + e); processor.auditChangeRequest(ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } catch (IOException e) { processor.log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_ERROR_MARKING_CERT_REVOKED_1", e.toString())); processor.auditChangeRequest(ILogger.FAILURE); - throw new CMSException(CMS.getLogMessage("CMSGW_ERROR_MARKING_CERT_REVOKED")); + throw new PKIException(CMS.getLogMessage("CMSGW_ERROR_MARKING_CERT_REVOKED")); } // change audit processing from "REQUEST" to "REQUEST_PROCESSED" @@ -221,7 +221,7 @@ public class CertService extends PKIService implements CertResource { processor.log(ILogger.LL_FAILURE, "Error " + e); processor.auditChangeRequestProcessed(ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } try { @@ -230,7 +230,7 @@ public class CertService extends PKIService implements CertResource { return dao.getRequest(certRequest.getRequestId(), uriInfo); } catch (EBaseException e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -249,7 +249,7 @@ public class CertService extends PKIService implements CertResource { processor.setAuthority(authority); } catch (EBaseException e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } try { @@ -262,7 +262,7 @@ public class CertService extends PKIService implements CertResource { processor.log(ILogger.LL_FAILURE, "Error " + e); processor.auditChangeRequest(ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } // change audit processing from "REQUEST" to "REQUEST_PROCESSED" @@ -278,7 +278,7 @@ public class CertService extends PKIService implements CertResource { processor.log(ILogger.LL_FAILURE, "Error " + e); processor.auditChangeRequestProcessed(ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } try { @@ -287,7 +287,7 @@ public class CertService extends PKIService implements CertResource { return dao.getRequest(certRequest.getRequestId(), uriInfo); } catch (EBaseException e) { - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } } @@ -306,7 +306,7 @@ public class CertService extends PKIService implements CertResource { return filter; } - private String createSearchFilter(CertSearchData data) { + private String createSearchFilter(CertSearchRequest data) { if (data == null) { return null; } @@ -325,13 +325,13 @@ public class CertService extends PKIService implements CertResource { infos = getCertList(filter, maxResults, maxTime); } catch (EBaseException e) { e.printStackTrace(); - throw new CMSException("Error listing certs in CertsResourceService.listCerts!"); + throw new PKIException("Error listing certs in CertsResourceService.listCerts!"); } return infos; } @Override - public CertDataInfos searchCerts(CertSearchData data, Integer start, Integer size) { + public CertDataInfos searchCerts(CertSearchRequest data, Integer start, Integer size) { if (data == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } @@ -372,7 +372,7 @@ public class CertService extends PKIService implements CertResource { infos.addLink(new Link("next", uri)); } } catch (EBaseException e1) { - throw new CMSException("Error listing certs in CertsResourceService.listCerts!" + e.toString()); + throw new PKIException("Error listing certs in CertsResourceService.listCerts!" + e.toString()); } return infos; @@ -412,14 +412,14 @@ public class CertService extends PKIService implements CertResource { return ret; } - public CertificateData getCert(CertRetrievalRequestData data) throws EBaseException, CertificateEncodingException { + public CertData getCert(CertRetrievalRequest data) throws EBaseException, CertificateEncodingException { CertId certId = data.getCertId(); //find the cert in question ICertRecord record = repo.readCertificateRecord(certId.toBigInteger()); X509CertImpl cert = record.getCertificate(); - CertificateData certData = new CertificateData(); + CertData certData = new CertData(); certData.setSerialNumber(certId); diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java b/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java index 167385ea9..f74a6bbac 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java +++ b/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java @@ -65,7 +65,7 @@ import com.netscape.certsrv.usrgrp.Certificates; import com.netscape.certsrv.usrgrp.ICertUserLocator; 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.CMSServlet; import com.netscape.cms.servlet.common.CMSRequest; import com.netscape.cms.servlet.common.CMSTemplate; @@ -473,7 +473,7 @@ public class DoRevoke extends CMSServlet { processor.addCertificateToRevoke(targetCert); rarg.addStringValue("error", null); - } catch (CMSException ex) { + } catch (PKIException ex) { rarg.addStringValue("error", ex.getMessage()); } diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java index 292f60457..0f41d3e6a 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java +++ b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java @@ -50,7 +50,7 @@ import com.netscape.certsrv.publish.IPublisherProcessor; import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.RequestId; import com.netscape.certsrv.request.RequestStatus; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.base.CMSServlet; import com.netscape.cms.servlet.common.CMSRequest; import com.netscape.cms.servlet.common.CMSTemplate; @@ -274,7 +274,7 @@ public class DoUnrevoke extends CMSServlet { processor.log(ILogger.LL_FAILURE, "Error " + e); processor.auditChangeRequest(ILogger.FAILURE); - throw new CMSException(e.getMessage()); + throw new PKIException(e.getMessage()); } // change audit processing from "REQUEST" to "REQUEST_PROCESSED" diff --git a/base/common/src/com/netscape/cms/servlet/cert/EnrollmentProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/EnrollmentProcessor.java index c1841051b..1d8a5695a 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/EnrollmentProcessor.java +++ b/base/common/src/com/netscape/cms/servlet/cert/EnrollmentProcessor.java @@ -38,7 +38,7 @@ import com.netscape.certsrv.request.IRequest; import com.netscape.cms.servlet.common.CMSRequest; import com.netscape.cms.servlet.profile.SSLClientCertProvider; import com.netscape.cms.servlet.profile.model.ProfileInput; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; import com.netscape.cms.servlet.request.model.CertEnrollmentRequestFactory; public class EnrollmentProcessor extends CertProcessor { @@ -47,7 +47,7 @@ public class EnrollmentProcessor extends CertProcessor { super(id, locale); } - private void setInputsIntoContext(EnrollmentRequestData data, IProfile profile, IProfileContext ctx) { + private void setInputsIntoContext(CertEnrollmentRequest data, IProfile profile, IProfileContext ctx) { // put profile inputs into a local map HashMap dataInputs = new HashMap(); for (ProfileInput input : data.getInputs()) { @@ -97,7 +97,7 @@ public class EnrollmentProcessor extends CertProcessor { throw new BadRequestDataException(CMS.getUserMessage(locale, "CMS_PROFILE_NOT_FOUND", profileId)); } - EnrollmentRequestData data = CertEnrollmentRequestFactory.create(cmsReq, profile, locale); + CertEnrollmentRequest data = CertEnrollmentRequestFactory.create(cmsReq, profile, locale); return processEnrollment(data, cmsReq.getHttpReq()); } @@ -118,7 +118,7 @@ public class EnrollmentProcessor extends CertProcessor { * @param cmsReq the object holding the request and response information * @exception EBaseException an error has occurred */ - public HashMap processEnrollment(EnrollmentRequestData data, HttpServletRequest request) + public HashMap processEnrollment(CertEnrollmentRequest data, HttpServletRequest request) throws EBaseException { try { diff --git a/base/common/src/com/netscape/cms/servlet/cert/RenewalProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/RenewalProcessor.java index 3e6c77fbf..3714d9807 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/RenewalProcessor.java +++ b/base/common/src/com/netscape/cms/servlet/cert/RenewalProcessor.java @@ -44,7 +44,7 @@ import com.netscape.certsrv.profile.IProfileInput; import com.netscape.certsrv.request.IRequest; import com.netscape.cms.servlet.common.CMSRequest; import com.netscape.cms.servlet.profile.SSLClientCertProvider; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; import com.netscape.cms.servlet.request.model.CertEnrollmentRequestFactory; public class RenewalProcessor extends CertProcessor { @@ -61,7 +61,7 @@ public class RenewalProcessor extends CertProcessor { throw new BadRequestDataException(CMS.getUserMessage(locale, "CMS_PROFILE_NOT_FOUND", profileId)); } - EnrollmentRequestData data = CertEnrollmentRequestFactory.create(cmsReq, profile, locale); + CertEnrollmentRequest data = CertEnrollmentRequestFactory.create(cmsReq, profile, locale); //only used in renewal data.setSerialNum(req.getParameter("serial_num")); @@ -78,7 +78,7 @@ public class RenewalProcessor extends CertProcessor { * Things to note: * * the renew request will contain the original profile instead of the new */ - public HashMap processRenewal(EnrollmentRequestData data, HttpServletRequest request) + public HashMap processRenewal(CertEnrollmentRequest data, HttpServletRequest request) throws EBaseException { try { if (CMS.debugOn()) { diff --git a/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java index 8822be2b2..2b26773f6 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java +++ b/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java @@ -57,7 +57,7 @@ import com.netscape.cms.servlet.profile.model.ProfileAttribute; import com.netscape.cms.servlet.profile.model.ProfileOutput; import com.netscape.cms.servlet.profile.model.ProfileOutputFactory; import com.netscape.cms.servlet.profile.model.ProfilePolicySet; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertReviewResponseFactory; public class RequestProcessor extends CertProcessor { @@ -66,19 +66,19 @@ public class RequestProcessor extends CertProcessor { super(id, locale); } - public AgentEnrollmentRequestData processRequest(CMSRequest cmsReq, IRequest request, String op) throws EBaseException { + public CertReviewResponse processRequest(CMSRequest cmsReq, IRequest request, String op) throws EBaseException { HttpServletRequest req = cmsReq.getHttpReq(); IRequest ireq = cmsReq.getIRequest(); String profileId = ireq.getExtDataInString("profileId"); IProfile profile = ps.getProfile(profileId); - AgentEnrollmentRequestData data = CertReviewResponseFactory.create(cmsReq, profile, nonces, locale); + CertReviewResponse data = CertReviewResponseFactory.create(cmsReq, profile, nonces, locale); processRequest(req, data, request, op); return data; } - public void processRequest(HttpServletRequest request, AgentEnrollmentRequestData data, IRequest req, String op) + public void processRequest(HttpServletRequest request, CertReviewResponse data, IRequest req, String op) throws EBaseException { try { startTiming("approval"); @@ -355,7 +355,7 @@ public class RequestProcessor extends CertProcessor { * @exception EProfileException an error related to this profile has * occurred */ - private void approveRequest(IRequest req, AgentEnrollmentRequestData data, IProfile profile, Locale locale) + private void approveRequest(IRequest req, CertReviewResponse data, IProfile profile, Locale locale) throws EProfileException { String auditMessage = null; String auditSubjectID = auditSubjectID(); @@ -404,7 +404,7 @@ public class RequestProcessor extends CertProcessor { } } - private void updateValues(AgentEnrollmentRequestData data, IRequest req, + private void updateValues(CertReviewResponse data, IRequest req, IProfile profile, Locale locale) throws ERejectException, EDeferException, EPropertyException { @@ -443,7 +443,7 @@ public class RequestProcessor extends CertProcessor { } - private void updateNotes(AgentEnrollmentRequestData data, IRequest req) { + private void updateNotes(CertReviewResponse data, IRequest req) { String notes = data.getRequestNotes(); if (notes != null) { diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertData.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertData.java new file mode 100644 index 000000000..50fcf81da --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertData.java @@ -0,0 +1,283 @@ +// --- 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.cert.model; + +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import org.jboss.resteasy.plugins.providers.atom.Link; + +import com.netscape.certsrv.dbs.certdb.CertId; +import com.netscape.certsrv.dbs.certdb.CertIdAdapter; + +/** + * @author alee + * + */ +@XmlRootElement(name = "CertData") +public class CertData { + + public static Marshaller marshaller; + public static Unmarshaller unmarshaller; + + static { + try { + marshaller = JAXBContext.newInstance(CertData.class).createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + unmarshaller = JAXBContext.newInstance(CertData.class).createUnmarshaller(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + CertId serialNumber; + String issuerDN; + String subjectDN; + String prettyPrint; + String encoded; + String pkcs7CertChain; + String notBefore; + String notAfter; + String status; + + Link link; + + @XmlAttribute(name="id") + @XmlJavaTypeAdapter(CertIdAdapter.class) + public CertId getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(CertId serialNumber) { + this.serialNumber = serialNumber; + } + + @XmlElement(name="IssuerDN") + public String getIssuerDN() { + return issuerDN; + } + + public void setIssuerDN(String issuerDN) { + this.issuerDN = issuerDN; + } + + @XmlElement(name="SubjectDN") + public String getSubjectDN() { + return subjectDN; + } + + public void setSubjectDN(String subjectDN) { + this.subjectDN = subjectDN; + } + + @XmlElement(name="PrettyPrint") + public String getPrettyPrint() { + return prettyPrint; + } + + public void setPrettyPrint(String prettyPrint) { + this.prettyPrint = prettyPrint; + } + + @XmlElement(name="Encoded") + public String getEncoded() { + return encoded; + } + + public void setEncoded(String encoded) { + this.encoded = encoded; + } + + @XmlElement(name="PKCS7CertChain") + public void setPkcs7CertChain(String chain) { + this.pkcs7CertChain = chain; + } + + public String getPkcs7CertChain() { + return pkcs7CertChain; + } + + @XmlElement(name="NotBefore") + public String getNotBefore() { + return notBefore; + } + + public void setNotBefore(String notBefore) { + this.notBefore = notBefore; + } + + @XmlElement(name="NotAfter") + public String getNotAfter() { + return notAfter; + } + + public void setNotAfter(String notAfter) { + this.notAfter = notAfter; + } + + @XmlElement(name="Status") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @XmlElement(name="Link") + public Link getLink() { + return link; + } + + public void setLink(Link link) { + this.link = link; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((encoded == null) ? 0 : encoded.hashCode()); + result = prime * result + ((issuerDN == null) ? 0 : issuerDN.hashCode()); + result = prime * result + ((notAfter == null) ? 0 : notAfter.hashCode()); + result = prime * result + ((notBefore == null) ? 0 : notBefore.hashCode()); + result = prime * result + ((pkcs7CertChain == null) ? 0 : pkcs7CertChain.hashCode()); + result = prime * result + ((prettyPrint == null) ? 0 : prettyPrint.hashCode()); + result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((subjectDN == null) ? 0 : subjectDN.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CertData other = (CertData) obj; + if (encoded == null) { + if (other.encoded != null) + return false; + } else if (!encoded.equals(other.encoded)) + return false; + if (issuerDN == null) { + if (other.issuerDN != null) + return false; + } else if (!issuerDN.equals(other.issuerDN)) + return false; + if (notAfter == null) { + if (other.notAfter != null) + return false; + } else if (!notAfter.equals(other.notAfter)) + return false; + if (notBefore == null) { + if (other.notBefore != null) + return false; + } else if (!notBefore.equals(other.notBefore)) + return false; + if (pkcs7CertChain == null) { + if (other.pkcs7CertChain != null) + return false; + } else if (!pkcs7CertChain.equals(other.pkcs7CertChain)) + return false; + if (prettyPrint == null) { + if (other.prettyPrint != null) + return false; + } else if (!prettyPrint.equals(other.prettyPrint)) + return false; + if (serialNumber == null) { + if (other.serialNumber != null) + return false; + } else if (!serialNumber.equals(other.serialNumber)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (subjectDN == null) { + if (other.subjectDN != null) + return false; + } else if (!subjectDN.equals(other.subjectDN)) + return false; + return true; + } + + public String toString() { + try { + StringWriter sw = new StringWriter(); + marshaller.marshal(this, sw); + return sw.toString(); + + } catch (Exception e) { + return super.toString(); + } + } + + public static CertData valueOf(String string) throws Exception { + try { + return (CertData)unmarshaller.unmarshal(new StringReader(string)); + } catch (Exception e) { + return null; + } + } + + public static void main(String args[]) throws Exception { + + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw, true); + + out.println("-----BEGIN CERTIFICATE-----"); + out.println("MIIB/zCCAWgCCQCtpWH58pqsejANBgkqhkiG9w0BAQUFADBEMRQwEgYDVQQKDAtF"); + out.println("WEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYDVQQDDAlU"); + out.println("ZXN0IFVzZXIwHhcNMTIwNTE0MTcxNzI3WhcNMTMwNTE0MTcxNzI3WjBEMRQwEgYD"); + out.println("VQQKDAtFWEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYD"); + out.println("VQQDDAlUZXN0IFVzZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKmmiPJp"); + out.println("Agh/gPUAZjfgJ3a8QiHvpMzZ/hZy1FVP3+2sNhCkMv+D/I8Y7AsrbJGxxvD7bTDm"); + out.println("zQYtYx2ryGyOgY7KBRxEj/IrNVHIkJMYq5G/aIU4FAzpc6ntNSwUQBYUAamfK8U6"); + out.println("Wo4Cp6rLePXIDE6sfGn3VX6IeSJ8U2V+vwtzAgMBAAEwDQYJKoZIhvcNAQEFBQAD"); + out.println("gYEAY9bjcD/7Z+oX6gsJtX6Rd79E7X5IBdOdArYzHNE4vjdaQrZw6oCxrY8ffpKC"); + out.println("0T0q5PX9I7er+hx/sQjGPMrJDEN+vFBSNrZE7sTeLRgkyiqGvChSyuG05GtGzXO4"); + out.println("bFBr+Gwk2VF2wJvOhTXU2hN8sfkkd9clzIXuL8WCDhWk1bY="); + out.println("-----END CERTIFICATE-----"); + + CertData before = new CertData(); + before.setSerialNumber(new CertId("12512514865863765114")); + before.setIssuerDN("CN=Test User,UID=testuser,O=EXAMPLE-COM"); + before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM"); + before.setEncoded(sw.toString()); + + String string = before.toString(); + System.out.println(string); + + CertData after = CertData.valueOf(string); + System.out.println(before.equals(after)); + } +} diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchData.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchData.java deleted file mode 100644 index 44092ac16..000000000 --- a/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchData.java +++ /dev/null @@ -1,862 +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) 2011 Red Hat, Inc. -//All rights reserved. -//--- END COPYRIGHT BLOCK --- - -// TODO: This class is brute force. Come up with a way to divide these search filter entities into -// smaller classes -package com.netscape.cms.servlet.cert.model; - -import java.io.Reader; -import java.util.Calendar; -import java.util.StringTokenizer; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.netscape.cmsutil.ldap.LDAPUtil; - -/** - * @author jmagne - * - */ -@XmlRootElement(name = "CertSearchData") -@XmlAccessorType(XmlAccessType.FIELD) -public class CertSearchData { - - private final static String MATCH_EXACTLY = "exact"; - //Serial Number - @XmlElement - protected boolean serialNumberRangeInUse; - - @XmlElement - protected String serialTo; - - @XmlElement - protected String serialFrom; - - //Subject Name - @XmlElement - protected boolean subjectInUse; - - @XmlElement - protected String eMail; - - @XmlElement - protected String commonName; - - @XmlElement - protected String userID; - - @XmlElement - protected String orgUnit; - - @XmlElement - protected String org; - - @XmlElement - protected String locality; - - @XmlElement - protected String state; - - @XmlElement - protected String country; - - @XmlElement - protected boolean matchExactly; - - //Revoked By - - @XmlElement - protected String revokedBy; - - //Revoked On - - @XmlElement - protected String revokedOnFrom; - - @XmlElement - protected String revokedOnTo; - - //Revocation Reason - - @XmlElement - protected String revocationReason; - - //Issued By - - @XmlElement - protected String issuedBy; - - //Issued On - - @XmlElement - protected String issuedOnFrom; - - @XmlElement - protected String issuedOnTo; - - //Valid Not Before - - @XmlElement - protected String validNotBeforeFrom; - - @XmlElement - protected String validNotBeforeTo; - - //Valid Not After - - @XmlElement - protected String validNotAfterFrom; - - @XmlElement - protected String validNotAfterTo; - - //Validity Length - - @XmlElement - protected String validityOperation; - - @XmlElement - protected String validityCount; - - @XmlElement - protected String validityUnit; - - // Cert Type - - @XmlElement - protected String certTypeSubEmailCA; - - @XmlElement - protected String certTypeSubSSLCA; - - @XmlElement - protected String certTypeSecureEmail; - - @XmlElement - protected String certTypeSSLClient; - - @XmlElement - protected String certTypeSSLServer; - - //Revoked By - @XmlElement - protected boolean revokedByInUse; - - //Revoked On - @XmlElement - protected boolean revokedOnInUse; - - @XmlElement - protected boolean revocationReasonInUse; - - @XmlElement - protected boolean issuedByInUse; - - @XmlElement - protected boolean issuedOnInUse; - - @XmlElement - protected boolean validNotBeforeInUse; - - @XmlElement - protected boolean validNotAfterInUse; - - @XmlElement - protected boolean validityLengthInUse; - - @XmlElement - protected boolean certTypeInUse; - - //Boolean values - public boolean getSerialNumberRangeInUse() { - return serialNumberRangeInUse; - } - - public void setSerialNumberRangeInUse(boolean serialNumberRangeInUse) { - this.serialNumberRangeInUse = serialNumberRangeInUse; - } - - public boolean getSubjectInUse() { - return subjectInUse; - } - - public void setSubjectInUse(boolean subjectInUse) { - this.subjectInUse = subjectInUse; - } - - public boolean getRevokedByInUse() { - return revokedByInUse; - } - - public void setRevokedByInUse(boolean revokedByInUse) { - this.revokedByInUse = revokedByInUse; - } - - public boolean getRevokedOnInUse() { - return revokedOnInUse; - } - - public void setRevokedOnInUse(boolean revokedOnInUse) { - this.revokedOnInUse = revokedOnInUse; - } - - public void setRevocationReasonInUse(boolean revocationReasonInUse) { - this.revocationReasonInUse = revocationReasonInUse; - } - - public boolean getRevocationReasonInUse() { - return revocationReasonInUse; - } - - public void setIssuedByInUse(boolean issuedByInUse) { - this.issuedByInUse = issuedByInUse; - } - - public boolean getIssuedByInUse() { - return issuedByInUse; - } - - public void setIssuedOnInUse(boolean issuedOnInUse) { - this.issuedOnInUse = issuedOnInUse; - } - - public boolean getIssuedOnInUse() { - return issuedOnInUse; - } - - public void setValidNotBeforeInUse(boolean validNotBeforeInUse) { - this.validNotBeforeInUse = validNotBeforeInUse; - } - - public boolean getValidNotBeforeInUse() { - return validNotBeforeInUse; - } - - public void setValidNotAfterInUse(boolean validNotAfterInUse) { - this.validNotAfterInUse = validNotAfterInUse; - } - - public boolean getValidNotAfterInUse() { - return validNotAfterInUse; - } - - public void setValidityLengthInUse(boolean validityLengthInUse) { - this.validityLengthInUse = validityLengthInUse; - } - - public boolean getValidityLengthInUse() { - return validityLengthInUse; - } - - public void setCertTypeInUse(boolean certTypeInUse) { - this.certTypeInUse = certTypeInUse; - } - - public boolean getCertTypeInUse() { - return certTypeInUse; - } - - //Actual Values - - public String getSerialTo() { - return serialTo; - } - - public void setSerialTo(String serialTo) { - this.serialTo = serialTo; - } - - public String getSerialFrom() { - return serialFrom; - } - - public void setSerialFrom(String serialFrom) { - this.serialFrom = serialFrom; - } - - //Subject Name - - public String getEmail() { - return eMail; - } - - public void setEmail(String email) { - this.eMail = email; - } - - public String getCommonName() { - return commonName; - } - - public void setCommonName(String commonName) { - this.commonName = commonName; - } - - public String getUserID() { - return userID; - } - - public void setUserID(String userID) { - this.userID = userID; - } - - public String getOrgUnit() { - return orgUnit; - } - - public void setOrgUnit(String orgUnit) { - this.orgUnit = orgUnit; - } - - public String getOrg() { - return org; - } - - public void setOrg(String org) { - this.org = org; - } - - public String getLocality() { - return locality; - } - - public void setLocality(String locality) { - this.locality = locality; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public boolean getMatchExactly() { - return matchExactly; - } - - public void setMatchExactly(boolean matchExactly) { - this.matchExactly = matchExactly; - } - - //Revoked On - - public String getRevokedOnTo() { - return revokedOnTo; - } - - public void setRevokedOnTo(String revokedOnTo) { - this.revokedOnTo = revokedOnTo; - } - - public String getRevokedOnFrom() { - return revokedOnFrom; - } - - public void setRevokedOnFrom(String revokedOnFrom) { - this.revokedOnFrom = revokedOnFrom; - } - - //Revoked By - - public String getRevokedBy() { - return revokedBy; - } - - public void setRevokedBy(String revokedBy) { - this.revokedBy = revokedBy; - } - - //Revocation Reason - - public String getRevocationReason() { - return revocationReason; - } - - public void setRevocationReason(String revocationReason) { - this.revocationReason = revocationReason; - } - - //Issued By - - public String getIssuedBy() { - return issuedBy; - } - - public void setIssuedBy(String issuedBy) { - this.issuedBy = issuedBy; - } - - //Issued On - - public String getIssuedOnFrom() { - return issuedOnFrom; - } - - public void setIssuedOnFrom(String issuedOnFrom) { - this.issuedOnFrom = issuedOnFrom; - } - - public String getIssuedOnTo() { - return getIssuedOnTo(); - } - - //Valid Not After - - public String getValidNotAfterFrom() { - return validNotAfterFrom; - } - - public void setValidNotAfterFrom(String validNotAfterFrom) { - this.validNotAfterFrom = validNotAfterFrom; - } - - public String getValidNotAfterTo() { - return validNotAfterTo; - } - - public void setValidNotAfterTo(String validNotAfterTo) { - this.validNotAfterTo = validNotAfterTo; - } - - //Valid Not Before - - public String getValidNotBeforeFrom() { - return validNotBeforeFrom; - } - - public void setValidNotBeforeFrom(String validNotBeforeFrom) { - this.validNotBeforeFrom = validNotBeforeFrom; - } - - public String getValidNotBeforeTo() { - return validNotBeforeTo; - } - - public void setValidNotBeforeTo(String validNotBeforeTo) { - this.validNotBeforeTo = validNotBeforeTo; - } - - //Validity Length - - public String getValidityOperation() { - return validityOperation; - } - - public void setValidityOperation(String validityOperation) { - this.validityOperation = validityOperation; - } - - public String getValidityUnit() { - return validityUnit; - } - - public void setValidityUnit(String validityUnit) { - this.validityUnit = validityUnit; - } - - public String getValidityCount() { - return validityCount; - } - - public void setValidityCount(String validityCount) { - this.validityCount = validityCount; - } - - //Cert Type - - public String getCertTypeSubEmailCA() { - return certTypeSubEmailCA; - } - - public void setCertTypeSubEmailCA(String certTypeSubEmailCA) { - this.certTypeSubEmailCA = certTypeSubEmailCA; - } - - public String getCertTypeSubSSLCA() { - return certTypeSubSSLCA; - } - - public void setCertTypeSubSSLCA(String certTypeSubSSLCA) { - this.certTypeSubSSLCA = certTypeSubSSLCA; - } - - public String getCertTypeSecureEmail() { - return certTypeSecureEmail; - } - - public void setCertTypeSecureEmail(String certTypeSecureEmail) { - this.certTypeSecureEmail = certTypeSecureEmail; - } - - public String getCertTypeSSLClient() { - return certTypeSSLClient; - } - - public void setCertTypeSSLClient(String SSLClient) { - this.certTypeSSLClient = SSLClient; - } - - public String getCertTypeSSLServer() { - return certTypeSSLServer; - } - - public void setCertTypeSSLServer(String SSLServer) { - this.certTypeSSLServer = SSLServer; - } - - public CertSearchData() { - // required for JAXB (defaults) - } - - public void buildFromServletRequest(HttpServletRequest req) { - //Set values from the servlet request - if (req == null) { - return; - } - } - - public CertSearchData(MultivaluedMap form) { - } - - public String buildFilter() { - StringBuffer filter = new StringBuffer(); - buildSerialNumberRangeFilter(filter); - buildSubjectFilter(filter); - buildRevokedByFilter(filter); - buildRevokedOnFilter(filter); - buildRevocationReasonFilter(filter); - buildIssuedByFilter(filter); - buildIssuedOnFilter(filter); - buildValidNotBeforeFilter(filter); - buildValidNotAfterFilter(filter); - buildValidityLengthFilter(filter); - buildCertTypeFilter(filter); - - searchFilter = filter.toString(); - - if (searchFilter != null && !searchFilter.equals("")) { - searchFilter = "(&" + searchFilter + ")"; - } - - return searchFilter; - } - - private void buildSerialNumberRangeFilter(StringBuffer filter) { - - if (!getSerialNumberRangeInUse()) { - return; - } - boolean changed = false; - String serialFrom = getSerialFrom(); - if (serialFrom != null && !serialFrom.equals("")) { - filter.append("(certRecordId>=" + LDAPUtil.escapeFilter(serialFrom) + ")"); - changed = true; - } - String serialTo = getSerialTo(); - if (serialTo != null && !serialTo.equals("")) { - filter.append("(certRecordId<=" + LDAPUtil.escapeFilter(serialTo) + ")"); - changed = true; - } - if (!changed) { - filter.append("(certRecordId=*)"); - } - - } - - private void buildSubjectFilter(StringBuffer filter) { - if (!getSubjectInUse()) { - return; - } - StringBuffer lf = new StringBuffer(); - - String matchStr = null; - boolean match = getMatchExactly(); - - if (match == true) { - matchStr = MATCH_EXACTLY; - } - - buildAVAFilter(getEmail(), "E", lf, matchStr); - buildAVAFilter(getCommonName(), "CN", lf, matchStr); - buildAVAFilter(getUserID(), "UID", lf, matchStr); - buildAVAFilter(getOrgUnit(), "OU", lf, matchStr); - buildAVAFilter(getOrg(), "O", lf, matchStr); - buildAVAFilter(getLocality(), "L", lf, matchStr); - buildAVAFilter(getState(), "ST", lf, matchStr); - buildAVAFilter(getCountry(), "C", lf, matchStr); - - if (lf.length() == 0) { - filter.append("(x509cert.subject=*)"); - return; - } - if (matchStr != null && matchStr.equals(MATCH_EXACTLY)) { - filter.append("(&"); - filter.append(lf); - filter.append(")"); - } else { - filter.append("(|"); - filter.append(lf); - filter.append(")"); - } - } - - private void buildRevokedByFilter(StringBuffer filter) { - if (!getRevokedByInUse()) { - return; - } - - String revokedBy = getRevokedBy(); - if (revokedBy == null || revokedBy.equals("")) { - filter.append("(certRevokedBy=*)"); - } else { - filter.append("(certRevokedBy="); - filter.append(LDAPUtil.escapeFilter(revokedBy)); - filter.append(")"); - } - } - - private void buildDateFilter(String prefix, - String outStr, long adjustment, - StringBuffer filter) { - long epoch = 0; - try { - epoch = Long.parseLong(prefix); - } catch (NumberFormatException e) { - // exception safely ignored - } - Calendar from = Calendar.getInstance(); - from.setTimeInMillis(epoch); - filter.append("("); - filter.append(LDAPUtil.escapeFilter(outStr)); - filter.append(Long.toString(from.getTimeInMillis() + adjustment)); - filter.append(")"); - } - - private void buildRevokedOnFilter(StringBuffer filter) { - if (!getRevokedOnInUse()) { - return; - } - buildDateFilter(getRevokedOnFrom(), "certRevokedOn>=", 0, filter); - buildDateFilter(getRevokedOnTo(), "certRevokedOn<=", 86399999, filter); - } - - private void buildRevocationReasonFilter(StringBuffer filter) { - if (!getRevocationReasonInUse()) { - return; - } - String reasons = getRevocationReason(); - if (reasons == null) { - return; - } - String queryCertFilter = null; - StringTokenizer st = new StringTokenizer(reasons, ","); - if (st.hasMoreTokens()) { - filter.append("(|"); - while (st.hasMoreTokens()) { - String token = st.nextToken(); - if (queryCertFilter == null) { - queryCertFilter = ""; - } - filter.append("(x509cert.certRevoInfo="); - filter.append(LDAPUtil.escapeFilter(token)); - filter.append(")"); - } - filter.append(")"); - } - } - - private void buildIssuedByFilter(StringBuffer filter) { - if (!getIssuedByInUse()) { - return; - } - String issuedBy = getIssuedBy(); - ; - if (issuedBy == null || issuedBy.equals("")) { - filter.append("(certIssuedBy=*)"); - } else { - filter.append("(certIssuedBy="); - filter.append(LDAPUtil.escapeFilter(issuedBy)); - filter.append(")"); - } - } - - private void buildIssuedOnFilter(StringBuffer filter) { - if (!getIssuedOnInUse()) { - return; - } - buildDateFilter(getIssuedOnFrom(), "certCreateTime>=", 0, filter); - buildDateFilter(getIssuedOnTo(), "certCreateTime<=", 86399999, filter); - } - - private void buildValidNotBeforeFilter(StringBuffer filter) { - if (!getValidNotBeforeInUse()) { - return; - } - buildDateFilter(validNotBeforeFrom, "x509cert.notBefore>=", 0, filter); - buildDateFilter(validNotBeforeTo, "x509cert.notBefore<=", 86399999, filter); - - } - - private void buildValidNotAfterFilter(StringBuffer filter) { - if (!getValidNotAfterInUse()) { - return; - } - buildDateFilter(getValidNotAfterFrom(), "x509cert.notAfter>=", 0, filter); - buildDateFilter(getValidNotAfterTo(), "x509cert.notAfter<=", 86399999, filter); - - } - - private void buildValidityLengthFilter(StringBuffer filter) { - if (!getValidityLengthInUse()) { - return; - } - String op = getValidityOperation(); - long count = 0; - try { - count = Long.parseLong(getValidityCount()); - } catch (NumberFormatException e) { - // safely ignore - } - long unit = 0; - try { - unit = Long.parseLong(getValidityUnit()); - } catch (NumberFormatException e) { - // safely ignore - } - filter.append("("); - filter.append("x509cert.duration"); - filter.append(LDAPUtil.escapeFilter(op)); - filter.append(count * unit); - filter.append(")"); - } - - private void buildCertTypeFilter(StringBuffer filter) { - if (!getCertTypeInUse()) { - return; - } - if (isOn(getCertTypeSSLClient())) { - filter.append("(x509cert.nsExtension.SSLClient=on)"); - } else if (isOff(getCertTypeSSLClient())) { - filter.append("(x509cert.nsExtension.SSLClient=off)"); - } - if (isOn(getCertTypeSSLServer())) { - filter.append("(x509cert.nsExtension.SSLServer=on)"); - } else if (isOff(getCertTypeSSLServer())) { - filter.append("(x509cert.nsExtension.SSLServer=off)"); - } - if (isOn(getCertTypeSecureEmail())) { - filter.append("(x509cert.nsExtension.SecureEmail=on)"); - } else if (isOff(getCertTypeSecureEmail())) { - filter.append("(x509cert.nsExtension.SecureEmail=off)"); - } - if (isOn(getCertTypeSubSSLCA())) { - filter.append("(x509cert.nsExtension.SubordinateSSLCA=on)"); - } else if (isOff(getCertTypeSubSSLCA())) { - filter.append("(x509cert.nsExtension.SubordinateSSLCA=off)"); - } - if (isOn(getCertTypeSubEmailCA())) { - filter.append("(x509cert.nsExtension.SubordinateEmailCA=on)"); - } else if (isOff(getCertTypeSubEmailCA())) { - filter.append("(x509cert.nsExtension.SubordinateEmailCA=off)"); - } - } - - private boolean isOn(String value) { - String inUse = value; - if (inUse == null) { - return false; - } - if (inUse.equals("on")) { - return true; - } - return false; - } - - private boolean isOff(String value) { - String inUse = value; - if (inUse == null) { - return false; - } - if (inUse.equals("off")) { - return true; - } - return false; - } - - private void buildAVAFilter(String param, - String avaName, StringBuffer lf, String match) { - if (param != null && !param.equals("")) { - if (match != null && match.equals(MATCH_EXACTLY)) { - lf.append("(|"); - lf.append("(x509cert.subject=*"); - lf.append(avaName); - lf.append("="); - lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); - lf.append(",*)"); - lf.append("(x509cert.subject=*"); - lf.append(avaName); - lf.append("="); - lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); - lf.append(")"); - lf.append(")"); - } else { - lf.append("(x509cert.subject=*"); - lf.append(avaName); - lf.append("="); - lf.append("*"); - lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); - lf.append("*)"); - } - } - - } - - private String searchFilter = null; - - public String getSearchFilter() { - return searchFilter; - } - - public void setSearchFilter(String searchFilter) { - this.searchFilter = searchFilter; - } - - public static CertSearchData valueOf(Reader reader) throws JAXBException { - JAXBContext context = JAXBContext.newInstance(CertSearchData.class); - Unmarshaller unmarshaller = context.createUnmarshaller(); - return (CertSearchData) unmarshaller.unmarshal(reader); - } -} diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchRequest.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchRequest.java new file mode 100644 index 000000000..54b9ad8e6 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertSearchRequest.java @@ -0,0 +1,862 @@ +//--- 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) 2011 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- + +// TODO: This class is brute force. Come up with a way to divide these search filter entities into +// smaller classes +package com.netscape.cms.servlet.cert.model; + +import java.io.Reader; +import java.util.Calendar; +import java.util.StringTokenizer; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.netscape.cmsutil.ldap.LDAPUtil; + +/** + * @author jmagne + * + */ +@XmlRootElement(name = "CertSearchRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class CertSearchRequest { + + private final static String MATCH_EXACTLY = "exact"; + //Serial Number + @XmlElement + protected boolean serialNumberRangeInUse; + + @XmlElement + protected String serialTo; + + @XmlElement + protected String serialFrom; + + //Subject Name + @XmlElement + protected boolean subjectInUse; + + @XmlElement + protected String eMail; + + @XmlElement + protected String commonName; + + @XmlElement + protected String userID; + + @XmlElement + protected String orgUnit; + + @XmlElement + protected String org; + + @XmlElement + protected String locality; + + @XmlElement + protected String state; + + @XmlElement + protected String country; + + @XmlElement + protected boolean matchExactly; + + //Revoked By + + @XmlElement + protected String revokedBy; + + //Revoked On + + @XmlElement + protected String revokedOnFrom; + + @XmlElement + protected String revokedOnTo; + + //Revocation Reason + + @XmlElement + protected String revocationReason; + + //Issued By + + @XmlElement + protected String issuedBy; + + //Issued On + + @XmlElement + protected String issuedOnFrom; + + @XmlElement + protected String issuedOnTo; + + //Valid Not Before + + @XmlElement + protected String validNotBeforeFrom; + + @XmlElement + protected String validNotBeforeTo; + + //Valid Not After + + @XmlElement + protected String validNotAfterFrom; + + @XmlElement + protected String validNotAfterTo; + + //Validity Length + + @XmlElement + protected String validityOperation; + + @XmlElement + protected String validityCount; + + @XmlElement + protected String validityUnit; + + // Cert Type + + @XmlElement + protected String certTypeSubEmailCA; + + @XmlElement + protected String certTypeSubSSLCA; + + @XmlElement + protected String certTypeSecureEmail; + + @XmlElement + protected String certTypeSSLClient; + + @XmlElement + protected String certTypeSSLServer; + + //Revoked By + @XmlElement + protected boolean revokedByInUse; + + //Revoked On + @XmlElement + protected boolean revokedOnInUse; + + @XmlElement + protected boolean revocationReasonInUse; + + @XmlElement + protected boolean issuedByInUse; + + @XmlElement + protected boolean issuedOnInUse; + + @XmlElement + protected boolean validNotBeforeInUse; + + @XmlElement + protected boolean validNotAfterInUse; + + @XmlElement + protected boolean validityLengthInUse; + + @XmlElement + protected boolean certTypeInUse; + + //Boolean values + public boolean getSerialNumberRangeInUse() { + return serialNumberRangeInUse; + } + + public void setSerialNumberRangeInUse(boolean serialNumberRangeInUse) { + this.serialNumberRangeInUse = serialNumberRangeInUse; + } + + public boolean getSubjectInUse() { + return subjectInUse; + } + + public void setSubjectInUse(boolean subjectInUse) { + this.subjectInUse = subjectInUse; + } + + public boolean getRevokedByInUse() { + return revokedByInUse; + } + + public void setRevokedByInUse(boolean revokedByInUse) { + this.revokedByInUse = revokedByInUse; + } + + public boolean getRevokedOnInUse() { + return revokedOnInUse; + } + + public void setRevokedOnInUse(boolean revokedOnInUse) { + this.revokedOnInUse = revokedOnInUse; + } + + public void setRevocationReasonInUse(boolean revocationReasonInUse) { + this.revocationReasonInUse = revocationReasonInUse; + } + + public boolean getRevocationReasonInUse() { + return revocationReasonInUse; + } + + public void setIssuedByInUse(boolean issuedByInUse) { + this.issuedByInUse = issuedByInUse; + } + + public boolean getIssuedByInUse() { + return issuedByInUse; + } + + public void setIssuedOnInUse(boolean issuedOnInUse) { + this.issuedOnInUse = issuedOnInUse; + } + + public boolean getIssuedOnInUse() { + return issuedOnInUse; + } + + public void setValidNotBeforeInUse(boolean validNotBeforeInUse) { + this.validNotBeforeInUse = validNotBeforeInUse; + } + + public boolean getValidNotBeforeInUse() { + return validNotBeforeInUse; + } + + public void setValidNotAfterInUse(boolean validNotAfterInUse) { + this.validNotAfterInUse = validNotAfterInUse; + } + + public boolean getValidNotAfterInUse() { + return validNotAfterInUse; + } + + public void setValidityLengthInUse(boolean validityLengthInUse) { + this.validityLengthInUse = validityLengthInUse; + } + + public boolean getValidityLengthInUse() { + return validityLengthInUse; + } + + public void setCertTypeInUse(boolean certTypeInUse) { + this.certTypeInUse = certTypeInUse; + } + + public boolean getCertTypeInUse() { + return certTypeInUse; + } + + //Actual Values + + public String getSerialTo() { + return serialTo; + } + + public void setSerialTo(String serialTo) { + this.serialTo = serialTo; + } + + public String getSerialFrom() { + return serialFrom; + } + + public void setSerialFrom(String serialFrom) { + this.serialFrom = serialFrom; + } + + //Subject Name + + public String getEmail() { + return eMail; + } + + public void setEmail(String email) { + this.eMail = email; + } + + public String getCommonName() { + return commonName; + } + + public void setCommonName(String commonName) { + this.commonName = commonName; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + public String getOrgUnit() { + return orgUnit; + } + + public void setOrgUnit(String orgUnit) { + this.orgUnit = orgUnit; + } + + public String getOrg() { + return org; + } + + public void setOrg(String org) { + this.org = org; + } + + public String getLocality() { + return locality; + } + + public void setLocality(String locality) { + this.locality = locality; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public boolean getMatchExactly() { + return matchExactly; + } + + public void setMatchExactly(boolean matchExactly) { + this.matchExactly = matchExactly; + } + + //Revoked On + + public String getRevokedOnTo() { + return revokedOnTo; + } + + public void setRevokedOnTo(String revokedOnTo) { + this.revokedOnTo = revokedOnTo; + } + + public String getRevokedOnFrom() { + return revokedOnFrom; + } + + public void setRevokedOnFrom(String revokedOnFrom) { + this.revokedOnFrom = revokedOnFrom; + } + + //Revoked By + + public String getRevokedBy() { + return revokedBy; + } + + public void setRevokedBy(String revokedBy) { + this.revokedBy = revokedBy; + } + + //Revocation Reason + + public String getRevocationReason() { + return revocationReason; + } + + public void setRevocationReason(String revocationReason) { + this.revocationReason = revocationReason; + } + + //Issued By + + public String getIssuedBy() { + return issuedBy; + } + + public void setIssuedBy(String issuedBy) { + this.issuedBy = issuedBy; + } + + //Issued On + + public String getIssuedOnFrom() { + return issuedOnFrom; + } + + public void setIssuedOnFrom(String issuedOnFrom) { + this.issuedOnFrom = issuedOnFrom; + } + + public String getIssuedOnTo() { + return getIssuedOnTo(); + } + + //Valid Not After + + public String getValidNotAfterFrom() { + return validNotAfterFrom; + } + + public void setValidNotAfterFrom(String validNotAfterFrom) { + this.validNotAfterFrom = validNotAfterFrom; + } + + public String getValidNotAfterTo() { + return validNotAfterTo; + } + + public void setValidNotAfterTo(String validNotAfterTo) { + this.validNotAfterTo = validNotAfterTo; + } + + //Valid Not Before + + public String getValidNotBeforeFrom() { + return validNotBeforeFrom; + } + + public void setValidNotBeforeFrom(String validNotBeforeFrom) { + this.validNotBeforeFrom = validNotBeforeFrom; + } + + public String getValidNotBeforeTo() { + return validNotBeforeTo; + } + + public void setValidNotBeforeTo(String validNotBeforeTo) { + this.validNotBeforeTo = validNotBeforeTo; + } + + //Validity Length + + public String getValidityOperation() { + return validityOperation; + } + + public void setValidityOperation(String validityOperation) { + this.validityOperation = validityOperation; + } + + public String getValidityUnit() { + return validityUnit; + } + + public void setValidityUnit(String validityUnit) { + this.validityUnit = validityUnit; + } + + public String getValidityCount() { + return validityCount; + } + + public void setValidityCount(String validityCount) { + this.validityCount = validityCount; + } + + //Cert Type + + public String getCertTypeSubEmailCA() { + return certTypeSubEmailCA; + } + + public void setCertTypeSubEmailCA(String certTypeSubEmailCA) { + this.certTypeSubEmailCA = certTypeSubEmailCA; + } + + public String getCertTypeSubSSLCA() { + return certTypeSubSSLCA; + } + + public void setCertTypeSubSSLCA(String certTypeSubSSLCA) { + this.certTypeSubSSLCA = certTypeSubSSLCA; + } + + public String getCertTypeSecureEmail() { + return certTypeSecureEmail; + } + + public void setCertTypeSecureEmail(String certTypeSecureEmail) { + this.certTypeSecureEmail = certTypeSecureEmail; + } + + public String getCertTypeSSLClient() { + return certTypeSSLClient; + } + + public void setCertTypeSSLClient(String SSLClient) { + this.certTypeSSLClient = SSLClient; + } + + public String getCertTypeSSLServer() { + return certTypeSSLServer; + } + + public void setCertTypeSSLServer(String SSLServer) { + this.certTypeSSLServer = SSLServer; + } + + public CertSearchRequest() { + // required for JAXB (defaults) + } + + public void buildFromServletRequest(HttpServletRequest req) { + //Set values from the servlet request + if (req == null) { + return; + } + } + + public CertSearchRequest(MultivaluedMap form) { + } + + public String buildFilter() { + StringBuffer filter = new StringBuffer(); + buildSerialNumberRangeFilter(filter); + buildSubjectFilter(filter); + buildRevokedByFilter(filter); + buildRevokedOnFilter(filter); + buildRevocationReasonFilter(filter); + buildIssuedByFilter(filter); + buildIssuedOnFilter(filter); + buildValidNotBeforeFilter(filter); + buildValidNotAfterFilter(filter); + buildValidityLengthFilter(filter); + buildCertTypeFilter(filter); + + searchFilter = filter.toString(); + + if (searchFilter != null && !searchFilter.equals("")) { + searchFilter = "(&" + searchFilter + ")"; + } + + return searchFilter; + } + + private void buildSerialNumberRangeFilter(StringBuffer filter) { + + if (!getSerialNumberRangeInUse()) { + return; + } + boolean changed = false; + String serialFrom = getSerialFrom(); + if (serialFrom != null && !serialFrom.equals("")) { + filter.append("(certRecordId>=" + LDAPUtil.escapeFilter(serialFrom) + ")"); + changed = true; + } + String serialTo = getSerialTo(); + if (serialTo != null && !serialTo.equals("")) { + filter.append("(certRecordId<=" + LDAPUtil.escapeFilter(serialTo) + ")"); + changed = true; + } + if (!changed) { + filter.append("(certRecordId=*)"); + } + + } + + private void buildSubjectFilter(StringBuffer filter) { + if (!getSubjectInUse()) { + return; + } + StringBuffer lf = new StringBuffer(); + + String matchStr = null; + boolean match = getMatchExactly(); + + if (match == true) { + matchStr = MATCH_EXACTLY; + } + + buildAVAFilter(getEmail(), "E", lf, matchStr); + buildAVAFilter(getCommonName(), "CN", lf, matchStr); + buildAVAFilter(getUserID(), "UID", lf, matchStr); + buildAVAFilter(getOrgUnit(), "OU", lf, matchStr); + buildAVAFilter(getOrg(), "O", lf, matchStr); + buildAVAFilter(getLocality(), "L", lf, matchStr); + buildAVAFilter(getState(), "ST", lf, matchStr); + buildAVAFilter(getCountry(), "C", lf, matchStr); + + if (lf.length() == 0) { + filter.append("(x509cert.subject=*)"); + return; + } + if (matchStr != null && matchStr.equals(MATCH_EXACTLY)) { + filter.append("(&"); + filter.append(lf); + filter.append(")"); + } else { + filter.append("(|"); + filter.append(lf); + filter.append(")"); + } + } + + private void buildRevokedByFilter(StringBuffer filter) { + if (!getRevokedByInUse()) { + return; + } + + String revokedBy = getRevokedBy(); + if (revokedBy == null || revokedBy.equals("")) { + filter.append("(certRevokedBy=*)"); + } else { + filter.append("(certRevokedBy="); + filter.append(LDAPUtil.escapeFilter(revokedBy)); + filter.append(")"); + } + } + + private void buildDateFilter(String prefix, + String outStr, long adjustment, + StringBuffer filter) { + long epoch = 0; + try { + epoch = Long.parseLong(prefix); + } catch (NumberFormatException e) { + // exception safely ignored + } + Calendar from = Calendar.getInstance(); + from.setTimeInMillis(epoch); + filter.append("("); + filter.append(LDAPUtil.escapeFilter(outStr)); + filter.append(Long.toString(from.getTimeInMillis() + adjustment)); + filter.append(")"); + } + + private void buildRevokedOnFilter(StringBuffer filter) { + if (!getRevokedOnInUse()) { + return; + } + buildDateFilter(getRevokedOnFrom(), "certRevokedOn>=", 0, filter); + buildDateFilter(getRevokedOnTo(), "certRevokedOn<=", 86399999, filter); + } + + private void buildRevocationReasonFilter(StringBuffer filter) { + if (!getRevocationReasonInUse()) { + return; + } + String reasons = getRevocationReason(); + if (reasons == null) { + return; + } + String queryCertFilter = null; + StringTokenizer st = new StringTokenizer(reasons, ","); + if (st.hasMoreTokens()) { + filter.append("(|"); + while (st.hasMoreTokens()) { + String token = st.nextToken(); + if (queryCertFilter == null) { + queryCertFilter = ""; + } + filter.append("(x509cert.certRevoInfo="); + filter.append(LDAPUtil.escapeFilter(token)); + filter.append(")"); + } + filter.append(")"); + } + } + + private void buildIssuedByFilter(StringBuffer filter) { + if (!getIssuedByInUse()) { + return; + } + String issuedBy = getIssuedBy(); + ; + if (issuedBy == null || issuedBy.equals("")) { + filter.append("(certIssuedBy=*)"); + } else { + filter.append("(certIssuedBy="); + filter.append(LDAPUtil.escapeFilter(issuedBy)); + filter.append(")"); + } + } + + private void buildIssuedOnFilter(StringBuffer filter) { + if (!getIssuedOnInUse()) { + return; + } + buildDateFilter(getIssuedOnFrom(), "certCreateTime>=", 0, filter); + buildDateFilter(getIssuedOnTo(), "certCreateTime<=", 86399999, filter); + } + + private void buildValidNotBeforeFilter(StringBuffer filter) { + if (!getValidNotBeforeInUse()) { + return; + } + buildDateFilter(validNotBeforeFrom, "x509cert.notBefore>=", 0, filter); + buildDateFilter(validNotBeforeTo, "x509cert.notBefore<=", 86399999, filter); + + } + + private void buildValidNotAfterFilter(StringBuffer filter) { + if (!getValidNotAfterInUse()) { + return; + } + buildDateFilter(getValidNotAfterFrom(), "x509cert.notAfter>=", 0, filter); + buildDateFilter(getValidNotAfterTo(), "x509cert.notAfter<=", 86399999, filter); + + } + + private void buildValidityLengthFilter(StringBuffer filter) { + if (!getValidityLengthInUse()) { + return; + } + String op = getValidityOperation(); + long count = 0; + try { + count = Long.parseLong(getValidityCount()); + } catch (NumberFormatException e) { + // safely ignore + } + long unit = 0; + try { + unit = Long.parseLong(getValidityUnit()); + } catch (NumberFormatException e) { + // safely ignore + } + filter.append("("); + filter.append("x509cert.duration"); + filter.append(LDAPUtil.escapeFilter(op)); + filter.append(count * unit); + filter.append(")"); + } + + private void buildCertTypeFilter(StringBuffer filter) { + if (!getCertTypeInUse()) { + return; + } + if (isOn(getCertTypeSSLClient())) { + filter.append("(x509cert.nsExtension.SSLClient=on)"); + } else if (isOff(getCertTypeSSLClient())) { + filter.append("(x509cert.nsExtension.SSLClient=off)"); + } + if (isOn(getCertTypeSSLServer())) { + filter.append("(x509cert.nsExtension.SSLServer=on)"); + } else if (isOff(getCertTypeSSLServer())) { + filter.append("(x509cert.nsExtension.SSLServer=off)"); + } + if (isOn(getCertTypeSecureEmail())) { + filter.append("(x509cert.nsExtension.SecureEmail=on)"); + } else if (isOff(getCertTypeSecureEmail())) { + filter.append("(x509cert.nsExtension.SecureEmail=off)"); + } + if (isOn(getCertTypeSubSSLCA())) { + filter.append("(x509cert.nsExtension.SubordinateSSLCA=on)"); + } else if (isOff(getCertTypeSubSSLCA())) { + filter.append("(x509cert.nsExtension.SubordinateSSLCA=off)"); + } + if (isOn(getCertTypeSubEmailCA())) { + filter.append("(x509cert.nsExtension.SubordinateEmailCA=on)"); + } else if (isOff(getCertTypeSubEmailCA())) { + filter.append("(x509cert.nsExtension.SubordinateEmailCA=off)"); + } + } + + private boolean isOn(String value) { + String inUse = value; + if (inUse == null) { + return false; + } + if (inUse.equals("on")) { + return true; + } + return false; + } + + private boolean isOff(String value) { + String inUse = value; + if (inUse == null) { + return false; + } + if (inUse.equals("off")) { + return true; + } + return false; + } + + private void buildAVAFilter(String param, + String avaName, StringBuffer lf, String match) { + if (param != null && !param.equals("")) { + if (match != null && match.equals(MATCH_EXACTLY)) { + lf.append("(|"); + lf.append("(x509cert.subject=*"); + lf.append(avaName); + lf.append("="); + lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); + lf.append(",*)"); + lf.append("(x509cert.subject=*"); + lf.append(avaName); + lf.append("="); + lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); + lf.append(")"); + lf.append(")"); + } else { + lf.append("(x509cert.subject=*"); + lf.append(avaName); + lf.append("="); + lf.append("*"); + lf.append(LDAPUtil.escapeFilter(LDAPUtil.escapeDN(param, false))); + lf.append("*)"); + } + } + + } + + private String searchFilter = null; + + public String getSearchFilter() { + return searchFilter; + } + + public void setSearchFilter(String searchFilter) { + this.searchFilter = searchFilter; + } + + public static CertSearchRequest valueOf(Reader reader) throws JAXBException { + JAXBContext context = JAXBContext.newInstance(CertSearchRequest.class); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return (CertSearchRequest) unmarshaller.unmarshal(reader); + } +} diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java deleted file mode 100644 index bfdb894cb..000000000 --- a/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java +++ /dev/null @@ -1,283 +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.cert.model; - -import java.io.PrintWriter; -import java.io.StringReader; -import java.io.StringWriter; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import org.jboss.resteasy.plugins.providers.atom.Link; - -import com.netscape.certsrv.dbs.certdb.CertId; -import com.netscape.certsrv.dbs.certdb.CertIdAdapter; - -/** - * @author alee - * - */ -@XmlRootElement(name = "CertificateData") -public class CertificateData { - - public static Marshaller marshaller; - public static Unmarshaller unmarshaller; - - static { - try { - marshaller = JAXBContext.newInstance(CertificateData.class).createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - unmarshaller = JAXBContext.newInstance(CertificateData.class).createUnmarshaller(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - CertId serialNumber; - String issuerDN; - String subjectDN; - String prettyPrint; - String encoded; - String pkcs7CertChain; - String notBefore; - String notAfter; - String status; - - Link link; - - @XmlAttribute(name="id") - @XmlJavaTypeAdapter(CertIdAdapter.class) - public CertId getSerialNumber() { - return serialNumber; - } - - public void setSerialNumber(CertId serialNumber) { - this.serialNumber = serialNumber; - } - - @XmlElement(name="IssuerDN") - public String getIssuerDN() { - return issuerDN; - } - - public void setIssuerDN(String issuerDN) { - this.issuerDN = issuerDN; - } - - @XmlElement(name="SubjectDN") - public String getSubjectDN() { - return subjectDN; - } - - public void setSubjectDN(String subjectDN) { - this.subjectDN = subjectDN; - } - - @XmlElement(name="PrettyPrint") - public String getPrettyPrint() { - return prettyPrint; - } - - public void setPrettyPrint(String prettyPrint) { - this.prettyPrint = prettyPrint; - } - - @XmlElement(name="Encoded") - public String getEncoded() { - return encoded; - } - - public void setEncoded(String encoded) { - this.encoded = encoded; - } - - @XmlElement(name="PKCS7CertChain") - public void setPkcs7CertChain(String chain) { - this.pkcs7CertChain = chain; - } - - public String getPkcs7CertChain() { - return pkcs7CertChain; - } - - @XmlElement(name="NotBefore") - public String getNotBefore() { - return notBefore; - } - - public void setNotBefore(String notBefore) { - this.notBefore = notBefore; - } - - @XmlElement(name="NotAfter") - public String getNotAfter() { - return notAfter; - } - - public void setNotAfter(String notAfter) { - this.notAfter = notAfter; - } - - @XmlElement(name="Status") - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - @XmlElement(name="Link") - public Link getLink() { - return link; - } - - public void setLink(Link link) { - this.link = link; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((encoded == null) ? 0 : encoded.hashCode()); - result = prime * result + ((issuerDN == null) ? 0 : issuerDN.hashCode()); - result = prime * result + ((notAfter == null) ? 0 : notAfter.hashCode()); - result = prime * result + ((notBefore == null) ? 0 : notBefore.hashCode()); - result = prime * result + ((pkcs7CertChain == null) ? 0 : pkcs7CertChain.hashCode()); - result = prime * result + ((prettyPrint == null) ? 0 : prettyPrint.hashCode()); - result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((subjectDN == null) ? 0 : subjectDN.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CertificateData other = (CertificateData) obj; - if (encoded == null) { - if (other.encoded != null) - return false; - } else if (!encoded.equals(other.encoded)) - return false; - if (issuerDN == null) { - if (other.issuerDN != null) - return false; - } else if (!issuerDN.equals(other.issuerDN)) - return false; - if (notAfter == null) { - if (other.notAfter != null) - return false; - } else if (!notAfter.equals(other.notAfter)) - return false; - if (notBefore == null) { - if (other.notBefore != null) - return false; - } else if (!notBefore.equals(other.notBefore)) - return false; - if (pkcs7CertChain == null) { - if (other.pkcs7CertChain != null) - return false; - } else if (!pkcs7CertChain.equals(other.pkcs7CertChain)) - return false; - if (prettyPrint == null) { - if (other.prettyPrint != null) - return false; - } else if (!prettyPrint.equals(other.prettyPrint)) - return false; - if (serialNumber == null) { - if (other.serialNumber != null) - return false; - } else if (!serialNumber.equals(other.serialNumber)) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - if (subjectDN == null) { - if (other.subjectDN != null) - return false; - } else if (!subjectDN.equals(other.subjectDN)) - return false; - return true; - } - - public String toString() { - try { - StringWriter sw = new StringWriter(); - marshaller.marshal(this, sw); - return sw.toString(); - - } catch (Exception e) { - return super.toString(); - } - } - - public static CertificateData valueOf(String string) throws Exception { - try { - return (CertificateData)unmarshaller.unmarshal(new StringReader(string)); - } catch (Exception e) { - return null; - } - } - - public static void main(String args[]) throws Exception { - - StringWriter sw = new StringWriter(); - PrintWriter out = new PrintWriter(sw, true); - - out.println("-----BEGIN CERTIFICATE-----"); - out.println("MIIB/zCCAWgCCQCtpWH58pqsejANBgkqhkiG9w0BAQUFADBEMRQwEgYDVQQKDAtF"); - out.println("WEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYDVQQDDAlU"); - out.println("ZXN0IFVzZXIwHhcNMTIwNTE0MTcxNzI3WhcNMTMwNTE0MTcxNzI3WjBEMRQwEgYD"); - out.println("VQQKDAtFWEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYD"); - out.println("VQQDDAlUZXN0IFVzZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKmmiPJp"); - out.println("Agh/gPUAZjfgJ3a8QiHvpMzZ/hZy1FVP3+2sNhCkMv+D/I8Y7AsrbJGxxvD7bTDm"); - out.println("zQYtYx2ryGyOgY7KBRxEj/IrNVHIkJMYq5G/aIU4FAzpc6ntNSwUQBYUAamfK8U6"); - out.println("Wo4Cp6rLePXIDE6sfGn3VX6IeSJ8U2V+vwtzAgMBAAEwDQYJKoZIhvcNAQEFBQAD"); - out.println("gYEAY9bjcD/7Z+oX6gsJtX6Rd79E7X5IBdOdArYzHNE4vjdaQrZw6oCxrY8ffpKC"); - out.println("0T0q5PX9I7er+hx/sQjGPMrJDEN+vFBSNrZE7sTeLRgkyiqGvChSyuG05GtGzXO4"); - out.println("bFBr+Gwk2VF2wJvOhTXU2hN8sfkkd9clzIXuL8WCDhWk1bY="); - out.println("-----END CERTIFICATE-----"); - - CertificateData before = new CertificateData(); - before.setSerialNumber(new CertId("12512514865863765114")); - before.setIssuerDN("CN=Test User,UID=testuser,O=EXAMPLE-COM"); - before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM"); - before.setEncoded(sw.toString()); - - String string = before.toString(); - System.out.println(string); - - CertificateData after = CertificateData.valueOf(string); - System.out.println(before.equals(after)); - } -} 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; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/key/KeyResource.java b/base/common/src/com/netscape/cms/servlet/key/KeyResource.java index 4d352eaea..948f2ff99 100644 --- a/base/common/src/com/netscape/cms/servlet/key/KeyResource.java +++ b/base/common/src/com/netscape/cms/servlet/key/KeyResource.java @@ -12,7 +12,7 @@ import javax.ws.rs.core.MultivaluedMap; import com.netscape.cms.servlet.key.model.KeyData; import com.netscape.cms.servlet.key.model.KeyDataInfos; -import com.netscape.cms.servlet.request.model.RecoveryRequestData; +import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; @Path("agent/keys") public interface KeyResource { @@ -37,7 +37,7 @@ public interface KeyResource { @Path("retrieve") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public KeyData retrieveKey(RecoveryRequestData data); + public KeyData retrieveKey(KeyRecoveryRequest data); // retrieval - used to test integration with a browser @POST diff --git a/base/common/src/com/netscape/cms/servlet/key/KeyService.java b/base/common/src/com/netscape/cms/servlet/key/KeyService.java index 59847da1c..ffd0ef739 100644 --- a/base/common/src/com/netscape/cms/servlet/key/KeyService.java +++ b/base/common/src/com/netscape/cms/servlet/key/KeyService.java @@ -47,7 +47,7 @@ import com.netscape.cms.servlet.key.model.KeyDataInfo; import com.netscape.cms.servlet.key.model.KeyDataInfos; import com.netscape.cms.servlet.request.model.KeyRequestDAO; import com.netscape.cms.servlet.request.model.KeyRequestInfo; -import com.netscape.cms.servlet.request.model.RecoveryRequestData; +import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; import com.netscape.cmsutil.ldap.LDAPUtil; /** @@ -71,7 +71,7 @@ public class KeyService extends PKIService implements KeyResource{ * @param data * @return */ - public KeyData retrieveKey(RecoveryRequestData data) { + public KeyData retrieveKey(KeyRecoveryRequest data) { // auth and authz KeyId keyId = validateRequest(data); KeyData keyData; @@ -90,11 +90,11 @@ public class KeyService extends PKIService implements KeyResource{ // retrieval - used to test integration with a browser public KeyData retrieveKey(MultivaluedMap form) { - RecoveryRequestData data = new RecoveryRequestData(form); + KeyRecoveryRequest data = new KeyRecoveryRequest(form); return retrieveKey(data); } - public KeyData getKey(KeyId keyId, RecoveryRequestData data) throws EBaseException { + public KeyData getKey(KeyId keyId, KeyRecoveryRequest data) throws EBaseException { KeyData keyData; RequestId rId = data.getRequestId(); @@ -192,7 +192,7 @@ public class KeyService extends PKIService implements KeyResource{ return keyData; } - private KeyId validateRequest(RecoveryRequestData data) { + private KeyId validateRequest(KeyRecoveryRequest data) { // confirm request exists RequestId reqId = data.getRequestId(); diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java index 30a1a5852..e597f471e 100644 --- a/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileNotFoundException.java @@ -19,9 +19,9 @@ package com.netscape.cms.servlet.profile; import javax.ws.rs.core.Response; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; -public class ProfileNotFoundException extends CMSException { +public class ProfileNotFoundException extends PKIException { private static final long serialVersionUID = -4784839378360933483L; diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileProcessServlet.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileProcessServlet.java index 0f9f34144..56f754874 100644 --- a/base/common/src/com/netscape/cms/servlet/profile/ProfileProcessServlet.java +++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileProcessServlet.java @@ -43,7 +43,7 @@ import com.netscape.cms.servlet.cert.RequestProcessor; import com.netscape.cms.servlet.common.CMSRequest; import com.netscape.cms.servlet.profile.model.ProfileAttribute; import com.netscape.cms.servlet.profile.model.ProfileOutput; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; /** * This servlet approves profile-based request. @@ -103,7 +103,7 @@ public class ProfileProcessServlet extends ProfileServlet { // set request in cmsReq for later retrieval cmsReq.setIRequest(req); - AgentEnrollmentRequestData data = null; + CertReviewResponse data = null; try { data = processor.processRequest(cmsReq, req, op); } catch (EAuthException e) { diff --git a/base/common/src/com/netscape/cms/servlet/request/CertRequestResource.java b/base/common/src/com/netscape/cms/servlet/request/CertRequestResource.java index fc06e5e10..8a6d1b182 100644 --- a/base/common/src/com/netscape/cms/servlet/request/CertRequestResource.java +++ b/base/common/src/com/netscape/cms/servlet/request/CertRequestResource.java @@ -29,10 +29,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import com.netscape.certsrv.request.RequestId; -import com.netscape.cms.servlet.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; @Path("") public interface CertRequestResource { @@ -66,7 +66,7 @@ public interface CertRequestResource { @GET @Path("agent/certrequests/{id}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public AgentEnrollmentRequestData reviewRequest(@PathParam("id") RequestId id); + public CertReviewResponse reviewRequest(@PathParam("id") RequestId id); // Enrollment - used to test integration with a browser @POST @@ -79,40 +79,40 @@ public interface CertRequestResource { @Path("certrequests") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public CertRequestInfos enrollCert(EnrollmentRequestData data); + public CertRequestInfos enrollCert(CertEnrollmentRequest data); @POST @Path("agent/certrequests/{id}/approve") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void approveRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void approveRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/reject") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void rejectRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void rejectRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/cancel") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void cancelRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void cancelRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/update") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void updateRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void updateRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/validate") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void validateRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void validateRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/unassign") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void unassignRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void unassignRequest(@PathParam("id") RequestId id, CertReviewResponse data); @POST @Path("agent/certrequests/{id}/assign") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void assignRequest(@PathParam("id") RequestId id, AgentEnrollmentRequestData data); + public void assignRequest(@PathParam("id") RequestId id, CertReviewResponse data); } diff --git a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java index 9178d4c9e..e1aa56592 100644 --- a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java +++ b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java @@ -33,13 +33,13 @@ import com.netscape.certsrv.profile.ERejectException; import com.netscape.certsrv.property.EPropertyException; import com.netscape.certsrv.request.RequestId; import com.netscape.cms.servlet.base.BadRequestException; -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.request.model.AgentEnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertReviewResponse; import com.netscape.cms.servlet.request.model.CertRequestDAO; import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; -import com.netscape.cms.servlet.request.model.EnrollmentRequestData; +import com.netscape.cms.servlet.request.model.CertEnrollmentRequest; import com.netscape.cmsutil.ldap.LDAPUtil; /** @@ -61,7 +61,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc } catch (EBaseException e) { // log error e.printStackTrace(); - throw new CMSException("Error getting Cert request info!"); + throw new PKIException("Error getting Cert request info!"); } if (info == null) { @@ -74,11 +74,11 @@ public class CertRequestService extends PKIService implements CertRequestResourc // Enrollment - used to test integration with a browser public CertRequestInfos enrollCert(MultivaluedMap form) { - EnrollmentRequestData data = new EnrollmentRequestData(form); + CertEnrollmentRequest data = new CertEnrollmentRequest(form); return enrollCert(data); } - public CertRequestInfos enrollCert(EnrollmentRequestData data) { + public CertRequestInfos enrollCert(CertEnrollmentRequest data) { CertRequestInfos infos; if (data == null) { throw new BadRequestException("Bad data input into CertRequestResourceService.enrollCert!"); @@ -89,49 +89,49 @@ public class CertRequestService extends PKIService implements CertRequestResourc infos = dao.submitRequest(data, servletRequest, uriInfo, getLocale()); } catch (EAuthException e) { CMS.debug("enrollCert: authentication failed: " + e); - throw new CMSException(Response.Status.UNAUTHORIZED, e.toString()); + throw new PKIException(Response.Status.UNAUTHORIZED, e.toString()); } catch (EAuthzException e) { CMS.debug("enrollCert: authorization failed: " + e); - throw new CMSException(Response.Status.UNAUTHORIZED, e.toString()); + throw new PKIException(Response.Status.UNAUTHORIZED, e.toString()); } catch (BadRequestDataException e) { CMS.debug("enrollCert: bad request data: " + e); - throw new CMSException(Response.Status.BAD_REQUEST, e.toString()); + throw new PKIException(Response.Status.BAD_REQUEST, e.toString()); } catch (EBaseException e) { - throw new CMSException(e.toString()); + throw new PKIException(e.toString()); } return infos; } - public void approveRequest(RequestId id, AgentEnrollmentRequestData data) { + public void approveRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "approve"); } - public void rejectRequest(RequestId id, AgentEnrollmentRequestData data) { + public void rejectRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "reject"); } - public void cancelRequest(RequestId id, AgentEnrollmentRequestData data) { + public void cancelRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "cancel"); } - public void updateRequest(RequestId id, AgentEnrollmentRequestData data) { + public void updateRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "update"); } - public void validateRequest(RequestId id, AgentEnrollmentRequestData data) { + public void validateRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "validate"); } - public void unassignRequest(RequestId id, AgentEnrollmentRequestData data) { + public void unassignRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "unassign"); } - public void assignRequest(RequestId id, AgentEnrollmentRequestData data) { + public void assignRequest(RequestId id, CertReviewResponse data) { changeRequestState(id, data, "assign"); } - public void changeRequestState(RequestId id, AgentEnrollmentRequestData data, String op) { + public void changeRequestState(RequestId id, CertReviewResponse data, String op) { if (id == null) { throw new BadRequestException("Bad data input in CertRequestResourceService. op:" + op); } @@ -140,36 +140,36 @@ public class CertRequestService extends PKIService implements CertRequestResourc dao.changeRequestState(id, servletRequest, data, getLocale(), op); } catch (ERejectException e) { CMS.debug("changeRequestState: execution rejected " + e); - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, CMS.getUserMessage(getLocale(), "CMS_PROFILE_REJECTED", e.toString())); } catch (EDeferException e) { CMS.debug("changeRequestState: execution defered " + e); // TODO do we throw an exception here? - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, CMS.getUserMessage(getLocale(), "CMS_PROFILE_DEFERRED", e.toString())); } catch (BadRequestDataException e) { CMS.debug("changeRequestState: bad request data: " + e); - throw new CMSException(Response.Status.BAD_REQUEST, e.toString()); + throw new PKIException(Response.Status.BAD_REQUEST, e.toString()); } catch (EPropertyException e) { CMS.debug("changeRequestState: execution error " + e); - throw new CMSException(CMS.getUserMessage(getLocale(), + throw new PKIException(CMS.getUserMessage(getLocale(), "CMS_PROFILE_PROPERTY_ERROR", e.toString())); } catch (EProfileException e) { CMS.debug("ProfileProcessServlet: execution error " + e); - throw new CMSException(CMS.getUserMessage(getLocale(), "CMS_INTERNAL_ERROR")); + throw new PKIException(CMS.getUserMessage(getLocale(), "CMS_INTERNAL_ERROR")); } catch (EBaseException e) { e.printStackTrace(); - throw new CMSException("Problem approving request in CertRequestResource.assignRequest! " + e); + throw new PKIException("Problem approving request in CertRequestResource.assignRequest! " + e); } catch (RequestNotFoundException e) { CMS.debug(e); - throw new CMSException(Response.Status.BAD_REQUEST, + throw new PKIException(Response.Status.BAD_REQUEST, CMS.getUserMessage(getLocale(), "CMS_REQUEST_NOT_FOUND", id.toString())); } } - public AgentEnrollmentRequestData reviewRequest(@PathParam("id") RequestId id) { + public CertReviewResponse reviewRequest(@PathParam("id") RequestId id) { // auth and authz - AgentEnrollmentRequestData info; + CertReviewResponse info; CertRequestDAO dao = new CertRequestDAO(); try { @@ -177,7 +177,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc } catch (EBaseException e) { // log error e.printStackTrace(); - throw new CMSException("Error getting Cert request info!"); + throw new PKIException("Error getting Cert request info!"); } if (info == null) { @@ -211,7 +211,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc } catch (EBaseException e) { CMS.debug("listRequests: error in obtaining request results" + e); e.printStackTrace(); - throw new CMSException("Error listing cert requests!"); + throw new PKIException("Error listing cert requests!"); } return requests; } diff --git a/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java b/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java index 9ed2eb2a1..d583d9580 100644 --- a/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java +++ b/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java @@ -12,10 +12,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import com.netscape.certsrv.request.RequestId; -import com.netscape.cms.servlet.request.model.ArchivalRequestData; +import com.netscape.cms.servlet.request.model.KeyArchivalRequest; import com.netscape.cms.servlet.request.model.KeyRequestInfo; import com.netscape.cms.servlet.request.model.KeyRequestInfos; -import com.netscape.cms.servlet.request.model.RecoveryRequestData; +import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; @Path("agent/keyrequests") public interface KeyRequestResource { @@ -62,7 +62,7 @@ public interface KeyRequestResource { @Path("archive") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public KeyRequestInfo archiveKey(ArchivalRequestData data); + public KeyRequestInfo archiveKey(KeyArchivalRequest data); //Recovery - used to test integration with a browser @POST @@ -75,7 +75,7 @@ public interface KeyRequestResource { @Path("recover") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public KeyRequestInfo recoverKey(RecoveryRequestData data); + public KeyRequestInfo recoverKey(KeyRecoveryRequest data); @POST @Path("{id}/approve") diff --git a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java index ebe6062c8..e2afaf58c 100644 --- a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java +++ b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java @@ -25,13 +25,13 @@ import javax.ws.rs.core.Response; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.request.RequestId; -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.request.model.ArchivalRequestData; +import com.netscape.cms.servlet.request.model.KeyArchivalRequest; import com.netscape.cms.servlet.request.model.KeyRequestDAO; import com.netscape.cms.servlet.request.model.KeyRequestInfo; import com.netscape.cms.servlet.request.model.KeyRequestInfos; -import com.netscape.cms.servlet.request.model.RecoveryRequestData; +import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; import com.netscape.cmsutil.ldap.LDAPUtil; /** @@ -52,7 +52,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource } catch (EBaseException e) { // log error e.printStackTrace(); - throw new CMSException(e.getMessage(), e); + throw new PKIException(e.getMessage(), e); } if (info == null) { // request does not exist @@ -63,11 +63,11 @@ public class KeyRequestService extends PKIService implements KeyRequestResource // Archiving - used to test integration with a browser public KeyRequestInfo archiveKey(MultivaluedMap form) { - ArchivalRequestData data = new ArchivalRequestData(form); + KeyArchivalRequest data = new KeyArchivalRequest(form); return archiveKey(data); } - public KeyRequestInfo archiveKey(ArchivalRequestData data) { + public KeyRequestInfo archiveKey(KeyArchivalRequest data) { // auth and authz // Catch this before internal server processing has to deal with it @@ -91,11 +91,11 @@ public class KeyRequestService extends PKIService implements KeyRequestResource //Recovery - used to test integration with a browser public KeyRequestInfo recoverKey(MultivaluedMap form) { - RecoveryRequestData data = new RecoveryRequestData(form); + KeyRecoveryRequest data = new KeyRecoveryRequest(form); return recoverKey(data); } - public KeyRequestInfo recoverKey(RecoveryRequestData data) { + public KeyRequestInfo recoverKey(KeyRecoveryRequest data) { // auth and authz //Check for entirely illegal data combination here diff --git a/base/common/src/com/netscape/cms/servlet/request/RequestNotFoundException.java b/base/common/src/com/netscape/cms/servlet/request/RequestNotFoundException.java index 5d6b5563b..6bef885f9 100644 --- a/base/common/src/com/netscape/cms/servlet/request/RequestNotFoundException.java +++ b/base/common/src/com/netscape/cms/servlet/request/RequestNotFoundException.java @@ -3,9 +3,9 @@ package com.netscape.cms.servlet.request; import javax.ws.rs.core.Response; import com.netscape.certsrv.request.RequestId; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; -public class RequestNotFoundException extends CMSException { +public class RequestNotFoundException extends PKIException { private static final long serialVersionUID = -4784839378360933483L; diff --git a/base/common/src/com/netscape/cms/servlet/request/model/AgentEnrollmentRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/AgentEnrollmentRequestData.java deleted file mode 100644 index fb0874353..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/AgentEnrollmentRequestData.java +++ /dev/null @@ -1,252 +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.request.model; - -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.netscape.certsrv.request.RequestId; -import com.netscape.certsrv.request.RequestIdAdapter; -import com.netscape.cms.servlet.profile.model.PolicyDefault; -import com.netscape.cms.servlet.profile.model.ProfileAttribute; -import com.netscape.cms.servlet.profile.model.ProfilePolicy; -import com.netscape.cms.servlet.profile.model.ProfilePolicySet; - -@XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) -public class AgentEnrollmentRequestData extends EnrollmentRequestData { - - @XmlElement(name="ProfilePolicySet") - protected List policySets = new ArrayList(); - - protected String nonce; - - @XmlElement - @XmlJavaTypeAdapter(RequestIdAdapter.class) - protected RequestId requestId; - - protected String requestType; - - protected String requestStatus; - - protected String requestOwner; - - protected String requestCreationTime; - - protected String requestModificationTime; - - protected String requestNotes; - - protected String profileApprovedBy; - - protected String profileSetId; - - protected String profileIsVisible; - - protected String profileName; - - protected String profileDescription; - - protected String profileRemoteHost; - - protected String profileRemoteAddr; - - public String getNonce() { - return nonce; - } - - public void setNonce(String nonce) { - this.nonce = nonce; - } - - public RequestId getRequestId() { - return requestId; - } - - public void setRequestId(RequestId requestId) { - this.requestId = requestId; - } - - public String getRequestType() { - return requestType; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public String getRequestStatus() { - return requestStatus; - } - - public void setRequestStatus(String requestStatus) { - this.requestStatus = requestStatus; - } - - public String getRequestOwner() { - return requestOwner; - } - - public void setRequestOwner(String requestOwner) { - this.requestOwner = requestOwner; - } - - public String getRequestCreationTime() { - return requestCreationTime; - } - - public void setRequestCreationTime(String requestCreationTime) { - this.requestCreationTime = requestCreationTime; - } - - public String getRequestModificationTime() { - return requestModificationTime; - } - - public void setRequestModificationTime(String requestModificationTime) { - this.requestModificationTime = requestModificationTime; - } - - public String getRequestNotes() { - return requestNotes; - } - - public void setRequestNotes(String requestNotes) { - this.requestNotes = requestNotes; - } - - public String getProfileApprovedBy() { - return profileApprovedBy; - } - - public void setProfileApprovedBy(String profileApprovedBy) { - this.profileApprovedBy = profileApprovedBy; - } - - public String getProfileSetId() { - return profileSetId; - } - - public void setProfileSetId(String profileSetId) { - this.profileSetId = profileSetId; - } - - public String getProfileIsVisible() { - return profileIsVisible; - } - - public void setProfileIsVisible(String profileIsVisible) { - this.profileIsVisible = profileIsVisible; - } - - public String getProfileName() { - return profileName; - } - - public void setProfileName(String profileName) { - this.profileName = profileName; - } - - public String getProfileDescription() { - return profileDescription; - } - - public void setProfileDescription(String profileDescription) { - this.profileDescription = profileDescription; - } - - public String getProfileRemoteHost() { - return profileRemoteHost; - } - - public void setProfileRemoteHost(String profileRemoteHost) { - this.profileRemoteHost = profileRemoteHost; - } - - public String getProfileRemoteAddr() { - return profileRemoteAddr; - } - - public void setProfileRemoteAddr(String profileRemoteAddr) { - this.profileRemoteAddr = profileRemoteAddr; - } - - public String toString() { - try { - JAXBContext context = JAXBContext.newInstance(AgentEnrollmentRequestData.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - - marshaller.marshal(this, stream); - return stream.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public List getPolicySets() { - return policySets; - } - - public void setPolicySets(List policySets) { - this.policySets = policySets; - } - - public void addProfilePolicySet(ProfilePolicySet policySet) { - policySets.add(policySet); - } - - public void removeProfilePolicySet(ProfilePolicySet policySet) { - policySets.remove(policySet); - } - - @Override - public HashMap toParams() { - HashMap ret = super.toParams(); - - if (requestId != null) ret.put("requestId", requestId.toString()); - if (requestNotes != null) ret.put("requestNotes", requestNotes); - if (nonce != null) ret.put("nonces", nonce); - if (requestType != null) ret.put("requestType", requestType); - - for (ProfilePolicySet policySet: policySets) { - for (ProfilePolicy policy: policySet.getPolicies()) { - PolicyDefault def = policy.getDef(); - List attrs = def.getAttributes(); - for (ProfileAttribute attr: attrs) { - ret.put(attr.getName(), attr.getValue()); - } - } - } - return ret; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java deleted file mode 100644 index bcc51bf96..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java +++ /dev/null @@ -1,123 +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) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -/** - * - */ -package com.netscape.cms.servlet.request.model; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; - -/** - * @author alee - * - */ -@XmlRootElement(name="SecurityDataArchivalRequest") -@XmlAccessorType(XmlAccessType.FIELD) -public class ArchivalRequestData { - - private static final String CLIENT_ID = "clientID"; - private static final String TRANS_WRAPPED_SESSION_KEY = "transWrappedSessionKey"; - private static final String DATA_TYPE = "dataType"; - private static final String WRAPPED_PRIVATE_DATA = "wrappedPrivateData"; - - @XmlElement - protected String clientId; - - @XmlElement - protected String transWrappedSessionKey; - - @XmlElement - protected String dataType; - - @XmlElement - protected String wrappedPrivateData; - - public ArchivalRequestData() { - // required for JAXB (defaults) - } - - public ArchivalRequestData(MultivaluedMap form) { - clientId = form.getFirst(CLIENT_ID); - transWrappedSessionKey = form.getFirst(TRANS_WRAPPED_SESSION_KEY); - dataType = form.getFirst(DATA_TYPE); - wrappedPrivateData = form.getFirst(WRAPPED_PRIVATE_DATA); - } - - /** - * @return the clientId - */ - public String getClientId() { - return clientId; - } - - /** - * @param clientId the clientId to set - */ - public void setClientId(String clientId) { - this.clientId = clientId; - } - - /** - * @return the transWrappedSessionKey - */ - public String getTransWrappedSessionKey() { - return transWrappedSessionKey; - } - - /** - * @param transWrappedSessionKey the transWrappedSessionKey to set - */ - public void setTransWrappedSessionKey(String transWrappedSessionKey) { - this.transWrappedSessionKey = transWrappedSessionKey; - } - - /** - * @return the dataType - */ - public String getDataType() { - return dataType; - } - - /** - * @param dataType the dataType to set - */ - public void setDataType(String dataType) { - this.dataType = dataType; - } - - /** - * @return the wrappedPrivateData - */ - public String getWrappedPrivateData() { - return wrappedPrivateData; - } - - /** - * @param wrappedPrivateData the wrappedPrivateData to set - */ - public void setWrappedPrivateData(String wrappedPrivateData) { - this.wrappedPrivateData = wrappedPrivateData; - } - - -} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequest.java b/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequest.java new file mode 100644 index 000000000..a249d657d --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequest.java @@ -0,0 +1,321 @@ +// --- 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) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.request.model; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.netscape.cms.servlet.profile.model.ProfileInput; +import com.netscape.cms.servlet.profile.model.ProfileOutput; + +/** + * @author jmagne + * + */ + +@XmlRootElement(name = "CertEnrollmentRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class CertEnrollmentRequest { + + private static final String PROFILE_ID = "profileId"; + private static final String RENEWAL = "renewal"; + private static final String SERIAL_NUM = "serial_num"; + + @XmlElement + protected String profileId; + + @XmlElement + protected boolean isRenewal; + + @XmlElement + protected String serialNum; // used for one type of renewal + + @XmlElement + protected String remoteHost; + + @XmlElement + protected String remoteAddr; + + @XmlElement(name = "Input") + protected List inputs = new ArrayList(); + + @XmlElement(name = "Output") + protected List outputs = new ArrayList(); + + public CertEnrollmentRequest() { + // required for jaxb + } + + public CertEnrollmentRequest(MultivaluedMap form) { + profileId = form.getFirst(PROFILE_ID); + String renewalStr = form.getFirst(RENEWAL); + serialNum = form.getFirst(SERIAL_NUM); + isRenewal = new Boolean(renewalStr); + } + + /** + * @return the profileId + */ + public String getProfileId() { + return profileId; + } + + /** + * @param profileId the profileId to set + */ + + public void setProfileId(String profileId) { + this.profileId = profileId; + } + + /** + * @return renewal + */ + + public boolean getIsRenewal() { + return isRenewal; + } + + public void addInput(ProfileInput input) { + ProfileInput curInput = getInput(input.getInputId()); + if (curInput != null) { + getInputs().remove(curInput); + } + getInputs().add(input); + } + + public void deleteInput(ProfileInput input) { + ProfileInput curInput = getInput(input.getInputId()); + if (curInput != null) { + getInputs().remove(curInput); + } + } + + public ProfileInput createInput(String name) { + + ProfileInput oldInput = getInput(name); + + if (oldInput != null) + return oldInput; + + ProfileInput newInput = new ProfileInput(); + newInput.setInputId(name); + + getInputs().add(newInput); + + return newInput; + } + + public ProfileInput getInput(String name) { + + ProfileInput input = null; + + Iterator it = getInputs().iterator(); + + ProfileInput curInput = null; + while (it.hasNext()) { + curInput = it.next(); + if (curInput != null && curInput.getInputId().equals(name)) + break; + } + + return input; + } + + public void addOutput(ProfileOutput output) { + ProfileOutput curOutput = getOutput(output.getOutputId()); + if (curOutput != null) { + getOutputs().remove(curOutput); + } + getOutputs().add(output); + } + + public void deleteOutput(ProfileOutput output) { + ProfileOutput curOutput = getOutput(output.getOutputId()); + if (curOutput != null) { + getInputs().remove(curOutput); + } + } + + public ProfileOutput getOutput(String name) { + ProfileOutput output = null; + ProfileOutput curOutput = null; + + Iterator it = getOutputs().iterator(); + while (it.hasNext()) { + curOutput = it.next(); + if (curOutput != null && curOutput.getOutputId().equals(name)) + break; + } + + return output; + } + + /** + * @param renewal the renewal to set + */ + public void setIsRenewal(boolean isRenewal) { + this.isRenewal = isRenewal; + } + + public HashMap toParams() { + HashMap ret = new HashMap(); + ret.put("isRenewal", Boolean.valueOf(isRenewal).toString()); + if (profileId != null) ret.put(PROFILE_ID, profileId); + if (serialNum != null) ret.put(SERIAL_NUM, serialNum); + if (remoteHost != null) ret.put("remoteHost", remoteHost); + if (remoteAddr != null) ret.put("remoteAddr", remoteAddr); + + for (ProfileInput input: inputs) { + Map attrs = input.getAttributes(); + for (Map.Entry entry: attrs.entrySet()) { + ret.put(entry.getKey(), entry.getValue()); + } + } + + return ret; + } + + public static void main(String args[]) throws Exception { + CertEnrollmentRequest data = new CertEnrollmentRequest(); + data.setProfileId("caUserCert"); + data.setIsRenewal(false); + + //Simulate a "caUserCert" Profile enrollment + + ProfileInput certReq = data.createInput("KeyGenInput"); + certReq.setInputAttr("cert_request_type", "crmf"); + certReq.setInputAttr( + "cert_request", + "MIIBozCCAZ8wggEFAgQBMQp8MIHHgAECpQ4wDDEKMAgGA1UEAxMBeKaBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2NgaPHp0jiohcP4M+ufrJOZEqH8GV+liu5JLbT8nWpkfhC+8EUBqT6g+n3qroSxIcNVGNdcsBEqs1utvpItzyslAbpdyat3WwQep1dWMzo6RHrPDuIoxNA0Yka1n3qEX4U//08cLQtUv2bYglYgN/hOCNQemLV6vZWAv0n7zelkCAwEAAakQMA4GA1UdDwEB/wQEAwIF4DAzMBUGCSsGAQUFBwUBAQwIcmVnVG9rZW4wGgYJKwYBBQUHBQECDA1hdXRoZW50aWNhdG9yoYGTMA0GCSqGSIb3DQEBBQUAA4GBAJ1VOQcaSEhdHa94s8kifVbSZ2WZeYE5//qxL6wVlEst20vq4ybj13CetnbN3+WT49Zkwp7Fg+6lALKgSk47suTg3EbbQDm+8yOrC0nc/q4PTRoHl0alMmUxIhirYc1t3xoCMqJewmjX1bNP8lpVIZAYFZo4eZCpZaiSkM5BeHhz"); + + ProfileInput subjectName = data.createInput("SubjectNameInput"); + subjectName.setInputAttr("sn_uid", "jmagne"); + subjectName.setInputAttr("sn_e", "jmagne@redhat.com"); + subjectName.setInputAttr("sn_c", "US"); + subjectName.setInputAttr("sn_ou", "Development"); + subjectName.setInputAttr("sn_ou1", "IPA"); + subjectName.setInputAttr("sn_ou2", "Dogtag"); + subjectName.setInputAttr("sn_ou3", "CA"); + subjectName.setInputAttr("sn_cn", "Common"); + subjectName.setInputAttr("sn_o", "RedHat"); + + ProfileInput submitter = data.createInput("SubmitterInfoInput"); + submitter.setInputAttr("requestor_name", "admin"); + submitter.setInputAttr("requestor_email", "admin@redhat.com"); + submitter.setInputAttr("requestor_phone", "650-555-5555"); + + try { + JAXBContext context = JAXBContext.newInstance(CertEnrollmentRequest.class); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + marshaller.marshal(data, stream); + + System.out.println("Originally marshalled enrollment object. \n"); + + System.out.println(stream.toString()); + + //Try to unmarshall + + Unmarshaller unmarshaller = context.createUnmarshaller(); + + ByteArrayInputStream bais = new ByteArrayInputStream(stream.toByteArray()); + Object unmarshalled = unmarshaller.unmarshal(bais); + + //Try re-marshalling, unmarshalled object to compare + + stream.reset(); + + marshaller.marshal(unmarshalled, stream); + + System.out.println("Remarshalled unmarshalled enrollment object. \n"); + + System.out.println(stream.toString()); + + } catch (JAXBException e) { + System.out.println(e.toString()); + } + } + + public String getSerialNum() { + return serialNum; + } + + public void setSerialNum(String serialNum) { + this.serialNum = serialNum; + } + + public List getInputs() { + return inputs; + } + + public void setInputs(List inputs) { + this.inputs = inputs; + } + + public String getRemoteAddr() { + return remoteAddr; + } + + public void setRemoteAddr(String remoteAddr) { + this.remoteAddr = remoteAddr; + } + + public String getRemoteHost() { + return remoteHost; + } + + public void setRemoteHost(String remoteHost) { + this.remoteHost = remoteHost; + } + + public List getOutputs() { + return outputs; + } + + public void setOutputs(List outputs) { + this.outputs = outputs; + } + + public void setRenewal(boolean isRenewal) { + this.isRenewal = isRenewal; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequestFactory.java b/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequestFactory.java index 51582d13c..36c4adfca 100644 --- a/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequestFactory.java +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertEnrollmentRequestFactory.java @@ -30,11 +30,11 @@ import com.netscape.cms.servlet.profile.model.ProfileInputFactory; public class CertEnrollmentRequestFactory { - public static EnrollmentRequestData create(CMSRequest cmsReq, IProfile profile, Locale locale) + public static CertEnrollmentRequest create(CMSRequest cmsReq, IProfile profile, Locale locale) throws EProfileException { IArgBlock params = cmsReq.getHttpParams(); - EnrollmentRequestData ret = new EnrollmentRequestData(); + CertEnrollmentRequest ret = new CertEnrollmentRequest(); ret.setProfileId(profile.getId()); // populate profile inputs diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java index f662a6c89..3aacf1b88 100644 --- a/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java @@ -138,7 +138,7 @@ public class CertRequestDAO extends CMSRequestDAO { * @return info for specific request * @throws EBaseException */ - public AgentEnrollmentRequestData reviewRequest(HttpServletRequest servletRequest, RequestId id, + public CertReviewResponse reviewRequest(HttpServletRequest servletRequest, RequestId id, UriInfo uriInfo, Locale locale) throws EBaseException { IRequest request = queue.findRequest(id); if (request == null) { @@ -146,14 +146,14 @@ public class CertRequestDAO extends CMSRequestDAO { } String profileId = request.getExtDataInString("profileId"); IProfile profile = ps.getProfile(profileId); - AgentEnrollmentRequestData info = CertReviewResponseFactory.create(request, profile, uriInfo, locale); + CertReviewResponse info = CertReviewResponseFactory.create(request, profile, uriInfo, locale); if (ca.noncesEnabled()) { addNonce(info, servletRequest); } return info; } - private void addNonce(AgentEnrollmentRequestData info, HttpServletRequest servletRequest) throws EBaseException { + private void addNonce(CertReviewResponse info, HttpServletRequest servletRequest) throws EBaseException { if (nonces != null) { long n = random.nextLong(); long m = nonces.addNonce(n, Processor.getSSLClientCertificate(servletRequest)); @@ -171,7 +171,7 @@ public class CertRequestDAO extends CMSRequestDAO { * @throws EBaseException * @throws ServletException */ - public CertRequestInfos submitRequest(EnrollmentRequestData data, HttpServletRequest request, UriInfo uriInfo, + public CertRequestInfos submitRequest(CertEnrollmentRequest data, HttpServletRequest request, UriInfo uriInfo, Locale locale) throws EBaseException { HashMap results = null; if (data.getIsRenewal()) { @@ -196,7 +196,7 @@ public class CertRequestDAO extends CMSRequestDAO { return ret; } - public void changeRequestState(RequestId id, HttpServletRequest request, AgentEnrollmentRequestData data, + public void changeRequestState(RequestId id, HttpServletRequest request, CertReviewResponse data, Locale locale, String op) throws EBaseException { IRequest ireq = queue.findRequest(id); if (ireq == null) { diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequest.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequest.java new file mode 100644 index 000000000..9b8caacd9 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequest.java @@ -0,0 +1,78 @@ +// --- 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) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.request.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; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.netscape.certsrv.dbs.certdb.CertId; +import com.netscape.certsrv.dbs.certdb.CertIdAdapter; +import com.netscape.certsrv.request.RequestId; +import com.netscape.certsrv.request.RequestIdAdapter; + +/** + * @author alee + * + */ +@XmlRootElement(name = "CertRetrievalRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class CertRetrievalRequest { + + private static final String CERT_ID = "certId"; + + @XmlElement + @XmlJavaTypeAdapter(CertIdAdapter.class) + protected CertId certId; + + @XmlElement + @XmlJavaTypeAdapter(RequestIdAdapter.class) + protected RequestId requestId; + + public CertRetrievalRequest() { + // required for JAXB (defaults) + } + + public CertRetrievalRequest(MultivaluedMap form) { + if (form.containsKey(CERT_ID)) { + certId = new CertId(form.getFirst(CERT_ID)); + } + } + + /** + * @return the CertId + */ + public CertId getCertId() { + return certId; + } + + /** + * @param CertId the CertId to set + */ + public void setCertId(CertId certId) { + this.certId = certId; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java deleted file mode 100644 index 72e437c17..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java +++ /dev/null @@ -1,78 +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) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -/** - * - */ -package com.netscape.cms.servlet.request.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; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.netscape.certsrv.dbs.certdb.CertId; -import com.netscape.certsrv.dbs.certdb.CertIdAdapter; -import com.netscape.certsrv.request.RequestId; -import com.netscape.certsrv.request.RequestIdAdapter; - -/** - * @author alee - * - */ -@XmlRootElement(name = "CertRetrievalRequest") -@XmlAccessorType(XmlAccessType.FIELD) -public class CertRetrievalRequestData { - - private static final String CERT_ID = "certId"; - - @XmlElement - @XmlJavaTypeAdapter(CertIdAdapter.class) - protected CertId certId; - - @XmlElement - @XmlJavaTypeAdapter(RequestIdAdapter.class) - protected RequestId requestId; - - public CertRetrievalRequestData() { - // required for JAXB (defaults) - } - - public CertRetrievalRequestData(MultivaluedMap form) { - if (form.containsKey(CERT_ID)) { - certId = new CertId(form.getFirst(CERT_ID)); - } - } - - /** - * @return the CertId - */ - public CertId getCertId() { - return certId; - } - - /** - * @param CertId the CertId to set - */ - public void setCertId(CertId certId) { - this.certId = certId; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponse.java b/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponse.java new file mode 100644 index 000000000..3bec6bada --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponse.java @@ -0,0 +1,252 @@ +//--- 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.request.model; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.netscape.certsrv.request.RequestId; +import com.netscape.certsrv.request.RequestIdAdapter; +import com.netscape.cms.servlet.profile.model.PolicyDefault; +import com.netscape.cms.servlet.profile.model.ProfileAttribute; +import com.netscape.cms.servlet.profile.model.ProfilePolicy; +import com.netscape.cms.servlet.profile.model.ProfilePolicySet; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class CertReviewResponse extends CertEnrollmentRequest { + + @XmlElement(name="ProfilePolicySet") + protected List policySets = new ArrayList(); + + protected String nonce; + + @XmlElement + @XmlJavaTypeAdapter(RequestIdAdapter.class) + protected RequestId requestId; + + protected String requestType; + + protected String requestStatus; + + protected String requestOwner; + + protected String requestCreationTime; + + protected String requestModificationTime; + + protected String requestNotes; + + protected String profileApprovedBy; + + protected String profileSetId; + + protected String profileIsVisible; + + protected String profileName; + + protected String profileDescription; + + protected String profileRemoteHost; + + protected String profileRemoteAddr; + + public String getNonce() { + return nonce; + } + + public void setNonce(String nonce) { + this.nonce = nonce; + } + + public RequestId getRequestId() { + return requestId; + } + + public void setRequestId(RequestId requestId) { + this.requestId = requestId; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public String getRequestStatus() { + return requestStatus; + } + + public void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public String getRequestOwner() { + return requestOwner; + } + + public void setRequestOwner(String requestOwner) { + this.requestOwner = requestOwner; + } + + public String getRequestCreationTime() { + return requestCreationTime; + } + + public void setRequestCreationTime(String requestCreationTime) { + this.requestCreationTime = requestCreationTime; + } + + public String getRequestModificationTime() { + return requestModificationTime; + } + + public void setRequestModificationTime(String requestModificationTime) { + this.requestModificationTime = requestModificationTime; + } + + public String getRequestNotes() { + return requestNotes; + } + + public void setRequestNotes(String requestNotes) { + this.requestNotes = requestNotes; + } + + public String getProfileApprovedBy() { + return profileApprovedBy; + } + + public void setProfileApprovedBy(String profileApprovedBy) { + this.profileApprovedBy = profileApprovedBy; + } + + public String getProfileSetId() { + return profileSetId; + } + + public void setProfileSetId(String profileSetId) { + this.profileSetId = profileSetId; + } + + public String getProfileIsVisible() { + return profileIsVisible; + } + + public void setProfileIsVisible(String profileIsVisible) { + this.profileIsVisible = profileIsVisible; + } + + public String getProfileName() { + return profileName; + } + + public void setProfileName(String profileName) { + this.profileName = profileName; + } + + public String getProfileDescription() { + return profileDescription; + } + + public void setProfileDescription(String profileDescription) { + this.profileDescription = profileDescription; + } + + public String getProfileRemoteHost() { + return profileRemoteHost; + } + + public void setProfileRemoteHost(String profileRemoteHost) { + this.profileRemoteHost = profileRemoteHost; + } + + public String getProfileRemoteAddr() { + return profileRemoteAddr; + } + + public void setProfileRemoteAddr(String profileRemoteAddr) { + this.profileRemoteAddr = profileRemoteAddr; + } + + public String toString() { + try { + JAXBContext context = JAXBContext.newInstance(CertReviewResponse.class); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + marshaller.marshal(this, stream); + return stream.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public List getPolicySets() { + return policySets; + } + + public void setPolicySets(List policySets) { + this.policySets = policySets; + } + + public void addProfilePolicySet(ProfilePolicySet policySet) { + policySets.add(policySet); + } + + public void removeProfilePolicySet(ProfilePolicySet policySet) { + policySets.remove(policySet); + } + + @Override + public HashMap toParams() { + HashMap ret = super.toParams(); + + if (requestId != null) ret.put("requestId", requestId.toString()); + if (requestNotes != null) ret.put("requestNotes", requestNotes); + if (nonce != null) ret.put("nonces", nonce); + if (requestType != null) ret.put("requestType", requestType); + + for (ProfilePolicySet policySet: policySets) { + for (ProfilePolicy policy: policySet.getPolicies()) { + PolicyDefault def = policy.getDef(); + List attrs = def.getAttributes(); + for (ProfileAttribute attr: attrs) { + ret.put(attr.getName(), attr.getValue()); + } + } + } + return ret; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponseFactory.java b/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponseFactory.java index 5c2106802..a27437d0f 100644 --- a/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponseFactory.java +++ b/base/common/src/com/netscape/cms/servlet/request/model/CertReviewResponseFactory.java @@ -47,8 +47,8 @@ import com.netscape.cms.servlet.profile.model.ProfilePolicySet; public class CertReviewResponseFactory { - public static AgentEnrollmentRequestData create(IRequest request, IProfile profile, UriInfo uriInfo, Locale locale) throws EBaseException { - AgentEnrollmentRequestData ret = new AgentEnrollmentRequestData(); + public static CertReviewResponse create(IRequest request, IProfile profile, UriInfo uriInfo, Locale locale) throws EBaseException { + CertReviewResponse ret = new CertReviewResponse(); if (request.getRequestType().equals("renewal")) { ret.setIsRenewal(true); @@ -127,13 +127,13 @@ public class CertReviewResponseFactory { return ret; } - public static AgentEnrollmentRequestData create(CMSRequest cmsReq, IProfile profile, Nonces nonces, Locale locale) + public static CertReviewResponse create(CMSRequest cmsReq, IProfile profile, Nonces nonces, Locale locale) throws EPropertyException, EProfileException { HttpServletRequest req = cmsReq.getHttpReq(); IRequest ireq = cmsReq.getIRequest(); IArgBlock params = cmsReq.getHttpParams(); - AgentEnrollmentRequestData ret = new AgentEnrollmentRequestData(); + CertReviewResponse ret = new CertReviewResponse(); ret.setProfileId(profile.getId()); ret.setRequestNotes(req.getParameter("requestNotes")); ret.setRequestId(ireq.getRequestId()); diff --git a/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java deleted file mode 100644 index caff0261d..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java +++ /dev/null @@ -1,321 +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) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -/** - * - */ -package com.netscape.cms.servlet.request.model; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.netscape.cms.servlet.profile.model.ProfileInput; -import com.netscape.cms.servlet.profile.model.ProfileOutput; - -/** - * @author jmagne - * - */ - -@XmlRootElement(name = "EnrollmentRequest") -@XmlAccessorType(XmlAccessType.FIELD) -public class EnrollmentRequestData { - - private static final String PROFILE_ID = "profileId"; - private static final String RENEWAL = "renewal"; - private static final String SERIAL_NUM = "serial_num"; - - @XmlElement - protected String profileId; - - @XmlElement - protected boolean isRenewal; - - @XmlElement - protected String serialNum; // used for one type of renewal - - @XmlElement - protected String remoteHost; - - @XmlElement - protected String remoteAddr; - - @XmlElement(name = "Input") - protected List inputs = new ArrayList(); - - @XmlElement(name = "Output") - protected List outputs = new ArrayList(); - - public EnrollmentRequestData() { - // required for jaxb - } - - public EnrollmentRequestData(MultivaluedMap form) { - profileId = form.getFirst(PROFILE_ID); - String renewalStr = form.getFirst(RENEWAL); - serialNum = form.getFirst(SERIAL_NUM); - isRenewal = new Boolean(renewalStr); - } - - /** - * @return the profileId - */ - public String getProfileId() { - return profileId; - } - - /** - * @param profileId the profileId to set - */ - - public void setProfileId(String profileId) { - this.profileId = profileId; - } - - /** - * @return renewal - */ - - public boolean getIsRenewal() { - return isRenewal; - } - - public void addInput(ProfileInput input) { - ProfileInput curInput = getInput(input.getInputId()); - if (curInput != null) { - getInputs().remove(curInput); - } - getInputs().add(input); - } - - public void deleteInput(ProfileInput input) { - ProfileInput curInput = getInput(input.getInputId()); - if (curInput != null) { - getInputs().remove(curInput); - } - } - - public ProfileInput createInput(String name) { - - ProfileInput oldInput = getInput(name); - - if (oldInput != null) - return oldInput; - - ProfileInput newInput = new ProfileInput(); - newInput.setInputId(name); - - getInputs().add(newInput); - - return newInput; - } - - public ProfileInput getInput(String name) { - - ProfileInput input = null; - - Iterator it = getInputs().iterator(); - - ProfileInput curInput = null; - while (it.hasNext()) { - curInput = it.next(); - if (curInput != null && curInput.getInputId().equals(name)) - break; - } - - return input; - } - - public void addOutput(ProfileOutput output) { - ProfileOutput curOutput = getOutput(output.getOutputId()); - if (curOutput != null) { - getOutputs().remove(curOutput); - } - getOutputs().add(output); - } - - public void deleteOutput(ProfileOutput output) { - ProfileOutput curOutput = getOutput(output.getOutputId()); - if (curOutput != null) { - getInputs().remove(curOutput); - } - } - - public ProfileOutput getOutput(String name) { - ProfileOutput output = null; - ProfileOutput curOutput = null; - - Iterator it = getOutputs().iterator(); - while (it.hasNext()) { - curOutput = it.next(); - if (curOutput != null && curOutput.getOutputId().equals(name)) - break; - } - - return output; - } - - /** - * @param renewal the renewal to set - */ - public void setIsRenewal(boolean isRenewal) { - this.isRenewal = isRenewal; - } - - public HashMap toParams() { - HashMap ret = new HashMap(); - ret.put("isRenewal", Boolean.valueOf(isRenewal).toString()); - if (profileId != null) ret.put(PROFILE_ID, profileId); - if (serialNum != null) ret.put(SERIAL_NUM, serialNum); - if (remoteHost != null) ret.put("remoteHost", remoteHost); - if (remoteAddr != null) ret.put("remoteAddr", remoteAddr); - - for (ProfileInput input: inputs) { - Map attrs = input.getAttributes(); - for (Map.Entry entry: attrs.entrySet()) { - ret.put(entry.getKey(), entry.getValue()); - } - } - - return ret; - } - - public static void main(String args[]) throws Exception { - EnrollmentRequestData data = new EnrollmentRequestData(); - data.setProfileId("caUserCert"); - data.setIsRenewal(false); - - //Simulate a "caUserCert" Profile enrollment - - ProfileInput certReq = data.createInput("KeyGenInput"); - certReq.setInputAttr("cert_request_type", "crmf"); - certReq.setInputAttr( - "cert_request", - "MIIBozCCAZ8wggEFAgQBMQp8MIHHgAECpQ4wDDEKMAgGA1UEAxMBeKaBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2NgaPHp0jiohcP4M+ufrJOZEqH8GV+liu5JLbT8nWpkfhC+8EUBqT6g+n3qroSxIcNVGNdcsBEqs1utvpItzyslAbpdyat3WwQep1dWMzo6RHrPDuIoxNA0Yka1n3qEX4U//08cLQtUv2bYglYgN/hOCNQemLV6vZWAv0n7zelkCAwEAAakQMA4GA1UdDwEB/wQEAwIF4DAzMBUGCSsGAQUFBwUBAQwIcmVnVG9rZW4wGgYJKwYBBQUHBQECDA1hdXRoZW50aWNhdG9yoYGTMA0GCSqGSIb3DQEBBQUAA4GBAJ1VOQcaSEhdHa94s8kifVbSZ2WZeYE5//qxL6wVlEst20vq4ybj13CetnbN3+WT49Zkwp7Fg+6lALKgSk47suTg3EbbQDm+8yOrC0nc/q4PTRoHl0alMmUxIhirYc1t3xoCMqJewmjX1bNP8lpVIZAYFZo4eZCpZaiSkM5BeHhz"); - - ProfileInput subjectName = data.createInput("SubjectNameInput"); - subjectName.setInputAttr("sn_uid", "jmagne"); - subjectName.setInputAttr("sn_e", "jmagne@redhat.com"); - subjectName.setInputAttr("sn_c", "US"); - subjectName.setInputAttr("sn_ou", "Development"); - subjectName.setInputAttr("sn_ou1", "IPA"); - subjectName.setInputAttr("sn_ou2", "Dogtag"); - subjectName.setInputAttr("sn_ou3", "CA"); - subjectName.setInputAttr("sn_cn", "Common"); - subjectName.setInputAttr("sn_o", "RedHat"); - - ProfileInput submitter = data.createInput("SubmitterInfoInput"); - submitter.setInputAttr("requestor_name", "admin"); - submitter.setInputAttr("requestor_email", "admin@redhat.com"); - submitter.setInputAttr("requestor_phone", "650-555-5555"); - - try { - JAXBContext context = JAXBContext.newInstance(EnrollmentRequestData.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - - marshaller.marshal(data, stream); - - System.out.println("Originally marshalled enrollment object. \n"); - - System.out.println(stream.toString()); - - //Try to unmarshall - - Unmarshaller unmarshaller = context.createUnmarshaller(); - - ByteArrayInputStream bais = new ByteArrayInputStream(stream.toByteArray()); - Object unmarshalled = unmarshaller.unmarshal(bais); - - //Try re-marshalling, unmarshalled object to compare - - stream.reset(); - - marshaller.marshal(unmarshalled, stream); - - System.out.println("Remarshalled unmarshalled enrollment object. \n"); - - System.out.println(stream.toString()); - - } catch (JAXBException e) { - System.out.println(e.toString()); - } - } - - public String getSerialNum() { - return serialNum; - } - - public void setSerialNum(String serialNum) { - this.serialNum = serialNum; - } - - public List getInputs() { - return inputs; - } - - public void setInputs(List inputs) { - this.inputs = inputs; - } - - public String getRemoteAddr() { - return remoteAddr; - } - - public void setRemoteAddr(String remoteAddr) { - this.remoteAddr = remoteAddr; - } - - public String getRemoteHost() { - return remoteHost; - } - - public void setRemoteHost(String remoteHost) { - this.remoteHost = remoteHost; - } - - public List getOutputs() { - return outputs; - } - - public void setOutputs(List outputs) { - this.outputs = outputs; - } - - public void setRenewal(boolean isRenewal) { - this.isRenewal = isRenewal; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/KeyArchivalRequest.java b/base/common/src/com/netscape/cms/servlet/request/model/KeyArchivalRequest.java new file mode 100644 index 000000000..9cd544ff8 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/KeyArchivalRequest.java @@ -0,0 +1,123 @@ +// --- 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) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.request.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="KeyArchivalRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class KeyArchivalRequest { + + private static final String CLIENT_ID = "clientID"; + private static final String TRANS_WRAPPED_SESSION_KEY = "transWrappedSessionKey"; + private static final String DATA_TYPE = "dataType"; + private static final String WRAPPED_PRIVATE_DATA = "wrappedPrivateData"; + + @XmlElement + protected String clientId; + + @XmlElement + protected String transWrappedSessionKey; + + @XmlElement + protected String dataType; + + @XmlElement + protected String wrappedPrivateData; + + public KeyArchivalRequest() { + // required for JAXB (defaults) + } + + public KeyArchivalRequest(MultivaluedMap form) { + clientId = form.getFirst(CLIENT_ID); + transWrappedSessionKey = form.getFirst(TRANS_WRAPPED_SESSION_KEY); + dataType = form.getFirst(DATA_TYPE); + wrappedPrivateData = form.getFirst(WRAPPED_PRIVATE_DATA); + } + + /** + * @return the clientId + */ + public String getClientId() { + return clientId; + } + + /** + * @param clientId the clientId to set + */ + public void setClientId(String clientId) { + this.clientId = clientId; + } + + /** + * @return the transWrappedSessionKey + */ + public String getTransWrappedSessionKey() { + return transWrappedSessionKey; + } + + /** + * @param transWrappedSessionKey the transWrappedSessionKey to set + */ + public void setTransWrappedSessionKey(String transWrappedSessionKey) { + this.transWrappedSessionKey = transWrappedSessionKey; + } + + /** + * @return the dataType + */ + public String getDataType() { + return dataType; + } + + /** + * @param dataType the dataType to set + */ + public void setDataType(String dataType) { + this.dataType = dataType; + } + + /** + * @return the wrappedPrivateData + */ + public String getWrappedPrivateData() { + return wrappedPrivateData; + } + + /** + * @param wrappedPrivateData the wrappedPrivateData to set + */ + public void setWrappedPrivateData(String wrappedPrivateData) { + this.wrappedPrivateData = wrappedPrivateData; + } + + +} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/KeyRecoveryRequest.java b/base/common/src/com/netscape/cms/servlet/request/model/KeyRecoveryRequest.java new file mode 100644 index 000000000..3cb17d283 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/KeyRecoveryRequest.java @@ -0,0 +1,155 @@ +// --- 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) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.request.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; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.netscape.certsrv.dbs.keydb.KeyId; +import com.netscape.certsrv.dbs.keydb.KeyIdAdapter; +import com.netscape.certsrv.request.RequestId; +import com.netscape.certsrv.request.RequestIdAdapter; + +/** + * @author alee + * + */ +@XmlRootElement(name="KeyRecoveryRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class KeyRecoveryRequest { + + private static final String KEY_ID = "keyId"; + private static final String REQUEST_ID = "requestId"; + private static final String TRANS_WRAPPED_SESSION_KEY = "transWrappedSessionKey"; + private static final String SESSION_WRAPPED_PASSPHRASE = "sessionWrappedPassphrase"; + private static final String NONCE_DATA = "nonceData"; + + @XmlElement + @XmlJavaTypeAdapter(KeyIdAdapter.class) + protected KeyId keyId; + + @XmlElement + @XmlJavaTypeAdapter(RequestIdAdapter.class) + protected RequestId requestId; + + @XmlElement + protected String transWrappedSessionKey; + + @XmlElement + protected String sessionWrappedPassphrase; + + @XmlElement + protected String nonceData; + + public KeyRecoveryRequest() { + // required for JAXB (defaults) + } + + public KeyRecoveryRequest(MultivaluedMap form) { + if (form.containsKey(KEY_ID)) { + keyId = new KeyId(form.getFirst(KEY_ID)); + } + if (form.containsKey(REQUEST_ID)) { + requestId = new RequestId(form.getFirst(REQUEST_ID)); + } + transWrappedSessionKey = form.getFirst(TRANS_WRAPPED_SESSION_KEY); + sessionWrappedPassphrase = form.getFirst(SESSION_WRAPPED_PASSPHRASE); + nonceData = form.getFirst(NONCE_DATA); + } + + /** + * @return the keyId + */ + public KeyId getKeyId() { + return keyId; + } + + /** + * @param keyId the keyId to set + */ + public void setKeyId(KeyId keyId) { + this.keyId = keyId; + } + + /** + * @return the requestId + */ + public RequestId getRequestId() { + return requestId; + } + + /** + * @param requestId the requestId to set + */ + public void setRequestId(RequestId requestId) { + this.requestId = requestId; + } + + /** + * @return the transWrappedSessionKey + */ + public String getTransWrappedSessionKey() { + return transWrappedSessionKey; + } + + /** + * @param transWrappedSessionKey the transWrappedSessionKey to set + */ + public void setTransWrappedSessionKey(String transWrappedSessionKey) { + this.transWrappedSessionKey = transWrappedSessionKey; + } + + /** + * @return the sessionWrappedPassphrase + */ + public String getSessionWrappedPassphrase() { + return sessionWrappedPassphrase; + } + + /** + * @param sessionWrappedPassphrase the sessionWrappedPassphrase to set + */ + public void setSessionWrappedPassphrase(String sessionWrappedPassphrase) { + this.sessionWrappedPassphrase = sessionWrappedPassphrase; + } + + /** + * @return nonceData + */ + + public String getNonceData() { + return nonceData; + } + + /** + * @param nonceData the nonceData to set + */ + + public void setNonceData(String nonceData) { + this.nonceData = nonceData; + } + +} diff --git a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java index 36a869aaf..6e9de9290 100644 --- a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java +++ b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java @@ -127,7 +127,7 @@ public class KeyRequestDAO extends CMSRequestDAO { * @return info for the request submitted. * @throws EBaseException */ - public KeyRequestInfo submitRequest(ArchivalRequestData data, UriInfo uriInfo) throws EBaseException { + public KeyRequestInfo submitRequest(KeyArchivalRequest data, UriInfo uriInfo) throws EBaseException { String clientId = data.getClientId(); String wrappedSecurityData = data.getWrappedPrivateData(); String dataType = data.getDataType(); @@ -158,7 +158,7 @@ public class KeyRequestDAO extends CMSRequestDAO { * @return info on the recovery request created * @throws EBaseException */ - public KeyRequestInfo submitRequest(RecoveryRequestData data, UriInfo uriInfo) throws EBaseException { + public KeyRequestInfo submitRequest(KeyRecoveryRequest data, UriInfo uriInfo) throws EBaseException { // set data using request.setExtData(field, data) String wrappedSessionKeyStr = data.getTransWrappedSessionKey(); diff --git a/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequest.java b/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequest.java new file mode 100644 index 000000000..8670605fc --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequest.java @@ -0,0 +1,67 @@ +// --- 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) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +/** + * + */ +package com.netscape.cms.servlet.request.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 = "ProfileRetrievalRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class ProfileRetrievalRequest { + + private static final String PROFILE_ID = "profileId"; + + @XmlElement + protected String profileId; + + public ProfileRetrievalRequest() { + // required for JAXB (defaults) + } + + public ProfileRetrievalRequest(MultivaluedMap form) { + if (form.containsKey(PROFILE_ID)) { + profileId = form.getFirst(PROFILE_ID); + } + } + + /** + * @return the ProfileId + */ + public String getProfileId() { + return profileId; + } + + /** + * @param ProfileId the ProfileId to set + */ + public void setProfileId(String profileId) { + this.profileId = profileId; + } + +} \ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java deleted file mode 100644 index 7a0359587..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java +++ /dev/null @@ -1,67 +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) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -/** - * - */ -package com.netscape.cms.servlet.request.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 = "ProfileRetrievalRequest") -@XmlAccessorType(XmlAccessType.FIELD) -public class ProfileRetrievalRequestData { - - private static final String PROFILE_ID = "profileId"; - - @XmlElement - protected String profileId; - - public ProfileRetrievalRequestData() { - // required for JAXB (defaults) - } - - public ProfileRetrievalRequestData(MultivaluedMap form) { - if (form.containsKey(PROFILE_ID)) { - profileId = form.getFirst(PROFILE_ID); - } - } - - /** - * @return the ProfileId - */ - public String getProfileId() { - return profileId; - } - - /** - * @param ProfileId the ProfileId to set - */ - public void setProfileId(String profileId) { - this.profileId = profileId; - } - -} \ No newline at end of file diff --git a/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java deleted file mode 100644 index 335414792..000000000 --- a/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java +++ /dev/null @@ -1,155 +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) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- - -/** - * - */ -package com.netscape.cms.servlet.request.model; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.netscape.certsrv.dbs.keydb.KeyId; -import com.netscape.certsrv.dbs.keydb.KeyIdAdapter; -import com.netscape.certsrv.request.RequestId; -import com.netscape.certsrv.request.RequestIdAdapter; - -/** - * @author alee - * - */ -@XmlRootElement(name="SecurityDataRecoveryRequest") -@XmlAccessorType(XmlAccessType.FIELD) -public class RecoveryRequestData { - - private static final String KEY_ID = "keyId"; - private static final String REQUEST_ID = "requestId"; - private static final String TRANS_WRAPPED_SESSION_KEY = "transWrappedSessionKey"; - private static final String SESSION_WRAPPED_PASSPHRASE = "sessionWrappedPassphrase"; - private static final String NONCE_DATA = "nonceData"; - - @XmlElement - @XmlJavaTypeAdapter(KeyIdAdapter.class) - protected KeyId keyId; - - @XmlElement - @XmlJavaTypeAdapter(RequestIdAdapter.class) - protected RequestId requestId; - - @XmlElement - protected String transWrappedSessionKey; - - @XmlElement - protected String sessionWrappedPassphrase; - - @XmlElement - protected String nonceData; - - public RecoveryRequestData() { - // required for JAXB (defaults) - } - - public RecoveryRequestData(MultivaluedMap form) { - if (form.containsKey(KEY_ID)) { - keyId = new KeyId(form.getFirst(KEY_ID)); - } - if (form.containsKey(REQUEST_ID)) { - requestId = new RequestId(form.getFirst(REQUEST_ID)); - } - transWrappedSessionKey = form.getFirst(TRANS_WRAPPED_SESSION_KEY); - sessionWrappedPassphrase = form.getFirst(SESSION_WRAPPED_PASSPHRASE); - nonceData = form.getFirst(NONCE_DATA); - } - - /** - * @return the keyId - */ - public KeyId getKeyId() { - return keyId; - } - - /** - * @param keyId the keyId to set - */ - public void setKeyId(KeyId keyId) { - this.keyId = keyId; - } - - /** - * @return the requestId - */ - public RequestId getRequestId() { - return requestId; - } - - /** - * @param requestId the requestId to set - */ - public void setRequestId(RequestId requestId) { - this.requestId = requestId; - } - - /** - * @return the transWrappedSessionKey - */ - public String getTransWrappedSessionKey() { - return transWrappedSessionKey; - } - - /** - * @param transWrappedSessionKey the transWrappedSessionKey to set - */ - public void setTransWrappedSessionKey(String transWrappedSessionKey) { - this.transWrappedSessionKey = transWrappedSessionKey; - } - - /** - * @return the sessionWrappedPassphrase - */ - public String getSessionWrappedPassphrase() { - return sessionWrappedPassphrase; - } - - /** - * @param sessionWrappedPassphrase the sessionWrappedPassphrase to set - */ - public void setSessionWrappedPassphrase(String sessionWrappedPassphrase) { - this.sessionWrappedPassphrase = sessionWrappedPassphrase; - } - - /** - * @return nonceData - */ - - public String getNonceData() { - return nonceData; - } - - /** - * @param nonceData the nonceData to set - */ - - public void setNonceData(String nonceData) { - this.nonceData = nonceData; - } - -} diff --git a/base/deploy/src/scriptlets/pkijython.py b/base/deploy/src/scriptlets/pkijython.py index 95fc4ae1d..18fabf9be 100644 --- a/base/deploy/src/scriptlets/pkijython.py +++ b/base/deploy/src/scriptlets/pkijython.py @@ -141,9 +141,9 @@ from org.mozilla.jss.util import Password # PKI Java Imports from com.netscape.cms.servlet.csadmin import SystemConfigClient -from com.netscape.cms.servlet.csadmin.model import CertData -from com.netscape.cms.servlet.csadmin.model import ConfigurationData -from com.netscape.cms.servlet.csadmin.model import ConfigurationResponseData +from com.netscape.cms.servlet.csadmin.model import SystemCertData +from com.netscape.cms.servlet.csadmin.model import ConfigurationRequest +from com.netscape.cms.servlet.csadmin.model import ConfigurationResponse from com.netscape.cmsutil.util import Utils from netscape.security.x509 import X500Name @@ -276,10 +276,10 @@ class rest_client: log.PKI_JYTHON_CONSTRUCTING_PKI_DATA, master['pki_subsystem']) if not master['pki_dry_run_flag']: - data = ConfigurationData() + data = ConfigurationRequest() # Miscellaneous Configuration Information data.setPin(sensitive['pki_one_time_pin']) - data.setToken(ConfigurationData.TOKEN_DEFAULT) + data.setToken(ConfigurationRequest.TOKEN_DEFAULT) if master['pki_instance_type'] == "Tomcat": data.setSubsystemName(master['pki_subsystem_name']) if master['pki_subsystem'] == "CA": @@ -347,7 +347,7 @@ class rest_client: # CA Clone, KRA Clone, OCSP Clone, TKS Clone, or # Subordinate CA data.setSecurityDomainType( - ConfigurationData.EXISTING_DOMAIN) + ConfigurationRequest.EXISTING_DOMAIN) data.setSecurityDomainUri( master['pki_security_domain_uri']) data.setSecurityDomainUser( @@ -357,7 +357,7 @@ class rest_client: elif not config.str2bool(master['pki_external']): # PKI CA data.setSecurityDomainType( - ConfigurationData.NEW_DOMAIN) + ConfigurationRequest.NEW_DOMAIN) data.setSecurityDomainName( master['pki_security_domain_name']) # Directory Server Information @@ -428,7 +428,7 @@ class rest_client: if not config.str2bool(master['pki_clone']): if master['pki_subsystem'] == "CA": # External CA, Subordinate CA, or PKI CA - cert1 = CertData() + cert1 = SystemCertData() cert1.setTag(master['pki_ca_signing_tag']) cert1.setKeyAlgorithm( master['pki_ca_signing_key_algorithm']) @@ -446,7 +446,7 @@ class rest_client: if master['pki_subsystem'] == "CA" or\ master['pki_subsystem'] == "OCSP": # External CA, Subordinate CA, PKI CA, or PKI OCSP - cert2 = CertData() + cert2 = SystemCertData() cert2.setTag(master['pki_ocsp_signing_tag']) cert2.setKeyAlgorithm( master['pki_ocsp_signing_key_algorithm']) @@ -464,7 +464,7 @@ class rest_client: # PKI CA, PKI KRA, PKI OCSP, PKI TKS, # PKI CA CLONE, PKI KRA CLONE, PKI OCSP CLONE, PKI TKS CLONE, # External CA, or Subordinate CA - cert3 = CertData() + cert3 = SystemCertData() cert3.setTag(master['pki_ssl_server_tag']) cert3.setKeyAlgorithm(master['pki_ssl_server_key_algorithm']) cert3.setKeySize(master['pki_ssl_server_key_size']) @@ -476,7 +476,7 @@ class rest_client: # Create 'Subsystem Certificate' if master['pki_instance_type'] == "Apache": # PKI RA or PKI TPS - cert4 = CertData() + cert4 = SystemCertData() cert4.setTag(master['pki_subsystem_tag']) cert4.setKeyAlgorithm(master['pki_subsystem_key_algorithm']) cert4.setKeySize(master['pki_subsystem_key_size']) @@ -489,7 +489,7 @@ class rest_client: if not config.str2bool(master['pki_clone']): # PKI CA, PKI KRA, PKI OCSP, PKI TKS, # External CA, or Subordinate CA - cert4 = CertData() + cert4 = SystemCertData() cert4.setTag(master['pki_subsystem_tag']) cert4.setKeyAlgorithm(master['pki_subsystem_key_algorithm']) cert4.setKeySize(master['pki_subsystem_key_size']) @@ -502,7 +502,7 @@ class rest_client: if master['pki_instance_type'] == "Apache": if master['pki_subsystem'] != "RA": # PKI TPS - cert5 = CertData() + cert5 = SystemCertData() cert5.setTag(master['pki_audit_signing_tag']) cert5.setKeyAlgorithm( master['pki_audit_signing_key_algorithm']) @@ -518,7 +518,7 @@ class rest_client: if not config.str2bool(master['pki_clone']): # PKI CA, PKI KRA, PKI OCSP, PKI TKS, # External CA, or Subordinate CA - cert5 = CertData() + cert5 = SystemCertData() cert5.setTag(master['pki_audit_signing_tag']) cert5.setKeyAlgorithm( master['pki_audit_signing_key_algorithm']) @@ -535,7 +535,7 @@ class rest_client: if not config.str2bool(master['pki_clone']): if master['pki_subsystem'] == "KRA": # PKI KRA - cert6 = CertData() + cert6 = SystemCertData() cert6.setTag(master['pki_transport_tag']) cert6.setKeyAlgorithm( master['pki_transport_key_algorithm']) @@ -552,7 +552,7 @@ class rest_client: if not config.str2bool(master['pki_clone']): if master['pki_subsystem'] == "KRA": # PKI KRA - cert7 = CertData() + cert7 = SystemCertData() cert7.setTag(master['pki_storage_tag']) cert7.setKeyAlgorithm( master['pki_storage_key_algorithm']) diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java index 0f12eada2..dfb34ed13 100644 --- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java +++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java @@ -10,17 +10,17 @@ import com.netscape.certsrv.dbs.keydb.KeyId; import com.netscape.certsrv.request.RequestId; import com.netscape.cms.client.cli.ClientConfig; import com.netscape.cms.servlet.admin.SystemCertificateResource; -import com.netscape.cms.servlet.cert.model.CertificateData; +import com.netscape.cms.servlet.cert.model.CertData; import com.netscape.cms.servlet.csadmin.PKIClient; import com.netscape.cms.servlet.key.KeyResource; import com.netscape.cms.servlet.key.model.KeyData; import com.netscape.cms.servlet.key.model.KeyDataInfo; import com.netscape.cms.servlet.key.model.KeyDataInfos; import com.netscape.cms.servlet.request.KeyRequestResource; -import com.netscape.cms.servlet.request.model.ArchivalRequestData; +import com.netscape.cms.servlet.request.model.KeyArchivalRequest; import com.netscape.cms.servlet.request.model.KeyRequestInfo; import com.netscape.cms.servlet.request.model.KeyRequestInfos; -import com.netscape.cms.servlet.request.model.RecoveryRequestData; +import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; import com.netscape.cmsutil.util.Utils; public class DRMClient extends PKIClient { @@ -39,9 +39,9 @@ public class DRMClient extends PKIClient { public String getTransportCert() { @SuppressWarnings("unchecked") - ClientResponse response = (ClientResponse) systemCertClient + ClientResponse response = (ClientResponse) systemCertClient .getTransportCert(); - CertificateData certData = getEntity(response); + CertData certData = getEntity(response); String transportCert = certData.getEncoded(); return transportCert; } @@ -56,7 +56,7 @@ public class DRMClient extends PKIClient { public KeyRequestInfo archiveSecurityData(byte[] encoded, String clientId, String dataType) { // create archival request - ArchivalRequestData data = new ArchivalRequestData(); + KeyArchivalRequest data = new KeyArchivalRequest(); String req1 = Utils.base64encode(encoded); data.setWrappedPrivateData(req1); data.setClientId(clientId); @@ -83,7 +83,7 @@ public class DRMClient extends PKIClient { public KeyRequestInfo requestRecovery(KeyId keyId, byte[] rpwd, byte[] rkey, byte[] nonceData) { // create recovery request - RecoveryRequestData data = new RecoveryRequestData(); + KeyRecoveryRequest data = new KeyRecoveryRequest(); data.setKeyId(keyId); if (rpwd != null) { data.setSessionWrappedPassphrase(Utils.base64encode(rpwd)); @@ -106,7 +106,7 @@ public class DRMClient extends PKIClient { public KeyData retrieveKey(KeyId keyId, RequestId requestId, byte[] rpwd, byte[] rkey, byte[] nonceData) { // create recovery request - RecoveryRequestData data = new RecoveryRequestData(); + KeyRecoveryRequest data = new KeyRecoveryRequest(); data.setKeyId(keyId); data.setRequestId(requestId); if (rkey != null) { diff --git a/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java b/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java index 9a884f872..d8c0ece00 100644 --- a/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java +++ b/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java @@ -10,7 +10,7 @@ import com.netscape.cms.servlet.admin.GroupService; import com.netscape.cms.servlet.admin.SystemCertService; import com.netscape.cms.servlet.admin.UserCertService; import com.netscape.cms.servlet.admin.UserService; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.csadmin.SystemConfigService; import com.netscape.cms.servlet.key.KeyService; import com.netscape.cms.servlet.request.KeyRequestService; @@ -38,7 +38,7 @@ public class KeyRecoveryAuthorityApplication extends Application { classes.add(SystemCertService.class); // exception mapper - classes.add(CMSException.Mapper.class); + classes.add(PKIException.Mapper.class); } diff --git a/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java b/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java index 7331c38d6..f78cf730d 100644 --- a/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java +++ b/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java @@ -10,7 +10,7 @@ import com.netscape.cms.servlet.admin.GroupService; import com.netscape.cms.servlet.admin.SystemCertService; import com.netscape.cms.servlet.admin.UserCertService; import com.netscape.cms.servlet.admin.UserService; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.csadmin.SystemConfigService; public class OCSPApplication extends Application { @@ -32,7 +32,7 @@ public class OCSPApplication extends Application { classes.add(SystemCertService.class); // exception mapper - classes.add(CMSException.Mapper.class); + classes.add(PKIException.Mapper.class); } public Set> getClasses() { diff --git a/base/tks/src/com/netscape/tks/TKSApplication.java b/base/tks/src/com/netscape/tks/TKSApplication.java index 2afdf1297..68fbd7d35 100644 --- a/base/tks/src/com/netscape/tks/TKSApplication.java +++ b/base/tks/src/com/netscape/tks/TKSApplication.java @@ -10,7 +10,7 @@ import com.netscape.cms.servlet.admin.GroupService; import com.netscape.cms.servlet.admin.SystemCertService; import com.netscape.cms.servlet.admin.UserCertService; import com.netscape.cms.servlet.admin.UserService; -import com.netscape.cms.servlet.base.CMSException; +import com.netscape.cms.servlet.base.PKIException; import com.netscape.cms.servlet.csadmin.SystemConfigService; public class TKSApplication extends Application { @@ -32,7 +32,7 @@ public class TKSApplication extends Application { classes.add(SystemCertService.class); // exception mapper - classes.add(CMSException.Mapper.class); + classes.add(PKIException.Mapper.class); } public Set> getClasses() { -- cgit