]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/dbObjects/Certificate.java
upd: move revocation info to own table
[gigi.git] / src / club / wpia / gigi / dbObjects / Certificate.java
index ffc5154766f19ef7039be8346b68f5fd2516dfb0..c3ff5ab1f2e3e1abb126f964035ea187717a70b7 100644 (file)
@@ -27,6 +27,21 @@ import club.wpia.gigi.util.KeyStorage;
 
 public class Certificate implements IdCachable {
 
+    public enum RevocationType implements DBEnum {
+        USER("user"), SUPPORT("support"), PING_TIMEOUT("ping_timeout");
+
+        private final String dbName;
+
+        private RevocationType(String dbName) {
+            this.dbName = dbName;
+        }
+
+        @Override
+        public String getDBName() {
+            return dbName;
+        }
+    }
+
     public enum SANType implements DBEnum {
         EMAIL("email"), DNS("DNS");
 
@@ -282,7 +297,7 @@ public class Certificate implements IdCachable {
     }
 
     public synchronized CertificateStatus getStatus() {
-        try (GigiPreparedStatement searcher = new GigiPreparedStatement("SELECT crt_name, created, revoked, serial, caid FROM certs WHERE id=?")) {
+        try (GigiPreparedStatement searcher = new GigiPreparedStatement("SELECT crt_name, created, `revoked`, serial, caid FROM certs LEFT JOIN `certsRevoked` ON `certs`.`id` = `certsRevoked`.`id` WHERE `certs`.id=?")) {
             searcher.setInt(1, id);
             GigiResultSet rs = searcher.executeQuery();
             if ( !rs.next()) {
@@ -325,11 +340,11 @@ public class Certificate implements IdCachable {
 
     }
 
-    public Job revoke() {
+    public Job revoke(RevocationType type) {
         if (getStatus() != CertificateStatus.ISSUED) {
             throw new IllegalStateException();
         }
-        return Job.revoke(this);
+        return Job.revoke(this, type);
 
     }
 
@@ -467,7 +482,7 @@ public class Certificate implements IdCachable {
 
     public java.util.Date getRevocationDate() {
         if (getStatus() == CertificateStatus.REVOKED) {
-            try (GigiPreparedStatement prep = new GigiPreparedStatement("SELECT revoked FROM certs WHERE id=?")) {
+            try (GigiPreparedStatement prep = new GigiPreparedStatement("SELECT revoked FROM `certsRevoked` WHERE id=?")) {
                 prep.setInt(1, getId());
                 GigiResultSet res = prep.executeQuery();
                 if (res.next()) {