Examples of HookResult


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

        URIRBLHandler handler = new URIRBLHandler();

        handler.setDNSService(setupMockedDnsServer());
        handler.setUriRblServer(servers);
        HookResult response = handler.onMessage(session, mockedMail);

        assertEquals("Email was rejected", response.getResult(), HookReturnCode.DENY);
    }
View Full Code Here

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

        URIRBLHandler handler = new URIRBLHandler();

        handler.setDNSService(setupMockedDnsServer());
        handler.setUriRblServer(servers);
        HookResult response = handler.onMessage(session, mockedMail);

        assertEquals("Email was rejected", response.getResult(), HookReturnCode.DENY);
    }
View Full Code Here

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

        SpamAssassinHandler handler = new SpamAssassinHandler();

        handler.setSpamdHost(SPAMD_HOST);
        handler.setSpamdPort(port);
        handler.setSpamdRejectionHits(200.0);
        HookResult response = handler.onMessage(session, mockedMail);

        assertEquals("Email was not rejected", response.getResult(), HookReturnCode.DECLINED);
        assertEquals("email was not spam", mockedMail.getAttribute(
                SpamAssassinInvoker.FLAG_MAIL_ATTRIBUTE_NAME), "NO");
        assertNotNull("spam hits", mockedMail.getAttribute(
                SpamAssassinInvoker.STATUS_MAIL_ATTRIBUTE_NAME));
View Full Code Here

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

        SpamAssassinHandler handler = new SpamAssassinHandler();

        handler.setSpamdHost(SPAMD_HOST);
        handler.setSpamdPort(port);
        handler.setSpamdRejectionHits(2000.0);
        HookResult response = handler.onMessage(session, mockedMail);

        assertEquals("Email was not rejected", response.getResult(), HookReturnCode.DECLINED);
        assertEquals("email was spam", mockedMail.getAttribute(
                SpamAssassinInvoker.FLAG_MAIL_ATTRIBUTE_NAME), "YES");
        assertNotNull("spam hits", mockedMail.getAttribute(
                SpamAssassinInvoker.STATUS_MAIL_ATTRIBUTE_NAME));
    }
View Full Code Here

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

        SpamAssassinHandler handler = new SpamAssassinHandler();

        handler.setSpamdHost(SPAMD_HOST);
        handler.setSpamdPort(port);
        handler.setSpamdRejectionHits(200.0);
        HookResult response = handler.onMessage(session, mockedMail);

        assertEquals("Email was rejected", response.getResult(), HookReturnCode.DENY);
        assertEquals("email was spam", mockedMail.getAttribute(
                SpamAssassinInvoker.FLAG_MAIL_ATTRIBUTE_NAME), "YES");
        assertNotNull("spam hits", mockedMail.getAttribute(
                SpamAssassinInvoker.STATUS_MAIL_ATTRIBUTE_NAME));
    }
View Full Code Here

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

        if (!session.isRelayingAllowed()) {
            String blocklisted = (String) session.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME);
   
            if (blocklisted != null) { // was found in the RBL
                if (blocklistedDetail == null) {
                    return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,
                            DSNStatus.SECURITY_AUTH+ " Rejected: unauthenticated e-mail from " + session.getRemoteAddress().getAddress()
                            + " is restricted.  Contact the postmaster for details.");
                } else {
                    return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH) + " " + blocklistedDetail);
                }
              
            }
        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

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

            // if the timestamp is bigger as 0 we have allready a triplet stored
            if (createTimeStamp > 0) {
                long acceptTime = createTimeStamp + tempBlockTime;
       
                if ((time < acceptTime) && (count == 0)) {
                    return new HookResult(HookReturnCode.DENYSOFT, SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.NETWORK_DIR_SERVER)
                        + " Temporary rejected: Reconnect to fast. Please try again later");
                } else {
                   
                    session.getLogger().debug("Update triplet " + ipAddress + " | " + sender + " | " + recip + " -> timestamp: " + time);
                   
                    // update the triplet..
                    updateTriplet(ipAddress, sender, recip, count, time);

                }
            } else {
                session.getLogger().debug("New triplet " + ipAddress + " | " + sender + " | " + recip );
          
                // insert a new triplet
                insertTriplet(ipAddress, sender, recip, count, time);
     
                // Tempory block on new triplet!
                return new HookResult(HookReturnCode.DENYSOFT, SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.NETWORK_DIR_SERVER)
                    + " Temporary rejected: Please try again later");
            }

            // some kind of random cleanup process
            if (Math.random() > 0.99) {
                // cleanup old entries
           
                session.getLogger().debug("Delete old entries");
           
                cleanupAutoWhiteListGreyList(time - autoWhiteListLifeTime);
                cleanupGreyList(time - unseenLifeTime);
            }

        } catch (Exception e) {
            // just log the exception
            session.getLogger().error("Error on greylist method: " + e.getMessage());
        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

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

        if (!session.isRelayingAllowed()) {
            return doGreyListCheck(session, sender,rcpt);
        } else {
            session.getLogger().info("IpAddress " + session.getRemoteAddress().getAddress().getHostAddress() + " is allowed to send. Skip greylisting.");
        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here

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

        }
      
        if (reject) {
          //user not exist
            session.getLogger().info("Rejected message. Unknown user: " + rcpt.toString());
            return new HookResult(HookReturnCode.DENY,SMTPRetCode.MAILBOX_PERM_UNAVAILABLE, DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_MAILBOX) + " Unknown user: " + rcpt.toString());
        } else {
            return new HookResult(HookReturnCode.DECLINED);
        }
    }
View Full Code Here

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

            MailAddress rcpt) {
        if (!session.isRelayingAllowed()) {
            String toDomain = rcpt.getDomain();
            if (isLocalDomain(toDomain) == false) {
                if (session.isAuthSupported()) {
                    return new HookResult(HookReturnCode.DENY,
                            SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(
                                    DSNStatus.PERMANENT,
                                    DSNStatus.SECURITY_AUTH)
                                    + " Authentication Required");
                } else {
                    return new HookResult(
                            HookReturnCode.DENY,
                            // sendmail returns 554 (SMTPRetCode.TRANSACTION_FAILED).
                            // it is not clear in RFC wether it is better to use 550 or 554.
                            SMTPRetCode.MAILBOX_PERM_UNAVAILABLE,
                            DSNStatus.getStatus(DSNStatus.PERMANENT,
                                    DSNStatus.SECURITY_AUTH)
                                    + " Requested action not taken: relaying denied");
                }
            }

        }
        return new HookResult(HookReturnCode.DECLINED);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.