summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/servlet
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java75
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java80
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java (renamed from pki/base/common/src/com/netscape/cms/servlet/base/CMSResource.java)2
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/KeyResource.java114
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/KeyResourceService.java123
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/KeysResource.java94
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/KeysResourceService.java90
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java141
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java139
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResource.java121
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResourceService.java111
11 files changed, 588 insertions, 502 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java b/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java
index b1e47ec3a..6c4c0bc54 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResource.java
@@ -1,88 +1,21 @@
-// --- 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.cms.servlet.admin;
-import java.security.cert.CertificateEncodingException;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
-import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.kra.IKeyRecoveryAuthority;
-import com.netscape.certsrv.security.ITransportKeyUnit;
-import com.netscape.cms.servlet.base.CMSResource;
-import com.netscape.cms.servlet.cert.model.CertificateData;
-
-/**
- * This is the class used to list, retrieve and modify system certificates for all Java subsystems.
- *
- * @author alee
- *
- */
@Path("/config/cert")
-public class SystemCertificateResource extends CMSResource {
-
- @Context
- Request request;
+public interface SystemCertificateResource {
/**
* Used to retrieve the transport certificate
*/
@GET
@Path("/transport")
+ //@ClientResponseType(CertificateData.class)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
- public Response getTransportCert() {
- CertificateData cert = null;
- IKeyRecoveryAuthority kra = null;
-
- // auth and authz
-
- kra = (IKeyRecoveryAuthority) CMS.getSubsystem("kra");
- if (kra == null) {
- // no KRA
- throw new WebApplicationException(Response.Status.NOT_FOUND);
- }
-
- ITransportKeyUnit tu = kra.getTransportKeyUnit();
- if (tu == null) {
- CMS.debug("getTransportCert: transport key unit is null");
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- org.mozilla.jss.crypto.X509Certificate transportCert = tu.getCertificate();
- if (transportCert == null) {
- CMS.debug("getTransportCert: transport cert is null");
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- try {
- cert = createCertificateData(transportCert);
- } catch (CertificateEncodingException e) {
- CMS.debug("getTransportCert: certificate encoding exception with transport cert");
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- return sendConditionalGetResponse(DEFAULT_LONG_CACHE_LIFETIME, cert, request);
- }
+ public Response getTransportCert();
-}
+} \ No newline at end of file
diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java b/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java
new file mode 100644
index 000000000..48f410c73
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/admin/SystemCertificateResourceService.java
@@ -0,0 +1,80 @@
+// --- 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.cms.servlet.admin;
+
+import java.security.cert.CertificateEncodingException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.kra.IKeyRecoveryAuthority;
+import com.netscape.certsrv.security.ITransportKeyUnit;
+import com.netscape.cms.servlet.base.CMSResourceService;
+import com.netscape.cms.servlet.cert.model.CertificateData;
+
+/**
+ * This is the class used to list, retrieve and modify system certificates for all Java subsystems.
+ *
+ * @author alee
+ *
+ */
+public class SystemCertificateResourceService extends CMSResourceService implements SystemCertificateResource {
+
+ @Context
+ Request request;
+
+ /**
+ * Used to retrieve the transport certificate
+ */
+ public Response getTransportCert() {
+ CertificateData cert = null;
+ IKeyRecoveryAuthority kra = null;
+
+ // auth and authz
+
+ kra = (IKeyRecoveryAuthority) CMS.getSubsystem("kra");
+ if (kra == null) {
+ // no KRA
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ }
+
+ ITransportKeyUnit tu = kra.getTransportKeyUnit();
+ if (tu == null) {
+ CMS.debug("getTransportCert: transport key unit is null");
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ org.mozilla.jss.crypto.X509Certificate transportCert = tu.getCertificate();
+ if (transportCert == null) {
+ CMS.debug("getTransportCert: transport cert is null");
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ try {
+ cert = createCertificateData(transportCert);
+ } catch (CertificateEncodingException e) {
+ CMS.debug("getTransportCert: certificate encoding exception with transport cert");
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ return sendConditionalGetResponse(DEFAULT_LONG_CACHE_LIFETIME, cert, request);
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/base/CMSResource.java b/pki/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java
index 48b04859b..74d847d0a 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/base/CMSResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java
@@ -34,7 +34,7 @@ import com.netscape.cms.servlet.cert.model.CertificateData;
* @author alee
*
*/
-public class CMSResource {
+public class CMSResourceService {
protected static final String HEADER = "-----BEGIN NEW CERTIFICATE REQUEST-----";
protected static final String TRAILER = "-----END NEW CERTIFICATE REQUEST-----";
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/KeyResource.java b/pki/base/common/src/com/netscape/cms/servlet/key/KeyResource.java
index 3f8e8b2cf..c6ddda698 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/KeyResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/KeyResource.java
@@ -1,53 +1,18 @@
-// --- 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.key;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import com.netscape.cms.servlet.base.CMSResource;
-import com.netscape.cms.servlet.key.model.KeyDAO;
import com.netscape.cms.servlet.key.model.KeyData;
-import com.netscape.cms.servlet.request.model.KeyRequestDAO;
-import com.netscape.cms.servlet.request.model.KeyRequestInfo;
import com.netscape.cms.servlet.request.model.RecoveryRequestData;
-import com.netscape.certsrv.request.IRequest;
-import com.netscape.certsrv.request.RequestStatus;
-import com.netscape.certsrv.base.EBaseException;
-/**
- * @author alee
- *
- */
+
@Path("/key")
-public class KeyResource extends CMSResource {
-
- @Context
- UriInfo uriInfo;
-
+public interface KeyResource {
+
/**
* Used to retrieve a key
* @param data
@@ -57,80 +22,11 @@ public class KeyResource extends CMSResource {
@Path("retrieve")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public KeyData retrieveKey(RecoveryRequestData data) {
- // auth and authz
- String keyId = validateRequest(data);
- KeyDAO dao = new KeyDAO();
- KeyData keyData;
- try {
- keyData = dao.getKey(keyId, data);
- } catch (EBaseException e) {
- // log error
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- if (keyData == null) {
- // no key record
- throw new WebApplicationException(Response.Status.GONE);
- }
- return keyData;
- }
+ public KeyData retrieveKey(RecoveryRequestData data);
// retrieval - used to test integration with a browser
@POST
@Path("retrieve")
@Produces(MediaType.TEXT_XML)
- public KeyData retrieveKey(MultivaluedMap<String, String> form) {
- RecoveryRequestData data = new RecoveryRequestData(form);
- return retrieveKey(data);
- }
-
- private String validateRequest(RecoveryRequestData data) {
- // confirm that at least one wrapping method exists
- if ((data.getTransWrappedSessionKey() == null) && (data.getTransWrappedSessionKey() == null)) {
- // log error
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
- }
-
- // confirm request exists
- String reqId = data.getRequestId();
- if (reqId == null) {
- // log error
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
- }
- KeyRequestDAO reqDAO = new KeyRequestDAO();
- KeyRequestInfo reqInfo;
- try {
- reqInfo = reqDAO.getRequest(reqId, uriInfo);
- } catch (EBaseException e1) {
- // failed to get request
- e1.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- if (reqInfo == null) {
- // request not found
- throw new WebApplicationException(Response.Status.GONE);
- }
-
- //confirm request is of the right type
- String type = reqInfo.getRequestType();
- if (!type.equals(IRequest.SECURITY_DATA_RECOVERY_REQUEST)) {
- // log error
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
- }
-
- //confirm that agent is originator of request, else throw 401
- // TO-DO
-
- // confirm request is in approved state
- String status = reqInfo.getRequestStatus();
- if (!status.equals(RequestStatus.APPROVED.toString())) {
- // log error
- throw new WebApplicationException(Response.Status.UNAUTHORIZED);
- }
-
- String keyURL = reqInfo.getKeyURL();
- return keyURL.substring(keyURL.lastIndexOf("/"));
- }
-
+ public KeyData retrieveKey(MultivaluedMap<String, String> form);
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/KeyResourceService.java b/pki/base/common/src/com/netscape/cms/servlet/key/KeyResourceService.java
new file mode 100644
index 000000000..887820c3f
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/KeyResourceService.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.key;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.netscape.cms.servlet.base.CMSResourceService;
+import com.netscape.cms.servlet.key.model.KeyDAO;
+import com.netscape.cms.servlet.key.model.KeyData;
+import com.netscape.cms.servlet.request.model.KeyRequestDAO;
+import com.netscape.cms.servlet.request.model.KeyRequestInfo;
+import com.netscape.cms.servlet.request.model.RecoveryRequestData;
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.RequestStatus;
+import com.netscape.certsrv.base.EBaseException;
+/**
+ * @author alee
+ *
+ */
+public class KeyResourceService extends CMSResourceService implements KeyResource{
+
+ @Context
+ UriInfo uriInfo;
+
+ /**
+ * Used to retrieve a key
+ * @param data
+ * @return
+ */
+ public KeyData retrieveKey(RecoveryRequestData data) {
+ // auth and authz
+ String keyId = validateRequest(data);
+ KeyDAO dao = new KeyDAO();
+ KeyData keyData;
+ try {
+ keyData = dao.getKey(keyId, data);
+ } catch (EBaseException e) {
+ // log error
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ if (keyData == null) {
+ // no key record
+ throw new WebApplicationException(Response.Status.GONE);
+ }
+ return keyData;
+ }
+
+ // retrieval - used to test integration with a browser
+ public KeyData retrieveKey(MultivaluedMap<String, String> form) {
+ RecoveryRequestData data = new RecoveryRequestData(form);
+ return retrieveKey(data);
+ }
+
+ private String validateRequest(RecoveryRequestData data) {
+ // confirm that at least one wrapping method exists
+ if ((data.getTransWrappedSessionKey() == null) && (data.getTransWrappedSessionKey() == null)) {
+ // log error
+ throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ }
+
+ // confirm request exists
+ String reqId = data.getRequestId();
+ if (reqId == null) {
+ // log error
+ throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ }
+ KeyRequestDAO reqDAO = new KeyRequestDAO();
+ KeyRequestInfo reqInfo;
+ try {
+ reqInfo = reqDAO.getRequest(reqId, uriInfo);
+ } catch (EBaseException e1) {
+ // failed to get request
+ e1.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ if (reqInfo == null) {
+ // request not found
+ throw new WebApplicationException(Response.Status.GONE);
+ }
+
+ //confirm request is of the right type
+ String type = reqInfo.getRequestType();
+ if (!type.equals(IRequest.SECURITY_DATA_RECOVERY_REQUEST)) {
+ // log error
+ throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ }
+
+ //confirm that agent is originator of request, else throw 401
+ // TO-DO
+
+ // confirm request is in approved state
+ String status = reqInfo.getRequestStatus();
+ if (!status.equals(RequestStatus.APPROVED.toString())) {
+ // log error
+ throw new WebApplicationException(Response.Status.UNAUTHORIZED);
+ }
+
+ String keyURL = reqInfo.getKeyURL();
+ return keyURL.substring(keyURL.lastIndexOf("/"));
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/KeysResource.java b/pki/base/common/src/com/netscape/cms/servlet/key/KeysResource.java
index 4cf5db3f4..35cd5ccbe 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/KeysResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/KeysResource.java
@@ -1,23 +1,3 @@
-// --- 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.key;
import javax.ws.rs.DefaultValue;
@@ -25,81 +5,19 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.cms.servlet.base.CMSResource;
-import com.netscape.cms.servlet.key.model.KeyDAO;
import com.netscape.cms.servlet.key.model.KeyDataInfos;
-
-/**
- * @author alee
- *
- */
+
@Path("/keys")
-public class KeysResource extends CMSResource {
-
- private static final String DEFAULT_MAXTIME = "10";
- private static final String DEFAULT_MAXRESULTS = "100";
-
- @Context
- UriInfo uriInfo;
-
- /**
- * Used to generate list of key infos based on the search parameters
- */
+public interface KeysResource {
+ public static final String DEFAULT_MAXTIME = "10";
+ public static final String DEFAULT_MAXRESULTS = "100";
+
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
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) {
- // auth and authz
-
- // get ldap filter
- String filter = createSearchFilter(status, clientID);
- CMS.debug("listKeys: filter is " + filter);
-
- KeyDAO dao = new KeyDAO();
- KeyDataInfos infos;
- try {
- infos = dao.listKeys(filter, maxResults, maxTime, uriInfo);
- } catch (EBaseException e) {
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- return infos;
- }
+ @DefaultValue(DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
- private String createSearchFilter(String status, String clientID) {
- String filter = "";
- int matches = 0;
-
- if ((status == null) && (clientID == null)) {
- filter = "(serialno=*)";
- return filter;
- }
-
- if (status != null) {
- filter += "(status=" + status + ")";
- matches ++;
- }
-
- if (clientID != null) {
- filter += "(clientID=" + clientID + ")";
- matches ++;
- }
-
- if (matches > 1) {
- filter = "(&" + filter + ")";
- }
-
- return filter;
- }
-
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/KeysResourceService.java b/pki/base/common/src/com/netscape/cms/servlet/key/KeysResourceService.java
new file mode 100644
index 000000000..b5032fa86
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/KeysResourceService.java
@@ -0,0 +1,90 @@
+// --- 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.key;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.cms.servlet.base.CMSResourceService;
+import com.netscape.cms.servlet.key.model.KeyDAO;
+import com.netscape.cms.servlet.key.model.KeyDataInfos;
+
+/**
+ * @author alee
+ *
+ */
+public class KeysResourceService extends CMSResourceService implements KeysResource {
+
+ @Context
+ UriInfo uriInfo;
+
+ /**
+ * Used to generate list of key infos based on the search parameters
+ */
+ public KeyDataInfos listKeys(String clientID, String status, int maxResults, int maxTime) {
+ // auth and authz
+
+ // get ldap filter
+ String filter = createSearchFilter(status, clientID);
+ CMS.debug("listKeys: filter is " + filter);
+
+ KeyDAO dao = new KeyDAO();
+ KeyDataInfos infos;
+ try {
+ infos = dao.listKeys(filter, maxResults, maxTime, uriInfo);
+ } catch (EBaseException e) {
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ return infos;
+ }
+
+ private String createSearchFilter(String status, String clientID) {
+ String filter = "";
+ int matches = 0;
+
+ if ((status == null) && (clientID == null)) {
+ filter = "(serialno=*)";
+ return filter;
+ }
+
+ if (status != null) {
+ filter += "(status=" + status + ")";
+ matches ++;
+ }
+
+ if (clientID != null) {
+ filter += "(clientID=" + clientID + ")";
+ matches ++;
+ }
+
+ if (matches > 1) {
+ filter = "(&" + filter + ")";
+ }
+
+ return filter;
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java
index 154986624..0a476c49c 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResource.java
@@ -1,21 +1,3 @@
-// --- 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;
import javax.ws.rs.GET;
@@ -24,146 +6,57 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.cms.servlet.base.CMSResource;
import com.netscape.cms.servlet.request.model.ArchivalRequestData;
-import com.netscape.cms.servlet.request.model.KeyRequestDAO;
import com.netscape.cms.servlet.request.model.KeyRequestInfo;
import com.netscape.cms.servlet.request.model.RecoveryRequestData;
-
-/**
- * @author alee
- *
- */
+
@Path("/keyrequest")
-public class KeyRequestResource extends CMSResource {
+public interface KeyRequestResource {
- @Context
- UriInfo uriInfo;
-
/**
* Used to retrieve key request info for a specific request
*/
@GET
@Path("{id}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
- public KeyRequestInfo getRequestInfo(@PathParam("id") String id) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- KeyRequestInfo info;
- try {
- info = dao.getRequest(id, uriInfo);
- } catch (EBaseException e) {
- // log error
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- if (info == null) {
- // request does not exist
- throw new WebApplicationException(Response.Status.NOT_FOUND);
- }
- return info;
- }
-
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
+ public KeyRequestInfo getRequestInfo(@PathParam("id") String id);
+
// Archiving - used to test integration with a browser
@POST
@Path("archive")
@Produces({ MediaType.TEXT_XML })
- public KeyRequestInfo archiveKey(MultivaluedMap<String, String> form) {
- ArchivalRequestData data = new ArchivalRequestData(form);
- return archiveKey(data);
- }
+ public KeyRequestInfo archiveKey(MultivaluedMap<String, String> form);
@POST
@Path("archive")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public KeyRequestInfo archiveKey(ArchivalRequestData data) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- KeyRequestInfo info;
- try {
- info = dao.submitRequest(data, uriInfo);
- } catch (EBaseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- return info;
- }
-
+ public KeyRequestInfo archiveKey(ArchivalRequestData data);
+
//Recovery - used to test integration with a browser
@POST
@Path("recover")
@Produces({ MediaType.TEXT_XML })
- public KeyRequestInfo recoverKey(MultivaluedMap<String, String> form) {
- RecoveryRequestData data = new RecoveryRequestData(form);
- return recoverKey(data);
- }
+ public KeyRequestInfo recoverKey(MultivaluedMap<String, String> form);
@POST
@Path("recover")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public KeyRequestInfo recoverKey(RecoveryRequestData data) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- KeyRequestInfo info;
- try {
- info = dao.submitRequest(data, uriInfo);
- } catch (EBaseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- return info;
- }
-
+ public KeyRequestInfo recoverKey(RecoveryRequestData data);
+
@POST
@Path("approve/{id}")
- public void approveRequest(@PathParam("id") String id) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- try {
- dao.approveRequest(id);
- } catch (EBaseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- }
-
+ public void approveRequest(@PathParam("id") String id);
+
@POST
@Path("reject/{id}")
- public void rejectRequest(@PathParam("id") String id) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- try {
- dao.rejectRequest(id);
- } catch (EBaseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- }
-
+ public void rejectRequest(@PathParam("id") String id);
+
@POST
@Path("cancel/{id}")
- public void cancelRequest(@PathParam("id") String id) {
- // auth and authz
- KeyRequestDAO dao = new KeyRequestDAO();
- try {
- dao.cancelRequest(id);
- } catch (EBaseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- }
+ public void cancelRequest(@PathParam("id") String id);
+
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java
new file mode 100644
index 000000000..da08c4d69
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java
@@ -0,0 +1,139 @@
+// --- 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;
+
+import javax.ws.rs.PathParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.cms.servlet.base.CMSResourceService;
+import com.netscape.cms.servlet.request.model.ArchivalRequestData;
+import com.netscape.cms.servlet.request.model.KeyRequestDAO;
+import com.netscape.cms.servlet.request.model.KeyRequestInfo;
+import com.netscape.cms.servlet.request.model.RecoveryRequestData;
+
+/**
+ * @author alee
+ *
+ */
+public class KeyRequestResourceService extends CMSResourceService implements KeyRequestResource {
+
+ @Context
+ UriInfo uriInfo;
+
+ /**
+ * Used to retrieve key request info for a specific request
+ */
+ public KeyRequestInfo getRequestInfo(String id) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ KeyRequestInfo info;
+ try {
+ info = dao.getRequest(id, uriInfo);
+ } catch (EBaseException e) {
+ // log error
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ if (info == null) {
+ // request does not exist
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ }
+ return info;
+ }
+
+ // Archiving - used to test integration with a browser
+ public KeyRequestInfo archiveKey(MultivaluedMap<String, String> form) {
+ ArchivalRequestData data = new ArchivalRequestData(form);
+ return archiveKey(data);
+ }
+
+ public KeyRequestInfo archiveKey(ArchivalRequestData data) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ KeyRequestInfo info;
+ try {
+ info = dao.submitRequest(data, uriInfo);
+ } catch (EBaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ return info;
+ }
+
+ //Recovery - used to test integration with a browser
+ public KeyRequestInfo recoverKey(MultivaluedMap<String, String> form) {
+ RecoveryRequestData data = new RecoveryRequestData(form);
+ return recoverKey(data);
+ }
+
+ public KeyRequestInfo recoverKey(RecoveryRequestData data) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ KeyRequestInfo info;
+ try {
+ info = dao.submitRequest(data, uriInfo);
+ } catch (EBaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ return info;
+ }
+
+ public void approveRequest(@PathParam("id") String id) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ try {
+ dao.approveRequest(id);
+ } catch (EBaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ public void rejectRequest(@PathParam("id") String id) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ try {
+ dao.rejectRequest(id);
+ } catch (EBaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ public void cancelRequest(@PathParam("id") String id) {
+ // auth and authz
+ KeyRequestDAO dao = new KeyRequestDAO();
+ try {
+ dao.cancelRequest(id);
+ } catch (EBaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResource.java b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResource.java
index ce53053d4..0f8fbc78f 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResource.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResource.java
@@ -1,21 +1,3 @@
-// --- 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;
import javax.ws.rs.DefaultValue;
@@ -23,32 +5,16 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.cms.servlet.base.CMSResource;
-import com.netscape.cms.servlet.request.model.KeyRequestDAO;
import com.netscape.cms.servlet.request.model.KeyRequestInfos;
-
-/**
- * @author alee
- *
- */
-@Path("/keyrequests")
-public class KeyRequestsResource extends CMSResource {
- private static final int DEFAULT_START = 0;
- private static final String DEFAULT_PAGESIZE = "20";
- private static final String DEFAULT_MAXRESULTS = "100";
- private static final String DEFAULT_MAXTIME = "10";
+@Path("/keyrequests")
+public interface KeyRequestsResource {
- @Context
- UriInfo uriInfo;
+ public static final String DEFAULT_START = "0";
+ public static final String DEFAULT_PAGESIZE = "20";
+ public static final String DEFAULT_MAXRESULTS = "100";
+ public static final String DEFAULT_MAXTIME = "10";
/**
* Used to generate list of key requests based on the search parameters
@@ -56,74 +22,11 @@ public class KeyRequestsResource extends CMSResource {
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
public KeyRequestInfos listRequests(@QueryParam("requestState") String requestState,
- @QueryParam("requestType") String requestType,
- @QueryParam("clientID") String clientID,
- @QueryParam("start") String start_s,
- @DefaultValue(DEFAULT_PAGESIZE) @QueryParam("pageSize") int pageSize,
- @DefaultValue(DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
- @DefaultValue(DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime) {
- // auth and authz
-
- // get ldap filter
- String filter = createSearchFilter(requestState, requestType, clientID);
- CMS.debug("listRequests: filter is " + filter);
-
-
- // get start marker
- int start = DEFAULT_START;
- if (start_s != null) {
- try {
- if (start_s.trim().startsWith("0x")) {
- start = Integer.parseInt(start_s.trim().substring(2), 16);
- } else {
- start = Integer.parseInt(start_s.trim());
- }
- } catch (NumberFormatException e) {
- CMS.debug("listRequests: NumberformatException: Invalid value for start " + start_s);
- throw new WebApplicationException(Response.Status.NOT_FOUND);
- }
- }
-
- KeyRequestDAO reqDAO = new KeyRequestDAO();
- KeyRequestInfos requests;
- try {
- requests = reqDAO.listRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
- } catch (EBaseException e) {
- CMS.debug("listRequests: error in obtaining request results" + e);
- e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
- }
- return requests;
- }
+ @QueryParam("requestType") String requestType,
+ @QueryParam("clientID") String clientID,
+ @DefaultValue(DEFAULT_START) @QueryParam("start") String start_s,
+ @DefaultValue(DEFAULT_PAGESIZE) @QueryParam("pageSize") int pageSize,
+ @DefaultValue(DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
+ @DefaultValue(DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
- private String createSearchFilter(String requestState, String requestType, String clientID) {
- String filter = "";
- int matches = 0;
-
- if ((requestState == null) && (requestType == null) && (clientID == null)) {
- filter = "(requeststate=*)";
- return filter;
- }
-
- if (requestState != null) {
- filter += "(requeststate=" + requestState + ")";
- matches ++;
- }
-
- if (requestType != null) {
- filter += "(requesttype=" + requestType + ")";
- matches ++;
- }
-
- if (clientID != null) {
- filter += "(clientID=" + clientID + ")";
- matches ++;
- }
-
- if (matches > 1) {
- filter = "(&" + filter + ")";
- }
-
- return filter;
- }
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResourceService.java b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResourceService.java
new file mode 100644
index 000000000..290868ab5
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/KeyRequestsResourceService.java
@@ -0,0 +1,111 @@
+// --- 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;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.cms.servlet.base.CMSResourceService;
+import com.netscape.cms.servlet.request.model.KeyRequestDAO;
+import com.netscape.cms.servlet.request.model.KeyRequestInfos;
+
+/**
+ * @author alee
+ *
+ */
+public class KeyRequestsResourceService extends CMSResourceService implements KeyRequestsResource{
+
+ @Context
+ UriInfo uriInfo;
+
+ /**
+ * Used to generate list of key requests based on the search parameters
+ */
+ public KeyRequestInfos listRequests(String requestState, String requestType, String clientID,
+ String start_s, int pageSize, int maxResults,
+ int maxTime) {
+ // auth and authz
+
+ // get ldap filter
+ String filter = createSearchFilter(requestState, requestType, clientID);
+ CMS.debug("listRequests: filter is " + filter);
+
+
+ // get start marker
+ int start = Integer.parseInt(KeyRequestsResource.DEFAULT_START);
+ if (start_s != null) {
+ try {
+ if (start_s.trim().startsWith("0x")) {
+ start = Integer.parseInt(start_s.trim().substring(2), 16);
+ } else {
+ start = Integer.parseInt(start_s.trim());
+ }
+ } catch (NumberFormatException e) {
+ CMS.debug("listRequests: NumberformatException: Invalid value for start " + start_s);
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ }
+ }
+
+ KeyRequestDAO reqDAO = new KeyRequestDAO();
+ KeyRequestInfos requests;
+ try {
+ requests = reqDAO.listRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
+ } catch (EBaseException e) {
+ CMS.debug("listRequests: error in obtaining request results" + e);
+ e.printStackTrace();
+ throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ }
+ return requests;
+ }
+
+ private String createSearchFilter(String requestState, String requestType, String clientID) {
+ String filter = "";
+ int matches = 0;
+
+ if ((requestState == null) && (requestType == null) && (clientID == null)) {
+ filter = "(requeststate=*)";
+ return filter;
+ }
+
+ if (requestState != null) {
+ filter += "(requeststate=" + requestState + ")";
+ matches ++;
+ }
+
+ if (requestType != null) {
+ filter += "(requesttype=" + requestType + ")";
+ matches ++;
+ }
+
+ if (clientID != null) {
+ filter += "(clientID=" + clientID + ")";
+ matches ++;
+ }
+
+ if (matches > 1) {
+ filter = "(&" + filter + ")";
+ }
+
+ return filter;
+ }
+}