X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FCACertificate.java;h=bc900a84b422a4c6137023f1be8ede4cbdc52b13;hb=b47a25c5c2156fdd6adf40b72617b9bfc7688df4;hp=b6ede830e902887f8d58dcb34ba44fbebdb73e76;hpb=a7aea81ff9eebb35aef0f91dfa8b5e3c797568f8;p=gigi.git diff --git a/src/org/cacert/gigi/dbObjects/CACertificate.java b/src/org/cacert/gigi/dbObjects/CACertificate.java index b6ede830..bc900a84 100644 --- a/src/org/cacert/gigi/dbObjects/CACertificate.java +++ b/src/org/cacert/gigi/dbObjects/CACertificate.java @@ -16,6 +16,7 @@ import javax.security.auth.x500.X500Principal; import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.database.GigiResultSet; +import org.cacert.gigi.util.ServerConstants; public class CACertificate implements IdCachable { @@ -31,7 +32,7 @@ public class CACertificate implements IdCachable { private CACertificate(int id) { this.id = id; - GigiPreparedStatement conn = DatabaseConnection.getInstance().prepare("SELECT keyname, parentRoot, link FROM cacerts WHERE id = ?"); + GigiPreparedStatement conn = DatabaseConnection.getInstance().prepare("SELECT `keyname`, `parentRoot`, `link` FROM `cacerts` WHERE `id`=?"); conn.setInt(1, id); GigiResultSet res = conn.executeQuery(); if ( !res.next()) { @@ -109,7 +110,7 @@ public class CACertificate implements IdCachable { X500Principal subj = toInsert.getSubjectX500Principal(); boolean self = toInsert.getIssuerX500Principal().equals(subj); - GigiPreparedStatement q = DatabaseConnection.getInstance().prepare("SELECT id, parentRoot FROM cacerts WHERE keyname=?"); + GigiPreparedStatement q = DatabaseConnection.getInstance().prepare("SELECT `id`, `parentRoot` FROM `cacerts` WHERE `keyname`=?"); q.setString(1, names.get(subj)); GigiResultSet res = q.executeQuery(); int id; @@ -122,20 +123,20 @@ public class CACertificate implements IdCachable { String link; String keyname = names.get(subj); if ( !keyname.contains("_")) { - link = "http://g2.crt.cacert.org/g2/" + keyname + ".crt"; + link = "http://g2.crt." + ServerConstants.getSuffix() + "/g2/" + keyname + ".crt"; } else { String[] parts = keyname.split("_"); - link = "http://g2.crt.cacert.org/g2/" + parts[1] + "/" + parts[0] + "-" + parts[2] + ".crt"; + link = "http://g2.crt." + ServerConstants.getSuffix() + "/g2/" + parts[1] + "/" + parts[0] + "-" + parts[2] + ".crt"; } - GigiPreparedStatement q2 = DatabaseConnection.getInstance().prepare("INSERT INTO cacerts SET parentRoot=?, keyname=?, link=?"); + GigiPreparedStatement q2 = DatabaseConnection.getInstance().prepare("INSERT INTO `cacerts` SET `parentRoot`=?, `keyname`=?, `link`=?"); q2.setInt(1, self ? 0 : inserted.get(toInsert.getIssuerX500Principal())); q2.setString(2, keyname); q2.setString(3, link); q2.execute(); id = q2.lastInsertId(); if (self) { - GigiPreparedStatement q3 = DatabaseConnection.getInstance().prepare("UPDATE cacerts SET parentRoot=?, id=?"); + GigiPreparedStatement q3 = DatabaseConnection.getInstance().prepare("UPDATE `cacerts` SET `parentRoot`=?, `id`=?"); q3.setInt(1, id); q3.setInt(2, id); q3.execute();