]> WPIA git - gigi.git/commitdiff
upd: introduce constant for waiting time for jobs
authorINOPIAE <m.maengel@inopiae.de>
Mon, 29 Jul 2019 05:09:15 +0000 (07:09 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Sun, 22 Sep 2019 04:09:02 +0000 (06:09 +0200)
Change-Id: If5eed01faf1ceed1f68ef42f26907e0a69f87b5c

src/club/wpia/gigi/api/CreateCertificate.java
src/club/wpia/gigi/api/RevokeCertificate.java
src/club/wpia/gigi/dbObjects/Job.java
src/club/wpia/gigi/dbObjects/SupportedUser.java
src/club/wpia/gigi/dbObjects/User.java
src/club/wpia/gigi/pages/account/certs/CertificateIssueForm.java
src/club/wpia/gigi/pages/account/certs/CertificateModificationForm.java
src/club/wpia/gigi/pages/account/certs/RevokeSingleCertForm.java
src/club/wpia/gigi/pages/main/KeyCompromiseForm.java
tests/club/wpia/gigi/dbObjects/TestUserManaged.java

index 1890e4a9372d4eeb1e54faaa24f6758acea61d5b..41556d131a88052a2652e6adfa6b9682a2bb512e 100644 (file)
@@ -65,7 +65,7 @@ public class CreateCertificate extends APIPoint {
             CertificateRequest cr = new CertificateRequest(ctx, csr, cp);
             Certificate result = cr.draft();
             Job job = result.issue(null, "2y", u);
-            job.waitFor(60000);
+            job.waitFor(Job.WAIT_MIN);
             if (result.getStatus() != CertificateStatus.ISSUED) {
                 resp.sendError(510, "Error, issuing timed out");
                 return;
index 81e57cfbbf3ec23a184bf4f7710ffad0d960b4c1..e8e8b9643eb1e19b2ef781ba987dda97ee7edda4 100644 (file)
@@ -42,7 +42,7 @@ public class RevokeCertificate extends APIPoint {
         }
 
         Job job = c.revoke(RevocationType.USER);
-        job.waitFor(60000);
+        job.waitFor(Job.WAIT_MIN);
         if (c.getStatus() != CertificateStatus.REVOKED) {
             resp.sendError(510, "Error, issuing timed out");
             return;
index a505eb41a05a7a70bbf5e3627361803be1185b14..071b1b2ef0ced65f3eb6bfb0d217bdde6f1f4aa6 100644 (file)
@@ -11,6 +11,8 @@ import club.wpia.gigi.output.CertificateValiditySelector;
 
 public class Job implements IdCachable {
 
+    public static int WAIT_MIN = 60000;
+
     private int id;
 
     private Job(int id) {
index 84c43ab8e0db5261d745d200d34d69663be20ef8..1eae478f6a0eb872a03f8a14682f84958ab1e529 100644 (file)
@@ -70,7 +70,7 @@ public class SupportedUser {
         // TODO Check for open jobs!
         if (cert.getStatus() == CertificateStatus.ISSUED) {
             writeSELog("SE Revoke certificate");
-            cert.revoke(RevocationType.SUPPORT).waitFor(60000);
+            cert.revoke(RevocationType.SUPPORT).waitFor(Job.WAIT_MIN);
             // send notification to support
             String subject = "Revoke certificate";
             Outputable message = SprintfCommand.createSimple("Certificate with serial number {0} for {1} <{2}> has been revoked.", cert.getSerial(), target.getPreferredName().toString(), target.getEmail());
index 3213fd8ec31aa2c6b12b013b407c6f1abaa5866e..ab75628ba8f9bc2bc79968c8f2139fc8e25ab93a 100644 (file)
@@ -373,7 +373,7 @@ public class User extends CertificateOwner {
                 }
                 LinkedList<Job> revokes = new LinkedList<Job>();
                 for (Certificate cert : fetchActiveEmailCertificates(delMail.getAddress())) {
-                    revokes.add(cert.revoke(RevocationType.USER));
+                    cert.revoke(RevocationType.USER).waitFor(Job.WAIT_MIN);
                 }
                 long start = System.currentTimeMillis();
                 for (Job job : revokes) {
index 81925716caba4cc8376f47b312f0242f85473751..fe52149540c14a67c85d23fc4b1d3f501a18e302 100644 (file)
@@ -14,6 +14,7 @@ import club.wpia.gigi.dbObjects.Certificate.CertificateStatus;
 import club.wpia.gigi.dbObjects.Certificate.SubjectAlternateName;
 import club.wpia.gigi.dbObjects.CertificateProfile;
 import club.wpia.gigi.dbObjects.Domain;
+import club.wpia.gigi.dbObjects.Job;
 import club.wpia.gigi.dbObjects.Organisation;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.localisation.Language;
@@ -106,7 +107,7 @@ public class CertificateIssueForm extends Form {
                     }
                     result.setDescription(description);
                 }
-                result.issue(issueDate.getFrom(), issueDate.getTo(), c.getActor()).waitFor(60000);
+                result.issue(issueDate.getFrom(), issueDate.getTo(), c.getActor()).waitFor(Job.WAIT_MIN);
                 this.result = result;
                 Certificate c = result;
                 if (c.getStatus() != CertificateStatus.ISSUED) {
index 7ca73eb05908c3bc3c4c999f70fa0e9194855312..dd6161132a368a4ec5f2d1d01cbb22fdc4dcf85c 100644 (file)
@@ -54,7 +54,7 @@ public class CertificateModificationForm extends Form {
         }
         long start = System.currentTimeMillis();
         for (Job job : revokes) {
-            int toWait = (int) (60000 + start - System.currentTimeMillis());
+            int toWait = (int) (Job.WAIT_MIN + start - System.currentTimeMillis());
             if (toWait > 0) {
                 job.waitFor(toWait);
             } else {
index 30e404c0cc7b928b95de44eae5f394a6a6ca1c7a..12a7daa92cecac4b510b149e025a389451f9d0af 100644 (file)
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletRequest;
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.dbObjects.Certificate;
 import club.wpia.gigi.dbObjects.Certificate.RevocationType;
+import club.wpia.gigi.dbObjects.Job;
 import club.wpia.gigi.dbObjects.SupportedUser;
 import club.wpia.gigi.localisation.Language;
 import club.wpia.gigi.output.template.Form;
@@ -32,7 +33,7 @@ public class RevokeSingleCertForm extends Form {
         if (target != null) {
             target.revokeCertificate(c);
         } else {
-            c.revoke(RevocationType.USER).waitFor(60000);
+            c.revoke(RevocationType.USER).waitFor(Job.WAIT_MIN);
         }
         return new RedirectResult(req.getPathInfo());
     }
index e0690844d69189034628fb5a4cc2ce571918b103..ae3e30e02e79db35a90d8c76a9e695a0016f5fe8 100644 (file)
@@ -166,7 +166,7 @@ public class KeyCompromiseForm extends Form {
             throw new GigiApiException("Sending the notification mail failed.");
         }
         Job j = c.revoke(challenge, Base64.getEncoder().encodeToString(signature), message);
-        if ( !j.waitFor(60000)) {
+        if ( !j.waitFor(Job.WAIT_MIN)) {
             throw new PermamentFormException(new GigiApiException("Revocation timed out."));
         }
         if (c.getStatus() != CertificateStatus.REVOKED) {
index 50ac27dc6d741fc59fab177192b579ebfc4fe772..d0906ae06c83b03349e7af9fbeff8229ee8143fc 100644 (file)
@@ -27,7 +27,7 @@ public class TestUserManaged extends ManagedTest {
         KeyPair kp = generateKeypair();
         String key = generatePEMCSR(kp, "CN=" + email);
         Certificate c = new Certificate(u, u, Certificate.buildDN("CN", email), Digest.SHA256, key, CSRType.CSR, getClientProfile(), new Certificate.SubjectAlternateName(SANType.EMAIL, email));
-        c.issue(null, "2y", u).waitFor(60000);
+        c.issue(null, "2y", u).waitFor(Job.WAIT_MIN);
 
         u.deleteEmail(testAddress);