directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r723943 - in /directory/shared/branches/shared-mina2/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/actions/ test/java/org/apache/directory/shared/ldap/codec/bind/
Date Sat, 06 Dec 2008 01:38:05 GMT
Author: elecharny
Date: Fri Dec  5 17:38:05 2008
New Revision: 723943

URL: http://svn.apache.org/viewvc?rev=723943&view=rev
Log:
Fixed shared in order to handle correctly the PagedSearch control :
- the decoder was not handling the control at all
- a test was failing as soon as the previous bug was fixed
- the twixTransformer was not handling this control either.

Modified:
    directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ControlValueAction.java
    directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java

Modified: directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=723943&r1=723942&r2=723943&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Fri Dec  5 17:38:05 2008
@@ -60,6 +60,7 @@
 import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
 import org.apache.directory.shared.ldap.codec.search.controls.PSearchControlCodec;
+import org.apache.directory.shared.ldap.codec.search.controls.PagedSearchControlCodec;
 import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControlCodec;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -105,6 +106,7 @@
 import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.control.AbstractMutableControlImpl;
 import org.apache.directory.shared.ldap.message.control.CascadeControl;
+import org.apache.directory.shared.ldap.message.control.PagedSearchControl;
 import org.apache.directory.shared.ldap.message.control.PersistentSearchControl;
 import org.apache.directory.shared.ldap.message.control.SubentriesControl;
 import org.apache.directory.shared.ldap.message.extended.GracefulShutdownRequest;
@@ -934,6 +936,15 @@
                     neutralSubentriesControl.setVisibility( twixSubentriesControl.isVisible()
);
                     neutralSubentriesControl.setCritical( twixControl.getCriticality() );
                 }
+                else if ( twixControl.getControlValue() instanceof PagedSearchControlCodec
)
+                {
+                    PagedSearchControl neutralPagedSearchControl = new PagedSearchControl();
+                    neutralControl = neutralPagedSearchControl;
+                    PagedSearchControlCodec twixPagedSearchControl = (PagedSearchControlCodec)twixControl.getControlValue();
+                    neutralPagedSearchControl.setCookie( twixPagedSearchControl.getCookie()
);
+                    neutralPagedSearchControl.setSize( twixPagedSearchControl.getSize() );
+                    neutralPagedSearchControl.setCritical( twixControl.getCriticality() );
+                }
                 else if ( twixControl.getControlValue() instanceof byte[] )
                 {
                     neutralControl = new AbstractMutableControlImpl()

Modified: directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ControlValueAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ControlValueAction.java?rev=723943&r1=723942&r2=723943&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ControlValueAction.java
(original)
+++ directory/shared/branches/shared-mina2/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ControlValueAction.java
Fri Dec  5 17:38:05 2008
@@ -34,6 +34,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.controls.ManageDsaITControlDecoder;
 import org.apache.directory.shared.ldap.codec.search.controls.PSearchControlDecoder;
+import org.apache.directory.shared.ldap.codec.search.controls.PagedSearchControlDecoder;
 import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControlDecoder;
 import org.apache.directory.shared.ldap.util.StringTools;
 
@@ -73,6 +74,9 @@
 
         decoder = new SubEntryControlDecoder();
         controlDecoders.put( decoder.getControlType(), decoder );
+
+        decoder = new PagedSearchControlDecoder();
+        controlDecoders.put( decoder.getControlType(), decoder );
     }
 
 

Modified: directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java?rev=723943&r1=723942&r2=723943&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java
(original)
+++ directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindResponseTest.java
Fri Dec  5 17:38:05 2008
@@ -21,6 +21,7 @@
 
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
@@ -32,7 +33,9 @@
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+import org.apache.directory.shared.ldap.codec.search.controls.PagedSearchControlCodec;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.control.PagedSearchControl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import junit.framework.TestCase;
@@ -124,26 +127,32 @@
         ByteBuffer stream = ByteBuffer.allocate( 0x3C );
 
         stream.put( new byte[]
-            { 0x30, 0x3A, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x61, 0x07, // CHOICE { ..., bindResponse BindResponse, ...
-                // BindResponse ::= APPLICATION[1] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04, 0x00, // matchedDN LDAPDN,
-                0x04, 0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // serverSaslCreds [7] OCTET STRING OPTIONAL }
-                ( byte ) 0xa0, 0x2C, // controls
-                0x30, 0x2A, 0x04, 0x16, 0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 0x31,
0x31, 0x33, 0x35, 0x35,
-                0x36, 0x2e, 0x31, 0x2e, 0x34, 0x2e, 0x33, 0x31, 0x39, // control
-                                                                        // oid:
-                                                                        // 1.2.840.113556.1.4.319
-                0x01, 0x01, ( byte ) 0xff, // criticality: false
-                0x04, 0x0D, 0x30, 0x0B, 0x0A, 0x01, 0x08, 0x04, 0x03, 'a', '=', 'b', 0x02,
0x01, 0x10 } );
+            { 
+              0x30, 0x3A,                      // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01, 0x01,              // messageID MessageID
+                0x61, 0x07,                    // CHOICE { ..., bindResponse BindResponse,
...
+                                               // BindResponse ::= APPLICATION[1] SEQUENCE
{
+                                               // COMPONENTS OF LDAPResult,
+                  0x0A, 0x01, 0x00,            // LDAPResult ::= SEQUENCE {
+                                               // resultCode ENUMERATED {
+                                               // success (0), ...
+                                               // },
+                  0x04, 0x00,                  // matchedDN LDAPDN,
+                  0x04, 0x00,                  // errorMessage LDAPString,
+                                               // referral [3] Referral OPTIONAL }
+                                               // serverSaslCreds [7] OCTET STRING OPTIONAL
}
+                  ( byte ) 0xa0, 0x2C,         // controls
+                    0x30, 0x2A,                // The PagedSearchControl
+                      0x04, 0x16,              // Oid : 1.2.840.113556.1.4.319
+                        0x31, 0x2e, 0x32, 0x2e, 0x38, 0x34, 0x30, 0x2e, 
+                        0x31, 0x31, 0x33, 0x35, 0x35, 0x36, 0x2e, 0x31, 
+                        0x2e, 0x34, 0x2e, 0x33, 0x31, 0x39, // control
+                    0x01, 0x01, ( byte ) 0xff, // criticality: false
+                    0x04, 0x0D,
+                      0x30, 0x0B,
+                        0x02, 0x01, 0x05,      // Size = 5, cookie = "abcdef" 
+                        0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f'
+              } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -181,8 +190,12 @@
 
         Control control = message.getControls( 0 );
         assertEquals( "1.2.840.113556.1.4.319", control.getControlType() );
-        assertEquals( "0x30 0x0B 0x0A 0x01 0x08 0x04 0x03 0x61 0x3D 0x62 0x02 0x01 0x10 ",
StringTools
-            .dumpBytes( ( byte[] ) control.getControlValue() ) );
+        assertTrue( control.getControlValue() instanceof PagedSearchControlCodec );
+        
+        PagedSearchControlCodec pagedSearchControl = (PagedSearchControlCodec)control.getControlValue();
+        
+        assertEquals( 5, pagedSearchControl.getSize() );
+        assertTrue( Arrays.equals( "abcdef".getBytes(), pagedSearchControl.getCookie() )
);
 
         // Check the encoding
         try



Mime
View raw message