1 package club.wpia.gigi.ping;
3 import java.util.Arrays;
6 import javax.naming.NamingException;
8 import club.wpia.gigi.dbObjects.CertificateOwner;
9 import club.wpia.gigi.dbObjects.Domain;
10 import club.wpia.gigi.util.DNSUtil;
11 import club.wpia.gigi.util.SystemKeywords;
13 public class DNSPinger extends DomainPinger {
16 public void ping(Domain domain, String expToken, CertificateOwner u, int confId) {
17 String[] tokenParts = expToken.split(":", 2);
18 List<String> nameservers;
20 nameservers = Arrays.asList(DNSUtil.getNSNames(domain.getSuffix()));
21 } catch (NamingException e) {
22 enterPingResult(confId, "error", "No authorative nameserver found.", null);
25 StringBuffer result = new StringBuffer();
26 result.append("failed: ");
27 boolean failed = nameservers.isEmpty();
29 for (String NS : nameservers) {
30 boolean found = false;
32 for (String token : DNSUtil.getTXTEntries(tokenParts[0] + "." + SystemKeywords.DNS_PREFIX + "._auth." + domain.getSuffix(), NS)) {
33 if (token.isEmpty()) {
37 if (token.equals(tokenParts[1])) {
41 } catch (NamingException e) {
46 result.append(" DIFFER;");
48 result.append(" EMPTY;");
54 enterPingResult(confId, PING_SUCCEDED, "", null);
56 enterPingResult(confId, "error", result.toString(), null);