summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/key
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-08-11 09:47:39 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-08-15 12:07:43 -0500
commit1aa02e5207514d210e903d23e1d698b85fc29344 (patch)
tree3bd555aed82c2446208444939594aac3e3979308 /base/common/src/com/netscape/certsrv/key
parent3c9b8e787ccf066c38469e1fe2c119d5c410bb5e (diff)
downloadpki-1aa02e5207514d210e903d23e1d698b85fc29344.tar.gz
pki-1aa02e5207514d210e903d23e1d698b85fc29344.tar.xz
pki-1aa02e5207514d210e903d23e1d698b85fc29344.zip
Reorganized REST common classes.
The common classes used by REST client and services have been moved into the com.netscape.certsrv.<component> packages. Ticket #215
Diffstat (limited to 'base/common/src/com/netscape/certsrv/key')
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java123
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyData.java76
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyDataInfo.java85
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyDataInfos.java87
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java155
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java61
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java89
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestResource.java88
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyResource.java45
9 files changed, 809 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java b/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java
new file mode 100644
index 000000000..2d2d84c94
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/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.certsrv.key;
+
+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<String, String> 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/certsrv/key/KeyData.java b/base/common/src/com/netscape/certsrv/key/KeyData.java
new file mode 100644
index 000000000..63c0591c2
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyData.java
@@ -0,0 +1,76 @@
+// --- 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.certsrv.key;
+
+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="SecurityData")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class KeyData {
+ @XmlElement
+ String wrappedPrivateData;
+
+ @XmlElement
+ String nonceData;
+
+ public KeyData() {
+ // required for JAXB (defaults)
+ }
+
+ /**
+ * @return the wrappedPrivateData
+ */
+ public String getWrappedPrivateData() {
+ return wrappedPrivateData;
+ }
+
+ /**
+ * @param wrappedPrivateData the wrappedPrivateData to set
+ */
+ public void setWrappedPrivateData(String wrappedPrivateData) {
+ this.wrappedPrivateData = wrappedPrivateData;
+ }
+
+ /**
+ * @return the 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/certsrv/key/KeyDataInfo.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java
new file mode 100644
index 000000000..6f4751dcc
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java
@@ -0,0 +1,85 @@
+// --- 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.certsrv.key;
+
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import com.netscape.certsrv.dbs.keydb.KeyId;
+
+/**
+ * @author alee
+ *
+ */
+@XmlRootElement(name="SecurityDataInfo")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class KeyDataInfo {
+
+ @XmlElement
+ protected String keyURL;
+
+ @XmlElement
+ protected String clientID;
+
+ public KeyDataInfo() {
+ // required for JAXB (defaults)
+ }
+
+ /**
+ * @return the keyURL
+ */
+ public String getKeyURL() {
+ return keyURL;
+ }
+
+ /**
+ * @param keyURL the keyURL to set
+ */
+ public void setKeyURL(String keyURL) {
+ this.keyURL = keyURL;
+ }
+
+ /**
+ * @return the key ID in the keyURL
+ */
+ public KeyId getKeyId() {
+ String id = keyURL.substring(keyURL.lastIndexOf("/") + 1);
+ return new KeyId(id);
+ }
+
+ /**
+ * @return the clientID
+ */
+ public String getClientID() {
+ return clientID;
+ }
+
+ /**
+ * @param clientID the clientID to set
+ */
+ public void setClientID(String clientID) {
+ this.clientID = clientID;
+ }
+
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
new file mode 100644
index 000000000..c04820299
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
@@ -0,0 +1,87 @@
+// --- 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.certsrv.key;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import com.netscape.certsrv.base.Link;
+
+@XmlRootElement(name = "SecurityDataInfos")
+public class KeyDataInfos {
+
+ protected Collection<KeyDataInfo> keyInfos;
+ protected List<Link> links;
+
+ /**
+ * @return the keyInfos
+ */
+ @XmlElementRef
+ public Collection<KeyDataInfo> getKeyInfos() {
+ return keyInfos;
+ }
+ /**
+ * @param keyInfos the keyInfos to set
+ */
+ public void setKeyInfos(Collection<KeyDataInfo> keyInfos) {
+ this.keyInfos = keyInfos;
+ }
+ /**
+ * @return the links
+ */
+ @XmlElementRef
+ public List<Link> getLinks() {
+ return links;
+ }
+ /**
+ * @param links the links to set
+ */
+ public void setLinks(List<Link> links) {
+ this.links = links;
+ }
+
+ @XmlTransient
+ public String getNext() {
+ if (links == null) {
+ return null;
+ }
+ for (Link link : links) {
+ if ("next".equals(link.getRelationship())) {
+ return link.getHref();
+ }
+ }
+ return null;
+ }
+
+ @XmlTransient
+ public String getPrevious() {
+ if (links == null) {
+ return null;
+ }
+ for (Link link : links) {
+ if ("previous".equals(link.getRelationship())) {
+ return link.getHref();
+ }
+ }
+ return null;
+ }
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java b/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java
new file mode 100644
index 000000000..d14f61241
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/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.certsrv.key;
+
+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<String, String> 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/certsrv/key/KeyRequestInfo.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
new file mode 100644
index 000000000..2a0e062e5
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
@@ -0,0 +1,61 @@
+// --- 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.certsrv.key;
+
+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.certsrv.dbs.keydb.KeyId;
+import com.netscape.certsrv.request.CMSRequestInfo;
+
+@XmlRootElement(name = "SecurityDataRequestInfo")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class KeyRequestInfo extends CMSRequestInfo {
+
+ @XmlElement
+ protected String keyURL;
+
+ public KeyRequestInfo() {
+ // required to be here for JAXB (defaults)
+ }
+
+ /**
+ * @return the keyURL
+ */
+ public String getKeyURL() {
+ return keyURL;
+ }
+
+ /**
+ * @return the key ID in the keyURL
+ */
+ public KeyId getKeyId() {
+ String id = keyURL.substring(keyURL.lastIndexOf("/") + 1);
+ return new KeyId(id);
+ }
+
+ /**
+ * @param keyURL the keyURL to set
+ */
+ public void setKeyURL(String keyURL) {
+ this.keyURL = keyURL;
+ }
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
new file mode 100644
index 000000000..67e6fdf5c
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
@@ -0,0 +1,89 @@
+// --- 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.certsrv.key;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import com.netscape.certsrv.base.Link;
+
+@XmlRootElement(name = "SecurityDataRequestInfos")
+public class KeyRequestInfos {
+ protected Collection<KeyRequestInfo> requests;
+ protected List<Link> links;
+
+ /**
+ * @return the requests
+ */
+ @XmlElementRef
+ public Collection<KeyRequestInfo> getRequests() {
+ return requests;
+ }
+
+ /**
+ * @param requests the requests to set
+ */
+ public void setRequests(Collection<KeyRequestInfo> requests) {
+ this.requests = requests;
+ }
+
+ /**
+ * @return the links
+ */
+ @XmlElementRef
+ public List<Link> getLinks() {
+ return links;
+ }
+
+ /**
+ * @param links the links to set
+ */
+ public void setLinks(List<Link> links) {
+ this.links = links;
+ }
+
+ @XmlTransient
+ public String getNext() {
+ if (links == null) {
+ return null;
+ }
+ for (Link link : links) {
+ if ("next".equals(link.getRelationship())) {
+ return link.getHref();
+ }
+ }
+ return null;
+ }
+
+ @XmlTransient
+ public String getPrevious() {
+ if (links == null) {
+ return null;
+ }
+ for (Link link : links) {
+ if ("previous".equals(link.getRelationship())) {
+ return link.getHref();
+ }
+ }
+ return null;
+ }
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
new file mode 100644
index 000000000..7fecd0610
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
@@ -0,0 +1,88 @@
+package com.netscape.certsrv.key;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import com.netscape.certsrv.request.RequestId;
+
+@Path("agent/keyrequests")
+public interface KeyRequestResource {
+
+ public final String SYMMETRIC_KEY_TYPE = "symmetricKey";
+ public final String PASS_PHRASE_TYPE = "passPhrase";
+ public final String ASYMMETRIC_KEY_TYPE = "asymmetricKey";
+
+ public static final int DEFAULT_START = 0;
+ public static final int DEFAULT_PAGESIZE = 20;
+ public static final int DEFAULT_MAXRESULTS = 100;
+ public static final int DEFAULT_MAXTIME = 10;
+
+ /**
+ * Used to generate list of key requests based on the search parameters
+ */
+ @GET
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyRequestInfos listRequests(@QueryParam("requestState") String requestState,
+ @QueryParam("requestType") String requestType,
+ @QueryParam("clientID") String clientID,
+ @DefaultValue(""+DEFAULT_START) @QueryParam("start") RequestId start,
+ @DefaultValue(""+DEFAULT_PAGESIZE) @QueryParam("pageSize") int pageSize,
+ @DefaultValue(""+DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
+ @DefaultValue(""+DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
+
+
+ /**
+ * Used to retrieve key request info for a specific request
+ */
+ @GET
+ @Path("{id}")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyRequestInfo getRequestInfo(@PathParam("id") RequestId id);
+
+ // Archiving - used to test integration with a browser
+ @POST
+ @Path("archive")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED})
+ public KeyRequestInfo archiveKey(MultivaluedMap<String, String> form);
+
+ @POST
+ @Path("archive")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyRequestInfo archiveKey(KeyArchivalRequest data);
+
+ //Recovery - used to test integration with a browser
+ @POST
+ @Path("recover")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED})
+ public KeyRequestInfo recoverKey(MultivaluedMap<String, String> form);
+
+ @POST
+ @Path("recover")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyRequestInfo recoverKey(KeyRecoveryRequest data);
+
+ @POST
+ @Path("{id}/approve")
+ public void approveRequest(@PathParam("id") RequestId id);
+
+ @POST
+ @Path("{id}/reject")
+ public void rejectRequest(@PathParam("id") RequestId id);
+
+ @POST
+ @Path("{id}/cancel")
+ public void cancelRequest(@PathParam("id") RequestId id);
+
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyResource.java b/base/common/src/com/netscape/certsrv/key/KeyResource.java
new file mode 100644
index 000000000..a499ca11f
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyResource.java
@@ -0,0 +1,45 @@
+package com.netscape.certsrv.key;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+
+@Path("agent/keys")
+public interface KeyResource {
+
+ public static final int DEFAULT_MAXTIME = 10;
+ public static final int DEFAULT_MAXRESULTS = 100;
+
+ @GET
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyDataInfos listKeys(@QueryParam("clientID") String clientID,
+ @QueryParam("status") String status,
+ @DefaultValue(""+DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
+ @DefaultValue(""+DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
+
+
+ /**
+ * Used to retrieve a key
+ * @param data
+ * @return
+ */
+ @POST
+ @Path("retrieve")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public KeyData retrieveKey(KeyRecoveryRequest data);
+
+ // retrieval - used to test integration with a browser
+ @POST
+ @Path("retrieve")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
+ public KeyData retrieveKey(MultivaluedMap<String, String> form);
+}