directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r544715 - /directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java
Date Wed, 06 Jun 2007 03:16:59 GMT
Author: erodriguez
Date: Tue Jun  5 20:16:58 2007
New Revision: 544715

URL: http://svn.apache.org/viewvc?view=rev&rev=544715
Log:
Improved handling of large Kerberos requests when using TCP.

Modified:
    directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java?view=diff&rev=544715&r1=544714&r2=544715
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java
(original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java
Tue Jun  5 20:16:58 2007
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.server.kerberos.shared.io.decoder.KdcRequestDecoder;
+import org.apache.mina.common.BufferDataException;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
@@ -28,6 +29,9 @@
 
 
 /**
+ * A {@link CumulativeProtocolDecoder} which supports Kerberos operation over TCP,
+ * by reassembling split packets prior to ASN.1 DER decoding.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -35,21 +39,51 @@
 {
     private KdcRequestDecoder decoder = new KdcRequestDecoder();
 
+    private int maxObjectSize = 16384; // 16KB
 
-    protected boolean doDecode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out
) throws Exception
+
+    /**
+     * Returns the allowed maximum size of the object to be decoded.
+     * If the size of the object to be decoded exceeds this value, this
+     * decoder will throw a {@link BufferDataException}.  The default
+     * value is <tt>16384</tt> (16KB).
+     * 
+     * @return The max object size.
+     */
+    public int getMaxObjectSize()
+    {
+        return maxObjectSize;
+    }
+
+
+    /**
+     * Sets the allowed maximum size of the object to be decoded.
+     * If the size of the object to be decoded exceeds this value, this
+     * decoder will throw a {@link BufferDataException}.  The default
+     * value is <tt>16384</tt> (16KB).
+     * 
+     * @param maxObjectSize 
+     */
+    public void setMaxObjectSize( int maxObjectSize )
     {
-        if ( in.remaining() < 4 )
+        if ( maxObjectSize <= 0 )
         {
-            return false;
+            throw new IllegalArgumentException( "maxObjectSize: " + maxObjectSize );
         }
 
-        int recordLength = in.getInt();
+        this.maxObjectSize = maxObjectSize;
+    }
+
 
-        if ( in.remaining() < recordLength )
+    @Override
+    protected boolean doDecode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out
) throws Exception
+    {
+        if ( !in.prefixedDataAvailable( 4, maxObjectSize ) )
         {
-            in.rewind();
             return false;
         }
+
+        in.getInt();
 
         out.write( decoder.decode( in.buf() ) );
 



Mime
View raw message