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

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



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

        ByteBuffer stream = ByteBuffer.allocate( 0x06 );

        stream.put( new byte[]
            {
                0x30, 0x04,
                0x30, 0x02,
                ( byte ) 0xA0, 0x00 // ad-data
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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



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

        ByteBuffer stream = ByteBuffer.allocate( 0x08 );

        stream.put( new byte[]
            {
                0x30, 0x06,
                0x30, 0x04,
                ( byte ) 0xA0, 0x02, // ad-data
                0x02,
                0x00
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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


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

        ByteBuffer stream = ByteBuffer.allocate( 0x09 );

        stream.put( new byte[]
            {
                0x30, 0x07,
                0x30, 0x05,
                ( byte ) 0xA1, 0x03, // ad-data
                0x04,
                0x01,
                'a'
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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


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

        ByteBuffer stream = ByteBuffer.allocate( 0x09 );

        stream.put( new byte[]
            {
                0x30, 0x07,
                0x30, 0x05,
                ( byte ) 0xA0, 0x03, // ad-data
                0x02,
                0x01,
                0x02
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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


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

        ByteBuffer stream = ByteBuffer.allocate( 0xB );

        stream.put( new byte[]
            {
                0x30, 0x09,
                0x30, 0x07,
                ( byte ) 0xA0, 0x03, // ad-type
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x00 // ad-data
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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


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

        ByteBuffer stream = ByteBuffer.allocate( 0xD );

        stream.put( new byte[]
            {
                0x30, 0x0B,
                0x30, 0x09,
                ( byte ) 0xA0, 0x03, // ad-type
                0x02,
                0x01,
                0x02,
                ( byte ) 0xA1,
                0x02, // ad-data
                0x04,
                0x00
        } );

        stream.flip();

        AuthorizationDataContainer authDataContainer = new AuthorizationDataContainer();

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

{

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

        ByteBuffer buf = ByteBuffer.allocate( 0x30 );
        buf.put( new byte[]
            {
                0x30, 0x2E,
                ( byte ) 0xA0, 0x08, // newpasswd
                0x04,
                0x06,
                's',
                'e',
                'c',
                'r',
                'e',
                't',
                ( byte ) 0xA1,
                0x13, // targname
                0x30,
                0x11,
                ( byte ) 0xA0,
                0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x0A, // name-string
                0x30,
                0x08,
                0x1B,
                0x06,
                'k',
                'r',
                'b',
                't',
                'g',
                't',
                ( byte ) 0xA2,
                0x0D,
                0x1B,
                0x0B,
                'E',
                'X',
                'A',
                'M',
                'P',
                'L',
                'E',
                '.',
                'C',
                'O',
                'M'

        } );

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

        ChangePasswdDataContainer container = new ChangePasswdDataContainer( buf );

        decoder.decode( buf, container );

        ChangePasswdData chngPwdData = container.getChngPwdData();

        assertArrayEquals( "secret".getBytes(), chngPwdData.getNewPasswd() );
        assertEquals( "krbtgt", chngPwdData.getTargName().getNameString() );
View Full Code Here


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

        ByteBuffer buf = ByteBuffer.allocate( 0x1B );
        buf.put( new byte[]
            {
                0x30, 0x19,
                ( byte ) 0xA0, 0x08, // newpasswd
                0x04,
                0x06,
                's',
                'e',
                'c',
                'r',
                'e',
                't',
                ( byte ) 0xA2,
                0x0D,
                0x1B,
                0x0B,
                'E',
                'X',
                'A',
                'M',
                'P',
                'L',
                'E',
                '.',
                'C',
                'O',
                'M'

        } );

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

        ChangePasswdDataContainer container = new ChangePasswdDataContainer( buf );

        decoder.decode( buf, container );

        ChangePasswdData chngPwdData = container.getChngPwdData();

        assertArrayEquals( "secret".getBytes(), chngPwdData.getNewPasswd() );
        assertEquals( "EXAMPLE.COM", chngPwdData.getTargRealm() );
View Full Code Here


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

        ByteBuffer buf = ByteBuffer.allocate( 0x21 );
        buf.put( new byte[]
            {
                0x30, 0x1F,
                ( byte ) 0xA0, 0x08, // newpasswd
                0x04,
                0x06,
                's',
                'e',
                'c',
                'r',
                'e',
                't',
                ( byte ) 0xA1,
                0x13, // targname
                0x30,
                0x11,
                ( byte ) 0xA0,
                0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x0A, // name-string
                0x30,
                0x08,
                0x1B,
                0x06,
                'k',
                'r',
                'b',
                't',
                'g',
                't'
        } );

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

        ChangePasswdDataContainer container = new ChangePasswdDataContainer( buf );

        decoder.decode( buf, container );

        ChangePasswdData chngPwdData = container.getChngPwdData();

        assertArrayEquals( "secret".getBytes(), chngPwdData.getNewPasswd() );
        assertEquals( "krbtgt", chngPwdData.getTargName().getNameString() );
View Full Code Here


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

        ByteBuffer buf = ByteBuffer.allocate( 0x0C );
        buf.put( new byte[]
            {
                0x30, 0x0A,
                ( byte ) 0xA0, 0x08, // newpasswd
                0x04,
                0x06,
                's',
                'e',
                'c',
                'r',
                'e',
                't'
        } );

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

        ChangePasswdDataContainer container = new ChangePasswdDataContainer( buf );

        decoder.decode( buf, container );

        ChangePasswdData chngPwdData = container.getChngPwdData();

        assertArrayEquals( "secret".getBytes(), chngPwdData.getNewPasswd() );
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.