Package org.apache.james.jspf.executor

Examples of org.apache.james.jspf.executor.SPFResult


    public SpfChecker(MailTransaction mailTransaction) {
        this.mailTransaction = mailTransaction;
    }

    public SPFResult getResult() {
        SPFResult result =
                (SPFResult) mailTransaction.getAttribute(SPF_RESULT_NAME);
        if (result == null) {
            result = check();
            mailTransaction.setAttribute(SPF_RESULT_NAME, result);
        }
View Full Code Here


        String helo = mailTransaction.getMessageContext().getHelo();
        String heloNonNull =
                helo == null ? "["
                        + mailTransaction.getRemoteInetAddress()
                                .getHostAddress() + "]" : helo;
        SPFResult result =
                spf.checkSPF(mailTransaction.getRemoteInetAddress()
                        .getHostAddress(), fromNonNull, heloNonNull);
        logger.debug("SPF check result: {} {}", result.getResult(), result
                .getExplanation());
        return result;
    }
View Full Code Here

        }

        @Override
        public FilterReply verifyRecipient(RecipientContext recipientContext)
                throws RejectExceptionExt {
            SPFResult spfResult = spfChecker.getResult();
            String spfResultCode = spfResult.getResult();

            if (spfResultCode.equals(SPFErrorConstants.FAIL_CONV)) {
                String statusText;
                if (spfResult.getExplanation().isEmpty())
                    statusText = "Blocked by SPF";
                else
                    statusText = "Blocked - see: " + spfResult.getExplanation();
                throw new RejectException(550, statusText);
            } else if (spfResult.equals(SPFErrorConstants.TEMP_ERROR_CONV)) {
                throw new RejectException(451,
                        "Temporarily rejected: Problem on SPF lookup");
            } else if (rejectOnPermanentError
                    && spfResultCode.equals(SPFErrorConstants.PERM_ERROR_CONV)) {
                throw new RejectException(550, "Blocked - invalid SPF record");
View Full Code Here

        }

        @Override
        public void data(MailData data) throws RejectExceptionExt,
                TooMuchDataException, IOException {
            SPFResult spfResult = spfChecker.getResult();
            String headerString = spfResult.getHeader() + "\r\n";
            byte[] headerOctets = TextUtils.getAsciiBytes(headerString);
            SpfHeaderPrependedMailData prependedMailData =
                    new SpfHeaderPrependedMailData(headerOctets, data);

            chain.data(prependedMailData);
View Full Code Here

        }
        spf = new SPF(dns, parser, log.getChildLogger("spf"), macroExpand, executor);

        if (test != null) {
            String next = test;
            SPFResult res = runSingleTest(next);
            verifyResult(next, res);
        } else {
            Map queries = new HashMap();
            for (Iterator i = data.getTests().keySet().iterator(); i.hasNext(); ) {
                String next = (String) i.next();
                SPFResult res = runSingleTest(next);
                queries.put(next, res);
            }
            for (Iterator i = queries.keySet().iterator(); i.hasNext(); ) {
                String next = (String) i.next();
                verifyResult(next, (SPFResult) queries.get(next));
View Full Code Here

            sender = (String) currentTest.get("mailfrom");
        } else {
            sender = "";
        }
   
        SPFResult res = spf.checkSPF(ip, sender, helo);
        return res;
    }
View Full Code Here

            if (senderAddr != null) {
                sender = senderAddr.toString();
            } else {
                sender = "";
            }
            SPFResult result = spf.checkSPF(remoteAddr, sender, helo);
            mail.setAttribute(EXPLANATION_ATTRIBUTE, result.getExplanation());
            mail.setAttribute(RESULT_ATTRIBUTE, result.getResult());

            log("ip:" + remoteAddr + " from:" + sender + " helo:" + helo
                    + " = " + result.getResult());
            if (addHeader) {
                try {
                    MimeMessage msg = mail.getMessage();
                    msg.addHeader(result.getHeaderName(), result
                            .getHeaderText());
                    msg.saveChanges();
                } catch (MessagingException e) {
                    // Ignore not be able to add headers
                }
View Full Code Here

               
                if (useTrustedForwarder == true) {
                    spf.setUseTrustedForwarder(true);
                }

                SPFResult result = spf.checkSPF(ip, sender, helo);
                System.out.println(result.getResult());
                System.out.println(result.getHeader());
                System.exit(getReturnCode(result.getResult()));

            } else {
                usage();
            }
        } catch (ParseException e) {
View Full Code Here

        }
        spf = new SPF(dns, parser, log.getChildLogger("spf"), macroExpand, executor);

        if (test != null) {
            String next = test;
            SPFResult res = runSingleTest(next);
            verifyResult(next, res);
        } else {
            Map<String,SPFResult> queries = new HashMap<String,SPFResult>();
            for (Iterator<String> i = data.getTests().keySet().iterator(); i.hasNext(); ) {
                String next = i.next();
                SPFResult res = runSingleTest(next);
                queries.put(next, res);
            }
            AssertionFailedError firstError = null;
            for (Iterator<String> i = queries.keySet().iterator(); i.hasNext(); ) {
                String next = i.next();
View Full Code Here

            sender = (String) currentTest.get("mailfrom");
        } else {
            sender = "";
        }
   
        SPFResult res = spf.checkSPF(ip, sender, helo);
        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.james.jspf.executor.SPFResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.