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

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


    @Test
    public void testHeloHookTempraryError() throws Exception {
        HeloHook hook = new HeloHook() {

            public HookResult doHelo(SMTPSession session, String helo) {
                return new HookResult(HookReturnCode.DENYSOFT);
            }
        };
       
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
View Full Code Here


    @Test
    public void testMailHookPermanentError() throws Exception {
        MailHook hook = new MailHook() {

            public HookResult doMail(SMTPSession session, MailAddress sender) {
                return new HookResult(HookReturnCode.DENY);
            }
        };
       
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
View Full Code Here

    @Test
    public void testMailHookTemporaryError() throws Exception {
        MailHook hook = new MailHook() {

            public HookResult doMail(SMTPSession session, MailAddress sender) {
                return new HookResult(HookReturnCode.DENYSOFT);
            }
        };
       
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
View Full Code Here

    public void testRcptHookPermanentError() throws Exception {
        RcptHook hook = new RcptHook() {

            public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
                if (RCPT1.equals(rcpt.toString())) {
                    return new HookResult(HookReturnCode.DENY);
                } else {
                    return new HookResult(HookReturnCode.DECLINED);
                }
            }

        };
       
View Full Code Here

    public void testRcptHookTemporaryError() throws Exception {
        RcptHook hook = new RcptHook() {

            public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
                if (RCPT1.equals(rcpt.toString())) {
                    return new HookResult(HookReturnCode.DENYSOFT);
                } else {
                    return new HookResult(HookReturnCode.DECLINED);
                }
            }

        };
       
View Full Code Here

        TestMessageHook testHook = new TestMessageHook();

        MessageHook hook = new MessageHook() {

            public HookResult onMessage(SMTPSession session, MailEnvelope mail) {
                return new HookResult(HookReturnCode.DENY);
            }


        };
       
View Full Code Here

        MessageHook hook = new MessageHook() {

           
            public HookResult onMessage(SMTPSession session, MailEnvelope mail) {
                return new HookResult(HookReturnCode.DENYSOFT);
            }


        };
       
View Full Code Here

        private final List<MailEnvelope> queued = new ArrayList<MailEnvelope>();
       
        public HookResult onMessage(SMTPSession session, MailEnvelope mail) {
            queued.add(mail);
            return new HookResult(HookReturnCode.OK);
        }
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

            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 HookResult.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.