summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/request
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/request')
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/CertRequestService.java19
-rw-r--r--base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java33
2 files changed, 26 insertions, 26 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
index dba6d9c01..eef057644 100644
--- a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
+++ b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
@@ -20,7 +20,6 @@ package com.netscape.cms.servlet.request;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.EAuthException;
@@ -29,6 +28,7 @@ import com.netscape.certsrv.base.BadRequestDataException;
import com.netscape.certsrv.base.BadRequestException;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.PKIException;
+import com.netscape.certsrv.base.UnauthorizedException;
import com.netscape.certsrv.cert.CertEnrollmentRequest;
import com.netscape.certsrv.cert.CertRequestInfo;
import com.netscape.certsrv.cert.CertRequestInfos;
@@ -96,13 +96,13 @@ public class CertRequestService extends PKIService implements CertRequestResourc
infos = dao.submitRequest(data, servletRequest, uriInfo, getLocale());
} catch (EAuthException e) {
CMS.debug("enrollCert: authentication failed: " + e);
- throw new PKIException(Response.Status.UNAUTHORIZED, e.toString());
+ throw new UnauthorizedException(e.toString());
} catch (EAuthzException e) {
CMS.debug("enrollCert: authorization failed: " + e);
- throw new PKIException(Response.Status.UNAUTHORIZED, e.toString());
+ throw new UnauthorizedException(e.toString());
} catch (BadRequestDataException e) {
CMS.debug("enrollCert: bad request data: " + e);
- throw new PKIException(Response.Status.BAD_REQUEST, e.toString());
+ throw new BadRequestException(e.toString());
} catch (EBaseException e) {
throw new PKIException(e.toString());
}
@@ -147,16 +147,14 @@ public class CertRequestService extends PKIService implements CertRequestResourc
dao.changeRequestState(id, servletRequest, data, getLocale(), op);
} catch (ERejectException e) {
CMS.debug("changeRequestState: execution rejected " + e);
- throw new PKIException(Response.Status.BAD_REQUEST,
- CMS.getUserMessage(getLocale(), "CMS_PROFILE_REJECTED", e.toString()));
+ throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_PROFILE_REJECTED", e.toString()));
} catch (EDeferException e) {
CMS.debug("changeRequestState: execution defered " + e);
// TODO do we throw an exception here?
- throw new PKIException(Response.Status.BAD_REQUEST,
- CMS.getUserMessage(getLocale(), "CMS_PROFILE_DEFERRED", e.toString()));
+ throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_PROFILE_DEFERRED", e.toString()));
} catch (BadRequestDataException e) {
CMS.debug("changeRequestState: bad request data: " + e);
- throw new PKIException(Response.Status.BAD_REQUEST, e.toString());
+ throw new BadRequestException(e.toString());
} catch (EPropertyException e) {
CMS.debug("changeRequestState: execution error " + e);
throw new PKIException(CMS.getUserMessage(getLocale(),
@@ -169,8 +167,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc
throw new PKIException("Problem approving request in CertRequestResource.assignRequest! " + e);
} catch (RequestNotFoundException e) {
CMS.debug(e);
- throw new PKIException(Response.Status.BAD_REQUEST,
- CMS.getUserMessage(getLocale(), "CMS_REQUEST_NOT_FOUND", id.toString()));
+ throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_REQUEST_NOT_FOUND", id.toString()));
}
}
diff --git a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
index 12f3bb7ee..433206298 100644
--- a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
+++ b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
@@ -18,11 +18,10 @@
package com.netscape.cms.servlet.request;
-import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.BadRequestException;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.key.KeyArchivalRequest;
@@ -81,7 +80,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
if (data == null || data.getClientId() == null
|| data.getWrappedPrivateData() == null
|| data.getDataType() == null) {
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ throw new BadRequestException("Invalid key archival request.");
}
KeyRequestDAO dao = new KeyRequestDAO();
@@ -91,7 +90,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
return info;
}
@@ -109,9 +108,13 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
//Catch this before the internal server processing has to deal with it
//If data has been provided, we need at least the wrapped session key,
//or the command is invalid.
- if (data == null || (data.getTransWrappedSessionKey() == null
- && data.getSessionWrappedPassphrase() != null)) {
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
+
+ if (data == null) {
+ throw new BadRequestException("Invalid request.");
+ }
+ if (data.getTransWrappedSessionKey() == null
+ && data.getSessionWrappedPassphrase() != null) {
+ throw new BadRequestException("No wrapped session key.");
}
KeyRequestDAO dao = new KeyRequestDAO();
KeyRequestInfo info;
@@ -120,14 +123,14 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
return info;
}
public void approveRequest(RequestId id) {
if (id == null) {
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ throw new BadRequestException("Invalid request id.");
}
// auth and authz
KeyRequestDAO dao = new KeyRequestDAO();
@@ -136,13 +139,13 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
}
public void rejectRequest(RequestId id) {
if (id == null) {
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ throw new BadRequestException("Invalid request id.");
}
// auth and authz
KeyRequestDAO dao = new KeyRequestDAO();
@@ -151,13 +154,13 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
}
public void cancelRequest(RequestId id) {
if (id == null) {
- throw new WebApplicationException(Response.Status.BAD_REQUEST);
+ throw new BadRequestException("Request id is null.");
}
// auth and authz
KeyRequestDAO dao = new KeyRequestDAO();
@@ -166,7 +169,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
}
@@ -193,7 +196,7 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
} catch (EBaseException e) {
CMS.debug("listRequests: error in obtaining request results" + e);
e.printStackTrace();
- throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+ throw new PKIException(e.toString());
}
return requests;
}