X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FDomain.java;h=7e35225f4d99d409cee53e9aec64544c8563df9a;hb=e04e99de1af984634675056004cd031c0b526505;hp=8efa4ee1870910f961b1476ae743d1cee7454ccb;hpb=0396bd9a17ee73f8dc3c0f8a4424424f3ce16ead;p=gigi.git diff --git a/src/org/cacert/gigi/dbObjects/Domain.java b/src/org/cacert/gigi/dbObjects/Domain.java index 8efa4ee1..7e35225f 100644 --- a/src/org/cacert/gigi/dbObjects/Domain.java +++ b/src/org/cacert/gigi/dbObjects/Domain.java @@ -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 { @@ -68,10 +69,11 @@ public class Domain implements IdCachable { private int id; private static final Set 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 +234,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); @@ -260,7 +262,7 @@ public class Domain implements IdCachable { } - private static ObjectCache myCache = new ObjectCache<>(); + private static final ObjectCache myCache = new ObjectCache<>(); public static synchronized Domain getById(int id) throws IllegalArgumentException { Domain em = myCache.get(id);