X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fclub%2Fwpia%2Fgigi%2Fping%2FHTTPFetch.java;h=61f8b467e77e01b50084cf07ecedcce6a767f5c0;hb=e7f7dbb405adb8f3ea733da746842622b2693c4a;hp=7ad08b55b0bd6ddcfe9ec2793be9e497ce624853;hpb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;p=gigi.git diff --git a/src/club/wpia/gigi/ping/HTTPFetch.java b/src/club/wpia/gigi/ping/HTTPFetch.java index 7ad08b55..61f8b467 100644 --- a/src/club/wpia/gigi/ping/HTTPFetch.java +++ b/src/club/wpia/gigi/ping/HTTPFetch.java @@ -8,36 +8,33 @@ import java.net.URL; import club.wpia.gigi.dbObjects.CertificateOwner; import club.wpia.gigi.dbObjects.Domain; +import club.wpia.gigi.dbObjects.DomainPingConfiguration; +import club.wpia.gigi.dbObjects.DomainPingExecution; import club.wpia.gigi.util.SystemKeywords; public class HTTPFetch extends DomainPinger { @Override - public void ping(Domain domain, String expToken, CertificateOwner user, int confId) { + public DomainPingExecution ping(Domain domain, String expToken, CertificateOwner user, DomainPingConfiguration conf) { try { String[] tokenParts = expToken.split(":", 2); URL u = new URL("http://" + domain.getSuffix() + "/" + SystemKeywords.HTTP_CHALLENGE_PREFIX + tokenParts[0] + ".txt"); HttpURLConnection huc = (HttpURLConnection) u.openConnection(); if (huc.getResponseCode() != 200) { - enterPingResult(confId, "error", "Invalid status code " + huc.getResponseCode() + ".", null); - return; + return enterPingResult(conf, "error", "Invalid status code " + huc.getResponseCode() + ".", null); } BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream(), "UTF-8")); String line = br.readLine(); if (line == null) { - enterPingResult(confId, "error", "Empty document.", null); - return; + return enterPingResult(conf, "error", "Empty document.", null); } if (line.trim().equals(tokenParts[1])) { - enterPingResult(confId, PING_SUCCEDED, "", null); - return; + return enterPingResult(conf, PING_SUCCEDED, "", null); } - enterPingResult(confId, "error", "Challenge tokens differed.", null); - return; + return enterPingResult(conf, "error", "Challenge tokens differed.", null); } catch (IOException e) { e.printStackTrace(); - enterPingResult(confId, "error", "Exception: connection closed.", null); - return; + return enterPingResult(conf, "error", "Exception: connection closed.", null); } } }