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

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


            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
        }

        // Now, let's decode the HostAddress
        Asn1Decoder krbSafeBodyDecoder = new Asn1Decoder();

        KrbSafeBodyContainer krbSafeBodyContainer = new KrbSafeBodyContainer();

        // Passes the Stream to the decoder
        krbSafeBodyContainer.setStream( krbSafeContainer.getStream() );

        // Decode the KrbSafeBody PDU
        try
        {
            krbSafeBodyDecoder.decode( krbSafeContainer.getStream(), krbSafeBodyContainer );
        }
        catch ( DecoderException de )
        {
            throw de;
        }
View Full Code Here


public class EncKrbPrivPartDecoderTest
{
    @Test
    public void testDecodeEncKrbPrivPart() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x49;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x47,
                0x30, 0x45,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                ( byte ) 0xA1,
                0x11, // timestamp
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA2,
                0x03, // usec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA3,
                0x03, // seq-number
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
                ( byte ) 0xA5,
                0xF, // r-adress
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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


    @Test
    public void testDecodeEncKrbPrivPartWithoutTimestamp() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x36;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x34,
                0x30, 0x32,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                // NO timestamp
                ( byte ) 0xA2,
                0x03, // usec
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA3,
                0x03, // seq-number
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
                ( byte ) 0xA5,
                0xF, // r-adress
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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


    @Test
    public void testDecodeEncKrbPrivPartWithoutTimestampAndUsec() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x31;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x2F,
                0x30, 0x2D,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                // NO timestamp and usec
                ( byte ) 0xA3,
                0x03, // seq-number
                0x02,
                0x01,
                0x01,
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
                ( byte ) 0xA5,
                0xF, // r-adress
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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


    @Test
    public void testDecodeEncKrbPrivPartWithoutTimestampUsecAndSeqNumber() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x2C;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x2A,
                0x30, 0x28,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                // NO timestamp, usec and seq-number
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
                ( byte ) 0xA5,
                0xF, // r-adress
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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


    @Test
    public void testDecodeEncKrbPrivPartWithoutSequenceNumber() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x44;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x42,
                0x30, 0x40,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                ( byte ) 0xA1,
                0x11, // timestamp
                0x18,
                0xF,
                '2',
                '0',
                '1',
                '0',
                '1',
                '1',
                '1',
                '9',
                '0',
                '8',
                '0',
                '0',
                '4',
                '3',
                'Z',
                ( byte ) 0xA2,
                0x03, // usec
                0x02,
                0x01,
                0x01,
                // NO seq-number
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
                ( byte ) 0xA5,
                0xF, // r-adress
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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


    @Test
    public void testDecodeEncKrbPrivPartWithoutOptionalValues() throws Exception
    {
        Asn1Decoder decoder = new Asn1Decoder();

        int streamLen = 0x1B;
        ByteBuffer stream = ByteBuffer.allocate( streamLen );
        stream.put( new byte[]
            {
                0x7C, 0x19,
                0x30, 0x17,
                ( byte ) 0xA0, 0x4, // user-data
                0x04,
                0x02,
                0x00,
                0x01,
                // NO timestamp, usec and seq-number
                ( byte ) 0xA4,
                0xF, // s-address
                0x30,
                0x0D,
                ( byte ) 0xA0,
                0x03,
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x06,
                0x04,
                0x04,
                127,
                0,
                0,
                1,
            // NO r-address
        } );

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

        EncKrbPrivPartContainer container = new EncKrbPrivPartContainer( stream );

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

{

    @Test
    public void testAuthorizationData()
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x21 );

        stream.put( new byte[]
            {
                0x30, 0x1F,
                0x30, 0x0F,
                ( byte ) 0xA0, 0x03, // ad-type
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x08, // ad-data
                0x04,
                0x06,
                'a',
                'b',
                'c',
                'd',
                'e',
                'f',
                0x30,
                0x0C,
                ( byte ) 0xA0,
                0x03, // ad-type
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x05, // ad-data
                0x04,
                0x03,
                'g',
                'h',
                'i'
        } );

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

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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


    @Test(expected = DecoderException.class)
    public void testAuthorizationDataEmptyPdu() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x02 );

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

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

        kerberosDecoder.decode( stream, authDataContainer );
        fail();
    }
View Full Code Here


    @Test(expected = DecoderException.class)
    public void testAuthorizationDataWithNoInnerData() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x04 );

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

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

        kerberosDecoder.decode( stream, authDataContainer );
        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.