]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/dbObjects/CertificateOwner.java
add: check that new email address is not linked to organisation domain
[gigi.git] / src / club / wpia / gigi / dbObjects / CertificateOwner.java
index 1c7cdb4a2e2a2109cda94bb566b58f8f8c84e7b1..72e5a81672762a74510cfbe7743dda61f19d2231 100644 (file)
@@ -5,6 +5,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
+import java.math.BigInteger;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -24,7 +25,15 @@ public abstract class CertificateOwner implements IdCachable, Serializable {
         this.id = id;
     }
 
-    protected CertificateOwner() {
+    /**
+     * This constructor has a dummy parameter to allow callers to do checks
+     * before invoking the super constructor.
+     * 
+     * @param dummy
+     *            a parameter that is not used to allow callers to do checks
+     *            before super constructor invocation.
+     */
+    protected CertificateOwner(Void dummy) {
         try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `certOwners` DEFAULT VALUES")) {
             ps.execute();
             id = ps.lastInsertId();
@@ -83,7 +92,7 @@ public abstract class CertificateOwner implements IdCachable, Serializable {
     }
 
     public Certificate[] getCertificates(boolean includeRevoked) {
-        try (GigiPreparedStatement ps = new GigiPreparedStatement(includeRevoked ? "SELECT id FROM certs WHERE memid=? ORDER BY id DESC" : "SELECT id FROM certs WHERE memid=? AND revoked IS NULL ORDER BY id DESC")) {
+        try (GigiPreparedStatement ps = new GigiPreparedStatement(includeRevoked ? "SELECT id FROM certs WHERE memid=? ORDER BY id DESC" : "SELECT id FROM certs WHERE memid=? AND `revoked` IS NULL ORDER BY id DESC")) {
             ps.setInt(1, getId());
 
             GigiResultSet rs = ps.executeQuery();
@@ -131,9 +140,9 @@ public abstract class CertificateOwner implements IdCachable, Serializable {
         }
     }
 
-    public static CertificateOwner getByEnabledSerial(String serial) {
+    public static CertificateOwner getByEnabledSerial(BigInteger serial) {
         try (GigiPreparedStatement prep = new GigiPreparedStatement("SELECT `memid` FROM `certs` INNER JOIN `logincerts` ON `logincerts`.`id`=`certs`.`id` WHERE serial=? AND `revoked` is NULL")) {
-            prep.setString(1, serial);
+            prep.setString(1, serial.toString(16));
             GigiResultSet res = prep.executeQuery();
             if (res.next()) {
                 return getById(res.getInt(1));