Package org.apache.directory.shared.asn1.ber

Examples of org.apache.directory.shared.asn1.ber.Asn1Decoder


     * (&(&(a=b))(&(c=d)))
     */
    @Test
    public void testDecodeSearchRequestAnd_AndEq_AndEq()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x33 );
        stream.put( new byte[]
            { 0x30, 0x31, // LDAPMessage ::=SEQUENCE {
                0x02,
                0x01,
                0x01, // messageID MessageID
                0x63,
                0x2C, // CHOICE { ...,
                // searchRequest SearchRequest, ...
                // SearchRequest ::= APPLICATION[3] SEQUENCE {
                0x04,
                0x03, // baseObject LDAPDN,
                'a',
                '=',
                'b',
                0x0A,
                0x01,
                0x01, // scope ENUMERATED {
                //      baseObject (0),
                //      singleLevel (1),
                //      wholeSubtree (2) },
                0x0A,
                0x01,
                0x03, // derefAliases ENUMERATED {
                //      neverDerefAliases (0),
                //      derefInSearching (1),
                //      derefFindingBaseObj (2),
                //      derefAlways (3) },
                0x02,
                0x01,
                0x00, // sizeLimit INTEGER (0 .. maxInt), (0)
                0x02,
                0x01,
                0x00, // timeLimit INTEGER (0 .. maxInt), (1000)
                0x01,
                0x01,
                ( byte ) 0xFF,// typesOnly BOOLEAN, (TRUE)
                // filter Filter,
                ( byte ) 0xA0,
                0x14, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA0,
                0x08, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA3,
                0x06,//      equalityMatch [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'a', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'b', //      assertionValue AssertionValue (OCTET STRING) }
                ( byte ) 0xA0,
                0x08, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA3,
                0x06,//      equalityMatch [3] Assertion,
                //      equalityMatch [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'c', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'd', //      assertionValue AssertionValue (OCTET STRING) }
                0x30,
                0x00 // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
        } );

        String decodedPdu = Strings.dumpBytes( stream.array() );
        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here


     * (&(&(a=b)(c=d))(&(e=f)))
     */
    @Test
    public void testDecodeSearchRequestAnd_AndEqEq_AndEq()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x3B );
        stream.put( new byte[]
            { 0x30, 0x39, // LDAPMessage ::=SEQUENCE {
                0x02,
                0x01,
                0x01, // messageID MessageID
                0x63,
                0x34, // CHOICE { ...,
                // searchRequest SearchRequest, ...
                // SearchRequest ::= APPLICATION[3] SEQUENCE {
                0x04,
                0x03, // baseObject LDAPDN,
                'a',
                '=',
                'b',
                0x0A,
                0x01,
                0x01, // scope ENUMERATED {
                //      baseObject (0),
                //      singleLevel (1),
                //      wholeSubtree (2) },
                0x0A,
                0x01,
                0x03, // derefAliases ENUMERATED {
                //      neverDerefAliases (0),
                //      derefInSearching (1),
                //      derefFindingBaseObj (2),
                //      derefAlways (3) },
                0x02,
                0x01,
                0x00, // sizeLimit INTEGER (0 .. maxInt), (0)
                0x02,
                0x01,
                0x00, // timeLimit INTEGER (0 .. maxInt), (1000)
                0x01,
                0x01,
                ( byte ) 0xFF,// typesOnly BOOLEAN, (TRUE)
                // filter Filter,
                ( byte ) 0xA0,
                0x1C, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA0,
                0x10, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA3,
                0x06,//      equalityMatch [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'a', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'b', //      assertionValue AssertionValue (OCTET STRING) }
                ( byte ) 0xA3,
                0x06,//      equalityMatch [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'c', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'd', //      assertionValue AssertionValue (OCTET STRING) }
                ( byte ) 0xA0,
                0x08, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA3,
                0x06,//      equalityMatch [3] Assertion,
                //      equalityMatch [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'e', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'f', //      assertionValue AssertionValue (OCTET STRING) }
                0x30,
                0x00 // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
        } );

        String decodedPdu = Strings.dumpBytes( stream.array() );
        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * (&(|(abcdef=*)(ghijkl=*))(!(e>=f)))
     */
    @Test
    public void testDecodeSearchRequestAnd_OrPrPr_NotGEq()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x3B );
        stream.put( new byte[]
            { 0x30, 0x39, // LDAPMessage ::=SEQUENCE {
                0x02,
                0x01,
                0x01, // messageID MessageID
                0x63,
                0x34, // CHOICE { ...,
                // searchRequest SearchRequest, ...
                // SearchRequest ::= APPLICATION[3] SEQUENCE {
                0x04,
                0x03, // baseObject LDAPDN,
                'a',
                '=',
                'b',
                0x0A,
                0x01,
                0x01, // scope ENUMERATED {
                //      baseObject (0),
                //      singleLevel (1),
                //      wholeSubtree (2) },
                0x0A,
                0x01,
                0x03, // derefAliases ENUMERATED {
                //      neverDerefAliases (0),
                //      derefInSearching (1),
                //      derefFindingBaseObj (2),
                //      derefAlways (3) },
                0x02,
                0x01,
                0x00, // sizeLimit INTEGER (0 .. maxInt), (0)
                0x02,
                0x01,
                0x00, // timeLimit INTEGER (0 .. maxInt), (1000)
                0x01,
                0x01,
                ( byte ) 0xFF,// typesOnly BOOLEAN, (TRUE)
                // filter Filter,
                ( byte ) 0xA0,
                0x1C, // Filter ::= CHOICE { and             [0] SET OF Filter,
                ( byte ) 0xA1,
                0x10, // Filter ::= CHOICE { or             [0] SET OF Filter,
                ( byte ) 0x87,
                0x06,// present [7] AttributeDescription,
                'a',
                'b',
                'c', // AttributeDescription ::= LDAPString
                'd',
                'e',
                'f',
                ( byte ) 0x87,
                0x06,// present [7] AttributeDescription,
                'g',
                'h',
                'i', // AttributeDescription ::= LDAPString
                'j',
                'k',
                'l',
                ( byte ) 0xA2,
                0x08, // Filter ::= CHOICE { not             Filter,
                ( byte ) 0xA5,
                0x06,//      greaterOrEqual [3] Assertion,
                // Assertion ::= SEQUENCE {
                0x04,
                0x01,
                'e', //      attributeDesc AttributeDescription (LDAPString),
                0x04,
                0x01,
                'f', //      assertionValue AssertionValue (OCTET STRING) }
                0x30,
                0x00 // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
        } );

        String decodedPdu = Strings.dumpBytes( stream.array() );
        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * for rootDSE
     */
    @Test
    public void testDecodeSearchRequestRootDse()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x33 );
        stream.put( new byte[]
            { 0x30, ( byte ) 0x84, 0x00, 0x00, 0x00, 0x2D, 0x02, 0x01, 0x01, 0x63, ( byte ) 0x84, 0x00, 0x00, 0x00,
                0x24, 0x04, 0x00, 0x0A, 0x01, 0x00, 0x0A, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01,
                0x00, ( byte ) 0x87, 0x0B, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x30,
                ( byte ) 0x84, 0x00, 0x00, 0x00, 0x00 } );

        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * for rootDSE
     */
    @Test
    public void testDecodeSearchRequestDIRSERVER_810()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x6B );
        stream.put( new byte[]
            { 0x30, ( byte ) 0x84, 0x00, 0x00, 0x00, 0x65, 0x02, 0x01, 0x03, 0x63, ( byte ) 0x84, 0x00, 0x00, 0x00,
                0x5c, 0x04, 0x12, 0x6f, 0x75, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2c, 0x6f, 0x75, 0x3d, 0x73, 0x79,
                0x73,
                0x74,
                0x65,
                0x6d, // 'ou=users,ou=system'
                0x0a,
                0x01,
                0x01,
                0x0a,
                0x01,
                0x00,
                0x02,
                0x01,
                0x00,
                0x02,
                0x01,
                0x1e,
                0x01,
                0x01,
                ( byte ) 0xff,
                ( byte ) 0xa0,
                ( byte ) 0x84,
                0x00,
                0x00,
                0x00,
                0x2d,
                ( byte ) 0xa3,
                ( byte ) 0x84,
                0x00,
                0x00,
                0x00,
                0x0e,
                0x04,
                0x03,
                0x75,
                0x69,
                0x64,
                0x04,
                0x07,
                0x62,
                0x75,
                0x73,
                0x74,
                0x65,
                0x72,
                0x20, // 'buster ' (with a space at the end)
                ( byte ) 0xa3,
                ( byte ) 0x84,
                0x00,
                0x00,
                0x00,
                0x13,
                0x04,
                0x0b,
                0x73,
                0x62,
                0x41,
                0x74,
                0x74,
                0x72,
                0x69,
                0x62,
                0x75,
                0x74,
                0x65, // sbAttribute
                0x04,
                0x04,
                0x42,
                0x75,
                0x79,
                0x20, // 'Buy ' (with a space at the end)
                0x30,
                ( byte ) 0x84,
                0x00,
                0x00,
                0x00,
                0x00 } );

        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * (&(objectClass=person)(|(cn=Tori*)(sn=Jagger)))
     */
    @Test
    public void testDecodeSearchRequestComplexFilterWithControl()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x77 );
        stream.put( new byte[]
            { 0x30,
                0x75, // LdapMessage
                0x02,
                0x01,
                0x06, // message Id = 6
                0x63,
                0x53, // SearchRequest
                0x04,
                0x09, // BasDN 'ou=system'
                0x6F,
                0x75,
                0x3D,
                0x73,
                0x79,
                0x73,
                0x74,
                0x65,
                0x6D,
                0x0A,
                0x01,
                0x02, // scope = SUBTREE
                0x0A,
                0x01,
                0x03, // derefAlias = 3
                0x02,
                0x01,
                0x00, // sizeLimit = none
                0x02,
                0x01,
                0x00, // timeLimit = none
                0x01,
                0x01,
                0x00, // types only = false
                ( byte ) 0xA0,
                0x35, // AND
                ( byte ) 0xA3,
                0x15, // equals
                0x04,
                0x0B, // 'objectclass'
                0x6F,
                0x62,
                0x6A,
                0x65,
                0x63,
                0x74,
                0x43,
                0x6C,
                0x61,
                0x73,
                0x73,
                0x04,
                0x06, // 'person'
                0x70,
                0x65,
                0x72,
                0x73,
                0x6F,
                0x6E,
                ( byte ) 0xA1,
                0x1C, // OR
                ( byte ) 0xA4,
                0x0C, // substrings : 'cn=Tori*'
                0x04,
                0x02, // 'cn'
                0x63,
                0x6E,
                0x30,
                0x06, // initial = 'Tori'
                ( byte ) 0x80,
                0x04,
                0x54,
                0x6F,
                0x72,
                0x69,
                ( byte ) 0xA3,
                0x0C, // equals
                0x04,
                0x02, // 'sn'
                0x73,
                0x6E,
                0x04,
                0x06, // 'Jagger'
                0x4A,
                0x61,
                0x67,
                0x67,
                0x65,
                0x72,
                0x30,
                0x00, // Control
                ( byte ) 0xA0,
                0x1B,
                0x30,
                0x19,
                0x04,
                0x17,
                '2',
                '.',
                '1',
                '6',
                '.',
                '8',
                '4',
                '0',
                '.',
                '1',
                '.',
                '1',
                '1',
                '3',
                '7',
                '3',
                '0',
                '.',
                '3',
                '.',
                '4',
                '.',
                '2' } );

        stream.flip();

        // Allocate a BindRequest Container
        LdapMessageContainer<SearchRequestDecorator> ldapMessageContainer =
            new LdapMessageContainer<SearchRequestDecorator>( codec );

        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * Test the decoding of a bad name
     */
    @Test
    public void testDecodeExtendedBadRequestName()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x16 );

        stream.put( new byte[]
            { 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
                0x02, 0x01, 0x01, // messageID MessageID
                // CHOICE { ..., intermediateResponse IntermediateResponse, ...
                0x79, 0x0F, // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
                // responseName [0] LDAPOID,
                ( byte ) 0x80, 0x0D, '1', '-', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', } );

        stream.flip();

        // Allocate a LdapMessage Container
        LdapMessageContainer<IntermediateResponseDecorator> ldapMessageContainer =
            new LdapMessageContainer<IntermediateResponseDecorator>( codec );

        // Decode a IntermediateResponse PDU
        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
            fail( "We should never reach this point !!!" );
        }
        catch ( DecoderException de )
        {
            assertTrue( true );
View Full Code Here

     * Test the decoding of a name only IntermediateResponse
     */
    @Test
    public void testDecodeIntermediateResponseName()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x16 );

        stream.put( new byte[]
            { 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
                0x02, 0x01, 0x01, // messageID MessageID
                // CHOICE { ..., intermediateResponse IntermediateResponse, ...
                0x79, 0x0F, // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
                // responseName [0] LDAPOID,
                ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', } );

        String decodedPdu = Strings.dumpBytes(stream.array());
        stream.flip();

        // Allocate a LdapMessage Container
        LdapMessageContainer<IntermediateResponseDecorator> ldapMessageContainer =
            new LdapMessageContainer<IntermediateResponseDecorator>( codec );

        // Decode the IntermediateResponse PDU
        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * Test the decoding of an empty value IntermediateResponse
     */
    @Test
    public void testDecodeIntermediateResponseEmptyValue()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x18 );

        stream.put( new byte[]
            { 0x30,
                0x16, // LDAPMessage ::= SEQUENCE {
                0x02, 0x01,
                0x01, // messageID MessageID
                // CHOICE { ..., intermediateResponse IntermediateResponse, ...
                0x79,
                0x11, // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
                // responseName [0] LDAPOID,
                ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0x81,
                0x00 } );

        String decodedPdu = Strings.dumpBytes(stream.array());
        stream.flip();

        // Allocate a LdapMessage Container
        LdapMessageContainer<IntermediateResponseDecorator> ldapMessageContainer =
            new LdapMessageContainer<IntermediateResponseDecorator>( codec );

        // Decode the IntermediateResponse PDU
        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

     * Test the decoding of an IntermediateResponse without name
     */
    @Test
    public void testDecodeIntermediateResponseNoName()
    {
        Asn1Decoder ldapDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x0E );

        stream.put( new byte[]
            { 0x30, 0x0C, // LDAPMessage ::= SEQUENCE {
                0x02, 0x01, 0x01, // messageID MessageID
                // CHOICE { ..., intermediateResponse IntermediateResponse, ...
                0x79, 0x07, // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
                // responseValue [1] OCTET STRING OPTIONAL,
                ( byte ) 0x81, 0x05, 'v', 'a', 'l', 'u', 'e' } );

        String decodedPdu = Strings.dumpBytes(stream.array());
        stream.flip();

        // Allocate a LdapMessage Container
        LdapMessageContainer<IntermediateResponseDecorator> ldapMessageContainer =
            new LdapMessageContainer<IntermediateResponseDecorator>( codec );

        // Decode the IntermediateResponse PDU
        try
        {
            ldapDecoder.decode( stream, ldapMessageContainer );
        }
        catch ( DecoderException de )
        {
            de.printStackTrace();
            fail( de.getMessage() );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.asn1.ber.Asn1Decoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.