public DNSLookupContinuation onDNSResponse()

in resolver/src/main/java/org/apache/james/jspf/terms/ExpModifier.java [157:201]


    public DNSLookupContinuation onDNSResponse(DNSResponse lookup, SPFSession spfData) throws PermErrorException, TempErrorException, NeutralException, NoneException {
        try {
            List<String> records = lookup.getResponse();
        
            if (records == null) {
                return null;
            }
    
            // See SPF-Spec 6.2
            //
            // If domain-spec is empty, or there are any DNS processing errors (any RCODE other than 0), 
            // or if no records are returned, or if more than one record is returned, or if there are syntax 
            // errors in the explanation string, then proceed as if no exp modifier was given.   
            if (records.size() > 1) {
                
                LOGGER.debug("More then one TXT-Record found for explanation");
                // Only catch the error and return null
                
            } else {
                
                String exp = records.get(0);
                if (exp.length()>=2 && exp.charAt(0) == '"' && exp.charAt(exp.length() -1 ) == '"') {
                    exp = exp.substring(1, exp.length() - 1);
                }

                spfData.setAttribute(ATTRIBUTE_EXPAND_EXPLANATION, exp);
                
                if ((exp != null) && (!exp.equals(""))) {
                    
                    try {
                        spfData.pushChecker(expandedExplanationChecker);
                        return macroExpand.checkExpand(exp, spfData, MacroExpand.EXPLANATION);
                    } catch (PermErrorException e) {
                        // ignore syntax error on explanation expansion
                    }
                }
                
            }
            

        } catch (TimeoutException e) {
            // Nothing todo here.. just return null
        }
        return null;
    }