X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fping%2FHTTPFetch.java;fp=src%2Forg%2Fcacert%2Fgigi%2Fping%2FHTTPFetch.java;h=0000000000000000000000000000000000000000;hp=1f31ccd633d19f0e00b91140852448b4e024230e;hb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;hpb=c9ed09f0007fc2c813815be927a5a24b23dab83c diff --git a/src/org/cacert/gigi/ping/HTTPFetch.java b/src/org/cacert/gigi/ping/HTTPFetch.java deleted file mode 100644 index 1f31ccd6..00000000 --- a/src/org/cacert/gigi/ping/HTTPFetch.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.cacert.gigi.ping; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; - -import org.cacert.gigi.dbObjects.CertificateOwner; -import org.cacert.gigi.dbObjects.Domain; -import org.cacert.gigi.util.SystemKeywords; - -public class HTTPFetch extends DomainPinger { - - @Override - public void ping(Domain domain, String expToken, CertificateOwner user, int confId) { - 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; - } - BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream(), "UTF-8")); - String line = br.readLine(); - if (line == null) { - enterPingResult(confId, "error", "Empty document.", null); - return; - } - if (line.trim().equals(tokenParts[1])) { - enterPingResult(confId, PING_SUCCEDED, "", null); - return; - } - enterPingResult(confId, "error", "Challenge tokens differed.", null); - return; - } catch (IOException e) { - e.printStackTrace(); - enterPingResult(confId, "error", "Exception: connection closed.", null); - return; - } - } -}