Package org.apache.directory.api.asn1.ber

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


     * Test the decoding of a ETYPE-INFO
     */
    @Test
    public void testETypeInfo()
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x20 );

        stream.put( new byte[]
            {
                0x30, 0x1E,
                0x30, 0x0D,
                ( byte ) 0xA0, 0x03, // etype
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x06, // salt
                0x04,
                0x04,
                0x31,
                0x32,
                0x33,
                0x34,
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03, // etype
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x06, // salt
                0x04,
                0x04,
                0x35,
                0x36,
                0x37,
                0x38
        } );

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

        // Allocate a ETypeInfo Container
        Asn1Container etypeInfoContainer = new ETypeInfoContainer();
        etypeInfoContainer.setStream( stream );

        // Decode the ETypeInfo PDU
        try
        {
            kerberosDecoder.decode( stream, etypeInfoContainer );
        }
        catch ( DecoderException de )
        {
            fail( de.getMessage() );
        }
View Full Code Here


     * Test the decoding of a ETypeInfo with nothing in it
     */
    @Test(expected = DecoderException.class)
    public void testETypeInfoEmpty() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x02 );

        stream.put( new byte[]
            { 0x30, 0x00 } );

        stream.flip();

        // Allocate a ETypeInfo Container
        Asn1Container etypeInfoContainer = new ETypeInfoContainer();

        // Decode the ETypeInfo PDU
        kerberosDecoder.decode( stream, etypeInfoContainer );
        fail();
    }
View Full Code Here

     * Test the decoding of a ETypeInfo with empty ETypeInfoEntry in it
     */
    @Test(expected = DecoderException.class)
    public void testETypeInfoNoETypeInfoEntry() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x04 );

        stream.put( new byte[]
            {
                0x30, 0x02,
                ( byte ) 0x30, 0x00 // empty ETypeInfoEntry
        } );

        stream.flip();

        // Allocate a ETypeInfo Container
        Asn1Container etypeInfoContainer = new ETypeInfoContainer();

        // Decode the ETypeInfo PDU
        kerberosDecoder.decode( stream, etypeInfoContainer );
        fail();
    }
View Full Code Here

public class KrbErrorDecoderTest
{
    @Test
    public void testDecodeKrbError()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x8F;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x81, ( byte ) 0x8C,
                0x30, ( byte ) 0x81, ( byte ) 0x89,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                ( byte ) 0xA2,
                0x11, // ctime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA3,
                0x03, // cusec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA7,
                0x08, // crealm
                0x1B,
                0x06,
                'c',
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xA8,
                0x12, // cname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                'c',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here


    @Test
    public void testDecodeKrbErrorWithoutCtime()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x7A;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x78,
                0x30, ( byte ) 0x76,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                //
                // NO ctime
                //
                ( byte ) 0xA3,
                0x03, // cusec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA7,
                0x08, // crealm
                0x1B,
                0x06,
                'c',
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xA8,
                0x12, // cname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                'c',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here


    @Test
    public void testDecodeKrbErrorWithoutCusec()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x8A;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x81, ( byte ) 0x87,
                0x30, ( byte ) 0x81, ( byte ) 0x84,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                ( byte ) 0xA2,
                0x11, // ctime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                // NO cuses
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA7,
                0x08, // crealm
                0x1B,
                0x06,
                'c',
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xA8,
                0x12, // cname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                'c',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here


    @Test
    public void testDecodeKrbErrorWithoutCtimeAndCusec()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x75;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x73,
                0x30, ( byte ) 0x71,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                //
                // NO ctime, cusec
                //
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA7,
                0x08, // crealm
                0x1B,
                0x06,
                'c',
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xA8,
                0x12, // cname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                'c',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here

        stream.flip();
       
        // Allocate a EncryptedData Container
        Asn1Container encryptedDataContainer = new EncryptedDataContainer();

        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        // Decode the EncryptedData PDU
        try
        {
            kerberosDecoder.decode( stream, encryptedDataContainer );
        }
        catch ( DecoderException de )
        {
            throw new KerberosException( ErrorType.KRB_AP_ERR_BAD_INTEGRITY, de );
        }
View Full Code Here


    @Test
    public void testDecodeKrbErrorWithoutCrealm()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x84;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x81, ( byte ) 0x81,
                0x30, ( byte ) 0x7F,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                ( byte ) 0xA2,
                0x11, // ctime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA3,
                0x03, // cusec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                // NO crealm
                ( byte ) 0xA8,
                0x12, // cname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                'c',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here


    @Test
    public void testDecodeKrbErrorWithoutCname()
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x79;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7E, ( byte ) 0x77,
                0x30, ( byte ) 0x75,
                ( byte ) 0xA0, 0x03, // pvno
                0x02,
                0x01,
                0x05,
                ( byte ) 0xA1,
                0x03, // msg-type
                0x02,
                0x01,
                0x1E,
                ( byte ) 0xA2,
                0x11, // ctime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA3,
                0x03, // cusec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0x11, // stime
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA5,
                0x03, // susec
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA6,
                0x03, // error-code
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA7,
                0x08, // crealm
                0x1B,
                0x06,
                'c',
                'r',
                'e',
                'a',
                'l',
                'm',
                // NO cname
                ( byte ) 0xA9,
                0x07, // realm
                0x1B,
                0x05,
                'r',
                'e',
                'a',
                'l',
                'm',
                ( byte ) 0xAA,
                0x12, // sname
                0x30,
                0x10,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x00,
                ( byte ) 0xA1,
                0x09,
                0x30,
                0x07,
                0x1B,
                0x05,
                's',
                'n',
                'a',
                'm',
                'e',
                ( byte ) 0xAB,
                0x07, // e-text
                0x1B,
                0x5,
                'e',
                't',
                'e',
                'x',
                't',
                ( byte ) 0xAC,
                0x04, // e-data
                0x04,
                0x02,
                0x00,
                0x01
        } );

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

        KrbErrorContainer container = new KrbErrorContainer( stream );

        try
        {
            decoder.decode( stream, container );
        }
        catch ( DecoderException e )
        {
            fail();
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.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.