]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/Domain.java
upd: Beautify up the verification form.
[gigi.git] / src / org / cacert / gigi / dbObjects / Domain.java
index 8efa4ee1870910f961b1476ae743d1cee7454ccb..00f51c1fe87df68cf050dd3020c49bbc7e245f9f 100644 (file)
@@ -1,6 +1,7 @@
 package org.cacert.gigi.dbObjects;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.IDN;
 import java.util.Arrays;
 import java.util.Collections;
@@ -17,7 +18,7 @@ import org.cacert.gigi.database.GigiResultSet;
 import org.cacert.gigi.dbObjects.DomainPingConfiguration.PingType;
 import org.cacert.gigi.util.PublicSuffixes;
 
-public class Domain implements IdCachable {
+public class Domain implements IdCachable, Verifyable {
 
     public class DomainPingExecution {
 
@@ -70,8 +71,8 @@ public class Domain implements IdCachable {
     private static final Set<String> IDNEnabledTLDs;
     static {
         Properties CPS = new Properties();
-        try {
-            CPS.load(Domain.class.getResourceAsStream("CPS.properties"));
+        try (InputStream resourceAsStream = Domain.class.getResourceAsStream("CPS.properties")) {
+            CPS.load(resourceAsStream);
             IDNEnabledTLDs = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(CPS.getProperty("IDN-enabled").split(","))));
         } catch (IOException e) {
             throw new Error(e);
@@ -232,7 +233,7 @@ public class Domain implements IdCachable {
         configs = null;
     }
 
-    public void verify(String hash) 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=?)");
         ps.setString(1, hash);
         ps.setInt(2, id);