summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/servlet/request/model
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/request/model')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java123
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java138
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java101
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java122
4 files changed, 484 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java b/pki/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.java
new file mode 100644
index 000000000..8a25c6684
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/model/ArchivalRequestData.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.cms.servlet.request.model;
+
+import javax.ws.rs.core.MultivaluedMap;
+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="SecurityDataArchivalRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ArchivalRequestData {
+
+ 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 ArchivalRequestData() {
+ // required for JAXB (defaults)
+ }
+
+ public ArchivalRequestData(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/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java b/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java
new file mode 100644
index 000000000..b15e17c6d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java
@@ -0,0 +1,138 @@
+// --- 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.cms.servlet.request.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.kra.IKeyRecoveryAuthority;
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.IRequestList;
+import com.netscape.certsrv.request.IRequestQueue;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestStatus;
+
+/**
+ * @author alee
+ *
+ */
+public class KeyRequestDAO {
+ private IRequestQueue queue;
+
+ public KeyRequestDAO() {
+ IKeyRecoveryAuthority kra = null;
+ kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( "kra" );
+ queue = kra.getRequestQueue();
+ }
+
+ /**
+ * This will find the requests in the database matching the specified search parameters
+ * Needs input validation and probably paging, maybe using the vlv functions
+ * @throws EBaseException
+ */
+ public List<KeyRequestInfo> listRequests(String filter, UriInfo uriInfo) throws EBaseException {
+ List <KeyRequestInfo> list = new ArrayList<KeyRequestInfo>();
+ IRequestList requests = queue.listRequestsByFilter(filter);
+ while (requests.hasMoreElements()) {
+ RequestId rid = (RequestId) requests.nextElement();
+ IRequest request;
+ request = queue.findRequest(rid);
+ list.add(createKeyRequestInfo(request, uriInfo));
+ }
+ return list;
+ }
+
+ /**
+ * Gets info for a specific request
+ * @param id
+ * @return info for specific request
+ * @throws EBaseException
+ */
+ public KeyRequestInfo getRequest(String id, UriInfo uriInfo) throws EBaseException {
+ IRequest request = queue.findRequest(new RequestId(id));
+ if (request == null) {
+ return null;
+ }
+ KeyRequestInfo info = createKeyRequestInfo(request, uriInfo);
+ return info;
+ }
+ /**
+ * Submits an archival request and processes it.
+ * @param data
+ * @return info for the request submitted.
+ * @throws EBaseException
+ */
+ public KeyRequestInfo submitRequest(ArchivalRequestData data, UriInfo uriInfo) throws EBaseException {
+ IRequest request = queue.newRequest(IRequest.SECURITY_DATA_ENROLLMENT_REQUEST);
+ //TODO :
+ //set data using request.setExtData(field, data)
+ queue.processRequest(request);
+ return createKeyRequestInfo(request, uriInfo);
+ }
+ /**
+ * Submits a key recovery request.
+ * @param data
+ * @return info on the recovery request created
+ * @throws EBaseException
+ */
+ public KeyRequestInfo submitRequest(RecoveryRequestData data, UriInfo uriInfo) throws EBaseException {
+ IRequest request = queue.newRequest(IRequest.SECURITY_DATA_RECOVERY_REQUEST);
+ // set data using request.setExtData(field, data)
+ queue.processRequest(request);
+ return createKeyRequestInfo(request, uriInfo);
+ }
+
+ public void approveRequest(String id) throws EBaseException {
+ IRequest request = queue.findRequest(new RequestId(id));
+ request.setRequestStatus(RequestStatus.APPROVED);
+ }
+
+ public void rejectRequest(String id) throws EBaseException {
+ IRequest request = queue.findRequest(new RequestId(id));
+ request.setRequestStatus(RequestStatus.CANCELED);
+ }
+
+ public void cancelRequest(String id) throws EBaseException {
+ IRequest request = queue.findRequest(new RequestId(id));
+ request.setRequestStatus(RequestStatus.REJECTED);
+ }
+
+ public KeyRequestInfo createKeyRequestInfo(IRequest request, UriInfo uriInfo) {
+ KeyRequestInfo ret = new KeyRequestInfo();
+
+ ret.setRequestType(request.getRequestType());
+ ret.setRequestStatus(request.getRequestStatus().toString());
+
+ String rid = request.getRequestId().toString();
+ UriBuilder reqBuilder = uriInfo.getBaseUriBuilder();
+ reqBuilder.path("/keyrequest/" + rid);
+ ret.setRequestURL(reqBuilder.build().toString());
+
+ String kid = request.getExtDataInString("keyrecord");
+ UriBuilder keyBuilder = uriInfo.getBaseUriBuilder();
+ keyBuilder.path("/key/" + kid);
+ ret.setKeyURL(keyBuilder.build().toString());
+
+ return ret;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java b/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java
new file mode 100644
index 000000000..d768e2ba9
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java
@@ -0,0 +1,101 @@
+// --- 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.cms.servlet.request.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+@XmlRootElement(name="SecurityDataRequestInfo")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class KeyRequestInfo {
+
+ @XmlElement
+ protected String requestType;
+
+ @XmlElement
+ protected String requestStatus;
+
+ @XmlElement
+ protected String requestURL;
+
+ @XmlElement
+ protected String keyURL;
+
+ public KeyRequestInfo(){
+ // required to be here for JAXB (defaults)
+ }
+
+ /**
+ * @return the requestType
+ */
+ public String getRequestType() {
+ return requestType;
+ }
+
+ /**
+ * @param requestType the requestType to set
+ */
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ /**
+ * @return the requestStatus
+ */
+ public String getRequestStatus() {
+ return requestStatus;
+ }
+
+ /**
+ * @param requestStatus the requestStatus to set
+ */
+ public void setRequestStatus(String requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ /**
+ * @return the requestURL
+ */
+ public String getRequestURL() {
+ return requestURL;
+ }
+
+ /**
+ * @param requestURL the requestURL to set
+ */
+ public void setRequestURL(String requestURL) {
+ this.requestURL = requestURL;
+ }
+
+ /**
+ * @return the keyURL
+ */
+ public String getKeyURL() {
+ return keyURL;
+ }
+
+ /**
+ * @param keyURL the keyURL to set
+ */
+ public void setKeyURL(String keyURL) {
+ this.keyURL = keyURL;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java b/pki/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java
new file mode 100644
index 000000000..88533a38d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/model/RecoveryRequestData.java
@@ -0,0 +1,122 @@
+// --- 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.cms.servlet.request.model;
+
+import javax.ws.rs.core.MultivaluedMap;
+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="SecurityDataRecoveryRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RecoveryRequestData {
+
+ 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 TRANS_WRAPPED_PASSPHRASE = "transWrappedPassphrase";
+
+ @XmlElement
+ protected String keyId;
+
+ @XmlElement
+ protected String requestId;
+
+ @XmlElement
+ protected String transWrappedSessionKey;
+
+ @XmlElement
+ protected String transWrappedPassphrase;
+
+ public RecoveryRequestData() {
+ // required for JAXB (defaults)
+ }
+
+ public RecoveryRequestData(MultivaluedMap<String, String> form) {
+ keyId = form.getFirst(KEY_ID);
+ requestId = form.getFirst(REQUEST_ID);
+ transWrappedSessionKey = form.getFirst(TRANS_WRAPPED_SESSION_KEY);
+ transWrappedPassphrase = form.getFirst(TRANS_WRAPPED_PASSPHRASE);
+ }
+
+ /**
+ * @return the keyId
+ */
+ public String getKeyId() {
+ return keyId;
+ }
+
+ /**
+ * @param keyId the keyId to set
+ */
+ public void setKeyId(String keyId) {
+ this.keyId = keyId;
+ }
+
+ /**
+ * @return the requestId
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * @param requestId the requestId to set
+ */
+ public void setRequestId(String 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 transWrappedPassphrase
+ */
+ public String getTransWrappedPassphrase() {
+ return transWrappedPassphrase;
+ }
+
+ /**
+ * @param transWrappedPassphrase the transWrappedPassphrase to set
+ */
+ public void setTransWrappedPassphrase(String transWrappedPassphrase) {
+ this.transWrappedPassphrase = transWrappedPassphrase;
+ }
+
+}