diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-11 05:34:59 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-15 12:07:34 -0500 |
commit | 108bd269ab0eb512c334939fabde68eeab5b0b67 (patch) | |
tree | 7c9bbb80c7de89fede78a59576241c42394f5032 /base/kra | |
parent | f554dc2aa0478aa23f7e986b6779091f7d520bf5 (diff) | |
download | pki-108bd269ab0eb512c334939fabde68eeab5b0b67.tar.gz pki-108bd269ab0eb512c334939fabde68eeab5b0b67.tar.xz pki-108bd269ab0eb512c334939fabde68eeab5b0b67.zip |
Reorganized REST client classes.
The REST client classes have been moved into the
com.netscape.cms.client.<component> packages.
Ticket #215
Diffstat (limited to 'base/kra')
-rw-r--r-- | base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java | 130 | ||||
-rw-r--r-- | base/kra/functional/src/com/netscape/cms/servlet/test/DRMTest.java | 3 |
2 files changed, 2 insertions, 131 deletions
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 deleted file mode 100644 index dfb34ed13..000000000 --- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMClient.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.netscape.cms.servlet.test; - -import java.net.URISyntaxException; -import java.util.Collection; -import java.util.Iterator; - -import org.jboss.resteasy.client.ClientResponse; - -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.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.KeyArchivalRequest; -import com.netscape.cms.servlet.request.model.KeyRequestInfo; -import com.netscape.cms.servlet.request.model.KeyRequestInfos; -import com.netscape.cms.servlet.request.model.KeyRecoveryRequest; -import com.netscape.cmsutil.util.Utils; - -public class DRMClient extends PKIClient { - - private KeyResource keyClient; - private KeyRequestResource keyRequestClient; - private SystemCertificateResource systemCertClient; - - public DRMClient(ClientConfig config) throws URISyntaxException { - super(config); - - systemCertClient = createProxy(SystemCertificateResource.class); - keyRequestClient = createProxy(KeyRequestResource.class); - keyClient = createProxy(KeyResource.class); - } - - public String getTransportCert() { - @SuppressWarnings("unchecked") - ClientResponse<CertData> response = (ClientResponse<CertData>) systemCertClient - .getTransportCert(); - CertData certData = getEntity(response); - String transportCert = certData.getEncoded(); - return transportCert; - } - - public Collection<KeyRequestInfo> listRequests(String requestState, String requestType) { - KeyRequestInfos infos = keyRequestClient.listRequests( - requestState, requestType, null, new RequestId(0), 100, 100, 10 - ); - Collection<KeyRequestInfo> list = infos.getRequests(); - return list; - } - - public KeyRequestInfo archiveSecurityData(byte[] encoded, String clientId, String dataType) { - // create archival request - KeyArchivalRequest data = new KeyArchivalRequest(); - String req1 = Utils.base64encode(encoded); - data.setWrappedPrivateData(req1); - data.setClientId(clientId); - data.setDataType(dataType); - - KeyRequestInfo info = keyRequestClient.archiveKey(data); - return info; - } - - public KeyDataInfo getKeyData(String clientId, String status) { - KeyDataInfos infos = keyClient.listKeys(clientId, status, 100, 10); - Collection<KeyDataInfo> list = infos.getKeyInfos(); - Iterator<KeyDataInfo> iter = list.iterator(); - - while (iter.hasNext()) { - KeyDataInfo info = iter.next(); - if (info != null) { - // return the first one - return info; - } - } - return null; - } - - public KeyRequestInfo requestRecovery(KeyId keyId, byte[] rpwd, byte[] rkey, byte[] nonceData) { - // create recovery request - KeyRecoveryRequest data = new KeyRecoveryRequest(); - data.setKeyId(keyId); - if (rpwd != null) { - data.setSessionWrappedPassphrase(Utils.base64encode(rpwd)); - } - if (rkey != null) { - data.setTransWrappedSessionKey(Utils.base64encode(rkey)); - } - - if (nonceData != null) { - data.setNonceData(Utils.base64encode(nonceData)); - } - - KeyRequestInfo info = keyRequestClient.recoverKey(data); - return info; - } - - public void approveRecovery(RequestId recoveryId) { - keyRequestClient.approveRequest(recoveryId); - } - - public KeyData retrieveKey(KeyId keyId, RequestId requestId, byte[] rpwd, byte[] rkey, byte[] nonceData) { - // create recovery request - KeyRecoveryRequest data = new KeyRecoveryRequest(); - data.setKeyId(keyId); - data.setRequestId(requestId); - if (rkey != null) { - data.setTransWrappedSessionKey(Utils.base64encode(rkey)); - } - if (rpwd != null) { - data.setSessionWrappedPassphrase(Utils.base64encode(rpwd)); - } - - if (nonceData != null) { - data.setNonceData(Utils.base64encode(nonceData)); - } - - KeyData key = keyClient.retrieveKey(data); - return key; - } - - public KeyRequestInfo getRequest(RequestId id) { - return keyRequestClient.getRequestInfo(id); - } -} 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 3ccde1cd2..5a2013a60 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 @@ -39,7 +39,8 @@ import org.mozilla.jss.util.Password; import com.netscape.certsrv.dbs.keydb.KeyId; import com.netscape.certsrv.request.RequestId; -import com.netscape.cms.client.cli.ClientConfig; +import com.netscape.cms.client.ClientConfig; +import com.netscape.cms.client.kra.DRMClient; import com.netscape.cms.servlet.base.PKIService; import com.netscape.cms.servlet.key.model.KeyData; import com.netscape.cms.servlet.key.model.KeyDataInfo; |