}
- public static final int CURRENT_SCHEMA_VERSION = 6;
+ public static final int CURRENT_SCHEMA_VERSION = 7;
public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
"domainid" int NOT NULL,
"type" "pingType" NOT NULL,
"info" varchar(255) NOT NULL,
+ "deleted" timestamp NULL DEFAULT NULL,
PRIMARY KEY ("id")
);
"version" smallint NOT NULL,
PRIMARY KEY ("version")
);
-INSERT INTO "schemeVersion" (version) VALUES(6);
+INSERT INTO "schemeVersion" (version) VALUES(7);
DROP TABLE IF EXISTS `passwordResetTickets`;
CREATE TABLE `passwordResetTickets` (
--- /dev/null
+ALTER TABLE "pingconfig" ADD COLUMN "deleted" timestamp NULL DEFAULT NULL;
LinkedList<DomainPingConfiguration> configs = this.configs;
if (configs == null) {
configs = new LinkedList<>();
- try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=?")) {
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=? AND `deleted` IS NULL")) {
ps.setInt(1, id);
GigiResultSet rs = ps.executeQuery();
while (rs.next()) {
configs = null;
}
+ public void clearPings() throws GigiApiException {
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `pingconfig` SET `deleted`=CURRENT_TIMESTAMP WHERE `deleted` is NULL AND `domainid`=?")) {
+ ps.setInt(1, id);
+ ps.execute();
+ }
+ configs = null;
+ }
+
public synchronized void verify(String hash) throws GigiApiException {
try (GigiPreparedStatement ps = new GigiPreparedStatement("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);
@Override
public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
+ target.clearPings();
if (req.getParameter("emailType") != null && req.getParameter("email") != null) {
try {
String mail = AUTHORATIVE_EMAILS[Integer.parseInt(req.getParameter("email"))];
@Override
public void run() {
- searchNeededPings = new GigiPreparedStatement("SELECT `pingconfig`.`id` FROM `pingconfig` LEFT JOIN `domainPinglog` ON `domainPinglog`.`configId` = `pingconfig`.`id` INNER JOIN `domains` ON `domains`.`id` = `pingconfig`.`domainid` WHERE ( `domainPinglog`.`configId` IS NULL OR `domainPinglog`.`when` < CURRENT_TIMESTAMP - interval '6 mons') AND `domains`.`deleted` IS NOT NULL AND `pingconfig`.`deleted` IS NOT NULL GROUP BY `pingconfig`.`id`");
+ searchNeededPings = new GigiPreparedStatement("SELECT `pingconfig`.`id` FROM `pingconfig` LEFT JOIN `domainPinglog` ON `domainPinglog`.`configId` = `pingconfig`.`id` INNER JOIN `domains` ON `domains`.`id` = `pingconfig`.`domainid` WHERE ( `domainPinglog`.`configId` IS NULL OR `domainPinglog`.`when` < CURRENT_TIMESTAMP - interval '6 mons') AND `domains`.`deleted` IS NULL AND `pingconfig`.`deleted` IS NULL GROUP BY `pingconfig`.`id`");
pingers.put(DomainPingType.EMAIL, new EmailPinger());
pingers.put(DomainPingType.SSL, new SSLPinger(truststore));
pingers.put(DomainPingType.HTTP, new HTTPFetch());
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
java.security.cert.X509Certificate c = chain[0];
if ( !c.getExtendedKeyUsage().contains("1.3.6.1.5.5.7.3.1")) {
- System.out.println(c.getExtendedKeyUsage());
throw new java.security.cert.CertificateException("Illegal EKU");
}
}
}
return PING_SUCCEDED;
} catch (GeneralSecurityException e) {
- e.printStackTrace();
+ // e.printStackTrace();
return "Security failed";
} catch (SSLException e) {
- e.printStackTrace();
// e.printStackTrace(); TODO log for user debugging?
return "Security failed";
} catch (IOException e) {
// e.printStackTrace(); TODO log for user debugging?
return "Connection closed";
} catch (CertificateException e) {
- e.printStackTrace();
+ // e.printStackTrace();
return "Security failed";
}
}