Package org.apache.james.protocols.smtp.hook

Examples of org.apache.james.protocols.smtp.hook.HookResult


                AuthHook rawHook = hooks.get(i);
                session.getLogger().debug("executing  hook " + rawHook);
               

                long start = System.currentTimeMillis();
                HookResult hRes = rawHook.doAuth(session, user, pass);
                long executionTime = System.currentTimeMillis() - start;

                if (rHooks != null) {
                    for (int i2 = 0; i2 < rHooks.size(); i2++) {
                        Object rHook = rHooks.get(i2);
View Full Code Here


     * @see org.apache.james.protocols.smtp.hook.MailParametersHook#doMailParameter(org.apache.james.protocols.smtp.SMTPSession, java.lang.String, java.lang.String)
     */
    public HookResult doMailParameter(SMTPSession session, String paramName, String paramValue) {
        // Ignore the AUTH command.
        // TODO we should at least check for correct syntax and put the result in session
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

     * @see org.apache.james.protocols.smtp.hook.RcptHook#doRcpt(org.apache.james.protocols.smtp.SMTPSession, org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
     */
    public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
        String address = session.getRemoteAddress().getAddress().getHostAddress();
        if (isBlocked(address, session)) {
            return new HookResult(HookReturnCode.DENY);
        } else {
        
            if (spamTrapRecips.contains(rcpt.toString().toLowerCase())){
       
                addIp(address, session);
           
                return new HookResult(HookReturnCode.DENY);
            }
        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

     */
    public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
        if ((session.getRcptCount() + 1) > maxRcpt) {
            session.getLogger().info("Maximum recipients of " + maxRcpt + " reached");
           
            return new HookResult(HookReturnCode.DENY, SMTPRetCode.SYSTEM_STORAGE_ERROR, DSNStatus.getStatus(DSNStatus.NETWORK, DSNStatus.DELIVERY_TOO_MANY_REC)
                    + " Requested action not taken: max recipients reached");
        } else {
            return new HookResult(HookReturnCode.DECLINED);
        }
    }
View Full Code Here

            responseBuffer.append(DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.ADDRESS_VALID))
                          .append(" Recipient <")
                          .append(rcpt.toString())
                          .append("> OK");
            session.getLogger().debug("Duplicate recipient not add to recipient list: " + rcpt.toString());
            return new HookResult(HookReturnCode.OK,SMTPRetCode.MAIL_OK, responseBuffer.toString());
        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

            for (int i = 0; i < count; i++) {
                MessageHook rawHandler = (MessageHook) messageHandlers.get(i);
                session.getLogger().debug("executing message handler " + rawHandler);

                long start = System.currentTimeMillis();
                HookResult hRes = rawHandler.onMessage(session, mail);
                long executionTime = System.currentTimeMillis() - start;

                if (rHooks != null) {
                    for (int i2 = 0; i2 < rHooks.size(); i2++) {
                        Object rHook = rHooks.get(i2);
                        session.getLogger().debug("executing hook " + rHook);

                        hRes = ((HookResultHook) rHook).onHookResult(session, hRes, executionTime, rawHandler);
                    }
                }

                SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(hRes);

                // if the response is received, stop processing of command
                // handlers
                if (response != null) {
                    return response;
                }
            }

            // Not queue the message!
            SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(new HookResult(HookReturnCode.DENY));
            return response;

         
        }
       
View Full Code Here

    /**
     * @see org.apache.james.protocols.smtp.hook.RcptHook#doRcpt(org.apache.james.protocols.smtp.SMTPSession, org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
     */
    public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
        if (check(session,rcpt)) {
            return new HookResult(HookReturnCode.DENY,SMTPRetCode.SYNTAX_ERROR_ARGUMENTS,DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_INVALID_ARG)
                    + " Provided EHLO/HELO " + session.getState().get(SMTPSession.CURRENT_HELO_NAME) + " can not resolved.");
        } else {
            return new HookResult(HookReturnCode.DECLINED);
        }
    }
View Full Code Here

    /**
     * @see org.apache.james.protocols.smtp.hook.HeloHook#doHelo(org.apache.james.protocols.smtp.SMTPSession, java.lang.String)
     */
    public HookResult doHelo(SMTPSession session, String helo) {
        checkEhloHelo(session, helo);
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

    /**
     * @see org.apache.james.protocols.smtp.hook.MailHook#doMail(org.apache.james.protocols.smtp.SMTPSession, org.apache.mailet.MailAddress)
     */
    public HookResult doMail(SMTPSession session, MailAddress sender) {
        if (check(session,sender)) {
            return new HookResult(HookReturnCode.DENY,SMTPRetCode.SYNTAX_ERROR_ARGUMENTS,DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+ " sender " + sender + " contains a domain with no valid MX records");
        } else {
            return new HookResult(HookReturnCode.DECLINED);
        }
    }
View Full Code Here

        } else {
            count++;
        }
        session.getState().put(UNKOWN_COMMAND_COUNT, count);
        if (count > maxUnknown) {
            return new HookResult(HookReturnCode.DENY | HookReturnCode.DISCONNECT, "521", "Closing connection as to many unknown commands received");

        } else {
           
            return new HookResult(HookReturnCode.DECLINED);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.james.protocols.smtp.hook.HookResult

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.