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 2011/12/20 11:44:35 UTC

svn commit: r1221192 - in /james/protocols/trunk: lmtp/src/main/java/org/apache/james/protocols/lmtp/ smtp/ smtp/src/main/java/org/apache/james/protocols/smtp/core/

Author: norman
Date: Tue Dec 20 10:44:35 2011
New Revision: 1221192

URL: http://svn.apache.org/viewvc?rev=1221192&view=rev
Log:
Use the right delivery type in received headers when using LMTP. See PROTOCOLS-59

Added:
    james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPReceivedDataLineFilter.java
Modified:
    james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPProtocolHandlerChain.java
    james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/WelcomeMessageHandler.java
    james/protocols/trunk/smtp/pom.xml
    james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
    james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java

Modified: james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPProtocolHandlerChain.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPProtocolHandlerChain.java?rev=1221192&r1=1221191&r2=1221192&view=diff
==============================================================================
--- james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPProtocolHandlerChain.java (original)
+++ james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPProtocolHandlerChain.java Tue Dec 20 10:44:35 2011
@@ -31,7 +31,6 @@ import org.apache.james.protocols.smtp.c
 import org.apache.james.protocols.smtp.core.NoopCmdHandler;
 import org.apache.james.protocols.smtp.core.QuitCmdHandler;
 import org.apache.james.protocols.smtp.core.RcptCmdHandler;
-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;
@@ -69,7 +68,7 @@ public class LMTPProtocolHandlerChain ex
         defaultHandlers.add(new DataCmdHandler());
         defaultHandlers.add(new MailSizeEsmtpExtension());
         defaultHandlers.add(new WelcomeMessageHandler());
-        defaultHandlers.add(new ReceivedDataLineFilter());
+        defaultHandlers.add(new LMTPReceivedDataLineFilter());
         defaultHandlers.add(new LMTPDataLineMessageHookHandler());
         defaultHandlers.add(new StartTlsCmdHandler());
         return defaultHandlers;

Added: james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPReceivedDataLineFilter.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPReceivedDataLineFilter.java?rev=1221192&view=auto
==============================================================================
--- james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPReceivedDataLineFilter.java (added)
+++ james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/LMTPReceivedDataLineFilter.java Tue Dec 20 10:44:35 2011
@@ -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.protocols.lmtp;
+
+import org.apache.james.protocols.smtp.SMTPSession;
+import org.apache.james.protocols.smtp.core.ReceivedDataLineFilter;
+
+public class LMTPReceivedDataLineFilter extends ReceivedDataLineFilter {
+
+    /**
+     * Always returns <code>LMTP</code>
+     */
+    @Override
+    protected String getServiceType(SMTPSession session, String heloMode) {
+        return "LMTP";
+    }
+
+    @Override
+    protected String getProductName() {
+        return WelcomeMessageHandler.SOFTWARE_TYPE;
+    }
+
+}

Modified: james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/WelcomeMessageHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/WelcomeMessageHandler.java?rev=1221192&r1=1221191&r2=1221192&view=diff
==============================================================================
--- james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/WelcomeMessageHandler.java (original)
+++ james/protocols/trunk/lmtp/src/main/java/org/apache/james/protocols/lmtp/WelcomeMessageHandler.java Tue Dec 20 10:44:35 2011
@@ -25,7 +25,7 @@ package org.apache.james.protocols.lmtp;
  */
 public class WelcomeMessageHandler extends org.apache.james.protocols.smtp.core.WelcomeMessageHandler {
 
-    private final static String SOFTWARE_TYPE = "JAMES Protocols LMTP Server"; // +
+    public final static String SOFTWARE_TYPE = "JAMES Protocols LMTP Server"; 
 
     @Override
     protected String getProductName() {

Modified: james/protocols/trunk/smtp/pom.xml
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/pom.xml?rev=1221192&r1=1221191&r2=1221192&view=diff
==============================================================================
--- james/protocols/trunk/smtp/pom.xml (original)
+++ james/protocols/trunk/smtp/pom.xml Tue Dec 20 10:44:35 2011
@@ -120,7 +120,7 @@
                                             <exclude>org/apache/commons/codec/*</exclude>
                                         </excludes>
                                         <includes>
-                                            <include>org/apache/commons/codec/binary/Base64*</include>
+                                            <include>org/apache/commons/codec/binary/Base64.*</include>
                                         </includes>
                                     </filter>
                                 </filters>

Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java?rev=1221192&r1=1221191&r2=1221192&view=diff
==============================================================================
--- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java (original)
+++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java Tue Dec 20 10:44:35 2011
@@ -35,8 +35,6 @@ public class ReceivedDataLineFilter impl
 
     private final static String CHARSET = "US-ASCII";
     
-    private final static String SOFTWARE_TYPE = "JAMES SMTP Server ";
-
     private static final ThreadLocal<DateFormat> DATEFORMAT = new ThreadLocal<DateFormat>() {
 
         @Override
@@ -90,27 +88,9 @@ public class ReceivedDataLineFilter impl
             }
             headerLineBuffer.delete(0, headerLineBuffer.length());
 
-            headerLineBuffer.append("          by ").append(session.getHelloName()).append(" (").append(SOFTWARE_TYPE).append(") with ");
-
-            // Check if EHLO was used
-            if ("EHLO".equals(heloMode)) {
-                // Not successful auth
-                if (session.getUser() == null) {
-                    headerLineBuffer.append("ESMTP");
-                } else {
-                    // See RFC3848
-                    // The new keyword "ESMTPA" indicates the use of ESMTP when
-                    // the
-                    // SMTP
-                    // AUTH [3] extension is also used and authentication is
-                    // successfully
-                    // achieved.
-                    headerLineBuffer.append("ESMTPA");
-                }
-            } else {
-                headerLineBuffer.append("SMTP");
-            }
+            headerLineBuffer.append("          by ").append(session.getHelloName()).append(" (").append(getProductName()).append(") with ").append(getServiceType(session, heloMode));
 
+           
             headerLineBuffer.append(" ID ").append(session.getSessionID());
 
             if (((Collection<?>) session.getState().get(SMTPSession.RCPT_LIST)).size() == 1) {
@@ -148,4 +128,41 @@ public class ReceivedDataLineFilter impl
             throw new RuntimeException("No US-ASCII support ?");
         }
     }
+    
+    /**
+     * Return the product name to use in the headers
+     * 
+     * @return name
+     */
+    protected String getProductName() {
+        return WelcomeMessageHandler.SOFTWARE_TYPE;
+    }
+    
+    /**
+     * Return the service type which will be used in the Received headers
+     * 
+     * @param session
+     * @param heloMode
+     * @return type
+     */
+    protected String getServiceType(SMTPSession session, String heloMode) {
+     // Check if EHLO was used
+        if ("EHLO".equals(heloMode)) {
+            // Not successful auth
+            if (session.getUser() == null) {
+                return "ESMTP";
+            } else {
+                // See RFC3848
+                // The new keyword "ESMTPA" indicates the use of ESMTP when
+                // the
+                // SMTP
+                // AUTH [3] extension is also used and authentication is
+                // successfully
+                // achieved.
+                return "ESMTPA";
+            }
+        } else {
+            return "SMTP";
+        }
+    }
 }

Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java?rev=1221192&r1=1221191&r2=1221192&view=diff
==============================================================================
--- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java (original)
+++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java Tue Dec 20 10:44:35 2011
@@ -31,6 +31,8 @@ import org.apache.james.protocols.smtp.S
  */
 public class WelcomeMessageHandler implements ConnectHandler<SMTPSession> {
 
+    public final static String SOFTWARE_TYPE = "JAMES Protocols SMTP Server"; // +
+
 
     /**
      * @see org.apache.james.protocols.api.handler.ConnectHandler#onConnect(org.apache.james.protocols.api.ProtocolSession)
@@ -56,7 +58,7 @@ public class WelcomeMessageHandler imple
     }
     
     protected String getProductName() {
-        return "JAMES SMTP Server";
+        return SOFTWARE_TYPE;
     }
 
 }



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