summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/key
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/key')
-rw-r--r--base/common/src/com/netscape/cms/servlet/key/KeyRequestDAO.java15
-rw-r--r--base/common/src/com/netscape/cms/servlet/key/KeyService.java19
2 files changed, 16 insertions, 18 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/key/KeyRequestDAO.java b/base/common/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
index e64bcb2dc..bef0455a9 100644
--- a/base/common/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
+++ b/base/common/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.key;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -85,30 +84,22 @@ public class KeyRequestDAO extends CMSRequestDAO {
public KeyRequestInfos listRequests(String filter, RequestId start, int pageSize, int maxResults, int maxTime,
UriInfo uriInfo) throws EBaseException {
- CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
KeyRequestInfos ret = new KeyRequestInfos();
- if (cmsInfos == null) {
- ret.setRequests(null);
- ret.setLinks(null);
- return ret;
- }
+ CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
- 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;
+ List<KeyRequestInfo> list = (List<KeyRequestInfo>) cmsList;
+ ret.setRequests(list);
ret.setLinks(cmsInfos.getLinks());
- ret.setRequests(list);
return ret;
-
}
/**
diff --git a/base/common/src/com/netscape/cms/servlet/key/KeyService.java b/base/common/src/com/netscape/cms/servlet/key/KeyService.java
index 4db2fed0a..fe82d5fcd 100644
--- a/base/common/src/com/netscape/cms/servlet/key/KeyService.java
+++ b/base/common/src/com/netscape/cms/servlet/key/KeyService.java
@@ -20,10 +20,8 @@ package com.netscape.cms.servlet.key;
import java.math.BigInteger;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.List;
import javax.ws.rs.Path;
import javax.ws.rs.WebApplicationException;
@@ -56,6 +54,9 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
*/
public class KeyService extends PKIService implements KeyResource{
+ public static final int DEFAULT_MAXRESULTS = 100;
+ public static final int DEFAULT_MAXTIME = 10;
+
private IKeyRepository repo;
private IKeyRecoveryAuthority kra;
private IRequestQueue queue;
@@ -245,16 +246,18 @@ public class KeyService extends PKIService implements KeyResource{
/**
* Used to generate list of key infos based on the search parameters
*/
- public KeyDataInfos listKeys(String clientID, String status, int maxResults, int maxTime) {
+ public KeyDataInfos listKeys(String clientID, String status, Integer maxResults, Integer maxTime) {
// auth and authz
// get ldap filter
String filter = createSearchFilter(status, clientID);
CMS.debug("listKeys: filter is " + filter);
+ maxResults = maxResults == null ? DEFAULT_MAXRESULTS : maxResults;
+ maxTime = maxTime == null ? DEFAULT_MAXTIME : maxTime;
+
KeyDataInfos infos = new KeyDataInfos();
try {
- List <KeyDataInfo> list = new ArrayList<KeyDataInfo>();
Enumeration<IKeyRecord> e = null;
e = repo.searchKeys(filter, maxResults, maxTime);
@@ -265,11 +268,10 @@ public class KeyService extends PKIService implements KeyResource{
while (e.hasMoreElements()) {
IKeyRecord rec = e.nextElement();
if (rec != null) {
- list.add(createKeyDataInfo(rec));
+ infos.addKeyInfo(createKeyDataInfo(rec));
}
}
- infos.setKeyInfos(list);
} catch (EBaseException e) {
e.printStackTrace();
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
@@ -280,6 +282,11 @@ public class KeyService extends PKIService implements KeyResource{
public KeyDataInfo createKeyDataInfo(IKeyRecord rec) throws EBaseException {
KeyDataInfo ret = new KeyDataInfo();
+ ret.setClientID(rec.getClientId());
+ ret.setStatus(rec.getKeyStatus());
+ ret.setAlgorithm(rec.getAlgorithm());
+ ret.setSize(rec.getKeySize());
+ ret.setOwnerName(rec.getOwnerName());
Path keyPath = KeyResource.class.getAnnotation(Path.class);
BigInteger serial = rec.getSerialNumber();