summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2014-02-19 11:22:31 -0500
committerEndi S. Dewata <edewata@redhat.com>2014-02-19 12:51:02 -0500
commitd345bab896d2ac16dca164adb48031047affdf09 (patch)
tree5860c339fe823644a8691f980b26ba3636387b6d /base
parentabda3f089591fb9db31f6ddeb174e86c6bc0fbee (diff)
downloadpki-d345bab896d2ac16dca164adb48031047affdf09.tar.gz
pki-d345bab896d2ac16dca164adb48031047affdf09.tar.xz
pki-d345bab896d2ac16dca164adb48031047affdf09.zip
Updated REST interface for key requests.
The REST interface for key requests has been modified to return Response objects to allow better handling of server responses. Ticket #554
Diffstat (limited to 'base')
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyClient.java15
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestResource.java16
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java20
3 files changed, 33 insertions, 18 deletions
diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java
index bdb84fddb..374b793ff 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyClient.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java
@@ -102,7 +102,7 @@ public class KeyClient extends Client {
Integer pageSize,
Integer maxResults,
Integer maxTime) {
- return keyRequestClient.listRequests(
+ Response response = keyRequestClient.listRequests(
requestState,
requestType,
clientID,
@@ -110,10 +110,12 @@ public class KeyClient extends Client {
pageSize,
maxResults,
maxTime);
+ return client.getEntity(response, KeyRequestInfoCollection.class);
}
public KeyRequestInfo getRequestInfo(RequestId id) {
- return keyRequestClient.getRequestInfo(id);
+ Response response = keyRequestClient.getRequestInfo(id);
+ return client.getEntity(response, KeyRequestInfo.class);
}
public KeyRequestResponse archiveSecurityData(byte[] encoded, String clientId, String dataType, String algorithm, int strength) {
@@ -172,14 +174,17 @@ public class KeyClient extends Client {
}
public void approveRequest(RequestId id) {
- keyRequestClient.approveRequest(id);
+ Response response = keyRequestClient.approveRequest(id);
+ client.getEntity(response, Void.class);
}
public void rejectRequest(RequestId id) {
- keyRequestClient.rejectRequest(id);
+ Response response = keyRequestClient.rejectRequest(id);
+ client.getEntity(response, Void.class);
}
public void cancelRequest(RequestId id) {
- keyRequestClient.cancelRequest(id);
+ Response response = keyRequestClient.cancelRequest(id);
+ client.getEntity(response, Void.class);
}
}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
index e6e6c2e70..867136bc1 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
@@ -40,8 +40,9 @@ public interface KeyRequestResource {
* Used to generate list of key requests based on the search parameters
*/
@GET
+ @ClientResponseType(entityType=KeyRequestInfoCollection.class)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public KeyRequestInfoCollection listRequests(@QueryParam("requestState") String requestState,
+ public Response listRequests(@QueryParam("requestState") String requestState,
@QueryParam("requestType") String requestType,
@QueryParam("clientID") String clientID,
@QueryParam("start") RequestId start,
@@ -66,19 +67,22 @@ public interface KeyRequestResource {
*/
@GET
@Path("{id}")
+ @ClientResponseType(entityType=KeyRequestInfo.class)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public KeyRequestInfo getRequestInfo(@PathParam("id") RequestId id);
+ public Response getRequestInfo(@PathParam("id") RequestId id);
@POST
@Path("{id}/approve")
- public void approveRequest(@PathParam("id") RequestId id);
+ @ClientResponseType(entityType=Void.class)
+ public Response approveRequest(@PathParam("id") RequestId id);
@POST
@Path("{id}/reject")
- public void rejectRequest(@PathParam("id") RequestId id);
+ @ClientResponseType(entityType=Void.class)
+ public Response rejectRequest(@PathParam("id") RequestId id);
@POST
@Path("{id}/cancel")
- public void cancelRequest(@PathParam("id") RequestId id);
-
+ @ClientResponseType(entityType=Void.class)
+ public Response cancelRequest(@PathParam("id") RequestId id);
}
diff --git a/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java b/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java
index a81ca0acb..b85978a34 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java
@@ -136,7 +136,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
* Used to retrieve key request info for a specific request
*/
@Override
- public KeyRequestInfo getRequestInfo(RequestId id) {
+ public Response getRequestInfo(RequestId id) {
if (id == null) {
CMS.debug("getRequestInfo: is is null");
throw new BadRequestException("Unable to get Request: invalid ID");
@@ -155,7 +155,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
// request does not exist
throw new RequestNotFoundException(id);
}
- return info;
+ return createOKResponse(info);
}
public Response archiveKey(KeyArchivalRequest data) {
@@ -251,7 +251,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
}
@Override
- public void approveRequest(RequestId id) {
+ public Response approveRequest(RequestId id) {
if (id == null) {
throw new BadRequestException("Invalid request id.");
}
@@ -272,10 +272,12 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
auditRecoveryRequestChange(id, ILogger.FAILURE, "approve");
throw new PKIException(e.toString());
}
+
+ return createNoContentResponse();
}
@Override
- public void rejectRequest(RequestId id) {
+ public Response rejectRequest(RequestId id) {
if (id == null) {
throw new BadRequestException("Invalid request id.");
}
@@ -289,10 +291,12 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
auditRecoveryRequestChange(id, ILogger.FAILURE, "reject");
throw new PKIException(e.toString());
}
+
+ return createNoContentResponse();
}
@Override
- public void cancelRequest(RequestId id) {
+ public Response cancelRequest(RequestId id) {
if (id == null) {
throw new BadRequestException("Invalid request id.");
}
@@ -306,13 +310,15 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
auditRecoveryRequestChange(id, ILogger.FAILURE, "cancel");
throw new PKIException(e.toString());
}
+
+ return createNoContentResponse();
}
/**
* Used to generate list of key requests based on the search parameters
*/
@Override
- public KeyRequestInfoCollection listRequests(String requestState, String requestType, String clientID,
+ public Response listRequests(String requestState, String requestType, String clientID,
RequestId start, Integer pageSize, Integer maxResults, Integer maxTime) {
// auth and authz
@@ -334,7 +340,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
e.printStackTrace();
throw new PKIException(e.toString());
}
- return requests;
+ return createOKResponse(requests);
}
private String createSearchFilter(String requestState, String requestType, String clientID) {