You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Norman Maurer <nm...@byteaction.de> on 2006/08/01 18:16:51 UTC

Re: svn commit: r427574 - in /james/server/sandbox/handlerapi2/src: java/org/apache/james/smtpserver/ java/org/apache/james/smtpserver/core/ java/org/apache/james/smtpserver/core/filter/fastfail/ test/org/apache/james/smtpserver/

I commited all the stuff to show the idea which noel and me discuss
about.. I know its "far away" from perfect.. But is it the right
direction? Is this idea the worth more work ?

Any feedback is welcome.


bye
Norman

Ps: I want to remove the "writeResponse" from SMTPSession so its not
possible to write "directly" to the client.. Im not 100 % sure how to do
it yet but i will see

Am Dienstag, den 01.08.2006, 13:23 +0000 schrieb norman@apache.org:
> Author: norman
> Date: Tue Aug  1 06:23:11 2006
> New Revision: 427574
> 
> URL: http://svn.apache.org/viewvc?rev=427574&view=rev
> Log:
> Complete reformatin
> 
> Modified:
>     james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java
>     james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java
>     james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.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/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/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/DNSRBLHandlerTest.java
>     james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java
>     james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -17,9 +17,6 @@
>   * under the License.                                           *
>   ****************************************************************/
>  
> -
> -
> -
>  package org.apache.james.smtpserver;
>  
>  import java.util.Iterator;
> @@ -38,7 +35,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 +44,24 @@
>       * @param session The SMTPSession
>       */
>      public void doChain(SMTPSession session) {
> -    
> -    // 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();
> -
> -        ((CommandHandler) handler).onCommand(session, this);
> -        } else if (handler instanceof MessageHandler) {
> -        ((MessageHandler) handler).onMessage(session, this);
> -        }
> -    }
> +
> +	// 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();
> +
> +		((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/CommandHandler.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java?rev=427574&r1=427573&r2=427574&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java (original)
> +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java Tue Aug  1 06:23:11 2006
> @@ -35,7 +35,7 @@
>      /**
>       * Handle the command
>      **/
> -    void onCommand(SMTPSession session,Chain chain);
> +    void onCommand(SMTPSession session, Chain chain);
>  
>      /**
>       * Return a Collection of implemented commands
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -239,108 +239,111 @@
>          }
>  
>          theWatchdog.start();
> -        while(!sessionEnded) {
> -          //Reset the current command values
> -          curCommandName = null;
> -          curCommandArgument = null;
> -          mode = COMMAND_MODE;
> -
> -          //parse the command
> -          String cmdString =  readCommandLine();
> -          if (cmdString == null) {
> -              break;
> -          }
> -          int spaceIndex = cmdString.indexOf(" ");
> -          if (spaceIndex > 0) {
> -              curCommandName = cmdString.substring(0, spaceIndex);
> -              curCommandArgument = cmdString.substring(spaceIndex + 1);
> -          } else {
> -              curCommandName = cmdString;
> -          }
> -          curCommandName = curCommandName.toUpperCase(Locale.US);
> -
> -          // fetch the command handlers registered to the command
> -          List commandHandlers = handlerChain.getCommandHandlers(curCommandName);
> -          if(commandHandlers == null) {
> -              // end the session
> -              break;
> -          } else {
> -              new Chain(commandHandlers.iterator()).doChain(this);
> -              
> -              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());
> -        }
> -        }
> -
> -          // do the clean up
> -          if(mail != null) {
> -              ContainerUtil.dispose(mail);
> -              
> -              // remember the ehlo mode
> -              Object currentHeloMode = state.get(CURRENT_HELO_MODE);
> -              
> -              mail = null;
> -              resetState();
> -
> -              // start again with the old helo mode
> -              if (currentHeloMode != null) {
> -                  state.put(CURRENT_HELO_MODE,currentHeloMode);
> -              }
> -          }
> -
> -        }
> -        theWatchdog.stop();
> -        getLogger().debug("Closing socket.");
> +        while (!sessionEnded) {
> +	    // Reset the current command values
> +	    curCommandName = null;
> +	    curCommandArgument = null;
> +	    mode = COMMAND_MODE;
> +
> +	    // parse the command
> +	    String cmdString = readCommandLine();
> +	    if (cmdString == null) {
> +		break;
> +	    }
> +	    int spaceIndex = cmdString.indexOf(" ");
> +	    if (spaceIndex > 0) {
> +		curCommandName = cmdString.substring(0, spaceIndex);
> +		curCommandArgument = cmdString.substring(spaceIndex + 1);
> +	    } else {
> +		curCommandName = cmdString;
> +	    }
> +	    curCommandName = curCommandName.toUpperCase(Locale.US);
> +
> +	    // fetch the command handlers registered to the command
> +	    List commandHandlers = handlerChain
> +		    .getCommandHandlers(curCommandName);
> +	    if (commandHandlers == null) {
> +		// end the session
> +		break;
> +	    } else {
> +		new Chain(commandHandlers.iterator()).doChain(this);
> +
> +		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());
> +		}
> +	    }
> +
> +	    // do the clean up
> +	    if (mail != null) {
> +		ContainerUtil.dispose(mail);
> +
> +		// remember the ehlo mode
> +		Object currentHeloMode = state.get(CURRENT_HELO_MODE);
> +
> +		mail = null;
> +		resetState();
> +
> +		// start again with the old helo mode
> +		if (currentHeloMode != null) {
> +		    state.put(CURRENT_HELO_MODE, currentHeloMode);
> +		}
> +	    }
> +
> +	}
> +	theWatchdog.stop();
> +	getLogger().debug("Closing socket.");
>      }
>  
>      /**
>       * Write a Collection of responseString to the client
>       * 
> -     * @param resp The Collection of responseStrings
> +     * @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();
> -        resetState();
> -        resetConnectionState();
> -
> -        clearResponseBuffer();
> -
> -        remoteHost = null;
> -        remoteIP = null;
> -        authenticatedUser = null;
> -        smtpID = null;
> +	getSMTPResponse().clear();
> +	resetState();
> +	resetConnectionState();
> +
> +	clearResponseBuffer();
> +
> +	remoteHost = null;
> +	remoteIP = null;
> +	authenticatedUser = null;
> +	smtpID = null;
>      }
>  
>     /**
> -     * Sets the SMTPHandlerChain
> -     *
> -     * @param handlerChain SMTPHandler object
> -     */
> +    * Sets the SMTPHandlerChain
> +    * 
> +    * @param handlerChain
> +    *                SMTPHandler object
> +    */
>      public void setHandlerChain(SMTPHandlerChain handlerChain) {
>          this.handlerChain = handlerChain;
>      }
> @@ -555,16 +558,25 @@
>          return count;
>      }
>      
> +    /**
> +     * @see org.apache.james.smtpserver.SMTPSession#resetConnectionState()
> +     */
>      public void resetConnectionState() {
>          connectionState.clear();
>      }
>      
> +    /**
> +     * @see org.apache.james.smtpserver.SMTPSession#getConnectionState()
> +     */
>      public Map getConnectionState() {
>          return connectionState;
>      }
>  
> +    /**
> +     * @see org.apache.james.smtpserver.SMTPSession#getSMTPResponse()
> +     */
>      public SMTPResponse getSMTPResponse() {
> -    return response;
> +	return response;
>      }
>  
>  }
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -56,16 +56,16 @@
>  
>      /**
>       * Adds header to the message
> +     * 
>       * @see org.apache.james.smtpserver#onMessage(SMTPSession)
>       */
>      public void onMessage(SMTPSession session, Chain chain) {
> -    System.err.println("YOOOO");
> -    session.getSMTPResponse().store(processMail(session));
> +	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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -38,8 +38,6 @@
>       * The name of the command handled by the command handler
>       */
>      public static final String UNKNOWN_COMMAND = "UNKNOWN";
> -    
> -    private boolean stopHandlerProcessing = true;
>  
>      /**
>       * Handler method called upon receipt of an unrecognized command.
> @@ -47,12 +45,12 @@
>       *
>       * @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);
> -    }
> +    public void onCommand(SMTPSession session, Chain chain) {
> +	String response = doUNKNOWN(session);
> +
> +	if (response != null) {
> +	    session.getSMTPResponse().store(response);
> +	}
>      }
>      
>      private String doUNKNOWN(SMTPSession session) {
> @@ -80,12 +78,4 @@
>          
>          return implCommands;
>      }
> -    
> -    /**
> -     * @see org.apache.james.smtpserver.CommandHandler#stopHandlerProcessing()
> -     */
> -    public boolean stopHandlerProcessing() {
> -        return stopHandlerProcessing ;
> -    }
> -
>  }
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -129,6 +129,8 @@
>      **/
>      public void onConnect(SMTPSession session, Chain chain) {
>          checkDNSRBL(session);
> +        
> +        // Call the next handler in chain
>          chain.doChain(session);
>      }
>      
> @@ -180,6 +182,7 @@
>  
>      public void checkDNSRBL(SMTPSession session) {
>          String ipAddress = session.getRemoteIPAddress();
> +        
>          /*
>           * don't check against rbllists if the client is allowed to relay..
>           * This whould make no sense.
> @@ -259,53 +262,54 @@
>       * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession)
>       */
>      public void onCommand(SMTPSession session, Chain chain) {
> -    String response = doRCPT(session);
> -
> -    if (response == null) {
> -        // call the next handler in chain
> -        chain.doChain(session);
> +	String response = doRCPT(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);
> +	}
>      }
>  
>      /**
>       * RCPT
>       * 
> -     * @param session The SMTPSession
> -     * @return responseString The responseString which should be returned 
> +     * @param session
> +     *                The SMTPSession
> +     * @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);
> -
> -    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;
> +	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"))) {
> +
> +	    // 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -67,35 +67,35 @@
>       * @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;
>      }
>  
>      /**
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 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=427574&r1=427573&r2=427574&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 06:23:11 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=427574&r1=427573&r2=427574&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 06:23:11 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -228,8 +228,11 @@
>          throw new UnsupportedOperationException("Unimplemented Stub Method");
>      }
>  
> +    /**
> +     * @see org.apache.james.smtpserver.SMTPSession#getSMTPResponse()
> +     */
>      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/DNSRBLHandlerTest.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?rev=427574&r1=427573&r2=427574&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
> +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Tue Aug  1 06:23:11 2006
> @@ -17,7 +17,6 @@
>   * under the License.                                           *
>   ****************************************************************/
>  
> -
>  package org.apache.james.smtpserver;
>  
>  import java.net.InetAddress;
> @@ -47,16 +46,16 @@
>  
>      private String remoteIp = "127.0.0.2";
>  
> -    private boolean relaying = false;   
> -    
> +    private boolean relaying = false;
> +
>      public static final String RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME = "org.apache.james.smtpserver.rbl.blocklisted";
> -    
> +
>      public static final String RBL_DETAIL_MAIL_ATTRIBUTE_NAME = "org.apache.james.smtpserver.rbl.detail";
>  
>      protected void setUp() throws Exception {
> -        super.setUp();
> -        setupMockedDnsServer();
> -        setRelayingAllowed(false);
> +	super.setUp();
> +	setupMockedDnsServer();
> +	setRelayingAllowed(false);
>      }
>  
>      /**
> @@ -65,7 +64,7 @@
>       * @param remoteIp The remoteIP to set
>       */
>      private void setRemoteIp(String remoteIp) {
> -        this.remoteIp = remoteIp;
> +	this.remoteIp = remoteIp;
>      }
>  
>      /**
> @@ -74,7 +73,7 @@
>       * @param relaying true or false
>       */
>      private void setRelayingAllowed(boolean relaying) {
> -        this.relaying = relaying;
> +	this.relaying = relaying;
>      }
>  
>      /**
> @@ -82,207 +81,224 @@
>       *
>       */
>      private void setupMockedDnsServer() {
> -        mockedDnsServer = new DNSServer() {
> +	mockedDnsServer = new DNSServer() {
>  
> -            public Collection findMXRecords(String hostname) {
> -                throw new UnsupportedOperationException("Unimplemented in mock");
> -            }
> -
> -            public Collection findTXTRecords(String hostname) {
> -                List res = new ArrayList();
> -                if (hostname == null) {
> -                    return res;
> -                }
> -                ;
> -                if ("2.0.0.127.bl.spamcop.net".equals(hostname)) {
> -                    res.add("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
> -                }
> -                return res;
> -            }
> -
> -            public Iterator getSMTPHostAddresses(String domainName) {
> -                throw new UnsupportedOperationException("Unimplemented in mock");
> -            }
> -
> -            public InetAddress[] getAllByName(String host)
> -                    throws UnknownHostException {
> -                throw new UnsupportedOperationException("Unimplemented in mock");
> -            }
> -
> -            public InetAddress getByName(String host)
> -                    throws UnknownHostException {
> -                if ("2.0.0.127.bl.spamcop.net".equals(host)) {
> -                    return InetAddress.getByName("127.0.0.1");
> -                } else if ("3.0.0.127.bl.spamcop.net".equals(host)) {
> -                    return InetAddress.getByName("127.0.0.1");
> -                } else if ("192.168.0.1.bl.spamcop.net".equals(host)) {
> -                    return InetAddress.getByName("fesdgaeg.deger");
> -                }
> -                return InetAddress.getByName(host);
> -            }
> -        };
> +	    public Collection findMXRecords(String hostname) {
> +		throw new UnsupportedOperationException("Unimplemented in mock");
> +	    }
> +
> +	    public Collection findTXTRecords(String hostname) {
> +		List res = new ArrayList();
> +		if (hostname == null) {
> +		    return res;
> +		}
> +		;
> +		if ("2.0.0.127.bl.spamcop.net".equals(hostname)) {
> +		    res
> +			    .add("Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2");
> +		}
> +		return res;
> +	    }
> +
> +	    public Iterator getSMTPHostAddresses(String domainName) {
> +		throw new UnsupportedOperationException("Unimplemented in mock");
> +	    }
> +
> +	    public InetAddress[] getAllByName(String host)
> +		    throws UnknownHostException {
> +		throw new UnsupportedOperationException("Unimplemented in mock");
> +	    }
> +
> +	    public InetAddress getByName(String host)
> +		    throws UnknownHostException {
> +		if ("2.0.0.127.bl.spamcop.net".equals(host)) {
> +		    return InetAddress.getByName("127.0.0.1");
> +		} else if ("3.0.0.127.bl.spamcop.net".equals(host)) {
> +		    return InetAddress.getByName("127.0.0.1");
> +		} else if ("192.168.0.1.bl.spamcop.net".equals(host)) {
> +		    return InetAddress.getByName("fesdgaeg.deger");
> +		}
> +		return InetAddress.getByName(host);
> +	    }
> +	};
>      }
>  
>      /**
>       * Setup mocked smtpsession
>       */
>      private void setupMockedSMTPSession() {
> -        mockedSMTPSession = new AbstractSMTPSession() {
> -            HashMap state = new HashMap();
> -            HashMap connectionState = new HashMap();
> -            boolean stopHandler = false;
> -            
> -            public String getRemoteIPAddress() {
> -                return remoteIp;
> -            }
> -
> -            public Map getState() {
> -                return state;
> -            }
> -
> -            public boolean isRelayingAllowed() {
> -                return relaying;
> -            }
> -
> -            public boolean isAuthRequired() {
> -                return false;
> -            }
> -
> -            public int getRcptCount() {
> -                return 0;
> -            }
> -
> -            public void setStopHandlerProcessing(boolean b) {
> -                stopHandler = b;  
> -            }
> -
> -            public boolean getStopHandlerProcessing() {
> -                return stopHandler;
> -            }
> -
> -            public Map getConnectionState() {       
> -                return connectionState;
> -            }
> -
> -            public void resetConnectionState() {
> -                connectionState.clear();
> -            }
> +	mockedSMTPSession = new AbstractSMTPSession() {
> +	    HashMap state = new HashMap();
> +
> +	    HashMap connectionState = new HashMap();
> +
> +	    boolean stopHandler = false;
> +
> +	    public String getRemoteIPAddress() {
> +		return remoteIp;
> +	    }
> +
> +	    public Map getState() {
> +		return state;
> +	    }
> +
> +	    public boolean isRelayingAllowed() {
> +		return relaying;
> +	    }
> +
> +	    public boolean isAuthRequired() {
> +		return false;
> +	    }
>  
> -        };
> +	    public int getRcptCount() {
> +		return 0;
> +	    }
> +
> +	    public void setStopHandlerProcessing(boolean b) {
> +		stopHandler = b;
> +	    }
> +
> +	    public boolean getStopHandlerProcessing() {
> +		return stopHandler;
> +	    }
> +
> +	    public Map getConnectionState() {
> +		return connectionState;
> +	    }
> +
> +	    public void resetConnectionState() {
> +		connectionState.clear();
> +	    }
> +
> +	};
>      }
>  
>      // ip is blacklisted and has txt details
>      public void testBlackListedTextPresent() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
>  
> -        setupMockedSMTPSession();
> -        rbl.setDNSServer(mockedDnsServer);
> +	setupMockedSMTPSession();
> +	rbl.setDNSServer(mockedDnsServer);
>  
> -        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(true);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertEquals("Details","Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2",
> -               mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNotNull("Blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(true);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertEquals("Details",
> +		"Blocked - see http://www.spamcop.net/bl.shtml?127.0.0.2",
> +		mockedSMTPSession.getConnectionState().get(
> +			RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNotNull("Blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
>  
>      // ip is blacklisted and has txt details but we don'T want to retrieve the txt record
>      public void testGetNoDetail() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
>  
> -        setupMockedSMTPSession();
> -        rbl.setDNSServer(mockedDnsServer);
> +	setupMockedSMTPSession();
> +	rbl.setDNSServer(mockedDnsServer);
>  
> -        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(false);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNotNull("Blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(false);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertNull("No details", mockedSMTPSession.getConnectionState().get(
> +		RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNotNull("Blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
>  
>      // ip is allowed to relay
>      public void testRelayAllowed() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
>  
> -        setRelayingAllowed(true);
> -        setupMockedSMTPSession();
> +	setRelayingAllowed(true);
> +	setupMockedSMTPSession();
>  
> -        rbl.setDNSServer(mockedDnsServer);
> +	rbl.setDNSServer(mockedDnsServer);
>  
> -        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(true);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNull("Not blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(true);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertNull("No details", mockedSMTPSession.getConnectionState().get(
> +		RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNull("Not blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
>  
>      // ip not on blacklist
>      public void testNotBlackListed() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> -        setRemoteIp("192.168.0.1");
> -        setupMockedSMTPSession();
> -
> -        rbl.setDNSServer(mockedDnsServer);
> -
> -        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(true);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertNull("No details",mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNull("Not blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
> +	setRemoteIp("192.168.0.1");
> +	setupMockedSMTPSession();
> +
> +	rbl.setDNSServer(mockedDnsServer);
> +
> +	rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(true);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertNull("No details", mockedSMTPSession.getConnectionState().get(
> +		RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNull("Not blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
>  
>      // ip on blacklist without txt details
>      public void testBlackListedNoTxt() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> -        setRemoteIp("127.0.0.3");
> -        setupMockedSMTPSession();
> -
> -        rbl.setDNSServer(mockedDnsServer);
> -
> -        rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(true);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertNull(mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNotNull("Blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
> +	setRemoteIp("127.0.0.3");
> +	setupMockedSMTPSession();
> +
> +	rbl.setDNSServer(mockedDnsServer);
> +
> +	rbl.setBlacklist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(true);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertNull(mockedSMTPSession.getConnectionState().get(
> +		RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNotNull("Blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
>  
>      // ip on whitelist
>      public void testWhiteListed() {
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> +	DNSRBLHandler rbl = new DNSRBLHandler();
>  
> -        ContainerUtil.enableLogging(rbl, new MockLogger());
> -        setRemoteIp("127.0.0.2");
> -        setupMockedSMTPSession();
> -
> -        rbl.setDNSServer(mockedDnsServer);
> -
> -        rbl.setWhitelist(new String[] { "bl.spamcop.net" });
> -        rbl.setGetDetail(true);
> -        rbl.onConnect(mockedSMTPSession, new Chain(null));
> -        assertNull(mockedSMTPSession.getConnectionState().get(RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> -        assertNull("Not blocked",mockedSMTPSession.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
> +	ContainerUtil.enableLogging(rbl, new MockLogger());
> +	setRemoteIp("127.0.0.2");
> +	setupMockedSMTPSession();
> +
> +	rbl.setDNSServer(mockedDnsServer);
> +
> +	rbl.setWhitelist(new String[] { "bl.spamcop.net" });
> +	rbl.setGetDetail(true);
> +	rbl.onConnect(mockedSMTPSession, new Chain(null));
> +	assertNull(mockedSMTPSession.getConnectionState().get(
> +		RBL_DETAIL_MAIL_ATTRIBUTE_NAME));
> +	assertNull("Not blocked", mockedSMTPSession.getConnectionState().get(
> +		RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME));
>      }
> -    
> +
>      public void testInvalidConfig() {
> -        boolean exception = false;
> -        DNSRBLHandler rbl = new DNSRBLHandler();
> -        try {
> -            rbl.configure((Configuration) new DefaultConfiguration("rblserver"));
> -        } catch (ConfigurationException e) {
> -            exception = true;
> -        }
> -        
> -        assertTrue("Invalid config",exception);
> +	boolean exception = false;
> +	DNSRBLHandler rbl = new DNSRBLHandler();
> +	try {
> +	    rbl.configure((Configuration) new DefaultConfiguration(
> +			    "rblserver"));
> +	} catch (ConfigurationException e) {
> +	    exception = true;
> +	}
> +
> +	assertTrue("Invalid config", exception);
>      }
>  
>  }
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -98,8 +98,8 @@
>              }
>              
>              public SMTPResponse getSMTPResponse() {
> -            return response;
> -            }
> +		return response;
> +	    }
>              
>              
>          };
> 
> Modified: james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
> URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java?rev=427574&r1=427573&r2=427574&view=diff
> ==============================================================================
> --- james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java (original)
> +++ james/server/sandbox/handlerapi2/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java Tue Aug  1 06:23:11 2006
> @@ -69,11 +69,6 @@
>              public Mail getMail() {
>                  return mockedMail;
>              }
> -
> -            public int getRcptCount() {
> -                return 0;
> -            }
> -
>          };
>      }
>  
> 
> 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=427574&r1=427573&r2=427574&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 06:23:11 2006
> @@ -86,8 +86,8 @@
>              }
>              
>              public SMTPResponse getSMTPResponse() {
> -            return response;
> -            }
> +		return response;
> +	    }
>              
>          };
>          return session;
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> !EXCUBATOR:1,44cf55e243381776350595!