Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 20412 invoked from network); 6 Dec 2008 01:38:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2008 01:38:56 -0000 Received: (qmail 59876 invoked by uid 500); 6 Dec 2008 01:39:09 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 59846 invoked by uid 500); 6 Dec 2008 01:39:08 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 59836 invoked by uid 99); 6 Dec 2008 01:39:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 17:39:08 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Dec 2008 01:37:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EF41B238889D; Fri, 5 Dec 2008 17:38:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081206013805.EF41B238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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