diff options
author | Endi S. Dewata <edewata@redhat.com> | 2014-02-14 22:27:56 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2014-02-19 11:10:04 -0500 |
commit | f28f20174d269dc0ef8ed67fb927e7d4efad7ed2 (patch) | |
tree | ae2a434975c2d620e0ca0228042377c35ebf408d /base/common | |
parent | 0ac1abb747d76321d5c4830c5bad9c41592959d3 (diff) | |
download | pki-f28f20174d269dc0ef8ed67fb927e7d4efad7ed2.tar.gz pki-f28f20174d269dc0ef8ed67fb927e7d4efad7ed2.tar.xz pki-f28f20174d269dc0ef8ed67fb927e7d4efad7ed2.zip |
Added REST client for system certificates.
A new REST client has been added to access system certificates.
Ticket #554
Diffstat (limited to 'base/common')
-rw-r--r-- | base/common/src/com/netscape/certsrv/kra/KRAClient.java | 13 | ||||
-rw-r--r-- | base/common/src/com/netscape/certsrv/system/SystemCertClient.java | 48 |
2 files changed, 50 insertions, 11 deletions
diff --git a/base/common/src/com/netscape/certsrv/kra/KRAClient.java b/base/common/src/com/netscape/certsrv/kra/KRAClient.java index b2bced319..52ec25349 100644 --- a/base/common/src/com/netscape/certsrv/kra/KRAClient.java +++ b/base/common/src/com/netscape/certsrv/kra/KRAClient.java @@ -7,7 +7,6 @@ import java.util.List; import javax.ws.rs.core.Response; -import com.netscape.certsrv.cert.CertData; import com.netscape.certsrv.client.PKIClient; import com.netscape.certsrv.client.SubsystemClient; import com.netscape.certsrv.dbs.keydb.KeyId; @@ -26,7 +25,7 @@ import com.netscape.certsrv.key.SymKeyGenerationRequest; import com.netscape.certsrv.logging.AuditClient; import com.netscape.certsrv.request.RequestId; import com.netscape.certsrv.selftests.SelfTestClient; -import com.netscape.certsrv.system.SystemCertResource; +import com.netscape.certsrv.system.SystemCertClient; import com.netscape.certsrv.user.UserClient; import com.netscape.cmsutil.util.Utils; @@ -34,7 +33,6 @@ public class KRAClient extends SubsystemClient { private KeyResource keyClient; private KeyRequestResource keyRequestClient; - private SystemCertResource systemCertClient; public KRAClient(PKIClient client) throws URISyntaxException { super(client, "kra"); @@ -46,20 +44,13 @@ public class KRAClient extends SubsystemClient { addClient(new AuditClient(client, name)); addClient(new GroupClient(client, name)); addClient(new SelfTestClient(client, name)); + addClient(new SystemCertClient(client, name)); addClient(new UserClient(client, name)); - systemCertClient = createProxy(SystemCertResource.class); keyRequestClient = createProxy(KeyRequestResource.class); keyClient = createProxy(KeyResource.class); } - public String getTransportCert() { - Response response = systemCertClient.getTransportCert(); - CertData certData = client.getEntity(response, CertData.class); - String transportCert = certData.getEncoded(); - return transportCert; - } - public Collection<KeyRequestInfo> listRequests(String requestState, String requestType) { KeyRequestInfoCollection infos = keyRequestClient.listRequests( requestState, requestType, null, new RequestId(0), 100, 100, 10 diff --git a/base/common/src/com/netscape/certsrv/system/SystemCertClient.java b/base/common/src/com/netscape/certsrv/system/SystemCertClient.java new file mode 100644 index 000000000..8e9e344bf --- /dev/null +++ b/base/common/src/com/netscape/certsrv/system/SystemCertClient.java @@ -0,0 +1,48 @@ +//--- 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) 2014 Red Hat, Inc. +//All rights reserved. +//--- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.system; + +import java.net.URISyntaxException; + +import javax.ws.rs.core.Response; + +import com.netscape.certsrv.cert.CertData; +import com.netscape.certsrv.client.Client; +import com.netscape.certsrv.client.PKIClient; + +/** + * @author Endi S. Dewata + */ +public class SystemCertClient extends Client { + + public SystemCertResource resource; + + public SystemCertClient(PKIClient client, String subsystem) throws URISyntaxException { + super(client, subsystem, "systemcert"); + init(); + } + + public void init() throws URISyntaxException { + resource = createProxy(SystemCertResource.class); + } + + public CertData getTransportCert() { + Response response = resource.getTransportCert(); + return client.getEntity(response, CertData.class); + } +} |