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 ba...@apache.org on 2007/01/08 00:27:48 UTC

svn commit: r493873 - 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/java/org/apache/james/smtpserver/ho...

Author: bago
Date: Sun Jan  7 15:27:45 2007
New Revision: 493873

URL: http://svn.apache.org/viewvc?view=rev&rev=493873
Log:
Merged EhloHook to HeloHook (EhloCmdHandler reuse HeloHook extension point)
Removed checkAuthUsers configurability from ResolvableEhloHeloHandler
UsersRepositoryAuthHook now setRelayingAllowed to true on successfull auth
Removed verifyIdentity configuration from the handlerchain/configurationData: we can do this by enabling/disabling its specific Hook (SenderAuthIdentifyVerificationRcptHook).
Added a new AcceptRecipientIfRelayingIsAllowed RcptHook

Added:
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java   (with props)
Removed:
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/hook/EhloHook.java
Modified:
    james/server/sandbox/handlerapi-experiment/TODO
    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/core/AuthRequiredToRelayRcptHook.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/MailCmdHandler.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/UsersRepositoryAuthHook.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/ResolvableEhloHeloHandlerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
    james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ValidRcptHandlerTest.java

Modified: james/server/sandbox/handlerapi-experiment/TODO
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/TODO?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/TODO (original)
+++ james/server/sandbox/handlerapi-experiment/TODO Sun Jan  7 15:27:45 2007
@@ -6,8 +6,6 @@
   - or maybe another non public api hook to be implemented by smtp extensions.
 - The AuthHook define a way to hook plain text user-pass tuple: this mean this won't work as soon as we'll try to implement another SASL mechanism: this is a common issue with POP3 APOP and IMAP SALS auth.
 - Decide what to do with services and DI (logging and more).
-- SenderAuthIdentifyVerificationRcptHook use session.getConfigurationData().isVerifyIdentity() to decide wether to enable itself or not: isn't it better to add the handler to the config and commenting/uncommenting the handler already do the trick? If so we shoudl simply remove that configuration and remove the check in the code.
-- I would like to Merge HeloHook and EhloHook to a single hook. They are alternative and I think there is no need for both in the high-level api. less is more ;-)
-  (currently we have a single handler implementing both hook and doing the same thing for both).
 - Check if we can delete the ComposedJunkScore class. I think the class is not needed anymore
-- We should probably move logging of ok/deny operations from specific hooks to this Hook result interceptor
\ No newline at end of file
+- We should probably move logging of ok/deny operations from specific hooks to this Hook result interceptor
+- ValidRcptHandlerTest.testNotRejectInvalidUserAuth fails: imho (bago) the test is wrong, but we should check it.

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -70,14 +70,6 @@
     boolean isAuthSupported(String remoteIP);
 
     /**
-     * Returns whether the service validates the identity
-     * of its senders.
-     *
-     * @return whether SMTP authentication is on
-     */
-    boolean isVerifyIdentity();
-    
-    /**
      * Returns whether the remote server needs to send a HELO/EHLO
      * of its senders.
      *

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -85,14 +85,6 @@
     private int authRequired = AUTH_DISABLED;
 
     /**
-     * Whether the server verifies that the user
-     * actually sending an email matches the
-     * authentication credentials attached to the
-     * SMTP interaction.
-     */
-    private boolean verifyIdentity = false;
-
-    /**
      * Whether the server needs helo to be send first
      */
     private boolean heloEhloEnforcement = false;
@@ -159,13 +151,8 @@
             if (authRequiredString.equals("true")) authRequired = AUTH_REQUIRED;
             else if (authRequiredString.equals("announce")) authRequired = AUTH_ANNOUNCE;
             else authRequired = AUTH_DISABLED;
-            verifyIdentity = handlerConfiguration.getChild("verifyIdentity").getValueAsBoolean(false);
             if (authRequired != AUTH_DISABLED) {
-                if (verifyIdentity) {
-                    getLogger().info("This SMTP server requires authentication and verifies that the authentication credentials match the sender address.");
-                } else {
-                    getLogger().info("This SMTP server requires authentication, but doesn't verify that the authentication credentials match the sender address.");
-                }
+                getLogger().info("This SMTP server requires authentication.");
             } else {
                 getLogger().info("This SMTP server does not require authentication.");
             }
@@ -344,13 +331,6 @@
                 authRequired = authRequired && !SMTPServer.this.authorizedNetworks.matchInetNetwork(remoteIP);
             }
             return authRequired;
-        }
-
-        /**
-         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isVerifyIdentity()
-         */
-        public boolean isVerifyIdentity() {
-            return SMTPServer.this.verifyIdentity;
         }
 
         /**

Added: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java?view=auto&rev=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java (added)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java Sun Jan  7 15:27:45 2007
@@ -0,0 +1,46 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.smtpserver.core;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.james.smtpserver.SMTPSession;
+import org.apache.james.smtpserver.hook.HookResult;
+import org.apache.james.smtpserver.hook.HookReturnCode;
+import org.apache.james.smtpserver.hook.RcptHook;
+import org.apache.mailet.MailAddress;
+
+/**
+ * This hook will stop the hook chain if relaying is allowed
+ */
+public class AcceptRecipientIfRelayingIsAllowed extends AbstractLogEnabled implements
+        RcptHook {
+
+    /**
+     * @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()) {
+            return new HookResult(HookReturnCode.OK);
+        }
+        return new HookResult(HookReturnCode.DECLINED);
+    }
+
+}

Propchange: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AcceptRecipientIfRelayingIsAllowed.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -43,13 +43,11 @@
             String toDomain = rcpt.getHost();
             if (!session.getConfigurationData().getMailServer().isLocalServer(toDomain)) {
                 if (session.isAuthSupported()) {
-                    if (session.getUser() == null) {
-                        return new HookResult(HookReturnCode.DENY,
-                                SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(
-                                        DSNStatus.PERMANENT,
-                                        DSNStatus.SECURITY_AUTH)
-                                        + " Authentication Required");
-                    }
+                    return new HookResult(HookReturnCode.DENY,
+                            SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(
+                                    DSNStatus.PERMANENT,
+                                    DSNStatus.SECURITY_AUTH)
+                                    + " Authentication Required");
                 } else {
                     return new HookResult(
                             HookReturnCode.DENY,

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java Sun Jan  7 15:27:45 2007
@@ -22,7 +22,7 @@
 import org.apache.james.smtpserver.CommandHandler;
 import org.apache.james.smtpserver.SMTPResponse;
 import org.apache.james.smtpserver.SMTPSession;
-import org.apache.james.smtpserver.hook.EhloHook;
+import org.apache.james.smtpserver.hook.HeloHook;
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.util.mail.SMTPRetCode;
 import org.apache.james.util.mail.dsn.DSNStatus;
@@ -44,7 +44,6 @@
 
     private List ehloExtensions;
 
-    
     /**
      * Handler method called upon receipt of a EHLO command. Responds with a
      * greeting and informs the client whether client authentication is
@@ -168,13 +167,14 @@
      * @see org.apache.james.smtpserver.core.AbstractHookableCmdHandler#getHookInterface()
      */
     protected Class getHookInterface() {
-        return EhloHook.class;
+        return HeloHook.class;
     }
-    
+
     /**
      * @see org.apache.james.smtpserver.core.AbstractHookableCmdHandler#callHook(java.lang.Object, org.apache.james.smtpserver.SMTPSession, java.lang.String)
      */
     protected HookResult callHook(Object rawHook, SMTPSession session, String parameters) {
-        return ((EhloHook) rawHook).doEhlo(session, parameters);
+        return ((HeloHook) rawHook).doHelo(session, parameters);
     }
+
 }

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/MailCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/MailCmdHandler.java?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/MailCmdHandler.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/MailCmdHandler.java Sun Jan  7 15:27:45 2007
@@ -58,8 +58,12 @@
         MailAddress sender = (MailAddress) session.getState().get(
                 SMTPSession.SENDER);
         responseBuffer.append(
-                DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.ADDRESS_OTHER)
-                        + " Sender <").append(sender).append("> OK");
+                DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.ADDRESS_OTHER))
+                .append(" Sender <");
+        if (sender != null) {
+            responseBuffer.append(sender);
+        }
+        responseBuffer.append("> OK");
         return new SMTPResponse(SMTPRetCode.MAIL_OK, responseBuffer);
     }
 

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -41,8 +41,7 @@
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender,
             MailAddress rcpt) {
-        if (!session.isRelayingAllowed() && session.getUser() != null
-                && session.getConfigurationData().isVerifyIdentity()) {
+        if (session.getUser() != null) {
             String authUser = (session.getUser()).toLowerCase(Locale.US);
             MailAddress senderAddress = (MailAddress) session.getState().get(
                     SMTPSession.SENDER);

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/UsersRepositoryAuthHook.java Sun Jan  7 15:27:45 2007
@@ -27,13 +27,13 @@
  * This Auth hook can be used to authenticate against the james user repository
  */
 public class UsersRepositoryAuthHook implements AuthHook {
-    
     /**
      * @see org.apache.james.smtpserver.hook.AuthHook#doAuth(org.apache.james.smtpserver.SMTPSession, java.lang.String, java.lang.String)
      */
     public HookResult doAuth(SMTPSession session, String username, String password) {
         if (session.getConfigurationData().getUsersRepository().test(username, password)) {
             session.setUser(username);
+            session.setRelayingAllowed(true);
             return new HookResult(HookReturnCode.OK, "Authentication Successful");
         }
         return new HookResult(HookReturnCode.DECLINED);

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -248,19 +248,20 @@
      * @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) {
-        String blocklisted = (String) session.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME);
-
-        if (blocklisted != null && // was found in the RBL
-                session.getUser() == null // Not authenticated
-                ) {
-            if (blocklistedDetail == null) {
-                return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,
-                        DSNStatus.SECURITY_AUTH)  + " Rejected: unauthenticated e-mail from " + session.getRemoteIPAddress() 
-                        + " is restricted.  Contact the postmaster for details.");
-            } else {
-                return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH) + " " + blocklistedDetail);
+        
+        if (!session.isRelayingAllowed()) {
+            String blocklisted = (String) session.getConnectionState().get(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME);
+    
+            if (blocklisted != null) { // was found in the RBL
+                if (blocklistedDetail == null) {
+                    return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,
+                            DSNStatus.SECURITY_AUTH)  + " Rejected: unauthenticated e-mail from " + session.getRemoteIPAddress() 
+                            + " is restricted.  Contact the postmaster for details.");
+                } else {
+                    return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH) + " " + blocklistedDetail);
+                }
+               
             }
-           
         }
         return new HookResult(HookReturnCode.DECLINED);
     }

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 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.getUser() == null) {
+        if (!session.isRelayingAllowed()) {
 
             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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -28,7 +28,6 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.james.services.DNSServer;
 import org.apache.james.smtpserver.SMTPSession;
-import org.apache.james.smtpserver.hook.EhloHook;
 import org.apache.james.smtpserver.hook.HeloHook;
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
@@ -44,14 +43,12 @@
 /**
  * This CommandHandler can be used to reject not resolvable EHLO/HELO
  */
-public class ResolvableEhloHeloHandler extends AbstractLogEnabled implements Configurable, Serviceable, RcptHook, EhloHook, HeloHook {
+public class ResolvableEhloHeloHandler extends AbstractLogEnabled implements Configurable, Serviceable, RcptHook, HeloHook {
 
     public final static String BAD_EHLO_HELO = "BAD_EHLO_HELO";
 
     protected boolean checkAuthNetworks = false;
 
-    private boolean checkAuthUsers = false;
-
     protected DNSServer dnsServer = null;
 
     /**
@@ -64,12 +61,6 @@
         if (configRelay != null) {
             setCheckAuthNetworks(configRelay.getValueAsBoolean(false));
         }
-
-        Configuration configAuthUser = handlerConfiguration.getChild(
-                "checkAuthUsers", false);
-        if (configAuthUser != null) {
-            setCheckAuthUsers(configAuthUser.getValueAsBoolean(false));
-        }
     }
 
     /**
@@ -90,16 +81,6 @@
     }
 
     /**
-     * Set to true if Auth users should be included in the EHLO/HELO check
-     * 
-     * @param checkAuthUsers
-     *            Set to true to enable
-     */
-    public void setCheckAuthUsers(boolean checkAuthUsers) {
-        this.checkAuthUsers = checkAuthUsers;
-    }
-
-    /**
      * Set the DNSServer
      * 
      * @param dnsServer
@@ -125,6 +106,7 @@
         
         if (isBadHelo(session, argument)) {
             session.getState().put(BAD_EHLO_HELO, "true");
+            System.out.println("bad_ehlo!");
         }
     }
     
@@ -149,35 +131,27 @@
      * @see org.apache.james.smtpserver.core.filter.fastfail.AbstractJunkHandler#check(org.apache.james.smtpserver.SMTPSession)
      */
     protected boolean check(SMTPSession session,MailAddress rcpt) {
-
         // not reject it
-        if (session.getState().get(BAD_EHLO_HELO) == null)
+        if (session.getState().get(BAD_EHLO_HELO) == null) {
+            System.out.println("doRcpt1");
             return false;
-
-        // Check if the client was authenticated
-        if ((session.getUser() == null || checkAuthUsers)) {
-            return true;
         }
-        return false;
+
+            System.out.println("doRcpt2");
+        return true;
     }
 
     /**
      * @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) {
+        System.out.println("doRcpt");
         if (check(session,rcpt)) {
             return new HookResult(HookReturnCode.DENY,SMTPRetCode.SYNTAX_ERROR_ARGUMENTS,DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_INVALID_ARG)
                     + " Provided EHLO/HELO " + session.getState().get(SMTPSession.CURRENT_HELO_NAME) + " can not resolved.");
         } else {
             return new HookResult(HookReturnCode.DECLINED);
         }
-    }
-
-    /**
-     * @see org.apache.james.smtpserver.hook.EhloHook#doEhlo(org.apache.james.smtpserver.SMTPSession, java.lang.String)
-     */
-    public HookResult doEhlo(SMTPSession session, String helo) {
-        return doHelo(session,helo);
     }
 
     /**

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -228,7 +228,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.getUser() == null) {
+        if (!session.isRelayingAllowed()) {
             // Check if session is blocklisted
             if (session.getState().get(SPF_BLOCKLISTED)!= null) {
                 return new HookResult(HookReturnCode.DENY,DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SECURITY_AUTH) + " "

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -168,7 +168,7 @@
      */
     public HookResult doRcpt(SMTPSession session, MailAddress sender, MailAddress rcpt) {
         
-        if (!session.isRelayingAllowed() && session.getUser() == null) {
+        if (!session.isRelayingAllowed()) {
             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/ResolvableEhloHeloHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/ResolvableEhloHeloHandlerTest.java?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -124,6 +124,8 @@
         assertEquals("Not reject", result,HookReturnCode.DECLINED);
     }
     
+    /* This is no more valid because it is handled by the hook sequence instead of
+     * checking it in each hook implementation.
     public void testNotRejectInvalidHeloAuthUser() throws ParseException {
         MailAddress mailAddress = new MailAddress("test@localhost");
         SMTPSession session = setupMockSession(INVALID_HOST,false,true,"valid@user",mailAddress);
@@ -140,6 +142,7 @@
         int result = handler.doRcpt(session,null, mailAddress).getResult();
         assertEquals("Not reject", result,HookReturnCode.DECLINED);
     }
+     */
     
     public void testRejectInvalidHeloAuthUser() throws ParseException {
         MailAddress mailAddress = new MailAddress("test@localhost");
@@ -149,7 +152,6 @@
         ContainerUtil.enableLogging(handler,new MockLogger());
         
         handler.setDnsServer(setupMockDNSServer());
-        handler.setCheckAuthUsers(true);
 
         handler.doHelo(session, INVALID_HOST);
         assertNotNull("Value stored",session.getState().get(ResolvableEhloHeloHandler.BAD_EHLO_HELO));
@@ -194,3 +196,4 @@
         assertEquals("Reject", result,HookReturnCode.DENY);
     }
 }
+    

Modified: james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java?view=diff&rev=493873&r1=493872&r2=493873
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java (original)
+++ james/server/sandbox/handlerapi-experiment/src/test/org/apache/james/smtpserver/SMTPServerTest.java Sun Jan  7 15:27:45 2007
@@ -885,11 +885,13 @@
         String userName = "test_user_smtp";
         m_usersRepository.addUser(userName, "pwd");
 
-        smtpProtocol.setSender("");
-
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0"+userName+"\0pwd\0"));
         assertEquals("authenticated", 235, smtpProtocol.getReplyCode());
+
+        smtpProtocol.setSender("");
+        assertEquals("expected sender ok", 250, smtpProtocol.getReplyCode());
+
 
         smtpProtocol.addRecipient("mail@sample.com");
         assertEquals("expected error", 503, smtpProtocol.getReplyCode());

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=493873&r1=493872&r2=493873
==============================================================================
--- 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 Sun Jan  7 15:27:45 2007
@@ -137,10 +137,6 @@
                 throw new UnsupportedOperationException("Unimplemented Stub Method");
             }
 
-            public boolean isVerifyIdentity() {
-                throw new UnsupportedOperationException("Unimplemented Stub Method");
-            }
-
             public boolean useHeloEhloEnforcement() {
                 throw new UnsupportedOperationException("Unimplemented Stub Method");
             }



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