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 no...@apache.org on 2010/06/30 16:28:42 UTC

svn commit: r959328 - in /james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver: SenderAuthIdentifyVerificationRcptHook.java netty/NioSMTPServer.java netty/SMTPNettySession.java

Author: norman
Date: Wed Jun 30 14:28:42 2010
New Revision: 959328

URL: http://svn.apache.org/viewvc?rev=959328&view=rev
Log:
respect the senderVerify configuration parameter in SMTPServer (JAMES-1023)

Modified:
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPNettySession.java

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java?rev=959328&r1=959327&r2=959328&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java Wed Jun 30 14:28:42 2010
@@ -20,8 +20,13 @@ package org.apache.james.smtpserver;
 
 import javax.annotation.Resource;
 
+import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
+import org.apache.james.protocols.smtp.hook.HookResult;
+import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.netty.SMTPNettySession;
+import org.apache.mailet.MailAddress;
 
 /**
  * Handler which check if the authenticated user is incorrect
@@ -47,6 +52,17 @@ public class SenderAuthIdentifyVerificat
         this.mailServer = mailServer;
     }
 
+    @Override
+    public HookResult doRcpt(SMTPSession session, MailAddress sender,
+            MailAddress rcpt) {
+        SMTPNettySession nSession =(SMTPNettySession) session;
+        if (nSession.verifyIdentity()) {
+            return super.doRcpt(session, sender, rcpt);
+        } else {
+            return new HookResult(HookReturnCode.DECLINED);
+        }
+    }
+
     /**
      * @see org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook#isLocalDomain(java.lang.String)
      */

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java?rev=959328&r1=959327&r2=959328&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/NioSMTPServer.java Wed Jun 30 14:28:42 2010
@@ -97,6 +97,8 @@ public class NioSMTPServer extends Abstr
 
     private MailServer mailServer;
 
+    private boolean verifyIdentity;
+
     @Resource(name="James")
     public final void setMailServer(MailServer mailServer) {
         this.mailServer = mailServer;
@@ -179,6 +181,9 @@ public class NioSMTPServer extends Abstr
             smtpGreeting = handlerConfiguration.getString("smtpGreeting",null);
 
             addressBracketsEnforcement = handlerConfiguration.getBoolean("addressBracketsEnforcement",true);
+            
+            verifyIdentity = handlerConfiguration.getBoolean("verifyIdentity",true);
+
         }
     }
 
@@ -200,7 +205,7 @@ public class NioSMTPServer extends Abstr
     /**
      * A class to provide SMTP handler configuration to the handlers
      */
-    private class SMTPHandlerConfigurationDataImpl implements SMTPConfiguration {
+    public class SMTPHandlerConfigurationDataImpl implements SMTPConfiguration {
 
         /**
          * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
@@ -279,6 +284,15 @@ public class NioSMTPServer extends Abstr
             return NioSMTPServer.this.isStartTLSSupported();
         }
 
+        /**
+         * Return true if the username and mail from must match for a authorized user
+         * 
+         * @return verify
+         */
+        public boolean verifyIdentity() {
+            return NioSMTPServer.this.verifyIdentity;
+        }
+
     }
     
     @Override

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPNettySession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPNettySession.java?rev=959328&r1=959327&r2=959328&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPNettySession.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPNettySession.java Wed Jun 30 14:28:42 2010
@@ -31,6 +31,7 @@ import org.apache.james.protocols.impl.A
 import org.apache.james.protocols.impl.LineHandlerUpstreamHandler;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
 import org.apache.james.protocols.smtp.SMTPSession;
+import org.apache.james.smtpserver.netty.NioSMTPServer.SMTPHandlerConfigurationDataImpl;
 import org.jboss.netty.channel.ChannelHandlerContext;
 
 /**
@@ -216,8 +217,20 @@ public class SMTPNettySession extends Ab
         return theConfigData.useHeloEhloEnforcement();
     }
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.smtp.SMTPSession#getPushedLineHandlerCount()
+     */
     public int getPushedLineHandlerCount() {
         return lineHandlerCount;
     }
 
+    public boolean verifyIdentity() {
+        if (theConfigData instanceof SMTPHandlerConfigurationDataImpl) {
+            return ((SMTPHandlerConfigurationDataImpl)theConfigData).verifyIdentity();
+        } else {
+            return true;
+        }
+    }
+
 }



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