resp.setStatus(500);
PrintWriter wr = resp.getWriter();
e.formatPlain(wr);
- } catch (InterruptedException e) {
- resp.sendError(500, "Interrupted");
}
}
}
resp.sendError(500, "Error, POST required.");
return;
}
+
if (req.getQueryString() != null) {
resp.sendError(500, "Error, no query String allowed.");
return;
}
+
String tserial = req.getParameter("serial");
if (tserial == null) {
resp.sendError(500, "Error, no Serial found");
return;
}
- try {
- Certificate c = Certificate.getBySerial(tserial);
- if (c == null || c.getOwner() != u) {
- resp.sendError(403, "Access Denied");
- return;
- }
- Job job = c.revoke();
- job.waitFor(60000);
- if (c.getStatus() != CertificateStatus.REVOKED) {
- resp.sendError(510, "Error, issuing timed out");
- return;
- }
- resp.getWriter().println("OK");
+
+ Certificate c = Certificate.getBySerial(tserial);
+ if (c == null || c.getOwner() != u) {
+ resp.sendError(403, "Access Denied");
+ return;
+ }
+
+ Job job = c.revoke();
+ job.waitFor(60000);
+ if (c.getStatus() != CertificateStatus.REVOKED) {
+ resp.sendError(510, "Error, issuing timed out");
return;
- } catch (InterruptedException e) {
- e.printStackTrace();
}
+
+ resp.getWriter().println("OK");
+
}
}
}
}
- public synchronized boolean waitFor(int max) throws InterruptedException {
+ public synchronized boolean waitFor(int max) {
long start = System.currentTimeMillis();
try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `jobs` WHERE id=? AND state='open'")) {
ps.setInt(1, id);
if (max != 0 && System.currentTimeMillis() - start > max) {
return false;
}
- Thread.sleep((long) (2000 + Math.random() * 2000));
+ try {
+ this.wait((long) (2000 + Math.random() * 2000));
+ } catch (InterruptedException ie) {
+ // Ignore the interruption
+ ie.printStackTrace();
+ }
rs = ps.executeQuery();
}
}
} catch (GeneralSecurityException e) {
e.printStackTrace();
throw new GigiApiException("Certificate Request format is invalid.");
- } catch (InterruptedException e) {
- e.printStackTrace();
}
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
}
long start = System.currentTimeMillis();
for (Job job : revokes) {
- try {
- int toWait = (int) (60000 + start - System.currentTimeMillis());
- if (toWait > 0) {
- job.waitFor(toWait);
- } else {
- break; // canceled... waited too log
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
+ int toWait = (int) (60000 + start - System.currentTimeMillis());
+ if (toWait > 0) {
+ job.waitFor(toWait);
+ } else {
+ break; // canceled... waited too log
}
}
resp.getWriter().println("error");
} catch (GigiApiException e) {
e.format(resp.getWriter(), Language.getInstance(Locale.ENGLISH));
- } catch (InterruptedException e) {
- e.printStackTrace();
- resp.getWriter().println("interrupted");
}
} else if (req.getParameter("addExDom") != null) {