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 2009/10/20 10:21:50 UTC

svn commit: r826996 - /james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java

Author: norman
Date: Tue Oct 20 08:21:50 2009
New Revision: 826996

URL: http://svn.apache.org/viewvc?rev=826996&view=rev
Log:
Fix format

Modified:
    james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java

Modified: james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java?rev=826996&r1=826995&r2=826996&view=diff
==============================================================================
--- james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java (original)
+++ james/server/trunk/smtp-protocol-library/src/main/java/org/apache/james/smtpserver/protocol/core/ReceivedDataLineFilter.java Tue Oct 20 08:21:50 2009
@@ -9,107 +9,102 @@
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.RFC822DateFormat;
 
-public class ReceivedDataLineFilter implements DataLineFilter{
+public class ReceivedDataLineFilter implements DataLineFilter {
 
     private final static String SOFTWARE_TYPE = "JAMES SMTP Server ";
-    	
+
     // Replace this with something usefull
-    // + Constants.SOFTWARE_VERSION;  
+    // + Constants.SOFTWARE_VERSION;
 
     /**
      * Static RFC822DateFormat used to generate date headers
      */
     private final static RFC822DateFormat rfc822DateFormat = new RFC822DateFormat();
-	private final static String HEADERS_WRITTEN = "HEADERS_WRITTEN";
-	
-	/**
-	 * @see org.apache.james.smtpserver.protocol.core.DataLineFilter#onLine(org.apache.james.smtpserver.protocol.SMTPSession, byte[], org.apache.james.smtpserver.protocol.LineHandler)
-	 */
-	public void onLine(SMTPSession session, byte[] line, LineHandler next) {
-		if (session.getState().containsKey(HEADERS_WRITTEN) == false) {
-			addNewReceivedMailHeaders(session, next);
-			session.getState().put(HEADERS_WRITTEN, true);
-		} 
-		next.onLine(session, line);
-	}
+    private final static String HEADERS_WRITTEN = "HEADERS_WRITTEN";
+
+    /**
+     * @see org.apache.james.smtpserver.protocol.core.DataLineFilter#onLine(org.apache.james.smtpserver.protocol.SMTPSession,
+     *      byte[], org.apache.james.smtpserver.protocol.LineHandler)
+     */
+    public void onLine(SMTPSession session, byte[] line, LineHandler next) {
+        if (session.getState().containsKey(HEADERS_WRITTEN) == false) {
+            addNewReceivedMailHeaders(session, next);
+            session.getState().put(HEADERS_WRITTEN, true);
+        }
+        next.onLine(session, line);
+    }
 
- 
     private void addNewReceivedMailHeaders(SMTPSession session, LineHandler next) {
         StringBuilder headerLineBuffer = new StringBuilder();
-        
-        String heloMode = (String) session.getConnectionState().get(SMTPSession.CURRENT_HELO_MODE);
-        String heloName = (String) session.getConnectionState().get(SMTPSession.CURRENT_HELO_NAME);
+
+        String heloMode = (String) session.getConnectionState().get(
+                SMTPSession.CURRENT_HELO_MODE);
+        String heloName = (String) session.getConnectionState().get(
+                SMTPSession.CURRENT_HELO_NAME);
 
         // Put our Received header first
-        headerLineBuffer.append(RFC2822Headers.RECEIVED + ": from ")
-                        .append(session.getRemoteHost());
-        
+        headerLineBuffer.append(RFC2822Headers.RECEIVED + ": from ").append(
+                session.getRemoteHost());
+
         if (heloName != null) {
-            headerLineBuffer.append(" (")
-                            .append(heloMode)
-                            .append(" ")
-                            .append(heloName)
-                            .append(") ");
+            headerLineBuffer.append(" (").append(heloMode).append(" ").append(
+                    heloName).append(") ");
         }
-        
-        headerLineBuffer.append(" ([")
-                        .append(session.getRemoteIPAddress())
-                        .append("])")
-        				.append("\r\n");
-        next.onLine(session,headerLineBuffer.toString().getBytes());
+
+        headerLineBuffer.append(" ([").append(session.getRemoteIPAddress())
+                .append("])").append("\r\n");
+        next.onLine(session, headerLineBuffer.toString().getBytes());
         headerLineBuffer.delete(0, headerLineBuffer.length());
-        
-        headerLineBuffer.append("          by ")
-                        .append(session.getHelloName())
-                        .append(" (")
-                        .append(SOFTWARE_TYPE)
-                        .append(") with ");
-     
-        // Check if EHLO was used 
+
+        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");  
+                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
+                // 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(" ID ")
-                        .append(session.getSessionID());
+
+        headerLineBuffer.append(" ID ").append(session.getSessionID());
 
         if (((Collection) session.getState().get(SMTPSession.RCPT_LIST)).size() == 1) {
             // Only indicate a recipient if they're the only recipient
             // (prevents email address harvesting and large headers in
-            //  bulk email)
-        	headerLineBuffer.append("\r\n");
-            next.onLine(session,headerLineBuffer.toString().getBytes());
+            // bulk email)
+            headerLineBuffer.append("\r\n");
+            next.onLine(session, headerLineBuffer.toString().getBytes());
             headerLineBuffer.delete(0, headerLineBuffer.length());
-            
+
             headerLineBuffer.delete(0, headerLineBuffer.length());
-            headerLineBuffer.append("          for <")
-                            .append(((List) session.getState().get(SMTPSession.RCPT_LIST)).get(0).toString())
-                            .append(">;")
-                            .append("\r\n");
-            
-            next.onLine(session,headerLineBuffer.toString().getBytes());
+            headerLineBuffer.append("          for <").append(
+                    ((List) session.getState().get(SMTPSession.RCPT_LIST)).get(
+                            0).toString()).append(">;").append("\r\n");
+
+            next.onLine(session, headerLineBuffer.toString().getBytes());
             headerLineBuffer.delete(0, headerLineBuffer.length());
-            
+
             headerLineBuffer.delete(0, headerLineBuffer.length());
         } else {
             // Put the ; on the end of the 'by' line
             headerLineBuffer.append(";");
             headerLineBuffer.append("\r\n");
-            next.onLine(session,headerLineBuffer.toString().getBytes());
+            next.onLine(session, headerLineBuffer.toString().getBytes());
             headerLineBuffer.delete(0, headerLineBuffer.length());
         }
         headerLineBuffer = null;
-        next.onLine(session,("          " + rfc822DateFormat.format(new Date()) + "\r\n").getBytes());
+        next.onLine(session, ("          "
+                + rfc822DateFormat.format(new Date()) + "\r\n").getBytes());
     }
 }



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