in resolver/src/main/java/org/apache/james/jspf/terms/AMechanism.java [71:117]
public DNSLookupContinuation checkSPF(SPFSession spfData) throws PermErrorException,
TempErrorException, NeutralException, NoneException {
// Get the right host.
String host = expandHost(spfData);
// get the ipAddress
try {
boolean validIPV4Address = Inet6Util.isValidIPV4Address(spfData.getIpAddress());
spfData.setAttribute(ATTRIBUTE_AMECHANISM_IPV4CHECK, Boolean.valueOf(validIPV4Address));
if (validIPV4Address) {
List<String> aRecords = getARecords(host);
if (aRecords == null) {
try {
DNSRequest request = new DNSRequest(host, DNSRequest.A);
return new DNSLookupContinuation(request, AMechanism.this);
} catch (NoneException e) {
return onDNSResponse(new DNSResponse(aRecords), spfData);
}
} else {
return onDNSResponse(new DNSResponse(aRecords), spfData);
}
} else {
List<String> aaaaRecords = getAAAARecords(host);
if (aaaaRecords == null) {
try {
DNSRequest request = new DNSRequest(host, DNSRequest.AAAA);
return new DNSLookupContinuation(request, AMechanism.this);
} catch (NoneException e) {
return onDNSResponse(new DNSResponse(aaaaRecords), spfData);
}
} else {
return onDNSResponse(new DNSResponse(aaaaRecords), spfData);
}
}
// PermError / TempError
// TODO: Should we replace this with the "right" Exceptions ?
} catch (Exception e) {
LOGGER.debug("No valid ipAddress: ", e);
throw new PermErrorException("No valid ipAddress: "
+ spfData.getIpAddress());
}
}