diff options
17 files changed, 40 insertions, 105 deletions
diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java index 24ce21277..cc6aa19d5 100644 --- a/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java +++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CAClient.java @@ -27,7 +27,7 @@ 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.csadmin.CMSRestClient; +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; @@ -37,13 +37,13 @@ import com.netscape.cms.servlet.request.model.CertRequestInfo; import com.netscape.cms.servlet.request.model.CertRequestInfos; import com.netscape.cms.servlet.request.model.EnrollmentRequestData; -public class CARestClient extends CMSRestClient { +public class CAClient extends PKIClient { private CertResource certClient; private CertRequestResource certRequestClient; private ProfileResource profileClient; - public CARestClient(ClientConfig config) throws URISyntaxException { + public CAClient(ClientConfig config) throws URISyntaxException { super(config); certRequestClient = createProxy(CertRequestResource.class); 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 8fa4b9bb4..185f01f24 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 @@ -148,13 +148,13 @@ public class CATest { log("Exception in logging into token:" + e.toString()); } - CARestClient client; + CAClient client; try { ClientConfig config = new ClientConfig(); config.setServerURI(protocol + "://" + host + ":" + port + "/ca"); config.setCertNickname(clientCertNickname); - client = new CARestClient(config); + client = new CAClient(config); } catch (Exception e) { e.printStackTrace(); return; @@ -275,7 +275,7 @@ public class CATest { } - private static void enrollAndApproveCertRequest(CARestClient client, EnrollmentRequestData data) { + private static void enrollAndApproveCertRequest(CAClient client, EnrollmentRequestData data) { CertRequestInfos reqInfo = null; try { reqInfo = client.enrollCertificate(data); @@ -295,7 +295,7 @@ public class CATest { } } - private static void enrollCertRequest(CARestClient client, EnrollmentRequestData data) { + private static void enrollCertRequest(CAClient client, EnrollmentRequestData data) { CertRequestInfos reqInfo = null; try { reqInfo = client.enrollCertificate(data); @@ -560,7 +560,7 @@ public class CATest { private static void usage(Options options) { HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("CARestClient Test:", options); + formatter.printHelp("CAClient Test:", options); System.exit(1); } 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 67b67fca0..dfa79c650 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 @@ -57,7 +57,7 @@ import org.mozilla.jss.pkix.primitive.SubjectPublicKeyInfo; import org.mozilla.jss.util.Password; import com.netscape.cms.client.cli.ClientConfig; -import com.netscape.cms.servlet.csadmin.ConfigurationRESTClient; +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; @@ -184,12 +184,12 @@ public class ConfigurationTest { System.out.println("Exception in logging into token:" + e.toString()); } - ConfigurationRESTClient client = null; + SystemConfigClient client = null; try { ClientConfig config = new ClientConfig(); config.setServerURI(protocol + "://" + host + ":" + port + "/" + cstype); - client = new ConfigurationRESTClient(config); + client = new SystemConfigClient(config); } catch (URISyntaxException e1) { e1.printStackTrace(); System.exit(1); 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 70ad9021e..2f7ab668e 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertCLI.java +++ b/base/common/src/com/netscape/cms/client/cert/CertCLI.java @@ -35,7 +35,7 @@ import com.netscape.cms.servlet.request.model.CertRequestInfo; public class CertCLI extends CLI { public MainCLI parent; - public CertRestClient client; + public CertClient client; public CertCLI(MainCLI parent) { super("cert", "Certificate management commands"); @@ -75,7 +75,7 @@ public class CertCLI extends CLI { public void execute(String[] args) throws Exception { - client = new CertRestClient(parent.config); + client = new CertClient(parent.config); client.setVerbose(verbose); if (args.length == 0) { diff --git a/base/common/src/com/netscape/cms/client/cert/CertRestClient.java b/base/common/src/com/netscape/cms/client/cert/CertClient.java index 7c8b9f3e4..b8fdde703 100644 --- a/base/common/src/com/netscape/cms/client/cert/CertRestClient.java +++ b/base/common/src/com/netscape/cms/client/cert/CertClient.java @@ -28,7 +28,7 @@ import com.netscape.cms.servlet.cert.model.CertRevokeRequest; import com.netscape.cms.servlet.cert.model.CertSearchData; import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest; import com.netscape.cms.servlet.cert.model.CertificateData; -import com.netscape.cms.servlet.csadmin.CMSRestClient; +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.CertRequestInfo; @@ -38,12 +38,12 @@ import com.netscape.cms.servlet.request.model.EnrollmentRequestData; /** * @author Endi S. Dewata */ -public class CertRestClient extends CMSRestClient { +public class CertClient extends PKIClient { public CertResource certClient; public CertRequestResource certRequestResource; - public CertRestClient(ClientConfig config) throws URISyntaxException { + public CertClient(ClientConfig config) throws URISyntaxException { super(config); certClient = createProxy(CertResource.class); diff --git a/base/common/src/com/netscape/cms/client/group/GroupCLI.java b/base/common/src/com/netscape/cms/client/group/GroupCLI.java index fefc1b0c9..b106c6fc1 100644 --- a/base/common/src/com/netscape/cms/client/group/GroupCLI.java +++ b/base/common/src/com/netscape/cms/client/group/GroupCLI.java @@ -34,7 +34,7 @@ import com.netscape.cms.client.cli.MainCLI; public class GroupCLI extends CLI { public MainCLI parent; - public GroupRestClient client; + public GroupClient client; public GroupCLI(MainCLI parent) { super("group", "Group management commands"); @@ -74,7 +74,7 @@ public class GroupCLI extends CLI { public void execute(String[] args) throws Exception { - client = new GroupRestClient(parent.config); + client = new GroupClient(parent.config); client.setVerbose(verbose); if (args.length == 0) { diff --git a/base/common/src/com/netscape/cms/client/group/GroupRestClient.java b/base/common/src/com/netscape/cms/client/group/GroupClient.java index 1b98035ea..410c1ad3d 100644 --- a/base/common/src/com/netscape/cms/client/group/GroupRestClient.java +++ b/base/common/src/com/netscape/cms/client/group/GroupClient.java @@ -28,17 +28,17 @@ import com.netscape.certsrv.group.GroupMemberData; import com.netscape.certsrv.group.GroupMemberResource; import com.netscape.certsrv.group.GroupResource; import com.netscape.cms.client.cli.ClientConfig; -import com.netscape.cms.servlet.csadmin.CMSRestClient; +import com.netscape.cms.servlet.csadmin.PKIClient; /** * @author Endi S. Dewata */ -public class GroupRestClient extends CMSRestClient { +public class GroupClient extends PKIClient { public GroupResource groupClient; public GroupMemberResource groupMemberClient; - public GroupRestClient(ClientConfig config) throws URISyntaxException { + public GroupClient(ClientConfig config) throws URISyntaxException { super(config); groupClient = createProxy(GroupResource.class); diff --git a/base/common/src/com/netscape/cms/client/user/UserCLI.java b/base/common/src/com/netscape/cms/client/user/UserCLI.java index a5104135b..cc9bc8aa5 100644 --- a/base/common/src/com/netscape/cms/client/user/UserCLI.java +++ b/base/common/src/com/netscape/cms/client/user/UserCLI.java @@ -34,7 +34,7 @@ import com.netscape.cms.client.cli.MainCLI; public class UserCLI extends CLI { public MainCLI parent; - public UserRestClient client; + public UserClient client; public UserCLI(MainCLI parent) { super("user", "User management commands"); @@ -75,7 +75,7 @@ public class UserCLI extends CLI { public void execute(String[] args) throws Exception { - client = new UserRestClient(parent.config); + client = new UserClient(parent.config); client.setVerbose(verbose); if (args.length == 0) { diff --git a/base/common/src/com/netscape/cms/client/user/UserRestClient.java b/base/common/src/com/netscape/cms/client/user/UserClient.java index 54c1e3fa1..ea2991ac8 100644 --- a/base/common/src/com/netscape/cms/client/user/UserRestClient.java +++ b/base/common/src/com/netscape/cms/client/user/UserClient.java @@ -28,17 +28,17 @@ import com.netscape.certsrv.user.UserCollection; import com.netscape.certsrv.user.UserData; import com.netscape.certsrv.user.UserResource; import com.netscape.cms.client.cli.ClientConfig; -import com.netscape.cms.servlet.csadmin.CMSRestClient; +import com.netscape.cms.servlet.csadmin.PKIClient; /** * @author Endi S. Dewata */ -public class UserRestClient extends CMSRestClient { +public class UserClient extends PKIClient { public UserResource userClient; public UserCertResource userCertClient; - public UserRestClient(ClientConfig config) throws URISyntaxException { + public UserClient(ClientConfig config) throws URISyntaxException { super(config); userClient = createProxy(UserResource.class); diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationErrorInterceptor.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationErrorInterceptor.java deleted file mode 100644 index 63af4101a..000000000 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationErrorInterceptor.java +++ /dev/null @@ -1,65 +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.core.MediaType; -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; - -/** - * @author alee - * - */ -public class ConfigurationErrorInterceptor implements ClientErrorInterceptor { - - public void handle(ClientResponse<?> response) { - - // handle HTTP code 4xx and 5xx - int code = response.getResponseStatus().getStatusCode(); - if (code < 400) return; - - MultivaluedMap<String, String> headers = response.getHeaders(); - String contentType = headers.getFirst("Content-Type"); - - // handle XML content only - System.out.println("Content-type: "+contentType); - if (!contentType.startsWith(MediaType.APPLICATION_XML)) return; - - CMSException exception; - - try { - // Requires RESTEasy 2.3.2 - // https://issues.jboss.org/browse/RESTEASY-652 - CMSException.Data data = response.getEntity(CMSException.Data.class); - - Class<?> clazz = Class.forName(data.className); - exception = (CMSException) clazz.getConstructor(CMSException.Data.class).newInstance(data); - - } catch (Exception e) { - e.printStackTrace(); - return; - } - - throw exception; - } - -} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java index 50c7853df..be66f5cf7 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java @@ -299,7 +299,7 @@ public class ConfigurationUtils { ClientConfig config = new ClientConfig(); config.setServerURI("https://" + sdhost + ":" + sdport + "/ca"); - ConfigurationRESTClient client = new ConfigurationRESTClient(config); + SystemConfigClient client = new SystemConfigClient(config); InstallToken token = client.getInstallToken(data); diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/CMSRestClient.java b/base/common/src/com/netscape/cms/servlet/csadmin/PKIClient.java index 9d7f2f9ac..647056bd1 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/CMSRestClient.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/PKIClient.java @@ -52,7 +52,7 @@ import org.mozilla.jss.ssl.SSLSocket; import com.netscape.cms.client.cli.ClientConfig; -public abstract class CMSRestClient { +public abstract class PKIClient { protected boolean verbose; @@ -62,7 +62,7 @@ public abstract class CMSRestClient { protected ClientErrorHandler errorHandler; protected ClientExecutor executor; - public CMSRestClient(ClientConfig config) { + public PKIClient(ClientConfig config) { this.config = config; DefaultHttpClient httpClient = new DefaultHttpClient(); @@ -147,7 +147,7 @@ public abstract class CMSRestClient { executor = new ApacheHttpClient4Executor(httpClient); providerFactory = ResteasyProviderFactory.getInstance(); - providerFactory.addClientErrorInterceptor(new CMSErrorInterceptor()); + providerFactory.addClientErrorInterceptor(new PKIErrorInterceptor()); errorHandler = new ClientErrorHandler(providerFactory.getClientErrorInterceptors()); } diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/CMSErrorInterceptor.java b/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java index 870422391..166c02eb9 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/CMSErrorInterceptor.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/PKIErrorInterceptor.java @@ -25,7 +25,7 @@ import org.jboss.resteasy.client.core.ClientErrorInterceptor; import com.netscape.cms.servlet.base.CMSException; -public class CMSErrorInterceptor implements ClientErrorInterceptor { +public class PKIErrorInterceptor implements ClientErrorInterceptor { public void handle(ClientResponse<?> response) { diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationRESTClient.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java index 7fe8af2f3..6167b0521 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/ConfigurationRESTClient.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigClient.java @@ -30,11 +30,11 @@ import com.netscape.cms.servlet.csadmin.model.InstallTokenRequest; * @author alee * */ -public class ConfigurationRESTClient extends CMSRestClient { +public class SystemConfigClient extends PKIClient { private SystemConfigurationResource configClient; - public ConfigurationRESTClient(ClientConfig config) throws URISyntaxException { + public SystemConfigClient(ClientConfig config) throws URISyntaxException { super(config); configClient = createProxy(SystemConfigurationResource.class); diff --git a/base/deploy/src/scriptlets/pkijython.py b/base/deploy/src/scriptlets/pkijython.py index 5adc7e022..95fc4ae1d 100644 --- a/base/deploy/src/scriptlets/pkijython.py +++ b/base/deploy/src/scriptlets/pkijython.py @@ -140,7 +140,7 @@ from org.mozilla.jss.util import Password # PKI Java Imports -from com.netscape.cms.servlet.csadmin import ConfigurationRESTClient +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 @@ -262,7 +262,7 @@ class rest_client: log.PKI_JYTHON_INITIALIZING_REST_CLIENT, client_config.serverURI) if not pki_dry_run_flag: - self.client = ConfigurationRESTClient(client_config) + self.client = SystemConfigClient(client_config) return self.client except URISyntaxException, e: e.printStackTrace() diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java index 372b8aea6..0f12eada2 100644 --- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java +++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java @@ -11,7 +11,7 @@ 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.csadmin.CMSRestClient; +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; @@ -23,13 +23,13 @@ import com.netscape.cms.servlet.request.model.KeyRequestInfos; import com.netscape.cms.servlet.request.model.RecoveryRequestData; import com.netscape.cmsutil.util.Utils; -public class DRMRestClient extends CMSRestClient { +public class DRMClient extends PKIClient { private KeyResource keyClient; private KeyRequestResource keyRequestClient; private SystemCertificateResource systemCertClient; - public DRMRestClient(ClientConfig config) throws URISyntaxException { + public DRMClient(ClientConfig config) throws URISyntaxException { super(config); systemCertClient = createProxy(SystemCertificateResource.class); diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java index 62cdfe992..9954ba94f 100644 --- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java +++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java @@ -194,13 +194,13 @@ public class DRMTest { // Set base URI and get client - DRMRestClient client; + DRMClient client; try { ClientConfig config = new ClientConfig(); config.setServerURI(protocol + "://" + host + ":" + port + "/kra"); config.setCertNickname(clientCertNickname); - client = new DRMRestClient(config); + client = new DRMClient(config); } catch (Exception e) { e.printStackTrace(); |