1 package org.cacert.gigi.api;
3 import java.io.IOException;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
8 import org.cacert.gigi.dbObjects.Certificate;
9 import org.cacert.gigi.dbObjects.Certificate.CertificateStatus;
10 import org.cacert.gigi.dbObjects.Job;
11 import org.cacert.gigi.dbObjects.User;
13 public class RevokeCertificate extends APIPoint {
15 public static final String PATH = "/account/certs/revoke";
18 public void process(HttpServletRequest req, HttpServletResponse resp, User u) throws IOException {
20 if ( !req.getMethod().equals("POST")) {
21 resp.sendError(500, "Error, POST required.");
24 if (req.getQueryString() != null) {
25 resp.sendError(500, "Error, no query String allowed.");
28 String tserial = req.getParameter("serial");
29 if (tserial == null) {
30 resp.sendError(500, "Error, no Serial found");
34 Certificate c = Certificate.getBySerial(tserial);
35 if (c == null || c.getOwner() != u) {
36 resp.sendError(403, "Access Denied");
41 if (c.getStatus() != CertificateStatus.REVOKED) {
42 resp.sendError(510, "Error, issuing timed out");
45 resp.getWriter().println("OK");
47 } catch (InterruptedException e) {