}
public Domain(User owner, String suffix) throws GigiApiException {
- checkCertifyableDomain(suffix, owner.isInGroup(Group.CODESIGNING));
- this.owner = owner;
- this.suffix = suffix;
-
+ synchronized (Domain.class) {
+ checkCertifyableDomain(suffix, owner.isInGroup(Group.CODESIGNING));
+ this.owner = owner;
+ this.suffix = suffix;
+ insert();
+ }
}
public static void checkCertifyableDomain(String s, boolean hasPunycodeRight) throws GigiApiException {
}
}
- public void insert() throws GigiApiException {
- synchronized (Domain.class) {
- if (id != 0) {
- throw new GigiApiException("already inserted.");
- }
- checkInsert(suffix);
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `domains` SET memid=?, domain=?");
- ps.setInt(1, owner.getId());
- ps.setString(2, suffix);
- ps.execute();
- id = ps.lastInsertId();
- myCache.put(this);
+ private void insert() throws GigiApiException {
+ if (id != 0) {
+ throw new GigiApiException("already inserted.");
}
+ checkInsert(suffix);
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `domains` SET memid=?, domain=?");
+ ps.setInt(1, owner.getId());
+ ps.setString(2, suffix);
+ ps.execute();
+ id = ps.lastInsertId();
+ myCache.put(this);
}
public void delete() throws GigiApiException {
}
public synchronized void verify(String hash) throws GigiApiException {
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE `domainPinglog` SET `state`='success' WHERE `challenge`=? AND `configId` IN (SELECT `id` FROM `pingconfig` WHERE `domainid`=?)");
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE `domainPinglog` SET `state`='success' WHERE `challenge`=? AND `state`='open' AND `configId` IN (SELECT `id` FROM `pingconfig` WHERE `domainid`=? AND `type`='email')");
ps.setString(1, hash);
ps.setInt(2, id);
ps.executeUpdate();