1 package org.cacert.gigi.ping;
3 import java.util.Arrays;
6 import javax.naming.NamingException;
8 import org.cacert.gigi.dbObjects.CertificateOwner;
9 import org.cacert.gigi.dbObjects.Domain;
10 import org.cacert.gigi.util.DNSUtil;
12 public class DNSPinger extends DomainPinger {
15 public void ping(Domain domain, String expToken, CertificateOwner u, int confId) {
16 String[] tokenParts = expToken.split(":", 2);
17 List<String> nameservers;
19 nameservers = Arrays.asList(DNSUtil.getNSNames(domain.getSuffix()));
20 } catch (NamingException e) {
21 enterPingResult(confId, "error", "No authorative nameserver found.", null);
24 StringBuffer result = new StringBuffer();
25 result.append("failed: ");
26 boolean failed = nameservers.isEmpty();
28 for (String NS : nameservers) {
29 boolean found = false;
31 for (String token : DNSUtil.getTXTEntries(tokenParts[0] + "._cacert._auth." + domain.getSuffix(), NS)) {
32 if (token.isEmpty()) {
36 if (token.equals(tokenParts[1])) {
40 } catch (NamingException e) {
45 result.append(" DIFFER;");
47 result.append(" EMPTY;");
53 enterPingResult(confId, PING_SUCCEDED, "", null);
55 enterPingResult(confId, "error", result.toString(), null);