X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclub%2Fwpia%2Fgigi%2FdbObjects%2FJob.java;h=071b1b2ef0ced65f3eb6bfb0d217bdde6f1f4aa6;hb=b373422ceb172e10e2ff32c09141158529b3f48b;hp=ea8fc97d560215facf75b73c94e99fea143a31da;hpb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;p=gigi.git diff --git a/src/club/wpia/gigi/dbObjects/Job.java b/src/club/wpia/gigi/dbObjects/Job.java index ea8fc97d..071b1b2e 100644 --- a/src/club/wpia/gigi/dbObjects/Job.java +++ b/src/club/wpia/gigi/dbObjects/Job.java @@ -6,10 +6,13 @@ import club.wpia.gigi.GigiApiException; import club.wpia.gigi.database.DBEnum; import club.wpia.gigi.database.GigiPreparedStatement; import club.wpia.gigi.database.GigiResultSet; +import club.wpia.gigi.dbObjects.Certificate.RevocationType; import club.wpia.gigi.output.CertificateValiditySelector; public class Job implements IdCachable { + public static int WAIT_MIN = 60000; + private int id; private Job(int id) { @@ -31,7 +34,7 @@ public class Job implements IdCachable { } } - public synchronized static Job sign(Certificate targetId, Date start, String period) throws GigiApiException { + protected synchronized static Job sign(Certificate targetId, Date start, String period) throws GigiApiException { CertificateValiditySelector.checkValidityLength(period); try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `jobs` SET targetId=?, task=?::`jobType`, executeFrom=?, executeTo=?")) { ps.setInt(1, targetId.getId()); @@ -43,7 +46,23 @@ public class Job implements IdCachable { } } - public synchronized static Job revoke(Certificate targetId) { + protected synchronized static Job revoke(Certificate targetId, RevocationType type) { + return revoke(targetId, type, null, null, null); + } + + protected synchronized static Job revoke(Certificate targetId, String challenge, String signature, String message) { + return revoke(targetId, RevocationType.KEY_COMPROMISE, challenge, signature, message); + } + + private synchronized static Job revoke(Certificate targetId, RevocationType type, String challenge, String signature, String message) { + try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `certs` SET `revocationType`=?::`revocationType`, `revocationChallenge`=?, `revocationSignature`=?, `revocationMessage`=? WHERE id=?")) { + ps.setEnum(1, type); + ps.setString(2, challenge); + ps.setString(3, signature); + ps.setString(4, message); + ps.setInt(5, targetId.getId()); + ps.execute(); + } try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `jobs` SET targetId=?, task=?::`jobType`")) { ps.setInt(1, targetId.getId());