james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r995745 - in /james/server/trunk: ./ core-library/src/main/java/org/apache/james/core/ lmtpserver/ lmtpserver/src/ lmtpserver/src/main/ lmtpserver/src/main/java/ lmtpserver/src/main/java/org/ lmtpserver/src/main/java/org/apache/ lmtpserver/...
Date Fri, 10 Sep 2010 10:51:11 GMT
Author: norman
Date: Fri Sep 10 10:51:11 2010
New Revision: 995745

URL: http://svn.apache.org/viewvc?rev=995745&view=rev
Log:
Add support LMTP to receive mail (JAMES-754)

Added:
    james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageInputStream.java
    james/server/trunk/lmtpserver/
    james/server/trunk/lmtpserver/LICENSE.txt
    james/server/trunk/lmtpserver/NOTICE.txt
    james/server/trunk/lmtpserver/pom.xml
    james/server/trunk/lmtpserver/src/
    james/server/trunk/lmtpserver/src/main/
    james/server/trunk/lmtpserver/src/main/java/
    james/server/trunk/lmtpserver/src/main/java/org/
    james/server/trunk/lmtpserver/src/main/java/org/apache/
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloCmdHandler.java
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloWelcomeMessageHandler.java
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java
    james/server/trunk/spring-deployment/src/main/config/james/lmtpserver.xml
Modified:
    james/server/trunk/pom.xml
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java
    james/server/trunk/spring-deployment/pom.xml
    james/server/trunk/spring-deployment/src/main/config/james/log4j.properties
    james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml

Added: james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageInputStream.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageInputStream.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageInputStream.java (added)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageInputStream.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,104 @@
+/****************************************************************
+ * 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.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+/**
+ * {@link InputStream} which contains the headers and the Body of the
+ * wrapped {@link MimeMessage}
+ * 
+ */
+public class MimeMessageInputStream extends InputStream {
+    private final InputStream headersInputStream;
+    private final InputStream bodyInputStream;
+    private int cStream = 0;
+
+    boolean nextCR = false;
+    boolean nextLF = false;
+
+    @SuppressWarnings("unchecked")
+    public MimeMessageInputStream(MimeMessage message) throws IOException {
+        try {
+            ByteArrayOutputStream headersOut = new ByteArrayOutputStream();
+            Enumeration headers = message.getAllHeaderLines();
+            while (headers.hasMoreElements()) {
+                headersOut.write(headers.nextElement().toString().getBytes("US-ASCII"));
+                headersOut.write("\r\n".getBytes());
+            }
+            headersInputStream = new ByteArrayInputStream(headersOut.toByteArray());
+            
+            // use the raw InputStream because we want to have no conversion here and just obtain the original message body
+            this.bodyInputStream = message.getRawInputStream();
+        } catch (MessagingException e) {
+            throw new IOException("Unable to read MimeMessage: " + e.getMessage());
+        }
+    }
+
+    @Override
+    public int read() throws IOException {
+        if (nextCR) {
+            nextCR = false;
+            nextLF = true;
+            return '\r';
+        } else if (nextLF) {
+            nextLF = false;
+            return '\n';
+        } else {
+            int i = -1;
+            if (cStream == 0) {
+                i = headersInputStream.read();
+            } else {
+                i = bodyInputStream.read();
+            }
+
+            if (i == -1 && cStream == 0) {
+                cStream++;
+                nextCR = true;
+                return read();
+            }
+            return i;
+        }
+
+    }
+
+    /** Closes all streams */
+    public void close() throws IOException {
+        headersInputStream.close();
+        bodyInputStream.close();
+    }
+
+    /** Is there more data to read */
+    public int available() throws IOException {
+        if (cStream == 0) {
+            return headersInputStream.available() + bodyInputStream.available() + 2;
+        } else {
+            return bodyInputStream.available();
+        }
+    }
+
+}

Added: james/server/trunk/lmtpserver/LICENSE.txt
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/LICENSE.txt?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/LICENSE.txt (added)
+++ james/server/trunk/lmtpserver/LICENSE.txt Fri Sep 10 10:51:11 2010
@@ -0,0 +1,218 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+   
+   
+   
+
+   THIS PRODUCT ALSO INCLUDES THIRD PARTY SOFTWARE REDISTRIBUTED UNDER THE
+   FOLLOWING LICENSES:
+   
+   
+   
+   Concurrent, Public Domain (see lib/concurrent.LICENSE)
+   
+   BouncyCastle, MIT License (see lib/BouncyCastle.LICENSE)
+     http://www.bouncycastle.org/licence.html
+     
+   DnsJava, BSD License (see lib/dnsjava.LICENSE)
+     http://www.dnsjava.org/README 
+     
+   JavaBeans Activation Framework, CDDL License
+     http://glassfish.dev.java.net/public/CDDLv1.0.html
+     
+   JavaMail, CDDL License
+     http://glassfish.dev.java.net/public/CDDLv1.0.html
+   
+   QDox, ASL 1.1 License (see tools/lib/qdox.LICENSE)
+     http://qdox.codehaus.org/license.html
+     
+   MX4J, ASL 1.1 License (see phoenix-bin/bin/lib/mx4j.LICENSE)
+   
+   Spice, ASL 1.1 License (see phoenix-bin/bin/lib/spice.LICENSE)
+     http://spice.codehaus.org/license.html
+     
+   Wrapper, MIT License (see phoenix-bin/bin/Wrapper.LICENSE)
+     http://wrapper.tanukisoftware.org/doc/english/license.html
+     
+   ISO-Relax, MIT License (see phoenix-bin/tools/lib/isorelax.LICENSE)
+
+   MSV, BSD License (see phoenix-bin/tools/lib/msv.LICENSE)
+
+   RelaxNG-Datatype, BSD License (see phoenix-bin/tools/lib/relaxngDatatype.LICENSE)
+   
+   XSDLib, BSD License (see phoenix-bin/tools/lib/xsdlib.LICENSE)
+   
\ No newline at end of file

Added: james/server/trunk/lmtpserver/NOTICE.txt
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/NOTICE.txt?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/NOTICE.txt (added)
+++ james/server/trunk/lmtpserver/NOTICE.txt Fri Sep 10 10:51:11 2010
@@ -0,0 +1,11 @@
+
+=========================================================================
+==      NOTICE file for use with the Apache License, Version 2.0,      ==
+=========================================================================
+
+Apache JAMES 
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+            
\ No newline at end of file

Added: james/server/trunk/lmtpserver/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/pom.xml?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/pom.xml (added)
+++ james/server/trunk/lmtpserver/pom.xml Fri Sep 10 10:51:11 2010
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<!--
+  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.    
+-->
+<project>
+  <parent>
+    <artifactId>james-server</artifactId>
+    <groupId>org.apache.james</groupId>
+    <version>3.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.james</groupId>
+  <artifactId>james-server-lmtpserver</artifactId>
+  <name>Apache JAMES Server LMTP</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-smtpserver</artifactId>
+    </dependency>    
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-common-util</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-user-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+    </dependency>    
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-netty-socket</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-domain-api</artifactId>
+    </dependency>            
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-mailet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-smtp</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-impl</artifactId>
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>${javax.mail.groupId}</groupId>
+      <artifactId>${javax.mail.artifactId}</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.netty</groupId>
+      <artifactId>netty</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>
+    </dependency>
+
+  </dependencies>
+</project>

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/CoreCmdHandlerLoader.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,96 @@
+/****************************************************************
+ * 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.lmtpserver;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.james.protocols.api.HandlersPackage;
+import org.apache.james.protocols.smtp.core.ExpnCmdHandler;
+import org.apache.james.protocols.smtp.core.NoopCmdHandler;
+import org.apache.james.protocols.smtp.core.PostmasterAbuseRcptHook;
+import org.apache.james.protocols.smtp.core.QuitCmdHandler;
+import org.apache.james.protocols.smtp.core.ReceivedDataLineFilter;
+import org.apache.james.protocols.smtp.core.RsetCmdHandler;
+import org.apache.james.protocols.smtp.core.SMTPCommandDispatcherLineHandler;
+import org.apache.james.protocols.smtp.core.VrfyCmdHandler;
+import org.apache.james.protocols.smtp.core.esmtp.MailSizeEsmtpExtension;
+import org.apache.james.smtpserver.AuthRequiredToRelayRcptHook;
+import org.apache.james.smtpserver.JamesDataCmdHandler;
+import org.apache.james.smtpserver.JamesMailCmdHandler;
+import org.apache.james.smtpserver.JamesRcptCmdHandler;
+import org.apache.james.smtpserver.fastfail.ValidRcptHandler;
+
+/**
+ * This class represent the base command handlers which are shipped with james.
+ */
+public class CoreCmdHandlerLoader implements HandlersPackage {
+
+    private final String COMMANDDISPATCHER = SMTPCommandDispatcherLineHandler.class.getName();
+    private final String DATACMDHANDLER = JamesDataCmdHandler.class.getName();
+    private final String EXPNCMDHANDLER = ExpnCmdHandler.class.getName();
+    private final String LHLOCMDHANDLER = LhloCmdHandler.class.getName();
+    private final String MAILCMDHANDLER = JamesMailCmdHandler.class.getName();
+    private final String NOOPCMDHANDLER = NoopCmdHandler.class.getName();
+    private final String QUITCMDHANDLER = QuitCmdHandler.class.getName();
+    private final String RCPTCMDHANDLER = JamesRcptCmdHandler.class.getName();
+    private final String VALIDRCPTHANDLER = ValidRcptHandler.class.getName();
+    
+    private final String RSETCMDHANDLER = RsetCmdHandler.class.getName();
+    private final String VRFYCMDHANDLER = VrfyCmdHandler.class.getName();
+    private final String MAILSIZEHOOK = MailSizeEsmtpExtension.class.getName();
+    private final String WELCOMEMESSAGEHANDLER = LhloWelcomeMessageHandler.class.getName();
+    private final String POSTMASTERABUSEHOOK = PostmasterAbuseRcptHook.class.getName();
+    private final String AUTHREQUIREDTORELAY = AuthRequiredToRelayRcptHook.class.getName();
+    private final String RECEIVEDDATALINEFILTER = ReceivedDataLineFilter.class.getName();
+    private final String DATALINEMESSAGEHOOKHANDLER = DataLineLMTPMessageHookHandler.class.getName();
+
+    private final List<String> commands = new LinkedList<String>();
+
+    public CoreCmdHandlerLoader() {
+        // Insert the base commands in the Map
+        commands.add(WELCOMEMESSAGEHANDLER);
+        commands.add(COMMANDDISPATCHER);
+        commands.add(DATACMDHANDLER);
+        commands.add(EXPNCMDHANDLER);
+        commands.add(LHLOCMDHANDLER);
+        commands.add(MAILCMDHANDLER);
+        commands.add(NOOPCMDHANDLER);
+        commands.add(QUITCMDHANDLER);
+        commands.add(RCPTCMDHANDLER);
+        commands.add(VALIDRCPTHANDLER);
+        commands.add(RSETCMDHANDLER);
+        commands.add(VRFYCMDHANDLER);
+        commands.add(MAILSIZEHOOK);
+        commands.add(AUTHREQUIREDTORELAY);
+        commands.add(POSTMASTERABUSEHOOK);
+        commands.add(RECEIVEDDATALINEFILTER);
+        commands.add(DATALINEMESSAGEHOOKHANDLER);
+    }
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.HandlersPackage#getHandlers()
+     */
+    public List<String> getHandlers() {
+        return commands;
+    }
+}

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,195 @@
+/****************************************************************
+ * 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.lmtpserver;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.mail.MessagingException;
+
+import org.apache.james.core.MailImpl;
+import org.apache.james.core.MimeMessageCopyOnWriteProxy;
+import org.apache.james.core.MimeMessageInputStream;
+import org.apache.james.core.MimeMessageInputStreamSource;
+import org.apache.james.lifecycle.LifecycleUtil;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPath;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.protocols.api.LineHandler;
+import org.apache.james.protocols.smtp.SMTPResponse;
+import org.apache.james.protocols.smtp.SMTPRetCode;
+import org.apache.james.protocols.smtp.SMTPSession;
+import org.apache.james.protocols.smtp.core.DataLineFilter;
+import org.apache.james.protocols.smtp.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.SMTPConstants;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+
+/**
+ * Handler which takes care of deliver the mail to the recipients INBOX
+ * 
+ *
+ */
+public class DataLineLMTPMessageHookHandler implements DataLineFilter {
+    private MailServer mailServer;
+    private MailboxManager mailboxManager;
+    
+   /**
+    * Sets the mail server.
+    * @param mailServer the mailServer to
+    */
+   @Resource(name="James")
+   public final void setMailServer(MailServer mailServer) {
+       this.mailServer = mailServer;
+   }
+   
+   @Resource(name="mailboxmanager")
+   public final void setMailboxManager(MailboxManager mailboxManager) {
+       this.mailboxManager = mailboxManager;
+   }
+   
+    @SuppressWarnings("unchecked")
+    public void onLine(SMTPSession session, byte[] line, LineHandler<SMTPSession> next) {
+        MimeMessageInputStreamSource mmiss = (MimeMessageInputStreamSource) session.getState().get(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE);
+
+        try {
+            OutputStream out = mmiss.getWritableOutputStream();
+
+            // 46 is "."
+            // Stream terminated
+            if (line.length == 3 && line[0] == 46) {
+                out.flush();
+                out.close();
+                
+                List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
+                MailImpl mail =
+                    new MailImpl(mailServer.getId(),
+                                 (MailAddress) session.getState().get(SMTPSession.SENDER),
+                                 recipientCollection);
+                
+                // store mail in the session so we can be sure it get disposed later
+                session.getState().put(SMTPConstants.MAIL, mail);
+                
+                MimeMessageCopyOnWriteProxy mimeMessageCopyOnWriteProxy = null;
+                try {
+                    mimeMessageCopyOnWriteProxy = new MimeMessageCopyOnWriteProxy(mmiss);
+                    mail.setMessage(mimeMessageCopyOnWriteProxy);
+                    
+                    deliverMail(session, mail);
+                    
+                    session.popLineHandler();
+                           
+                    // do the clean up
+                    session.resetState();
+                    
+                } catch (MessagingException e) {
+                    // TODO probably return a temporary problem
+                    session.getLogger().info("Unexpected error handling DATA stream",e);
+                    session.writeResponse(new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unexpected error handling DATA stream."));
+                } finally {
+                    LifecycleUtil.dispose(mimeMessageCopyOnWriteProxy);
+                    LifecycleUtil.dispose(mmiss);
+                    LifecycleUtil.dispose(mail);
+                }
+    
+                
+            // DotStuffing.
+            } else if (line[0] == 46 && line[1] == 46) {
+                out.write(line,1,line.length-1);
+            // Standard write
+            } else {
+                // TODO: maybe we should handle the Header/Body recognition here
+                // and if needed let a filter to cache the headers to apply some
+                // transformation before writing them to output.
+                out.write(line);
+            }
+            out.flush();
+        } catch (IOException e) {
+            LifecycleUtil.dispose(mmiss);
+
+            SMTPResponse response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,DSNStatus.getStatus(DSNStatus.TRANSIENT,
+                            DSNStatus.UNDEFINED_STATUS) + " Error processing message: " + e.getMessage());
+            
+            session.getLogger().error(
+                    "Unknown error occurred while processing DATA.", e);
+            session.writeResponse(response);
+            return;
+        }  
+    }
+
+    /**
+     * Deliver mail to mailboxes
+     * 
+     * @param session
+     * @param mail
+     */
+    @SuppressWarnings("unchecked")
+    protected void deliverMail(SMTPSession session, Mail mail) {
+        Iterator<MailAddress> recipients = mail.getRecipients().iterator();
+        while (recipients.hasNext()) {
+            MailAddress recipient = recipients.next();
+            String username;
+            if (mailServer.supportVirtualHosting()) {
+                username = recipient.toString();
+            } else {
+                username = recipient.getLocalPart();
+            }
+
+            SMTPResponse response;
+            
+            try {
+                
+                MailboxSession mailboxSession = mailboxManager.createSystemSession(username, session.getLogger());
+                MailboxPath inbox = MailboxPath.inbox(username);
+                
+                mailboxManager.startProcessingRequest(mailboxSession);
+                
+                // create inbox if not exist
+                if (mailboxManager.mailboxExists(inbox, mailboxSession) == false) {
+                    mailboxManager.createMailbox(inbox, mailboxSession);
+                }
+                mailboxManager.getMailbox(MailboxPath.inbox(username), mailboxSession).appendMessage(new MimeMessageInputStream(mail.getMessage()), new Date(), mailboxSession, true, null);
+                mailboxManager.endProcessingRequest(mailboxSession);
+                response = new SMTPResponse(SMTPRetCode.MAIL_OK, DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.CONTENT_OTHER)+" Message received");
+            } catch (IOException e) {
+                session.getLogger().info("Unexpected error handling DATA stream",e);
+
+                response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,DSNStatus.getStatus(DSNStatus.TRANSIENT,
+                        DSNStatus.UNDEFINED_STATUS) + " Temporary error deliver message to " + recipient);
+            
+            } catch (MessagingException e) {
+                session.getLogger().info("Unexpected error handling DATA stream",e);
+
+                response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,DSNStatus.getStatus(DSNStatus.TRANSIENT,
+                        DSNStatus.UNDEFINED_STATUS) + " Temporary error deliver message to " + recipient);
+            } 
+            session.writeResponse(response);
+        }
+        
+        
+    }
+   
+
+}

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloCmdHandler.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloCmdHandler.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloCmdHandler.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.lmtpserver;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.james.protocols.smtp.core.esmtp.EhloCmdHandler;
+
+/**
+ * Handles the LHLO command 
+ *
+ */
+public class LhloCmdHandler extends EhloCmdHandler{
+
+    @Override
+    public Collection<String> getImplCommands() {
+        return Arrays.asList("LHLO");
+    }
+    
+
+}

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloWelcomeMessageHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloWelcomeMessageHandler.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloWelcomeMessageHandler.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/LhloWelcomeMessageHandler.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.lmtpserver;
+
+import org.apache.james.Constants;
+import org.apache.james.protocols.smtp.core.WelcomeMessageHandler;
+
+/**
+ * Greeting for LMTP Server
+ * 
+ *
+ */
+public class LhloWelcomeMessageHandler extends WelcomeMessageHandler{
+
+    private final static String SOFTWARE_TYPE = "JAMES LMTP Server "
+                                                 + Constants.SOFTWARE_VERSION;
+
+    @Override
+    protected String getProductName() {
+        return SOFTWARE_TYPE;
+    }
+
+}

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java?rev=995745&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/NioLMTPServer.java Fri Sep 10 10:51:11 2010
@@ -0,0 +1,202 @@
+/****************************************************************
+ * 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.lmtpserver.netty;
+
+import javax.annotation.Resource;
+import javax.net.ssl.SSLContext;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.protocols.api.ProtocolHandlerChain;
+import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
+import org.apache.james.protocols.smtp.SMTPConfiguration;
+import org.apache.james.services.MailServer;
+import org.apache.james.smtpserver.netty.SMTPChannelUpstreamHandler;
+import org.apache.james.smtpserver.netty.SMTPResponseEncoder;
+import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelUpstreamHandler;
+import org.jboss.netty.channel.group.ChannelGroup;
+import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+
+public class NioLMTPServer extends AbstractConfigurableAsyncServer{
+
+    /**
+     * The maximum message size allowed by this SMTP server.  The default
+     * value, 0, means no limit.
+     */
+    private long maxMessageSize = 0;
+    private MailServer mailServer;
+    private ProtocolHandlerChain handlerChain;
+    private LMTPConfiguration lmtpConfig = new LMTPConfiguration();
+    private String lmtpGreeting;
+    
+
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
+
+    public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
+        this.handlerChain = handlerChain;
+    }
+
+    
+    @Override
+    protected int getDefaultPort() {
+        return 24;
+    }
+
+    @Override
+    protected String getServiceType() {
+        return "LMTP";
+    }
+
+    
+    public void doConfigure(final HierarchicalConfiguration configuration) throws ConfigurationException {
+        if (isEnabled()) {
+            HierarchicalConfiguration handlerConfiguration = configuration.configurationAt("handler");
+           
+
+            // get the message size limit from the conf file and multiply
+            // by 1024, to put it in bytes
+            maxMessageSize = handlerConfiguration.getLong( "maxmessagesize",maxMessageSize ) * 1024;
+            if (maxMessageSize > 0) {
+                getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes.");
+            } else {
+                getLogger().info("No maximum message size is enforced for this server.");
+            }
+            
+            // get the lmtpGreeting
+            lmtpGreeting = handlerConfiguration.getString("lmtpGreeting",null);
+
+
+        }
+    }
+    
+    @Override
+    protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
+        return new LMTPChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group);
+    }
+
+    /**
+     * A class to provide SMTP handler configuration to the handlers
+     */
+    public class LMTPConfiguration implements SMTPConfiguration {
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
+         */
+        public String getHelloName() {
+            if (NioLMTPServer.this.getHelloName() == null) {
+                return NioLMTPServer.this.mailServer.getHelloName();
+            } else {
+                return NioLMTPServer.this.getHelloName();
+            }
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getResetLength()
+         */
+        public int getResetLength() {
+            return -1;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getMaxMessageSize()
+         */
+        public long getMaxMessageSize() {
+            return NioLMTPServer.this.maxMessageSize;
+        }
+
+        /**
+         * Relaying not allowed with LMTP
+         */
+        public boolean isRelayingAllowed(String remoteIP) {
+            return false;
+        }
+
+        /**
+         * No enforcement
+         */
+        public boolean useHeloEhloEnforcement() {
+            return false;
+        }
+
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#getSMTPGreeting()
+         */
+        public String getSMTPGreeting() {
+            return NioLMTPServer.this.lmtpGreeting;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#useAddressBracketsEnforcement()
+         */
+        public boolean useAddressBracketsEnforcement() {
+            return true;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isAuthRequired(java.lang.String)
+         */
+        public boolean isAuthRequired(String remoteIP) {
+            return true;
+        }
+
+        /**
+         * @see org.apache.james.protocols.smtp.SMTPConfiguration#isStartTLSSupported()
+         */
+        public boolean isStartTLSSupported() {
+            return false;
+        }
+    }
+    
+    private final class LMTPChannelPipelineFactory extends AbstractSSLAwareChannelPipelineFactory {
+
+        public LMTPChannelPipelineFactory(int timeout, int maxConnections,
+                int maxConnectsPerIp, ChannelGroup group) {
+            super(timeout, maxConnections, maxConnectsPerIp, group);
+        }
+
+        @Override
+        protected SSLContext getSSLContext() {
+            return null;
+        }
+
+        @Override
+        protected boolean isSSLSocket() {
+            return  false;
+        }
+
+        @Override
+        protected OneToOneEncoder createEncoder() {
+            return new SMTPResponseEncoder();
+        }
+
+        @Override
+        protected ChannelUpstreamHandler createHandler() {
+            return new SMTPChannelUpstreamHandler(handlerChain, lmtpConfig, getLogger(), getSSLContext());
+        }
+        
+    }
+
+}

Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Fri Sep 10 10:51:11 2010
@@ -44,6 +44,7 @@
     <module>core-function</module>
     <module>imapserver</module>
     <module>smtpserver</module>
+    <module>lmtpserver</module>
     <module>pop3server</module>
     <module>spoolmanager</module>
     <module>remotemanager</module>
@@ -410,7 +411,13 @@
       <artifactId>james-server-user-function</artifactId>
       <version>${pom.version}</version>
     </dependency>
-  
+
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-lmtpserver</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+      
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-smtpserver</artifactId>

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java Fri Sep 10 10:51:11 2010
@@ -83,8 +83,9 @@ public class SMTPChannelUpstreamHandler 
             ctx.getChannel().write(new SMTPResponse(SMTPRetCode.SYNTAX_ERROR_COMMAND_UNRECOGNIZED, "Line length exceeded. See RFC 2821 #4.5.3.1."));
         } else {
             if (channel.isConnected()) {
-                ctx.getChannel().write(new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unable to process smtp request"));
+                ctx.getChannel().write(new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unable to process request"));
             }
+            logger.debug("Unable to process request", e.getCause());
             cleanup(channel);
             channel.close();
         }

Modified: james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/MailboxManagerPoster.java Fri Sep 10 10:51:11 2010
@@ -19,24 +19,21 @@
 
 package org.apache.james;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Date;
-import java.util.Enumeration;
 
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.logging.Log;
-import org.apache.james.mailbox.MailboxPath;
-import org.apache.james.mailbox.MessageManager;
+import org.apache.james.core.MimeMessageInputStream;
+import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.mailbox.MailboxConstants;
 import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPath;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.lifecycle.LogEnabled;
+import org.apache.james.mailbox.MessageManager;
 import org.apache.james.services.MailServer;
 import org.apache.jsieve.mailet.Poster;
 
@@ -161,78 +158,5 @@ public class MailboxManagerPoster implem
         this.logger = log;
     }
 
-    /**
-     * {@link InputStream} which contains the headers and the Body of the
-     * wrapped {@link MimeMessage}
-     * 
-     */
-    private final class MimeMessageInputStream extends InputStream {
-        private final InputStream headersInputStream;
-        private final InputStream bodyInputStream;
-        private int cStream = 0;
-
-        boolean nextCR = false;
-        boolean nextLF = false;
-
-        @SuppressWarnings("unchecked")
-        public MimeMessageInputStream(MimeMessage message) throws IOException {
-            try {
-                ByteArrayOutputStream headersOut = new ByteArrayOutputStream();
-                Enumeration headers = message.getAllHeaderLines();
-                while (headers.hasMoreElements()) {
-                    headersOut.write(headers.nextElement().toString().getBytes("US-ASCII"));
-                    headersOut.write("\r\n".getBytes());
-                }
-                headersInputStream = new ByteArrayInputStream(headersOut.toByteArray());
-                
-                // use the raw InputStream because we want to have no conversion here and just obtain the original message body
-                this.bodyInputStream = message.getRawInputStream();
-            } catch (MessagingException e) {
-                throw new IOException("Unable to read MimeMessage: " + e.getMessage());
-            }
-        }
 
-        @Override
-        public int read() throws IOException {
-            if (nextCR) {
-                nextCR = false;
-                nextLF = true;
-                return '\r';
-            } else if (nextLF) {
-                nextLF = false;
-                return '\n';
-            } else {
-                int i = -1;
-                if (cStream == 0) {
-                    i = headersInputStream.read();
-                } else {
-                    i = bodyInputStream.read();
-                }
-
-                if (i == -1 && cStream == 0) {
-                    cStream++;
-                    nextCR = true;
-                    return read();
-                }
-                return i;
-            }
-
-        }
-
-        /** Closes all streams */
-        public void close() throws IOException {
-            headersInputStream.close();
-            bodyInputStream.close();
-        }
-
-        /** Is there more data to read */
-        public int available() throws IOException {
-            if (cStream == 0) {
-                return headersInputStream.available() + bodyInputStream.available() + 2;
-            } else {
-                return bodyInputStream.available();
-            }
-        }
-
-    }
 }

Modified: james/server/trunk/spring-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/pom.xml?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/pom.xml (original)
+++ james/server/trunk/spring-deployment/pom.xml Fri Sep 10 10:51:11 2010
@@ -460,6 +460,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-lmtpserver</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-function</artifactId>
     </dependency>
     <dependency>

Added: james/server/trunk/spring-deployment/src/main/config/james/lmtpserver.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/lmtpserver.xml?rev=995745&view=auto
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/lmtpserver.xml (added)
+++ james/server/trunk/spring-deployment/src/main/config/james/lmtpserver.xml Fri Sep 10 10:51:11 2010
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+  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.                                           
+ -->
+<!-- The LMTP server is disabled by default -->
+<!-- Disabling blocks will stop them from listening, -->
+<!-- but does not free as many resources as removing them would -->
+<lmtpserver enabled="false">
+    <port>24</port>
+
+    <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+    <bind>127.0.0.1</bind>
+    
+    <connectionBacklog>200</connectionBacklog>
+      
+    <handler>
+        <!-- This is the name used by the server to identify itself in the LMTP -->
+        <!-- protocol.  If autodetect is TRUE, the server will discover its -->
+        <!-- own host name and use that in the protocol.  If discovery fails, -->
+        <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
+        <!-- will use the specified value. -->
+        <!--
+        <helloName autodetect="true">myMailServer</helloName>
+        -->
+        <!-- connection timeout in secconds -->
+        <connectiontimeout>1200</connectiontimeout>
+      
+        <!-- Set the maximum simultaneous incoming connections for this service -->
+        <connectionLimit> 0 </connectionLimit>
+         
+        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+        <connectionLimitPerIP> 0 </connectionLimitPerIP>
+         
+        <!--  This sets the maximum allowed message size (in kilobytes) for this -->
+        <!--  LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+        <maxmessagesize>0</maxmessagesize>
+         
+                 
+         <!-- This sets the LMTPGreeting which will be used when connect to the lmtpserver -->
+         <!-- If none is specified a default is generated -->
+         <!--
+         <smtpGreeting> JAMES LMTP Server </smtpGreeting>
+         -->
+         
+        <handlerchain>
+            <!-- This loads the core CommandHandlers. Only remove this if you really -->
+            <!-- know what you are doing -->
+            <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </handler>
+</lmtpserver>
\ No newline at end of file

Modified: james/server/trunk/spring-deployment/src/main/config/james/log4j.properties
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/log4j.properties?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/log4j.properties (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/log4j.properties Fri Sep 10 10:51:11 2010
@@ -82,6 +82,12 @@ log4j.appender.SMTPSERVER.DatePattern='.
 log4j.appender.SMTPSERVER.layout=org.apache.log4j.PatternLayout
 log4j.appender.SMTPSERVER.layout.ConversionPattern=%-5p %d{HH:mm:ss,SSS} | %c | %m%n
 
+log4j.appender.LMTPSERVER=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.LMTPSERVER.File=../log/lmtpserver.log
+log4j.appender.LMTPSERVER.DatePattern='.'yyyy-MM-dd
+log4j.appender.LMTPSERVER.layout=org.apache.log4j.PatternLayout
+log4j.appender.LMTPSERVER.layout.ConversionPattern=%-5p %d{HH:mm:ss,SSS} | %c | %m%n
+
 log4j.appender.NNTPSERVER=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.NNTPSERVER.File=../log/nntpserver.log
 log4j.appender.NNTPSERVER.DatePattern='.'yyyy-MM-dd
@@ -151,6 +157,7 @@ log4j.logger.james.dnsserver=INFO, DNSSE
 log4j.logger.james.remotemanager=INFO, REMOTEMANAGER
 log4j.logger.james.pop3server=INFO, POP3SERVER
 log4j.logger.james.smtpserver=INFO, SMTPSERVER
+log4j.logger.james.lmtpserver=INFO, LMTPSERVER
 log4j.logger.james.nntpserver=INFO, NNTPSERVER
 log4j.logger.james.nntp-repository=INFO, NNTP-REPOSITORY
 log4j.logger.james.mailstore=INFO, MAILSTORE

Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=995745&r1=995744&r2=995745&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Fri Sep 10 10:51:11 2010
@@ -74,6 +74,7 @@
             <map>
                 <entry key="mailboxmanager" value="imapserver" />
                 <entry key="mailetcontext" value="James"/>
+                <entry key="lmtpProtocolHandlerChain" value="lmtpserver"/>
                 <entry key="smtpProtocolHandlerChain" value="smtpserver"/>
                 <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
                 <entry key="remoteProtocolHandlerChain" value="remotemanager"/>
@@ -95,6 +96,7 @@
     <bean id="logRegistry" class="org.apache.james.container.spring.lifecycle.SpringLogRegistry">
         <property name="logMappings">
             <map>
+                <entry key="lmtpProtocolHandlerChain" value="lmtpserver"/>
                 <entry key="smtpProtocolHandlerChain" value="smtpserver"/>
                 <entry key="pop3ProtocolHandlerChain" value="pop3server"/>
                 <entry key="remoteProtocolHandlerChain" value="remoteManager"/>
@@ -220,6 +222,17 @@
         <property name="coreHandlersPackage" value="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
     </bean>
 
+    <!-- Async LMTP Server -->
+    <bean id="lmtpserver" class="org.apache.james.lmtpserver.NioLMTPServer">
+        <property name="protocolHandlerChain" ref="lmtpProtocolHandlerChain"/>
+    </bean>
+
+    <bean id="lmtpProtocolHandlerChain" class="org.apache.james.container.spring.SpringProtocolHandlerChain">
+        <property name="logRegistry" ref="logRegistry"/>
+        <property name="configurationRegistry" ref="configurationRegistry"/>
+        <property name="coreHandlersPackage" value="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+    </bean>
+    
     <!-- FetchMail Service -->
     <bean id="fetchmail" class="org.apache.james.fetchmail.FetchScheduler" />
 



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