summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/request/model
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/request/model')
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CMSRequestDAO.java166
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfo.java69
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfos.java59
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java207
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfo.java81
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfos.java89
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java78
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java202
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java147
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java68
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java67
11 files changed, 1066 insertions, 167 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestDAO.java b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestDAO.java
new file mode 100644
index 000000000..5ac984168
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestDAO.java
@@ -0,0 +1,166 @@
+// --- 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.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.authority.IAuthority;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.IRequestList;
+import com.netscape.certsrv.request.IRequestQueue;
+import com.netscape.certsrv.request.IRequestVirtualList;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.cms.servlet.base.model.Link;
+
+/**
+ * @author alee
+ *
+ */
+
+public abstract class CMSRequestDAO {
+ protected IRequestQueue queue;
+ protected IAuthority authority;
+
+ private String[] vlvFilters = {
+ "(requeststate=*)", "(requesttype=enrollment)",
+ "(requesttype=recovery)", "(requeststate=canceled)",
+ "(&(requeststate=canceled)(requesttype=enrollment))",
+ "(&(requeststate=canceled)(requesttype=recovery))",
+ "(requeststate=rejected)",
+ "(&(requeststate=rejected)(requesttype=enrollment))",
+ "(&(requeststate=rejected)(requesttype=recovery))",
+ "(requeststate=complete)",
+ "(&(requeststate=complete)(requesttype=enrollment))",
+ "(&(requeststate=complete)(requesttype=recovery))"
+ };
+
+ public static final String ATTR_SERIALNO = "serialNumber";
+
+ public CMSRequestDAO(String authorityName) {
+ authority = (IAuthority) CMS.getSubsystem(authorityName);
+ queue = authority.getRequestQueue();
+ }
+
+ /**
+ * Finds list of requests matching the specified search filter.
+ *
+ * If the filter corresponds to a VLV search, then that search is executed and the pageSize
+ * and start parameters are used. Otherwise, the maxResults and maxTime parameters are
+ * used in the regularly indexed search.
+ *
+ * @param filter - ldap search filter
+ * @param start - start position for VLV search
+ * @param pageSize - page size for VLV search
+ * @param maxResults - max results to be returned in normal search
+ * @param maxTime - max time for normal search
+ * @param uriInfo - uri context of request
+ * @return collection of key request info
+ * @throws EBaseException
+ */
+ public CMSRequestInfos listCMSRequests(String filter, RequestId start, int pageSize, int maxResults, int maxTime,
+ UriInfo uriInfo) throws EBaseException {
+ List<CMSRequestInfo> list = new ArrayList<CMSRequestInfo>();
+ List<Link> links = new ArrayList<Link>();
+ int totalSize = 0;
+ int current = 0;
+
+ if (isVLVSearch(filter)) {
+ IRequestVirtualList vlvlist = queue.getPagedRequestsByFilter(start, false, filter,
+ pageSize + 1, "requestId");
+ totalSize = vlvlist.getSize();
+ current = vlvlist.getCurrentIndex();
+
+ int numRecords = (totalSize > (current + pageSize)) ? pageSize :
+ totalSize - current;
+
+ for (int i = 0; i < numRecords; i++) {
+ IRequest request = vlvlist.getElementAt(i);
+ list.add(createCMSRequestInfo(request, uriInfo));
+ }
+ } else {
+ // The non-vlv requests are indexed, but are not paginated.
+ // We should think about whether they should be, or if we need to
+ // limit the number of results returned.
+ IRequestList requests = queue.listRequestsByFilter(filter, maxResults, maxTime);
+
+ if (requests == null) {
+ return null;
+ }
+ while (requests.hasMoreElements()) {
+ RequestId rid = requests.nextElement();
+ IRequest request = queue.findRequest(rid);
+ if (request != null) {
+ list.add(createCMSRequestInfo(request, uriInfo));
+ }
+ }
+ }
+
+ // builder for vlv links
+ MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
+ UriBuilder builder = uriInfo.getAbsolutePathBuilder();
+ if (params.containsKey("requestState")) {
+ builder.queryParam("requestState", params.getFirst("requestState"));
+ }
+ if (params.containsKey("requestType")) {
+ builder.queryParam("requestType", params.getFirst("requestType"));
+ }
+ builder.queryParam("start", "{start}");
+ builder.queryParam("pageSize", "{pageSize}");
+
+ // next link
+ if (totalSize > current + pageSize) {
+ int next = current + pageSize + 1;
+ URI nextUri = builder.clone().build(next, pageSize);
+ Link nextLink = new Link("next", nextUri.toString(), "application/xml");
+ links.add(nextLink);
+ }
+
+ // previous link
+ if (current > 0) {
+ int previous = current - pageSize;
+ URI previousUri = builder.clone().build(previous, pageSize);
+ Link previousLink = new Link("previous", previousUri.toString(), "application/xml");
+ links.add(previousLink);
+ }
+
+ CMSRequestInfos ret = new CMSRequestInfos();
+ ret.setRequests(list);
+ ret.setLinks(links);
+ return ret;
+ }
+
+ private boolean isVLVSearch(String filter) {
+ for (int i = 0; i < vlvFilters.length; i++) {
+ if (vlvFilters[i].equalsIgnoreCase(filter)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ abstract CMSRequestInfo createCMSRequestInfo(IRequest request, UriInfo uriInfo);
+}
+
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfo.java b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfo.java
new file mode 100644
index 000000000..b86b39fbd
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfo.java
@@ -0,0 +1,69 @@
+package com.netscape.cms.servlet.request.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+import com.netscape.certsrv.request.RequestId;
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CMSRequestInfo {
+ @XmlElement
+ protected String requestType;
+
+ @XmlElement
+ protected String requestStatus;
+
+ @XmlElement
+ protected String requestURL;
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @return the request ID in the requestURL
+ */
+ public RequestId getRequestId() {
+ String id = requestURL.substring(requestURL.lastIndexOf("/") + 1);
+ return new RequestId(id);
+ }
+
+ /**
+ * @param requestURL the requestURL to set
+ */
+ public void setRequestURL(String requestURL) {
+ this.requestURL = requestURL;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfos.java b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfos.java
new file mode 100644
index 000000000..63b2e56b1
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CMSRequestInfos.java
@@ -0,0 +1,59 @@
+//--- 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.Collection;
+import java.util.List;
+
+import com.netscape.cms.servlet.base.model.Link;
+
+//Convenience class to simply hold a Collection of CMSRequests and a List of Links.
+public class CMSRequestInfos {
+
+ protected Collection<CMSRequestInfo> requests;
+ protected List<Link> links;
+
+ /**
+ * @return the requests
+ */
+ public Collection<CMSRequestInfo> getRequests() {
+ return requests;
+ }
+
+ /**
+ * @param requests the requests to set
+ */
+ public void setRequests(Collection<CMSRequestInfo> requests) {
+ this.requests = requests;
+ }
+
+ /**
+ * @return the links
+ */
+ public List<Link> getLinks() {
+ return links;
+ }
+
+ /**
+ * @param links the links to set
+ */
+ public void setLinks(List<Link> links) {
+ this.links = links;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java
new file mode 100644
index 000000000..1d7f8aeae
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestDAO.java
@@ -0,0 +1,207 @@
+// --- 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.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import netscape.security.x509.X509CertImpl;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.ca.ICertificateAuthority;
+import com.netscape.certsrv.profile.IEnrollProfile;
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.IRequestQueue;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestStatus;
+import com.netscape.cms.servlet.cert.CertResource;
+import com.netscape.cms.servlet.request.CertRequestResource;
+
+/**
+ * @author alee
+ *
+ */
+public class CertRequestDAO extends CMSRequestDAO {
+ private IRequestQueue queue;
+ private ICertificateAuthority ca;
+
+ public static final String ATTR_SERIALNO = "serialNumber";
+ private static final String REQ_COMPLETE = "complete";
+
+ public CertRequestDAO() {
+
+ super("ca");
+ ca = (ICertificateAuthority) CMS.getSubsystem("ca");
+ queue = ca.getRequestQueue();
+
+ }
+
+ /**
+ * Finds list of requests matching the specified search filter.
+ *
+ * If the filter corresponds to a VLV search, then that search is executed and the pageSize
+ * and start parameters are used. Otherwise, the maxResults and maxTime parameters are
+ * used in the regularly indexed search.
+ *
+ * @param filter - ldap search filter
+ * @param start - start position for VLV search
+ * @param pageSize - page size for VLV search
+ * @param maxResults - max results to be returned in normal search
+ * @param maxTime - max time for normal search
+ * @param uriInfo - uri context of request
+ * @return collection of key request info
+ * @throws EBaseException
+ */
+
+ @SuppressWarnings("unchecked")
+ public CertRequestInfos listRequests(String filter, RequestId start, int pageSize, int maxResults, int maxTime,
+ UriInfo uriInfo) throws EBaseException {
+
+ CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
+
+ CertRequestInfos ret = new CertRequestInfos();
+
+ if (cmsInfos == null) {
+ ret.setRequests(null);
+ ret.setLinks(null);
+ return ret;
+ }
+
+ List<CertRequestInfo> list = new ArrayList<CertRequestInfo>();
+ ;
+ Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getRequests();
+
+ // We absolutely know 100% that this list is a list
+ // of CertRequestInfo objects. This is because the method
+ // createCMSRequestInfo. Is the only one adding to it
+
+ list = (List<CertRequestInfo>) cmsList;
+
+ ret.setLinks(cmsInfos.getLinks());
+ ret.setRequests(list);
+
+ return ret;
+ }
+
+ /**
+ * Gets info for a specific request
+ *
+ * @param id
+ * @return info for specific request
+ * @throws EBaseException
+ */
+ public CertRequestInfo getRequest(RequestId id, UriInfo uriInfo) throws EBaseException {
+ IRequest request = queue.findRequest(id);
+ if (request == null) {
+ return null;
+ }
+ CertRequestInfo info = createCMSRequestInfo(request, uriInfo);
+ return info;
+ }
+
+ /**
+ * Submits an enrollment request and processes it.
+ *
+ * @param data
+ * @return info for the request submitted.
+ * @throws EBaseException
+ */
+ public CertRequestInfo submitRequest(EnrollmentRequestData data, UriInfo uriInfo) throws EBaseException {
+
+ //TODO perform actual profile request.
+
+ throw new EBaseException("Not implemented.");
+ }
+
+ public void approveRequest(RequestId id) throws EBaseException {
+ IRequest request = queue.findRequest(id);
+ request.setRequestStatus(RequestStatus.APPROVED);
+ queue.updateRequest(request);
+ }
+
+ public void rejectRequest(RequestId id) throws EBaseException {
+ IRequest request = queue.findRequest(id);
+ request.setRequestStatus(RequestStatus.CANCELED);
+ queue.updateRequest(request);
+ }
+
+ public void cancelRequest(RequestId id) throws EBaseException {
+ IRequest request = queue.findRequest(id);
+ request.setRequestStatus(RequestStatus.REJECTED);
+ queue.updateRequest(request);
+ }
+
+ private CertRequestInfo createCertRequestInfo(IRequest request, UriInfo uriInfo) {
+ CertRequestInfo ret = new CertRequestInfo();
+
+ String requestType = request.getRequestType();
+ String requestStatus = request.getRequestStatus().toString();
+
+ ret.setRequestType(requestType);
+ ret.setRequestStatus(requestStatus);
+
+ ret.setCertRequestType(request.getExtDataInString("cert_request_type"));
+
+ Path certRequestPath = CertRequestResource.class.getAnnotation(Path.class);
+ RequestId rid = request.getRequestId();
+
+ UriBuilder reqBuilder = uriInfo.getBaseUriBuilder();
+ reqBuilder.path(certRequestPath.value() + "/" + rid);
+ ret.setRequestURL(reqBuilder.build().toString());
+
+ //Get Cert info if issued.
+
+ String serialNoStr = null;
+
+ if ((requestType != null) && (requestStatus != null)) {
+ if (requestStatus.equals(REQ_COMPLETE)) {
+ X509CertImpl impl[] = new X509CertImpl[1];
+ impl[0] = request.getExtDataInCert(IEnrollProfile.REQUEST_ISSUED_CERT);
+
+ BigInteger serialNo;
+ if (impl[0] != null) {
+ serialNo = impl[0].getSerialNumber();
+ serialNoStr = serialNo.toString();
+ }
+ }
+
+ }
+
+ if (serialNoStr != null && !serialNoStr.equals("")) {
+ Path certPath = CertResource.class.getAnnotation(Path.class);
+ UriBuilder certBuilder = uriInfo.getBaseUriBuilder();
+ certBuilder.path(certPath.value() + "/" + serialNoStr);
+ ret.setCertURL(certBuilder.build().toString());
+ }
+
+ return ret;
+ }
+
+ @Override
+ public CertRequestInfo createCMSRequestInfo(IRequest request, UriInfo uriInfo) {
+ return createCertRequestInfo(request, uriInfo);
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfo.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfo.java
new file mode 100644
index 000000000..25083126d
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfo.java
@@ -0,0 +1,81 @@
+// --- 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.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.netscape.certsrv.dbs.certdb.CertId;
+
+@XmlRootElement(name = "CertRequestInfo")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CertRequestInfo extends CMSRequestInfo {
+
+ @XmlElement
+ protected String certURL;
+
+ @XmlElement
+ protected String certRequestType;
+
+ public CertRequestInfo() {
+ // required to be here for JAXB (defaults)
+ }
+
+ /**
+ * @param certRequestType to set
+ */
+
+ public void setCertRequestType(String certRequestType) {
+ this.certRequestType = certRequestType;
+ }
+
+ /**
+ * @return the certRequestType
+ */
+
+ public String getCertRequestType() {
+ return certRequestType;
+ }
+
+ /**
+ * @set the certURL
+ */
+ public void setCertURL(String certURL) {
+ this.certURL = certURL;
+ }
+
+ /**
+ * @return the certURL
+ */
+ public String getCertURL() {
+ return certURL;
+ }
+
+ /**
+ * @return the certId
+ */
+
+ public CertId getCertId() {
+ String id = certURL.substring(certURL.lastIndexOf("/") + 1);
+ return new CertId(id);
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfos.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfos.java
new file mode 100644
index 000000000..a4c39a33e
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRequestInfos.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.cms.servlet.request.model;
+
+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.cms.servlet.base.model.Link;
+
+@XmlRootElement(name = "CertRequestInfos")
+public class CertRequestInfos {
+ protected Collection<CertRequestInfo> requests;
+ protected List<Link> links;
+
+ /**
+ * @return the requests
+ */
+ @XmlElementRef
+ public Collection<CertRequestInfo> getRequests() {
+ return requests;
+ }
+
+ /**
+ * @param requests the requests to set
+ */
+ public void setRequests(Collection<CertRequestInfo> 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/cms/servlet/request/model/CertRetrievalRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java
new file mode 100644
index 000000000..72e437c17
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/CertRetrievalRequestData.java
@@ -0,0 +1,78 @@
+// --- 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.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.certdb.CertId;
+import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestIdAdapter;
+
+/**
+ * @author alee
+ *
+ */
+@XmlRootElement(name = "CertRetrievalRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CertRetrievalRequestData {
+
+ private static final String CERT_ID = "certId";
+
+ @XmlElement
+ @XmlJavaTypeAdapter(CertIdAdapter.class)
+ protected CertId certId;
+
+ @XmlElement
+ @XmlJavaTypeAdapter(RequestIdAdapter.class)
+ protected RequestId requestId;
+
+ public CertRetrievalRequestData() {
+ // required for JAXB (defaults)
+ }
+
+ public CertRetrievalRequestData(MultivaluedMap<String, String> form) {
+ if (form.containsKey(CERT_ID)) {
+ certId = new CertId(form.getFirst(CERT_ID));
+ }
+ }
+
+ /**
+ * @return the CertId
+ */
+ public CertId getCertId() {
+ return certId;
+ }
+
+ /**
+ * @param CertId the CertId to set
+ */
+ public void setCertId(CertId certId) {
+ this.certId = certId;
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java
new file mode 100644
index 000000000..f2979ebce
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/EnrollmentRequestData.java
@@ -0,0 +1,202 @@
+// --- 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.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+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.cms.servlet.profile.model.ProfileInput;
+
+/**
+ * @author jmagne
+ *
+ */
+
+@XmlRootElement(name = "EnrollmentRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class EnrollmentRequestData {
+
+ private static final String PROFILE_ID = "profileId";
+ private static final String RENEWAL = "renewal";
+
+ @XmlElement
+ protected String profileId;
+
+ @XmlElement
+ protected boolean isRenewal;
+
+ @XmlElement(name = "Input")
+ protected List<ProfileInput> inputs = new ArrayList<ProfileInput>();
+
+ public EnrollmentRequestData() {
+ }
+
+ public EnrollmentRequestData(MultivaluedMap<String, String> form) {
+ profileId = form.getFirst(PROFILE_ID);
+ String renewalStr = form.getFirst(RENEWAL);
+
+ isRenewal = new Boolean(renewalStr);
+
+ }
+
+ /**
+ * @return the profileId
+ */
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /**
+ * @param profileId the profileId to set
+ */
+
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
+
+ /**
+ * @return renewal
+ */
+
+ public boolean getIsRenewal() {
+ return isRenewal;
+ }
+
+ public ProfileInput addInput(String name) {
+
+ ProfileInput oldInput = getInput(name);
+
+ if (oldInput != null)
+ return oldInput;
+
+ ProfileInput newInput = new ProfileInput();
+ newInput.setInputId(name);
+
+ inputs.add(newInput);
+
+ return newInput;
+ }
+
+ public ProfileInput getInput(String name) {
+
+ ProfileInput input = null;
+
+ Iterator<ProfileInput> it = inputs.iterator();
+
+ ProfileInput curInput = null;
+ while (it.hasNext())
+
+ {
+ curInput = it.next();
+
+ if (curInput != null && curInput.getInputId().equals(name))
+ break;
+ }
+
+ return input;
+ }
+
+ /**
+ * @param renewal the renewal to set
+ */
+ public void setIsRenewal(boolean isRenewal) {
+ this.isRenewal = isRenewal;
+ }
+
+ public static void main(String args[]) throws Exception {
+ EnrollmentRequestData data = new EnrollmentRequestData();
+ data.setProfileId("caUserCert");
+ data.setIsRenewal(false);
+
+ //Simulate a "caUserCert" Profile enrollment
+
+ ProfileInput certReq = data.addInput("KeyGenInput");
+ certReq.setInputAttr("cert_request_type", "crmf");
+ certReq.setInputAttr(
+ "cert_request",
+ "MIIBozCCAZ8wggEFAgQBMQp8MIHHgAECpQ4wDDEKMAgGA1UEAxMBeKaBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2NgaPHp0jiohcP4M+ufrJOZEqH8GV+liu5JLbT8nWpkfhC+8EUBqT6g+n3qroSxIcNVGNdcsBEqs1utvpItzyslAbpdyat3WwQep1dWMzo6RHrPDuIoxNA0Yka1n3qEX4U//08cLQtUv2bYglYgN/hOCNQemLV6vZWAv0n7zelkCAwEAAakQMA4GA1UdDwEB/wQEAwIF4DAzMBUGCSsGAQUFBwUBAQwIcmVnVG9rZW4wGgYJKwYBBQUHBQECDA1hdXRoZW50aWNhdG9yoYGTMA0GCSqGSIb3DQEBBQUAA4GBAJ1VOQcaSEhdHa94s8kifVbSZ2WZeYE5//qxL6wVlEst20vq4ybj13CetnbN3+WT49Zkwp7Fg+6lALKgSk47suTg3EbbQDm+8yOrC0nc/q4PTRoHl0alMmUxIhirYc1t3xoCMqJewmjX1bNP8lpVIZAYFZo4eZCpZaiSkM5BeHhz");
+
+ ProfileInput subjectName = data.addInput("SubjectNameInput");
+ subjectName.setInputAttr("sn_uid", "jmagne");
+ subjectName.setInputAttr("sn_e", "jmagne@redhat.com");
+ subjectName.setInputAttr("sn_c", "US");
+ subjectName.setInputAttr("sn_ou", "Development");
+ subjectName.setInputAttr("sn_ou1", "IPA");
+ subjectName.setInputAttr("sn_ou2", "Dogtag");
+ subjectName.setInputAttr("sn_ou3", "CA");
+ subjectName.setInputAttr("sn_cn", "Common");
+ subjectName.setInputAttr("sn_o", "RedHat");
+
+ ProfileInput submitter = data.addInput("SubmitterInfoInput");
+ submitter.setInputAttr("requestor_name", "admin");
+ submitter.setInputAttr("requestor_email", "admin@redhat.com");
+ submitter.setInputAttr("requestor_phone", "650-555-5555");
+
+ try {
+ JAXBContext context = JAXBContext.newInstance(EnrollmentRequestData.class);
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+
+ marshaller.marshal(data, stream);
+
+ System.out.println("Originally marshalled enrollment object. \n");
+
+ System.out.println(stream.toString());
+
+ //Try to unmarshall
+
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(stream.toByteArray());
+ Object unmarshalled = unmarshaller.unmarshal(bais);
+
+ //Try re-marshalling, unmarshalled object to compare
+
+ stream.reset();
+
+ marshaller.marshal(unmarshalled, stream);
+
+ System.out.println("Remarshalled unmarshalled enrollment object. \n");
+
+ System.out.println(stream.toString());
+
+ } catch (JAXBException e) {
+ System.out.println(e.toString());
+ }
+ }
+
+}
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java
index aaea45398..9def75248 100644
--- a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java
+++ b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestDAO.java
@@ -17,13 +17,12 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.request.model;
-import java.net.URI;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import javax.ws.rs.Path;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
@@ -31,54 +30,34 @@ import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.dbs.keydb.KeyId;
import com.netscape.certsrv.kra.IKeyRecoveryAuthority;
+import com.netscape.certsrv.profile.IEnrollProfile;
import com.netscape.certsrv.request.IRequest;
-import com.netscape.certsrv.request.IRequestList;
-import com.netscape.certsrv.request.IRequestQueue;
-import com.netscape.certsrv.request.IRequestVirtualList;
import com.netscape.certsrv.request.RequestId;
import com.netscape.certsrv.request.RequestStatus;
-import com.netscape.cms.servlet.base.model.Link;
import com.netscape.cms.servlet.key.KeyResource;
import com.netscape.cms.servlet.key.model.KeyDAO;
import com.netscape.cms.servlet.key.model.KeyDataInfos;
-import com.netscape.certsrv.profile.IEnrollProfile;
import com.netscape.cms.servlet.request.KeyRequestResource;
/**
* @author alee
*
*/
-public class KeyRequestDAO {
- private IRequestQueue queue;
- private IKeyRecoveryAuthority kra;
+public class KeyRequestDAO extends CMSRequestDAO {
private static String REQUEST_ARCHIVE_OPTIONS = IEnrollProfile.REQUEST_ARCHIVE_OPTIONS;
- private String[] vlvFilters = {
- "(requeststate=*)", "(requesttype=enrollment)",
- "(requesttype=recovery)", "(requeststate=canceled)",
- "(&(requeststate=canceled)(requesttype=enrollment))",
- "(&(requeststate=canceled)(requesttype=recovery))",
- "(requeststate=rejected)",
- "(&(requeststate=rejected)(requesttype=enrollment))",
- "(&(requeststate=rejected)(requesttype=recovery))",
- "(requeststate=complete)",
- "(&(requeststate=complete)(requesttype=enrollment))",
- "(&(requeststate=complete)(requesttype=recovery))"
- };
-
public static final String ATTR_SERIALNO = "serialNumber";
public KeyRequestDAO() {
- kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( "kra" );
- queue = kra.getRequestQueue();
+ super("kra");
}
/**
* Finds list of requests matching the specified search filter.
*
* If the filter corresponds to a VLV search, then that search is executed and the pageSize
- * and start parameters are used. Otherwise, the maxResults and maxTime parameters are
+ * and start parameters are used. Otherwise, the maxResults and maxTime parameters are
* used in the regularly indexed search.
*
* @param filter - ldap search filter
@@ -90,80 +69,39 @@ public class KeyRequestDAO {
* @return collection of key request info
* @throws EBaseException
*/
+ @SuppressWarnings("unchecked")
public KeyRequestInfos listRequests(String filter, RequestId start, int pageSize, int maxResults, int maxTime,
UriInfo uriInfo) throws EBaseException {
- List <KeyRequestInfo> list = new ArrayList<KeyRequestInfo>();
- List <Link> links = new ArrayList<Link>();
- int totalSize = 0;
- int current = 0;
-
- if (isVLVSearch(filter)) {
- IRequestVirtualList vlvlist = queue.getPagedRequestsByFilter(start, false, filter,
- pageSize +1 , "requestId");
- totalSize = vlvlist.getSize();
- current = vlvlist.getCurrentIndex();
-
- int numRecords = (totalSize > (current + pageSize)) ? pageSize :
- totalSize - current;
-
- for (int i=0; i < numRecords; i++) {
- IRequest request = vlvlist.getElementAt(i);
- list.add(createKeyRequestInfo(request, uriInfo));
- }
- } else {
- // The non-vlv requests are indexed, but are not paginated.
- // We should think about whether they should be, or if we need to
- // limit the number of results returned.
- IRequestList requests = queue.listRequestsByFilter(filter, maxResults, maxTime);
-
- if (requests == null) {
- return null;
- }
- while (requests.hasMoreElements()) {
- RequestId rid = requests.nextElement();
- IRequest request = queue.findRequest(rid);
- if (request != null) {
- list.add(createKeyRequestInfo(request, uriInfo));
- }
- }
- }
- // builder for vlv links
- MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
- UriBuilder builder = uriInfo.getAbsolutePathBuilder();
- if (params.containsKey("requestState")) {
- builder.queryParam("requestState", params.getFirst("requestState"));
- }
- if (params.containsKey("requestType")) {
- builder.queryParam("requestType", params.getFirst("requestType"));
- }
- builder.queryParam("start", "{start}");
- builder.queryParam("pageSize", "{pageSize}");
-
- // next link
- if (totalSize > current + pageSize) {
- int next = current + pageSize + 1;
- URI nextUri = builder.clone().build(next,pageSize);
- Link nextLink = new Link("next", nextUri.toString(), "application/xml");
- links.add(nextLink);
- }
+ CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
+ KeyRequestInfos ret = new KeyRequestInfos();
- // previous link
- if (current >0) {
- int previous = current - pageSize;
- URI previousUri = builder.clone().build(previous,pageSize);
- Link previousLink = new Link("previous", previousUri.toString(), "application/xml");
- links.add(previousLink);
+ if (cmsInfos == null) {
+ ret.setRequests(null);
+ ret.setLinks(null);
+ return ret;
}
- KeyRequestInfos ret = new KeyRequestInfos();
+ List<KeyRequestInfo> list = new ArrayList<KeyRequestInfo>();
+ ;
+ Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getRequests();
+
+ // We absolutely know 100% that this list is a list
+ // of KeyRequestInfo objects. This is because the method
+ // createCMSRequestInfo. Is the only one adding to it
+
+ list = (List<KeyRequestInfo>) cmsList;
+
+ ret.setLinks(cmsInfos.getLinks());
ret.setRequests(list);
- ret.setLinks(links);
+
return ret;
+
}
/**
* Gets info for a specific request
+ *
* @param id
* @return info for specific request
* @throws EBaseException
@@ -176,8 +114,10 @@ public class KeyRequestDAO {
KeyRequestInfo info = createKeyRequestInfo(request, uriInfo);
return info;
}
+
/**
* Submits an archival request and processes it.
+ *
* @param data
* @return info for the request submitted.
* @throws EBaseException
@@ -205,8 +145,10 @@ public class KeyRequestDAO {
return createKeyRequestInfo(request, uriInfo);
}
+
/**
* Submits a key recovery request.
+ *
* @param data
* @return info on the recovery request created
* @throws EBaseException
@@ -224,9 +166,10 @@ public class KeyRequestDAO {
KeyId keyId = data.getKeyId();
Hashtable<String, Object> requestParams;
- requestParams = kra.createVolatileRequest(request.getRequestId());
- if(requestParams == null) {
+ requestParams = ((IKeyRecoveryAuthority) authority).createVolatileRequest(request.getRequestId());
+
+ if (requestParams == null) {
throw new EBaseException("Can not create Volatile params in submitRequest!");
}
@@ -269,7 +212,7 @@ public class KeyRequestDAO {
queue.updateRequest(request);
}
- public KeyRequestInfo createKeyRequestInfo(IRequest request, UriInfo uriInfo) {
+ private KeyRequestInfo createKeyRequestInfo(IRequest request, UriInfo uriInfo) {
KeyRequestInfo ret = new KeyRequestInfo();
ret.setRequestType(request.getRequestType());
@@ -292,13 +235,11 @@ public class KeyRequestDAO {
return ret;
}
- private boolean isVLVSearch(String filter) {
- for (int i=0; i < vlvFilters.length; i++) {
- if (vlvFilters[i].equalsIgnoreCase(filter)) {
- return true;
- }
- }
- return false;
+ @Override
+ public KeyRequestInfo createCMSRequestInfo(IRequest request, UriInfo uriInfo) {
+
+ return createKeyRequestInfo(request, uriInfo);
+
}
//We only care if the key exists or not
@@ -306,19 +247,19 @@ public class KeyRequestDAO {
boolean ret = false;
String state = "active";
- KeyDAO keys = new KeyDAO();
+ KeyDAO keys = new KeyDAO();
KeyDataInfos existingKeys;
String filter = "(&(" + IRequest.SECURITY_DATA_CLIENT_ID + "=" + clientId + ")"
- + "(" + IRequest.SECURITY_DATA_STATUS + "=" + state + "))";
+ + "(" + IRequest.SECURITY_DATA_STATUS + "=" + state + "))";
try {
- existingKeys = keys.listKeys(filter, 1, 10, uriInfo);
+ existingKeys = keys.listKeys(filter, 1, 10, uriInfo);
- if(existingKeys != null && existingKeys.getKeyInfos().size() > 0) {
+ if (existingKeys != null && existingKeys.getKeyInfos().size() > 0) {
ret = true;
}
} catch (EBaseException e) {
- ret= false;
+ ret = false;
}
return ret;
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java
index fd3be8044..91d5f8210 100644
--- a/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java
+++ b/base/common/src/com/netscape/cms/servlet/request/model/KeyRequestInfo.java
@@ -19,84 +19,24 @@
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;
+import javax.xml.bind.annotation.XmlRootElement;
import com.netscape.certsrv.dbs.keydb.KeyId;
-import com.netscape.certsrv.request.RequestId;
-@XmlRootElement(name="SecurityDataRequestInfo")
+@XmlRootElement(name = "SecurityDataRequestInfo")
@XmlAccessorType(XmlAccessType.FIELD)
-public class KeyRequestInfo {
-
- @XmlElement
- protected String requestType;
-
- @XmlElement
- protected String requestStatus;
-
- @XmlElement
- protected String requestURL;
+public class KeyRequestInfo extends CMSRequestInfo {
@XmlElement
protected String keyURL;
- public KeyRequestInfo(){
+ 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;
- }
-
- /**
- * @return the request ID in the requestURL
- */
- public RequestId getRequestId() {
- String id = requestURL.substring(requestURL.lastIndexOf("/") + 1);
- return new RequestId(id);
- }
-
- /**
- * @param requestURL the requestURL to set
- */
- public void setRequestURL(String requestURL) {
- this.requestURL = requestURL;
- }
-
- /**
* @return the keyURL
*/
public String getKeyURL() {
diff --git a/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java b/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java
new file mode 100644
index 000000000..7a0359587
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/request/model/ProfileRetrievalRequestData.java
@@ -0,0 +1,67 @@
+// --- 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.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author alee
+ *
+ */
+@XmlRootElement(name = "ProfileRetrievalRequest")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ProfileRetrievalRequestData {
+
+ private static final String PROFILE_ID = "profileId";
+
+ @XmlElement
+ protected String profileId;
+
+ public ProfileRetrievalRequestData() {
+ // required for JAXB (defaults)
+ }
+
+ public ProfileRetrievalRequestData(MultivaluedMap<String, String> form) {
+ if (form.containsKey(PROFILE_ID)) {
+ profileId = form.getFirst(PROFILE_ID);
+ }
+ }
+
+ /**
+ * @return the ProfileId
+ */
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /**
+ * @param ProfileId the ProfileId to set
+ */
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
+
+} \ No newline at end of file