]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/Certificate.java
fix: a 0-point-assurance prexents account details editing
[gigi.git] / src / org / cacert / gigi / dbObjects / Certificate.java
index 7512712da7a43dbb504417f25522595ba071be1c..f355e67abe7cc72e3e1b6f678e0ebdef2baa0dbc 100644 (file)
@@ -354,26 +354,21 @@ public class Certificate implements IdCachable {
         if (serial == null || "".equals(serial)) {
             return null;
         }
-        try {
-            String concat = "string_agg(concat('/', `name`, '=', REPLACE(REPLACE(value, '\\\\', '\\\\\\\\'), '/', '\\\\/')), '')";
-            GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT certs.id, " + concat + " as `subject`, `md`, `csr_name`, `crt_name`,`memid`, `profile`, `certs`.`serial` FROM `certs` LEFT JOIN `certAvas` ON `certAvas`.`certId`=`certs`.`id` WHERE `serial`=? GROUP BY `certs`.`id`");
-            ps.setString(1, serial);
-            GigiResultSet rs = ps.executeQuery();
-            if ( !rs.next()) {
-                return null;
-            }
-            int id = rs.getInt(1);
-            Certificate c1 = cache.get(id);
-            if (c1 != null) {
-                return c1;
-            }
-            Certificate certificate = new Certificate(rs);
-            cache.put(certificate);
-            return certificate;
-        } catch (IllegalArgumentException e) {
-
+        String concat = "string_agg(concat('/', `name`, '=', REPLACE(REPLACE(value, '\\\\', '\\\\\\\\'), '/', '\\\\/')), '')";
+        GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT certs.id, " + concat + " as `subject`, `md`, `csr_name`, `crt_name`,`memid`, `profile`, `certs`.`serial` FROM `certs` LEFT JOIN `certAvas` ON `certAvas`.`certId`=`certs`.`id` WHERE `serial`=? GROUP BY `certs`.`id`");
+        ps.setString(1, serial);
+        GigiResultSet rs = ps.executeQuery();
+        if ( !rs.next()) {
+            return null;
         }
-        return null;
+        int id = rs.getInt(1);
+        Certificate c1 = cache.get(id);
+        if (c1 != null) {
+            return c1;
+        }
+        Certificate certificate = new Certificate(rs);
+        cache.put(certificate);
+        return certificate;
     }
 
     private static ObjectCache<Certificate> cache = new ObjectCache<>();
@@ -429,7 +424,6 @@ public class Certificate implements IdCachable {
             GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("SELECT revoked FROM certs WHERE id=?");
             prep.setInt(1, getId());
             GigiResultSet res = prep.executeQuery();
-            res.beforeFirst();
             if (res.next()) {
                 return new java.util.Date(res.getDate("revoked").getTime());
             }