You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/02/06 19:23:51 UTC

svn commit: r907267 - in /james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec: CRLFTerminatedLineDecoder.java JamesProtocolCodecFactory.java LineLengthExceededException.java

Author: norman
Date: Sat Feb  6 18:23:51 2010
New Revision: 907267

URL: http://svn.apache.org/viewvc?rev=907267&view=rev
Log:
Just some javadocs

Modified:
    james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
    james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/JamesProtocolCodecFactory.java
    james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java

Modified: james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java?rev=907267&r1=907266&r2=907267&view=diff
==============================================================================
--- james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java (original)
+++ james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java Sat Feb  6 18:23:51 2010
@@ -26,20 +26,31 @@
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
 /**
- * LineDecoder which buffer the input till a CRLF was found
+ * LineDecoder which buffer the input till a CRLF was found. It will throw an exception if a maxlinelength was 
+ * reached to prevent an DOS attack. The default is 2048 chars (including CRLF).
  *
  */
 public class CRLFTerminatedLineDecoder extends CumulativeProtocolDecoder {
 
     private int maxLineLength;
-
-
+    
+    public static int DEFAULT_MAX_LINE_LENTH = 2048;
+    
+    /**
+     * Construct new instance with a max line length given (chars per line). 
+     * 
+     * @param maxLineLength the maximal chars per line. If the length is exceed it will throw
+     *                      an LineLengthExceededException while decoding   
+     */
     public CRLFTerminatedLineDecoder(int maxLineLength) {
         this.maxLineLength = maxLineLength;
     }
     
+    /**
+     * Construct a new instance with a max line length of 2048 chars
+     */
     public CRLFTerminatedLineDecoder() {
-        this(2048);
+        this(DEFAULT_MAX_LINE_LENTH);
     }
     
     
@@ -62,6 +73,7 @@
             byte current = in.get();
             count++;
             
+            // max line lenth exceed. Throw exception to prevent DOS
             if (maxLineLength != -1 && count > maxLineLength) {
                 throw new LineLengthExceededException(maxLineLength, in.capacity());
             }

Modified: james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/JamesProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/JamesProtocolCodecFactory.java?rev=907267&r1=907266&r2=907267&view=diff
==============================================================================
--- james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/JamesProtocolCodecFactory.java (original)
+++ james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/JamesProtocolCodecFactory.java Sat Feb  6 18:23:51 2010
@@ -28,6 +28,11 @@
 import org.apache.mina.filter.codec.textline.LineDelimiter;
 import org.apache.mina.filter.codec.textline.TextLineEncoder;
 
+/**
+ * ProtocolCodecFactory which holds the standard implementation for James Services
+ * 
+ *
+ */
 public class JamesProtocolCodecFactory  implements ProtocolCodecFactory {
     
     private final ProtocolEncoder encoder = new TextLineEncoder(Charset.forName("US-ASCII"), LineDelimiter.CRLF);

Modified: james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java?rev=907267&r1=907266&r2=907267&view=diff
==============================================================================
--- james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java (original)
+++ james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java Sat Feb  6 18:23:51 2010
@@ -23,7 +23,7 @@
 import java.io.IOException;
 
 /**
- * Exception get thrown if the max line lenth was exceed
+ * Exception get thrown if the max line length was exceed (chars pers line)
  * 
  *
  */



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