diff options
Diffstat (limited to 'base/common')
12 files changed, 25 insertions, 90 deletions
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); |