summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/key/KeyService.java
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-10-25 11:52:15 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-10-29 10:38:38 -0500
commitc1aa8b2d05cb1873990d1a3e9cf007cca240f135 (patch)
treef12c76eaa1c385a79e40e7b38123360279c05fc0 /base/common/src/com/netscape/cms/servlet/key/KeyService.java
parent748605a324266bb515a3d1124bc55deb3be4df71 (diff)
downloadpki-c1aa8b2d05cb1873990d1a3e9cf007cca240f135.tar.gz
pki-c1aa8b2d05cb1873990d1a3e9cf007cca240f135.tar.xz
pki-c1aa8b2d05cb1873990d1a3e9cf007cca240f135.zip
Enabled authentication for key services.
The web.xml in KRA has been modified to enable the authentication for key and key request services. Some tools have been added to access the services via command-line. Ticket #376
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/key/KeyService.java')
-rw-r--r--base/common/src/com/netscape/cms/servlet/key/KeyService.java19
1 files changed, 13 insertions, 6 deletions
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();