james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r491763 - in /james/server/sandbox/handlerapi-experiment: ./ src/java/org/apache/james/smtpserver/ src/java/org/apache/james/smtpserver/core/ src/java/org/apache/james/smtpserver/core/filter/fastfail/ src/test/org/apache/james/smtpserver/
Date Tue, 02 Jan 2007 08:55:12 GMT
Author: bago
Date: Tue Jan  2 00:55:11 2007
New Revision: 491763

URL: http://svn.apache.org/viewvc?view=rev&rev=491763
Log:
removed CURRENT_RECIPIENT usage from state map: left it locally to the RcptHandler
renamed isAuthRequired to isAuthSupported.
replaced "isAuthSupported() && getUser() != null" with "getUser() != null" (when auth is not supported user is always null)

Modified:
    james/server/sandbox/handlerapi-experiment/TODO
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerConfigurationData.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPServer.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPSession.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ResolvableEhloHeloHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SPFHandlerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptMXTest.java

Modified: james/server/sandbox/handlerapi-experiment/TODO
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/TODO?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/TODO (original)
+++ james/server/sandbox/handlerapi-experiment/TODO Tue Jan  2 00:55:11 2007
@@ -3,7 +3,6 @@
 - Check DataCmdHandler for correct clean-up on every exceptions
 - on Rcpt message reject, the original code was logging a lot of informations. Maybe we should change the Hook callers to do something similar (in RcptCmdHandler create a log string including context() call)
 - Check AuthRequiredToRelayRcptHook to see if it is correct to return different SMTP codes if Auth is announced (for relaying denied)
-- Remove CURRENT_RECIPIENT key from state usage: I think we don't use it anymore but in tests.
 - RcptOptions: introduce a new extension points to have Handlers to declare support for given command options so that the syntax check can support them.
   - maybe also add to Mail and Rcpt standard hooks an options map parameter (MAIL's SIZE, RCPT's ORCPT/NOTIFY keyworks)
   - or maybe another non public api hook to be implemented by smtp extensions.

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandler.java Tue Jan  2 00:55:11 2007
@@ -66,7 +66,7 @@
     /**
      * whether or not authorization is required for this connection
      */
-    private boolean authRequired;
+    private boolean authSupported;
 
     /**
      * whether or not this connection can relay without authentication
@@ -126,7 +126,7 @@
     protected void handleProtocol() throws IOException {
         smtpID = random.nextInt(1024) + "";
         relayingAllowed = theConfigData.isRelayingAllowed(remoteIP);
-        authRequired = theConfigData.isAuthRequired(remoteIP);
+        authSupported = theConfigData.isAuthSupported(remoteIP);
         // Both called in resetHandler, we don't need to call them again here.
         // sessionEnded = false;
         // resetState();
@@ -322,10 +322,10 @@
     }
 
     /**
-     * @see org.apache.james.smtpserver.SMTPSession#isAuthRequired()
+     * @see org.apache.james.smtpserver.SMTPSession#isAuthSupported()
      */
-    public boolean isAuthRequired() {
-        return authRequired;
+    public boolean isAuthSupported() {
+        return authSupported;
     }
 
     /**

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerConfigurationData.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerConfigurationData.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerConfigurationData.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPHandlerConfigurationData.java Tue Jan  2 00:55:11 2007
@@ -67,14 +67,7 @@
      * @param remoteIP the remote IP address in String form
      * @return whether SMTP authentication is on
      */
-    boolean isAuthRequired(String remoteIP);
-
-    /**
-     * Returns whether SMTP auth is active for this server.
-     *
-     * @return whether SMTP authentication is on
-     */
-    boolean isAuthRequired();
+    boolean isAuthSupported(String remoteIP);
 
     /**
      * Returns whether the service validates the identity

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPServer.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPServer.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPServer.java Tue Jan  2 00:55:11 2007
@@ -324,7 +324,7 @@
         }
 
         /**
-         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired(String)
+         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthSupported(String)
          */
         public boolean isRelayingAllowed(String remoteIP) {
             boolean relayingAllowed = false;
@@ -335,22 +335,15 @@
         }
 
         /**
-         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired(String)
+         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthSupported(String)
          */
-        public boolean isAuthRequired(String remoteIP) {
+        public boolean isAuthSupported(String remoteIP) {
             if (SMTPServer.this.authRequired == AUTH_ANNOUNCE) return true;
             boolean authRequired = SMTPServer.this.authRequired != AUTH_DISABLED;
             if (authorizedNetworks != null) {
                 authRequired = authRequired && !SMTPServer.this.authorizedNetworks.matchInetNetwork(remoteIP);
             }
             return authRequired;
-        }
-
-        /**
-         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired()
-         */
-        public boolean isAuthRequired() {
-            return SMTPServer.this.authRequired != AUTH_DISABLED;
         }
 
         /**

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPSession.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPSession.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/SMTPSession.java Tue Jan  2 00:55:11 2007
@@ -34,7 +34,6 @@
     public final static String RCPT_LIST = "RCPT_LIST";   // The message recipients
     public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO
     public final static String CURRENT_HELO_NAME = "CURRENT_HELO_NAME"; 
-    public static final Object CURRENT_RECIPIENT = "CURRENT_RECIPIENT"; // Current recipient
     public final static String SESSION_STATE_MAP = "SESSION_STATE_MAP"; // the Session state 
 
     /**
@@ -90,7 +89,7 @@
      *
      * @return authentication required or not
      */
-    boolean isAuthRequired();
+    boolean isAuthSupported();
 
     /**
      * Returns the user name associated with this SMTP interaction.

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java Tue Jan  2 00:55:11 2007
@@ -389,7 +389,7 @@
      * @see org.apache.james.smtpserver.core.EhloExtension#getImplementedEsmtpFeatures(org.apache.james.smtpserver.SMTPSession)
      */
     public List getImplementedEsmtpFeatures(SMTPSession session) {
-        if (session.isAuthRequired()) {
+        if (session.isAuthSupported()) {
             List resp = new LinkedList();
             resp.add("AUTH LOGIN PLAIN");
             resp.add("AUTH=LOGIN PLAIN");

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java Tue Jan  2 00:55:11 2007
@@ -42,7 +42,7 @@
         if (!session.isRelayingAllowed()) {
             String toDomain = rcpt.getHost();
             if (!session.getConfigurationData().getMailServer().isLocalServer(toDomain)) {
-                if (session.isAuthRequired()) {
+                if (session.isAuthSupported()) {
                     if (session.getUser() == null) {
                         return new HookResult(HookReturnCode.DENY,
                                 SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/RcptCmdHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/RcptCmdHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/RcptCmdHandler.java Tue Jan  2 00:55:11 2007
@@ -38,6 +38,8 @@
 public class RcptCmdHandler extends AbstractHookableCmdHandler implements
         CommandHandler {
 
+    public static final Object CURRENT_RECIPIENT = "CURRENT_RECIPIENT"; // Current recipient
+
     /**
      * Handler method called upon receipt of a RCPT command. Reads recipient.
      * Does some connection validation.
@@ -56,7 +58,7 @@
             rcptColl = new ArrayList();
         }
         MailAddress recipientAddress = (MailAddress) session.getState().get(
-                SMTPSession.CURRENT_RECIPIENT);
+                CURRENT_RECIPIENT);
         rcptColl.add(recipientAddress);
         session.getState().put(SMTPSession.RCPT_LIST, rcptColl);
         StringBuffer response = new StringBuffer();
@@ -197,8 +199,7 @@
             optionTokenizer = null;
         }
 
-        session.getState().put(SMTPSession.CURRENT_RECIPIENT,
-                recipientAddress);
+        session.getState().put(CURRENT_RECIPIENT,recipientAddress);
 
         return null;
     }
@@ -249,8 +250,7 @@
             String parameters) {
         return calcDefaultSMTPResponse(((RcptHook) rawHook).doRcpt(session,
                 (MailAddress) session.getState().get(SMTPSession.SENDER),
-                (MailAddress) session.getState().get(
-                        SMTPSession.CURRENT_RECIPIENT)));
+                (MailAddress) session.getState().get(CURRENT_RECIPIENT)));
     }
 
 }

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java Tue Jan  2 00:55:11 2007
@@ -41,8 +41,7 @@
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender,
             MailAddress rcpt) {
-        if (!session.isRelayingAllowed() && session.isAuthRequired()
-                && session.getUser() != null
+        if (!session.isRelayingAllowed() && session.getUser() != null
                 && session.getConfigurationData().isVerifyIdentity()) {
             String authUser = (session.getUser()).toLowerCase(Locale.US);
             MailAddress senderAddress = (MailAddress) session.getState().get(

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java Tue Jan  2 00:55:11 2007
@@ -251,7 +251,7 @@
         String blocklisted = (String) session.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME);
 
         if (blocklisted != null && // was found in the RBL
-                !(session.isAuthRequired() && session.getUser() != null) // Not (SMTP AUTH is enabled and not authenticated)
+                session.getUser() == null // Not authenticated
                 ) {
             if (blocklistedDetail == null) {
                 return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java Tue Jan  2 00:55:11 2007
@@ -651,7 +651,7 @@
      * @see org.apache.james.smtpserver.hook.RcptHook#doRcpt(org.apache.james.smtpserver.SMTPSession, org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
-        if (!session.isRelayingAllowed() && !(session.isAuthRequired() && session.getUser() != null)) {
+        if (!session.isRelayingAllowed() && session.getUser() == null) {
 
             if ((wNetworks == null) || (!wNetworks.matchInetNetwork(session.getRemoteIPAddress()))) {
                 return doGreyListCheck(session, sender,rcpt);

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ResolvableEhloHeloHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ResolvableEhloHeloHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ResolvableEhloHeloHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ResolvableEhloHeloHandler.java Tue Jan  2 00:55:11 2007
@@ -143,7 +143,7 @@
             return false;
 
         // Check if the client was authenticated
-        if (!(session.isAuthRequired() && session.getUser() != null && !checkAuthUsers)) {
+        if (!(session.isAuthSupported() && session.getUser() != null && !checkAuthUsers)) {
             return true;
         }
         return false;

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java Tue Jan  2 00:55:11 2007
@@ -227,7 +227,7 @@
      * @see org.apache.james.smtpserver.hook.RcptHook#doRcpt(org.apache.james.smtpserver.SMTPSession, org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
-        if (session.isAuthRequired() && session.getUser() != null) {
+        if (session.getUser() != null) {
             return new HookResult(HookReturnCode.DECLINED);
         } else {
             // Check if session is blocklisted

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java Tue Jan  2 00:55:11 2007
@@ -168,7 +168,7 @@
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
         
-    if (!session.isRelayingAllowed() && !(session.isAuthRequired() && session.getUser() != null)) {
+    if (!session.isRelayingAllowed() && session.getUser() == null) {
             boolean invalidUser = true;
 
             if (session.getConfigurationData().getUsersRepository().contains(rcpt.getUser()) == true || recipients.contains(rcpt.toString().toLowerCase()) || domains.contains(rcpt.getHost().toLowerCase())) {

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/AbstractSMTPSession.java Tue Jan  2 00:55:11 2007
@@ -85,9 +85,9 @@
     }
 
     /**
-     * @see org.apache.james.smtpserver.SMTPSession#isAuthRequired()
+     * @see org.apache.james.smtpserver.SMTPSession#isAuthSupported()
      */
-    public boolean isAuthRequired() {
+    public boolean isAuthSupported() {
         throw new UnsupportedOperationException("Unimplemented Stub Method");
     }
 

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Tue Jan  2 00:55:11 2007
@@ -130,7 +130,6 @@
             }
 
             public Map getState() {
-                state.put(SMTPSession.CURRENT_RECIPIENT, rcpt);
                 return state;
             }
 
@@ -138,7 +137,7 @@
                 return relaying;
             }
 
-            public boolean isAuthRequired() {
+            public boolean isAuthSupported() {
                 return false;
             }
 

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java Tue Jan  2 00:55:11 2007
@@ -53,7 +53,7 @@
             HashMap connectionMap = new HashMap();
             HashMap map = new HashMap();
             
-            public boolean isAuthRequired() {
+            public boolean isAuthSupported() {
                 return authRequired;
             }
             
@@ -70,7 +70,6 @@
             }
             
             public Map getState() {
-                map.put(SMTPSession.CURRENT_RECIPIENT, recipient);
                 return map;
             }
             
@@ -93,7 +92,8 @@
     }
     
     public void testRejectInvalidHelo() throws ParseException {
-        SMTPSession session = setupMockSession(INVALID_HOST,false,false,null,new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(INVALID_HOST,false,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -103,13 +103,14 @@
         handler.doHelo(session, INVALID_HOST);
         assertNotNull("Invalid HELO",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
         
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Reject", result,HookReturnCode.DENY);
     }
     
     
     public void testNotRejectValidHelo() throws ParseException {
-        SMTPSession session = setupMockSession(VALID_HOST,false,false,null,new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(VALID_HOST,false,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -119,12 +120,13 @@
         handler.doHelo(session, VALID_HOST);
         assertNull("Valid HELO",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
 
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Not reject", result,HookReturnCode.DECLINED);
     }
     
     public void testNotRejectInvalidHeloAuthUser() throws ParseException {
-        SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -135,12 +137,13 @@
         assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
 
 
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Not reject", result,HookReturnCode.DECLINED);
     }
     
     public void testRejectInvalidHeloAuthUser() throws ParseException {
-        SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -152,12 +155,13 @@
         assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
         
         
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Reject", result,HookReturnCode.DENY);
     }
     
     public void testNotRejectRelay() throws ParseException {
-        SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -168,12 +172,13 @@
         handler.doHelo(session, INVALID_HOST);
         assertNull("Value not stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
 
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Not reject", result,HookReturnCode.DECLINED);
     }
     
     public void testRejectRelay() throws ParseException {
-        SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,new MailAddress("test@localhost"));
+        MailAddress mailAddress = new MailAddress("test@localhost");
+        SMTPSession session = setupMockSession(INVALID_HOST,true,false,null,mailAddress);
         ResolvableEhloHeloHandler handler = new ResolvableEhloHeloHandler();
         
         ContainerUtil.enableLogging(handler,new MockLogger());
@@ -185,7 +190,7 @@
         assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
         
         
-        int result = handler.doRcpt(session,null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Reject", result,HookReturnCode.DENY);
     }
 

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SPFHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SPFHandlerTest.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SPFHandlerTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SPFHandlerTest.java Tue Jan  2 00:55:11 2007
@@ -133,7 +133,7 @@
      * Setup mocked smtpsession
      */
     private void setupMockedSMTPSession(final String ip, final String helo,
-            final MailAddress sender, final MailAddress recipient) {
+            final MailAddress sender) {
         mockedSMTPSession = new AbstractSMTPSession() {
             HashMap state = new HashMap();
 
@@ -146,7 +146,6 @@
             public Map getState() {
                 state.put(SMTPSession.CURRENT_HELO_NAME, helo);
                 state.put(SMTPSession.SENDER, sender);
-                state.put(SMTPSession.CURRENT_RECIPIENT, recipient);
                 return state;
             }
 
@@ -154,7 +153,7 @@
                 return relaying;
             }
 
-            public boolean isAuthRequired() {
+            public boolean isAuthSupported() {
                 return false;
             }
 
@@ -169,9 +168,8 @@
         };
     }
 
-    private void runHandlers(SPFHandler spf, SMTPSession mockedSMTPSession) {
+    private void runHandlers(SPFHandler spf, SMTPSession mockedSMTPSession, MailAddress rcpt) {
         MailAddress sender = (MailAddress) mockedSMTPSession.getState().get(SMTPSession.SENDER);
-        MailAddress rcpt = (MailAddress) mockedSMTPSession.getState().get(SMTPSession.CURRENT_RECIPIENT);
 
         spf.doMail(mockedSMTPSession, sender);
 
@@ -181,9 +179,10 @@
     }
 
     public void testSPFpass() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf1.james.apache.org",
-                new MailAddress("test@spf1.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf1.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
 
@@ -193,7 +192,7 @@
         
         spf.initialize();
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNull("Not reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -208,9 +207,10 @@
     }
 
     public void testSPFfail() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf2.james.apache.org",
-                new MailAddress("test@spf2.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf2.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -219,7 +219,7 @@
         
         spf.initialize();
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNotNull("reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -232,9 +232,10 @@
     }
 
     public void testSPFsoftFail() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf3.james.apache.org",
-                new MailAddress("test@spf3.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf3.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -243,7 +244,7 @@
         
         spf.initialize();
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNull("not reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -258,9 +259,10 @@
     }
 
     public void testSPFsoftFailRejectEnabled() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf3.james.apache.org",
-                new MailAddress("test@spf3.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf3.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -271,7 +273,7 @@
         
         spf.setBlockSoftFail(true);
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNotNull("reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -284,9 +286,10 @@
     }
 
     public void testSPFpermError() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org",
-                new MailAddress("test@spf4.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf4.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -297,7 +300,7 @@
         
         spf.setBlockSoftFail(true);
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNotNull("reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -310,9 +313,10 @@
     }
 
     public void testSPFtempError() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf5.james.apache.org",
-                new MailAddress("test@spf5.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf5.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -321,7 +325,7 @@
 
         spf.initialize();
         
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNull("no reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -334,9 +338,10 @@
     }
 
     public void testSPFNoRecord() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf6.james.apache.org",
-                new MailAddress("test@spf6.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf6.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -345,7 +350,7 @@
 
         spf.initialize();
         
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNull("no reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -360,9 +365,10 @@
     }
 
     public void testSPFpermErrorNotRejectPostmaster() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "postmaster@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org",
-                new MailAddress("test@spf4.james.apache.org"), new MailAddress(
-                        "postmaster@localhost"));
+                new MailAddress("test@spf4.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -373,7 +379,7 @@
         
         spf.setBlockSoftFail(true);
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNotNull("not removed this state", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));
@@ -384,8 +390,9 @@
     }
 
     public void testSPFpermErrorNotRejectAbuse() throws Exception {
+        MailAddress mailAddress = new MailAddress("abuse@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org",
-                new MailAddress("test@spf4.james.apache.org"), new MailAddress("abuse@localhost"));
+                new MailAddress("test@spf4.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -395,13 +402,14 @@
         spf.setDNSService(mockedDnsService);
         spf.setBlockSoftFail(true);
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
     }
     
     public void testSPFpermErrorRejectDisabled() throws Exception {
+        MailAddress mailAddress = new MailAddress(
+                                "test@localhost");
         setupMockedSMTPSession("192.168.100.1", "spf4.james.apache.org",
-                new MailAddress("test@spf4.james.apache.org"), new MailAddress(
-                        "test@localhost"));
+                new MailAddress("test@spf4.james.apache.org"));
         SPFHandler spf = new SPFHandler();
 
         ContainerUtil.enableLogging(spf, new MockLogger());
@@ -412,7 +420,7 @@
         
         spf.setBlockPermError(false);
 
-        runHandlers(spf, mockedSMTPSession);
+        runHandlers(spf, mockedSMTPSession, mailAddress);
 
         assertNull("not reject", mockedSMTPSession.getState().get(
                 SPFHandler.SPF_BLOCKLISTED));

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java Tue Jan  2 00:55:11 2007
@@ -53,9 +53,8 @@
     private SMTPSession setupMockedSMTPSession(final SMTPHandlerConfigurationData conf, final MailAddress rcpt, final boolean relayingAllowed, final boolean authRequired, final String username) {
         SMTPSession session = new AbstractSMTPSession() {
             HashMap state = new HashMap();
-            boolean stop = false;
         
-            public boolean isAuthRequired() {
+            public boolean isAuthSupported() {
                 return authRequired;
             }
         
@@ -72,8 +71,6 @@
             }
         
             public Map getState() {
-                state.put(SMTPSession.CURRENT_RECIPIENT,rcpt);
-
                 return state;
             }
         };
@@ -132,11 +129,7 @@
                 return user;
             }
 
-            public boolean isAuthRequired(String remoteIP) {
-                throw new UnsupportedOperationException("Unimplemented Stub Method");
-            }
-
-            public boolean isAuthRequired() {
+            public boolean isAuthSupported(String remoteIP) {
                 throw new UnsupportedOperationException("Unimplemented Stub Method");
             }
 
@@ -164,10 +157,11 @@
     public void testRejectInvalidUser() throws Exception {
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(INVALID_USER + "@localhost"),false,false,null);
+        MailAddress mailAddress = new MailAddress(INVALID_USER + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
     
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
     
         assertEquals("Rejected",rCode,HookReturnCode.DENY);
     }
@@ -175,10 +169,11 @@
     public void testNotRejectInvalidUserAuth() throws Exception {
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(INVALID_USER + "@localhost"),false,true,"authedUser");
+        MailAddress mailAddress = new MailAddress(INVALID_USER + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,true,"authedUser");
         ContainerUtil.enableLogging(handler,new MockLogger());
     
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -186,10 +181,11 @@
     public void testNotRejectInvalidUserRelay() throws Exception {
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(INVALID_USER + "@localhost"),true,false,null);
+        MailAddress mailAddress = new MailAddress(INVALID_USER + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,true,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
 
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -197,10 +193,11 @@
     public void testNotRejectValidUser() throws Exception {
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(VALID_USER + "@localhost"),false,false,null);
+        MailAddress mailAddress = new MailAddress(VALID_USER + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
     
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -209,12 +206,13 @@
         String recipient = "recip@domain";
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(recipient),false,false,null);
+        MailAddress mailAddress = new MailAddress(recipient);
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
     
         handler.setValidRecipients(recipient);
 
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -225,12 +223,13 @@
 
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(recipient),false,false,null);
+        MailAddress mailAddress = new MailAddress(recipient);
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
     
         handler.setValidDomains(domain);
 
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -241,12 +240,13 @@
 
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(recipient),false,false,null);
+        MailAddress mailAddress = new MailAddress(recipient);
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
         ContainerUtil.enableLogging(handler,new MockLogger());
     
         handler.setValidRegex("reci.*");
 
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
@@ -267,25 +267,27 @@
     }
     
     public void testHasAddressMapping() throws Exception {
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(USER1 + "@localhost"),false,false,null);
+        MailAddress mailAddress = new MailAddress(USER1 + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
     
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
         ContainerUtil.enableLogging(handler,new MockLogger());
 
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
         
         assertEquals("Not rejected",rCode,HookReturnCode.DECLINED);
     }
     
     public void testHasErrorMapping() throws Exception {
-        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),new MailAddress(USER2 + "@localhost"),false,false,null);
+        MailAddress mailAddress = new MailAddress(USER2 + "@localhost");
+        SMTPSession session = setupMockedSMTPSession(setupMockedSMTPConfiguration(),mailAddress,false,false,null);
 
         ValidRcptHandler handler = new ValidRcptHandler();
         ContainerUtil.service(handler, setUpServiceManager());
         ContainerUtil.enableLogging(handler,new MockLogger());
 
-        int rCode = handler.doRcpt(session, null,(MailAddress)session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null,mailAddress).getResult();
     
         assertNull("Valid Error mapping",session.getState().get("VALID_USER"));
         assertEquals("Error mapping",rCode, HookReturnCode.DENY);

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptMXTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptMXTest.java?view=diff&rev=491763&r1=491762&r2=491763
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptMXTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptMXTest.java Tue Jan  2 00:55:11 2007
@@ -51,7 +51,6 @@
             HashMap state = new HashMap();
             
             public Map getState() {
-                state.put(SMTPSession.CURRENT_RECIPIENT, rcpt);
                 return state;
             }
             
@@ -94,14 +93,15 @@
         bNetworks.add("127.0.0.1");
         
         DNSServer dns = setupMockedDNSServer();
-        SMTPSession session = setupMockedSMTPSession(new MailAddress("test@" + INVALID_HOST));
+        MailAddress mailAddress = new MailAddress("test@" + INVALID_HOST);
+        SMTPSession session = setupMockedSMTPSession(mailAddress);
         ValidRcptMX handler = new ValidRcptMX();
 
         ContainerUtil.enableLogging(handler, new MockLogger());
 
         handler.setDNSServer(dns);
         handler.setBannedNetworks(bNetworks, dns);
-        int rCode = handler.doRcpt(session, null, (MailAddress) session.getState().get(SMTPSession.CURRENT_RECIPIENT)).getResult();
+        int rCode = handler.doRcpt(session, null, mailAddress).getResult();
 
         assertEquals("Reject", rCode, HookReturnCode.DENY);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message