From 1aa02e5207514d210e903d23e1d698b85fc29344 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Sat, 11 Aug 2012 09:47:39 -0500 Subject: Reorganized REST common classes. The common classes used by REST client and services have been moved into the com.netscape.certsrv. packages. Ticket #215 --- .../netscape/certsrv/key/KeyArchivalRequest.java | 123 ++++++++++++++++ .../src/com/netscape/certsrv/key/KeyData.java | 76 ++++++++++ .../src/com/netscape/certsrv/key/KeyDataInfo.java | 85 +++++++++++ .../src/com/netscape/certsrv/key/KeyDataInfos.java | 87 ++++++++++++ .../netscape/certsrv/key/KeyRecoveryRequest.java | 155 +++++++++++++++++++++ .../com/netscape/certsrv/key/KeyRequestInfo.java | 61 ++++++++ .../com/netscape/certsrv/key/KeyRequestInfos.java | 89 ++++++++++++ .../netscape/certsrv/key/KeyRequestResource.java | 88 ++++++++++++ .../src/com/netscape/certsrv/key/KeyResource.java | 45 ++++++ 9 files changed, 809 insertions(+) create mode 100644 base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyData.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyDataInfo.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyDataInfos.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyRequestResource.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyResource.java (limited to 'base/common/src/com/netscape/certsrv/key') 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 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 keyInfos; + protected List links; + + /** + * @return the keyInfos + */ + @XmlElementRef + public Collection getKeyInfos() { + return keyInfos; + } + /** + * @param keyInfos the keyInfos to set + */ + public void setKeyInfos(Collection keyInfos) { + this.keyInfos = keyInfos; + } + /** + * @return the links + */ + @XmlElementRef + public List getLinks() { + return links; + } + /** + * @param links the links to set + */ + public void setLinks(List 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 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 requests; + protected List links; + + /** + * @return the requests + */ + @XmlElementRef + public Collection getRequests() { + return requests; + } + + /** + * @param requests the requests to set + */ + public void setRequests(Collection requests) { + this.requests = requests; + } + + /** + * @return the links + */ + @XmlElementRef + public List getLinks() { + return links; + } + + /** + * @param links the links to set + */ + public void setLinks(List 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 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 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 form); +} -- cgit