directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r441709 - /directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java
Date Sat, 09 Sep 2006 00:57:06 GMT
Author: elecharny
Date: Fri Sep  8 17:57:05 2006
New Revision: 441709

URL: http://svn.apache.org/viewvc?view=rev&rev=441709
Log:
Added the control encoding

Modified:
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java

Modified: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java?view=diff&rev=441709&r1=441708&r2=441709
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java
(original)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/asn1ber/messages/ControlAsn1Ber.java
Fri Sep  8 17:57:05 2006
@@ -19,11 +19,14 @@
  */
 package org.apache.directory.shared.ldap.codec.asn1ber.messages;
 
+import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
 import javax.naming.ldap.Control;
 
+import org.apache.directory.shared.asn1.ber.ConstructedUniversalTags;
 import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.ber.tlv.ValueException;
 import org.apache.directory.shared.ldap.codec.Decoder;
 import org.apache.directory.shared.ldap.codec.Encoder;
@@ -120,6 +123,34 @@
     
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException, ValueException
     {
+        try
+        {
+            // The LdapMessage Sequence
+            buffer.put( ConstructedUniversalTags.SEQUENCE_SEQUENCE_OF.getValue() );
+
+            // The length has been calculated by the computeLength method
+            buffer.put( Length.getBytes( controlLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( "The PDU buffer size is too small !" );
+        }
+
+        // The control type
+        Value.encode( buffer, idBytes );
+
+        // The control criticality, if true
+        if ( isCritical() )
+        {
+            Value.encode( buffer, true );
+        }
+
+        // The control value, if any
+        if ( getControlValue() != null )
+        {
+            Value.encode( buffer, getControlValue() );
+        }
+
         return buffer;
     }
 }



Mime
View raw message