james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r422198 - in /james/server/trunk/src: java/org/apache/james/smtpserver/ java/org/apache/james/smtpserver/core/ java/org/apache/james/smtpserver/core/filter/ test/org/apache/james/smtpserver/ test/org/apache/james/test/util/
Date Sat, 15 Jul 2006 09:49:12 GMT
Author: norman
Date: Sat Jul 15 02:49:12 2006
New Revision: 422198

URL: http://svn.apache.org/viewvc?rev=422198&view=rev
Log:
Merge some more stuff by hand for smtp-api

Modified:
    james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
    james/server/trunk/src/java/org/apache/james/smtpserver/core/DNSRBLHandler.java
    james/server/trunk/src/java/org/apache/james/smtpserver/core/SpamAssassinHandler.java
    james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
    james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
    james/server/trunk/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
    james/server/trunk/src/test/org/apache/james/test/util/Util.java

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPServer.java Sat Jul 15 02:49:12
2006
@@ -241,7 +241,6 @@
         } else {
             mailetcontext.setAttribute(Constants.HELLO_NAME, "localhost");
         }
-        theHandlerFactory = new SMTPHandlerFactory();
     }
     
     /**
@@ -284,46 +283,24 @@
     }
 
     /**
-     * @see org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory#newHandler()
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
      */
-    protected ConnectionHandler newHandler()
-            throws Exception {
-        
-        SMTPHandler theHandler = (SMTPHandler) super.newHandler();
-
+    public Object newInstance() throws Exception {
+        SMTPHandler theHandler = new SMTPHandler();
         //pass the handler chain to every SMTPhandler
         theHandler.setHandlerChain(handlerChain);
-
+        
         return theHandler;
     }
-
+    
     /**
-     * The factory for producing handlers.
+     * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
      */
-    private static class SMTPHandlerFactory
-        implements ObjectFactory {
-
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()
-         */
-        public Object newInstance() throws Exception {
-            return new SMTPHandler();
-        }
+    public Class getCreatedClass() {
+        return SMTPHandler.class;
+    }
 
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()
-         */
-        public Class getCreatedClass() {
-            return SMTPHandler.class;
-        }
 
-        /**
-         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommision(Object)
-         */
-        public void decommission( Object object ) throws Exception {
-            return;
-        }
-    }
 
     /**
      * A class to provide SMTP handler configuration to the handlers

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/DNSRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/DNSRBLHandler.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/core/DNSRBLHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/core/DNSRBLHandler.java Sat Jul
15 02:49:12 2006
@@ -26,7 +26,6 @@
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.james.services.DNSServer;
 import org.apache.james.smtpserver.ConnectHandler;
-import org.apache.james.smtpserver.SMTPHandlerConfigurationData;
 import org.apache.james.smtpserver.SMTPSession;
 
 import java.util.ArrayList;

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/SpamAssassinHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/SpamAssassinHandler.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/core/SpamAssassinHandler.java
(original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/core/SpamAssassinHandler.java
Sat Jul 15 02:49:12 2006
@@ -14,7 +14,7 @@
  * implied.  See the License for the specific language governing       *
  * permissions and limitations under the License.                      *
  ***********************************************************************/
-package org.apache.james.smtpserver;
+package org.apache.james.smtpserver.core;
 
 import java.util.Iterator;
 
@@ -25,6 +25,8 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.james.smtpserver.MessageHandler;
+import org.apache.james.smtpserver.SMTPSession;
 import org.apache.james.util.SpamAssassinInvoker;
 import org.apache.james.util.mail.dsn.DSNStatus;
 import org.apache.mailet.Mail;

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
(original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/RcptFilterCmdHandler.java
Sat Jul 15 02:49:12 2006
@@ -141,7 +141,7 @@
             }
 
             if (session.isBlockListed() &&                                      
         // was found in the RBL
-                (!session.isRelayingAllowed() || (session.isAuthRequired() && session.getUser()
== null)) &&  // Not an authorized IP or SMTP AUTH is enabled and not authenticated
+                !(session.isRelayingAllowed() || (session.isAuthRequired() && session.getUser()
!= null)) &&  // Not (either an authorized IP or (SMTP AUTH is enabled and not authenticated))
                 !(recipientAddress.getUser().equalsIgnoreCase("postmaster") || recipientAddress.getUser().equalsIgnoreCase("abuse")))
{
                 
                 // trying to send e-mail to other than postmaster or abuse

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/DNSRBLHandlerTest.java Sat Jul
15 02:49:12 2006
@@ -29,6 +29,7 @@
 
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.james.services.DNSServer;
+import org.apache.james.smtpserver.core.DNSRBLHandler;
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.util.watchdog.Watchdog;
 import org.apache.mailet.Mail;
@@ -256,6 +257,21 @@
             public String getSessionID() {
                 throw new UnsupportedOperationException(
                         "Unimplemented mock service");
+            }
+
+            public int getRcptCount() {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+
+            public void setStopHandlerProcessing(boolean b) {
+                // TODO Auto-generated method stub
+                
+            }
+
+            public boolean getStopHandlerProcessing() {
+                // TODO Auto-generated method stub
+                return false;
             }
 
         };

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java (original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPTestConfiguration.java Sat
Jul 15 02:49:12 2006
@@ -21,6 +21,13 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.james.smtpserver.core.CoreCmdHandlerLoader;
+import org.apache.james.smtpserver.core.DNSRBLHandler;
+import org.apache.james.smtpserver.core.filter.CoreFilterCmdHandlerLoader;
+import org.apache.james.smtpserver.core.filter.fastfail.MaxRcptHandler;
+import org.apache.james.smtpserver.core.filter.fastfail.ResolvableEhloHeloHandler;
+import org.apache.james.smtpserver.core.filter.fastfail.ReverseEqualsEhloHeloHandler;
+import org.apache.james.smtpserver.core.filter.fastfail.ValidSenderDomainHandler;
 import org.apache.james.test.util.Util;
 
 public class SMTPTestConfiguration extends DefaultConfiguration {
@@ -141,10 +148,9 @@
         handlerConfig.addChild(Util.getValuedConfiguration("authRequired", m_authorizingMode));
         handlerConfig.addChild(Util.getValuedConfiguration("heloEhloEnforcement", m_heloEhloEnforcement+""));
         if (m_verifyIdentity) handlerConfig.addChild(Util.getValuedConfiguration("verifyIdentity",
"" + m_verifyIdentity));
-        
-        
-        handlerConfig.addChild(Util.createSMTPHandlerChainConfiguration());
-        
+ 
+        DefaultConfiguration config = new DefaultConfiguration("handlerchain");
+
         if (m_useRBL) {
             DefaultConfiguration handlerChain = (DefaultConfiguration) handlerConfig
                     .getChild("handlerchain");
@@ -152,28 +158,14 @@
             handler.setAttribute("class", DNSRBLHandler.class.getName());
             handlerChain.addChild(handler);
         }
-        
         // Add Configuration for Helo checks and Ehlo checks
-        Configuration[] heloConfig = handlerConfig.getChild("handlerchain").getChildren("handler");
+        Configuration[] heloConfig = handlerConfig.getChild("handlerchain")
+                .getChildren("handler");
         for (int i = 0; i < heloConfig.length; i++) {
             if (heloConfig[i] instanceof DefaultConfiguration) {
-                String cmd = ((DefaultConfiguration) heloConfig[i]).getAttribute("command",null);
-                if (cmd != null) {
-                    if ("HELO".equals(cmd)) {
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkResolvableHelo",m_heloResolv+""));
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkReverseEqualsHelo",m_reverseEqualsHelo+""));
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthNetworks",m_checkAuthNetworks+""));
-                    } else if ("EHLO".equals(cmd)) {
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkResolvableEhlo",m_ehloResolv+""));
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkReverseEqualsEhlo",m_reverseEqualsEhlo+""));
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthNetworks",m_checkAuthNetworks+""));
-                    } else if ("MAIL".equals(cmd)) {
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkValidSenderDomain",m_senderDomainResolv+""));
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("checkAuthClients",m_checkAuthClients+""));
-                    } else if ("RCPT".equals(cmd)) {
-                        ((DefaultConfiguration) heloConfig[i]).addChild(Util.getValuedConfiguration("maxRcpt",m_maxRcpt+""));
-                    }
-                } else {
+                String cmd = ((DefaultConfiguration) heloConfig[i])
+                        .getAttribute("command", null);
+                if (cmd == null) {
                     String className = ((DefaultConfiguration) heloConfig[i])
                             .getAttribute("class", null);
 
@@ -191,8 +183,58 @@
                 }
             }
         }
-        
+
+        config.addChild(createHandler(CoreFilterCmdHandlerLoader.class
+                .getName(), null));
+
+        if (m_heloResolv || m_ehloResolv) {
+            DefaultConfiguration d = createHandler(
+                    ResolvableEhloHeloHandler.class.getName(), null);
+            d.setAttribute("command", "EHLO,HELO");
+            d.addChild(Util.getValuedConfiguration("checkAuthNetworks",
+                    m_checkAuthNetworks + ""));
+            config.addChild(d);
+        }
+        if (m_reverseEqualsHelo || m_reverseEqualsEhlo) {
+            DefaultConfiguration d = createHandler(
+                    ReverseEqualsEhloHeloHandler.class.getName(), null);
+            d.setAttribute("command", "EHLO,HELO");
+            d.addChild(Util.getValuedConfiguration("checkAuthNetworks",
+                    m_checkAuthNetworks + ""));
+            config.addChild(d);
+        }
+        if (m_senderDomainResolv) {
+            DefaultConfiguration d = createHandler(
+                    ValidSenderDomainHandler.class.getName(), null);
+            d.setAttribute("command", "MAIL");
+            d.addChild(Util.getValuedConfiguration("checkAuthClients",
+                    m_checkAuthClients + ""));
+            config.addChild(d);
+        }
+        if (m_maxRcpt > 0) {
+            DefaultConfiguration d = createHandler(MaxRcptHandler.class
+                    .getName(), null);
+            d.setAttribute("command", "RCPT");
+            d.addChild(Util.getValuedConfiguration("maxRcpt", m_maxRcpt + ""));
+            config.addChild(d);
+        }
+        config.addChild(createHandler(CoreCmdHandlerLoader.class.getName(),
+                null));
+        config.addChild(createHandler(
+                org.apache.james.smtpserver.core.SendMailHandler.class
+                        .getName(), null));
+        handlerConfig.addChild(config);
         addChild(handlerConfig);
     }
 
+    private DefaultConfiguration createHandler(String className,
+            String commandName) {
+        DefaultConfiguration d = new DefaultConfiguration("handler");
+        if (commandName != null) {
+            d.setAttribute("command", commandName);
+        }
+        d.setAttribute("class", className);
+        return d;
+    }
+    
 }

Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SetMimeHeaderHandlerTest.java
Sat Jul 15 02:49:12 2006
@@ -19,6 +19,7 @@
 
 import junit.framework.TestCase;
 import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.james.smtpserver.core.SetMimeHeaderHandler;
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.test.util.Util;
 import org.apache.james.util.watchdog.Watchdog;
@@ -203,6 +204,21 @@
             public String getSessionID() {
                 throw new UnsupportedOperationException(
                         "Unimplemented mock service");
+            }
+
+            public int getRcptCount() {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+
+            public void setStopHandlerProcessing(boolean b) {
+                // TODO Auto-generated method stub
+                
+            }
+
+            public boolean getStopHandlerProcessing() {
+                // TODO Auto-generated method stub
+                return false;
             }
         };
     }

Modified: james/server/trunk/src/test/org/apache/james/test/util/Util.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/test/util/Util.java?rev=422198&r1=422197&r2=422198&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/test/util/Util.java (original)
+++ james/server/trunk/src/test/org/apache/james/test/util/Util.java Sat Jul 15 02:49:12 2006
@@ -18,7 +18,19 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.james.pop3server.QuitCmdHandler;
+import org.apache.james.pop3server.RsetCmdHandler;
 import org.apache.james.smtpserver.*;
+import org.apache.james.smtpserver.core.AuthCmdHandler;
+import org.apache.james.smtpserver.core.DataCmdHandler;
+import org.apache.james.smtpserver.core.EhloCmdHandler;
+import org.apache.james.smtpserver.core.ExpnCmdHandler;
+import org.apache.james.smtpserver.core.HeloCmdHandler;
+import org.apache.james.smtpserver.core.HelpCmdHandler;
+import org.apache.james.smtpserver.core.MailCmdHandler;
+import org.apache.james.smtpserver.core.RcptCmdHandler;
+import org.apache.james.smtpserver.core.SendMailHandler;
+import org.apache.james.smtpserver.core.VrfyCmdHandler;
 import org.apache.james.test.mock.mailet.MockMail;
 import org.apache.james.test.mock.javaxmail.MockMimeMessage;
 import org.apache.mailet.MailAddress;



---------------------------------------------------------------------
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