Author: norman Date: Tue Aug 1 04:52:38 2006 New Revision: 427544 URL: http://svn.apache.org/viewvc?rev=427544&view=rev Log: Fix bad formattin
Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/HeloCmdHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/SendMailHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/UnknownCmdHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/MaxRcptHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SpamAssassinHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/TarpitHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SPFHandlerTest.java james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SpamAssassinHandlerTest.java james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java Tue Aug 1 04:52:38 2006 @@ -38,7 +38,7 @@ * @param handlers The iterator which contains all handler for the current command or state */ public Chain(Iterator handlers) { - this.handlers = handlers; + this.handlers = handlers; } /** @@ -47,24 +47,24 @@ * @param session The SMTPSession */ public void doChain(SMTPSession session) { - - // should never happen - if (handlers == null) - return; - - if (handlers.hasNext()) { - Object handler = handlers.next(); + + // should never happen + if (handlers == null) + return; + + if (handlers.hasNext()) { + Object handler = handlers.next(); - if (handler instanceof ConnectHandler) { - ((ConnectHandler) handler).onConnect(session, this); - } else if (handler instanceof CommandHandler) { - // reset the idle timeout - session.getWatchdog().reset(); + if (handler instanceof ConnectHandler) { + ((ConnectHandler) handler).onConnect(session, this); + } else if (handler instanceof CommandHandler) { + // reset the idle timeout + session.getWatchdog().reset(); - ((CommandHandler) handler).onCommand(session, this); - } else if (handler instanceof MessageHandler) { - ((MessageHandler) handler).onMessage(session, this); - } - } + ((CommandHandler) handler).onCommand(session, this); + } else if (handler instanceof MessageHandler) { + ((MessageHandler) handler).onMessage(session, this); + } + } } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java Tue Aug 1 04:52:38 2006 @@ -267,20 +267,20 @@ } else { new Chain(commandHandlers.iterator()).doChain(this); - writeCompleteResponse(getSMTPResponse().retrieve()); + writeCompleteResponse(getSMTPResponse().retrieve()); } // handle messages - if (mode == MESSAGE_RECEIVED_MODE) { - getLogger().debug("executing message handlers"); - List messageHandlers = handlerChain.getMessageHandlers(); - - if (messageHandlers != null) { - new Chain(messageHandlers.iterator()).doChain(this); - - writeCompleteResponse(getSMTPResponse().retrieve()); - } - } + if (mode == MESSAGE_RECEIVED_MODE) { + getLogger().debug("executing message handlers"); + List messageHandlers = handlerChain.getMessageHandlers(); + + if (messageHandlers != null) { + new Chain(messageHandlers.iterator()).doChain(this); + + writeCompleteResponse(getSMTPResponse().retrieve()); + } + } // do the clean up if(mail != null) { @@ -309,22 +309,22 @@ * @param resp The Collection of responseStrings */ private void writeCompleteResponse(Collection resp) { - if (resp.size() > 0) { - Iterator response = resp.iterator(); + if (resp.size() > 0) { + Iterator response = resp.iterator(); - while (response.hasNext()) { + while (response.hasNext()) { - writeResponse(response.next().toString()); - } - getSMTPResponse().clear(); - } + writeResponse(response.next().toString()); + } + getSMTPResponse().clear(); + } } /** * Resets the handler data to a basic state. */ protected void resetHandler() { - getSMTPResponse().clear(); + getSMTPResponse().clear(); resetState(); resetConnectionState(); @@ -564,7 +564,7 @@ } public SMTPResponse getSMTPResponse() { - return response; + return response; } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java Tue Aug 1 04:52:38 2006 @@ -35,12 +35,12 @@ * @param response The RepsponseString which should be returned to the client socked */ public void store(String response) { - resp.clear(); - resp.add(response); + resp.clear(); + resp.add(response); } public void append(String response) { - resp.add(response); + resp.add(response); } /** @@ -57,6 +57,6 @@ * */ public void clear() { - resp.clear(); + resp.clear(); } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java Tue Aug 1 04:52:38 2006 @@ -65,9 +65,9 @@ * @param argument the argument passed in with the command by the SMTP client */ private Collection doEHLO(SMTPSession session) { - String argument = session.getCommandArgument(); - Collection response = new ArrayList(); - + String argument = session.getCommandArgument(); + Collection response = new ArrayList(); + StringBuffer responseBuffer = session.getResponseBuffer(); session.getConnectionState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME); Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/HeloCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/HeloCmdHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/HeloCmdHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/HeloCmdHandler.java Tue Aug 1 04:52:38 2006 @@ -59,7 +59,7 @@ * @param argument the argument passed in with the command by the SMTP client */ private String doHELO(SMTPSession session) { - String argument = session.getCommandArgument(); + String argument = session.getCommandArgument(); String responseString = null; session.getConnectionState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME); Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/SendMailHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/SendMailHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/SendMailHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/SendMailHandler.java Tue Aug 1 04:52:38 2006 @@ -59,13 +59,13 @@ * @see org.apache.james.smtpserver#onMessage(SMTPSession) */ public void onMessage(SMTPSession session, Chain chain) { - System.err.println("YOOOO"); - session.getSMTPResponse().store(processMail(session)); + System.err.println("YOOOO"); + session.getSMTPResponse().store(processMail(session)); } private String processMail(SMTPSession session) { - getLogger().debug("sending mail"); + getLogger().debug("sending mail"); Mail mail = session.getMail(); Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/UnknownCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/UnknownCmdHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/UnknownCmdHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/UnknownCmdHandler.java Tue Aug 1 04:52:38 2006 @@ -48,11 +48,11 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) **/ public void onCommand(SMTPSession session,Chain chain) { - String response = doUNKNOWN(session); - - if (response != null) { - session.getSMTPResponse().store(response); - } + String response = doUNKNOWN(session); + + if (response != null) { + session.getSMTPResponse().store(response); + } } private String doUNKNOWN(SMTPSession session) { Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/MailFilterCmdHandler.java Tue Aug 1 04:52:38 2006 @@ -68,7 +68,7 @@ * @param argument the argument passed in with the command by the SMTP client */ private String doMAIL(SMTPSession session) { - String argument = session.getCommandArgument(); + String argument = session.getCommandArgument(); String responseString = null; String sender = null; @@ -120,7 +120,7 @@ if (mailOptionName.startsWith(MAIL_OPTION_SIZE)) { String response = doMailSize(session, mailOptionValue, sender); - if (response != null) { + if (response != null) { return response; } } else { Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java Tue Aug 1 04:52:38 2006 @@ -47,7 +47,7 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) **/ public void onCommand(SMTPSession session, Chain chain) { - + System.err.println("ADDRESS: "); String response = doRCPT(session); @@ -69,7 +69,7 @@ */ private String doRCPT(SMTPSession session) { - String argument = session.getCommandArgument(); + String argument = session.getCommandArgument(); String responseString = null; String recipient = null; Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java Tue Aug 1 04:52:38 2006 @@ -259,16 +259,16 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) */ public void onCommand(SMTPSession session, Chain chain) { - String response = doRCPT(session); + String response = doRCPT(session); - if (response == null) { - // call the next handler in chain - chain.doChain(session); + if (response == null) { + // call the next handler in chain + chain.doChain(session); - } else { - // store the response - session.getSMTPResponse().store(response); - } + } else { + // store the response + session.getSMTPResponse().store(response); + } } /** @@ -278,34 +278,34 @@ * @return responseString The responseString which should be returned */ private String doRCPT(SMTPSession session) { - String responseString = null; - String blocklisted = (String) session.getConnectionState().get( - RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME); - MailAddress recipientAddress = (MailAddress) session.getState().get( - SMTPSession.CURRENT_RECIPIENT); + String responseString = null; + String blocklisted = (String) session.getConnectionState().get( + RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME); + MailAddress recipientAddress = (MailAddress) session.getState().get( + SMTPSession.CURRENT_RECIPIENT); - if (blocklisted != null && // was found in the RBL - !(session.isAuthRequired() && session.getUser() != null) && // Not (SMTP AUTH is enabled and - // not authenticated) - !(recipientAddress.getUser().equalsIgnoreCase("postmaster") || recipientAddress - .getUser().equalsIgnoreCase("abuse"))) { + if (blocklisted != null && // was found in the RBL + !(session.isAuthRequired() && session.getUser() != null) && // Not (SMTP AUTH is enabled and + // not authenticated) + !(recipientAddress.getUser().equalsIgnoreCase("postmaster") || recipientAddress + .getUser().equalsIgnoreCase("abuse"))) { - // trying to send e-mail to other than postmaster or abuse - if (blocklistedDetail != null) { - responseString = "530 " - + DSNStatus.getStatus(DSNStatus.PERMANENT, - DSNStatus.SECURITY_AUTH) + " " - + blocklistedDetail; - } else { - responseString = "530 " - + DSNStatus.getStatus(DSNStatus.PERMANENT, - DSNStatus.SECURITY_AUTH) - + " Rejected: unauthenticated e-mail from " - + session.getRemoteIPAddress() - + " is restricted. Contact the postmaster for details."; - } - return responseString; - } - return null; + // trying to send e-mail to other than postmaster or abuse + if (blocklistedDetail != null) { + responseString = "530 " + + DSNStatus.getStatus(DSNStatus.PERMANENT, + DSNStatus.SECURITY_AUTH) + " " + + blocklistedDetail; + } else { + responseString = "530 " + + DSNStatus.getStatus(DSNStatus.PERMANENT, + DSNStatus.SECURITY_AUTH) + + " Rejected: unauthenticated e-mail from " + + session.getRemoteIPAddress() + + " is restricted. Contact the postmaster for details."; + } + return responseString; + } + return null; } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/MaxRcptHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/MaxRcptHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/MaxRcptHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/MaxRcptHandler.java Tue Aug 1 04:52:38 2006 @@ -67,45 +67,45 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) */ public void onCommand(SMTPSession session, Chain chain) { - String response = doRCPT(session); + String response = doRCPT(session); - if (response == null) { - // call the next handler in chain - chain.doChain(session); - - } else { - // store the response - session.getSMTPResponse().store(response); - } + if (response == null) { + // call the next handler in chain + chain.doChain(session); + + } else { + // store the response + session.getSMTPResponse().store(response); + } } private String doRCPT(SMTPSession session) { - String responseString = null; - int rcptCount = 0; + String responseString = null; + int rcptCount = 0; - rcptCount = session.getRcptCount() + 1; + rcptCount = session.getRcptCount() + 1; - // check if the max recipients has reached - if (rcptCount > maxRcpt) { - responseString = "452 " - + DSNStatus.getStatus(DSNStatus.NETWORK, - DSNStatus.DELIVERY_TOO_MANY_REC) - + " Requested action not taken: max recipients reached"; + // check if the max recipients has reached + if (rcptCount > maxRcpt) { + responseString = "452 " + + DSNStatus.getStatus(DSNStatus.NETWORK, + DSNStatus.DELIVERY_TOO_MANY_REC) + + " Requested action not taken: max recipients reached"; - getLogger().error(responseString); - } + getLogger().error(responseString); + } - return responseString; + return responseString; } /** * @see org.apache.james.smtpserver.CommandHandler#getImplCommands() */ public Collection getImplCommands() { - Collection implCommands = new ArrayList(); - implCommands.add("RCPT"); + Collection implCommands = new ArrayList(); + implCommands.add("RCPT"); - return implCommands; + return implCommands; } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java Tue Aug 1 04:52:38 2006 @@ -287,8 +287,8 @@ * @see org.apache.james.smtpserver.MessageHandler#onMessage(SMTPSession) */ public void onMessage(SMTPSession session,Chain chain) { - addHeader(session); - chain.doChain(session); + addHeader(session); + chain.doChain(session); } private void addHeader(SMTPSession session) { Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SpamAssassinHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SpamAssassinHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SpamAssassinHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/SpamAssassinHandler.java Tue Aug 1 04:52:38 2006 @@ -144,73 +144,73 @@ * @see org.apache.james.smtpserver.MessageHandler#onMessage(SMTPSession) */ public void onMessage(SMTPSession session, Chain chain) { - String response = scanMessage(session); - if (response == null) { - // call the next handler in chain - chain.doChain(session); - - } else { - // store the response - session.getSMTPResponse().store(response); - session.abortMessage(); - } + String response = scanMessage(session); + if (response == null) { + // call the next handler in chain + chain.doChain(session); + + } else { + // store the response + session.getSMTPResponse().store(response); + session.abortMessage(); + } } private String scanMessage(SMTPSession session) { - // Not scan the message if relaying allowed - if (session.isRelayingAllowed() && !checkAuthNetworks) { - return null; - } - - try { - Mail mail = session.getMail(); - MimeMessage message = mail.getMessage(); - SpamAssassinInvoker sa = new SpamAssassinInvoker(spamdHost, - spamdPort); - sa.scanMail(message); - - Iterator headers = sa.getHeadersAsAttribute().keySet().iterator(); - - // Add the headers - while (headers.hasNext()) { - String key = headers.next().toString(); - - mail.setAttribute(key, (String) sa.getHeadersAsAttribute().get( - key)); - } - - // Check if rejectionHits was configured - if (spamdRejectionHits > 0) { - try { - double hits = Double.parseDouble(sa.getHits()); - - // if the hits are bigger the rejectionHits reject the - // message - if (spamdRejectionHits <= hits) { - String responseString = "554 " - + DSNStatus.getStatus(DSNStatus.PERMANENT, - DSNStatus.SECURITY_OTHER) - + " This message reach the spam hits treshold. Please contact the Postmaster if the email is not SPAM. Message rejected"; - StringBuffer buffer = new StringBuffer(256).append( - "Rejected message from ").append( - session.getState().get(SMTPSession.SENDER) - .toString()).append(" from host ") - .append(session.getRemoteHost()).append(" (") - .append(session.getRemoteIPAddress()).append( - ") " + responseString).append( - ". Required rejection hits: " - + spamdRejectionHits - + " hits: " + hits); - getLogger().info(buffer.toString()); - return responseString; - } - } catch (NumberFormatException e) { - // hits unknown - } - } - } catch (MessagingException e) { - getLogger().error(e.getMessage()); - } - return null; + // Not scan the message if relaying allowed + if (session.isRelayingAllowed() && !checkAuthNetworks) { + return null; + } + + try { + Mail mail = session.getMail(); + MimeMessage message = mail.getMessage(); + SpamAssassinInvoker sa = new SpamAssassinInvoker(spamdHost, + spamdPort); + sa.scanMail(message); + + Iterator headers = sa.getHeadersAsAttribute().keySet().iterator(); + + // Add the headers + while (headers.hasNext()) { + String key = headers.next().toString(); + + mail.setAttribute(key, (String) sa.getHeadersAsAttribute().get( + key)); + } + + // Check if rejectionHits was configured + if (spamdRejectionHits > 0) { + try { + double hits = Double.parseDouble(sa.getHits()); + + // if the hits are bigger the rejectionHits reject the + // message + if (spamdRejectionHits <= hits) { + String responseString = "554 " + + DSNStatus.getStatus(DSNStatus.PERMANENT, + DSNStatus.SECURITY_OTHER) + + " This message reach the spam hits treshold. Please contact the Postmaster if the email is not SPAM. Message rejected"; + StringBuffer buffer = new StringBuffer(256).append( + "Rejected message from ").append( + session.getState().get(SMTPSession.SENDER) + .toString()).append(" from host ") + .append(session.getRemoteHost()).append(" (") + .append(session.getRemoteIPAddress()).append( + ") " + responseString).append( + ". Required rejection hits: " + + spamdRejectionHits + + " hits: " + hits); + getLogger().info(buffer.toString()); + return responseString; + } + } catch (NumberFormatException e) { + // hits unknown + } + } + } catch (MessagingException e) { + getLogger().error(e.getMessage()); + } + return null; } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/TarpitHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/TarpitHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/TarpitHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/TarpitHandler.java Tue Aug 1 04:52:38 2006 @@ -101,8 +101,8 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) */ public void onCommand(SMTPSession session, Chain chain) { - doRCPT(session); - chain.doChain(session); + doRCPT(session); + chain.doChain(session); } private void doRCPT(SMTPSession session) { Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java Tue Aug 1 04:52:38 2006 @@ -87,50 +87,50 @@ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession) */ public void onCommand(SMTPSession session, Chain chain) { - String response = doMAIL(session); - if (response == null) { - // call the next handler in chain - chain.doChain(session); - - } else { - // store the response - session.getSMTPResponse().store(response); - } + String response = doMAIL(session); + if (response == null) { + // call the next handler in chain + chain.doChain(session); + + } else { + // store the response + session.getSMTPResponse().store(response); + } } private String doMAIL(SMTPSession session) { - String responseString = null; - MailAddress senderAddress = (MailAddress) session.getState().get( - SMTPSession.SENDER); - - // null sender so return - if (senderAddress == null) - return null; + String responseString = null; + MailAddress senderAddress = (MailAddress) session.getState().get( + SMTPSession.SENDER); + + // null sender so return + if (senderAddress == null) + return null; - /** + /** * don't check if the ip address is allowed to relay. Only check if it * is set in the config. */ - if (checkAuthClients || !session.isRelayingAllowed()) { - // try to resolv the provided domain in the - // senderaddress. If it can not resolved do not accept - // it. - - Collection records = dnsServer.findMXRecords(senderAddress - .getHost()); - - if (records == null || records.size() == 0) { - responseString = "501 " - + DSNStatus.getStatus(DSNStatus.PERMANENT, - DSNStatus.ADDRESS_SYNTAX_SENDER) + " sender " - + senderAddress - + " contains a domain with no valid MX records"; - getLogger().info(responseString); - } + if (checkAuthClients || !session.isRelayingAllowed()) { + // try to resolv the provided domain in the + // senderaddress. If it can not resolved do not accept + // it. + + Collection records = dnsServer.findMXRecords(senderAddress + .getHost()); + + if (records == null || records.size() == 0) { + responseString = "501 " + + DSNStatus.getStatus(DSNStatus.PERMANENT, + DSNStatus.ADDRESS_SYNTAX_SENDER) + " sender " + + senderAddress + + " contains a domain with no valid MX records"; + getLogger().info(responseString); + } - } - return responseString; + } + return responseString; } /** Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java (original) +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java Tue Aug 1 04:52:38 2006 @@ -229,7 +229,7 @@ } public SMTPResponse getSMTPResponse() { - throw new UnsupportedOperationException("Unimplemented Stub Method"); + throw new UnsupportedOperationException("Unimplemented Stub Method"); } } Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java (original) +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java Tue Aug 1 04:52:38 2006 @@ -98,7 +98,7 @@ } public SMTPResponse getSMTPResponse() { - return response; + return response; } Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SPFHandlerTest.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SPFHandlerTest.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SPFHandlerTest.java (original) +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SPFHandlerTest.java Tue Aug 1 04:52:38 2006 @@ -196,7 +196,7 @@ } public SMTPResponse getSMTPResponse() { - return response; + return response; } }; Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SpamAssassinHandlerTest.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SpamAssassinHandlerTest.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SpamAssassinHandlerTest.java (original) +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SpamAssassinHandlerTest.java Tue Aug 1 04:52:38 2006 @@ -61,7 +61,7 @@ } public SMTPResponse getSMTPResponse() { - return response; + return response; } public Mail getMail() { Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java?rev=427544&r1=427543&r2=427544&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java (original) +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ValidSenderDomainHandlerTest.java Tue Aug 1 04:52:38 2006 @@ -86,7 +86,7 @@ } public SMTPResponse getSMTPResponse() { - return response; + return response; } }; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]