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

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


     * Test the decoding of a PrincipalName with an empty name
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameEmptyName() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x09 );

        stream.put( new byte[]
            { 0x30, 0x07,
                ( byte ) 0xA0, 0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x00 // name-string
        } );

        stream.flip();

        // Allocate a PrincipalName Container
        Asn1Container principalNameContainer = new PrincipalNameContainer();

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


     * Test the decoding of a PrincipalName with no name
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameNoName() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x0B );

        stream.put( new byte[]
            { 0x30, 0x09,
                ( byte ) 0xA0, 0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x02, // name-string
                0x30,
                0x00
        } );

        stream.flip();

        // Allocate a PrincipalName Container
        Asn1Container principalNameContainer = new PrincipalNameContainer();

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

     * Test the decoding of a PrincipalName
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameBadName() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x0D );

        stream.put( new byte[]
            { 0x30, 0x0B,
                ( byte ) 0xA0, 0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x04, // name-string
                0x30,
                0x02,
                0x1B,
                0x00
        } );

        stream.flip();

        // Allocate a PrincipalName Container
        Asn1Container principalNameContainer = new PrincipalNameContainer();

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

     * Test the decoding of a PrincipalName
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameBadName2() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x29 );

        stream.put( new byte[]
            { 0x30, 0x27,
                ( byte ) 0xA0, 0x03, // name-type
                0x02,
                0x01,
                0x01, // NT-PRINCIPAL
                ( byte ) 0xA1,
                0x20, // name-string
                0x30,
                0x1E,
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                'l',
                's',
                'o',
                'n',
                '1',
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                '\r',
                's',
                'o',
                'n',
                '2',
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                'l',
                's',
                'o',
                'n',
                '3',
        } );

        stream.flip();

        // Allocate a PrincipalName Container
        Asn1Container principalNameContainer = new PrincipalNameContainer();

        // Decode the PrincipalName PDU
        kerberosDecoder.decode( stream, principalNameContainer );
    }
View Full Code Here

     * Test the decoding of a PrincipalName with no name-type
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameNoNameType() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x24 );

        stream.put( new byte[]
            { 0x30, 0x22,
                ( byte ) 0xA1, 0x20, // name-string
                0x30,
                0x1E,
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                'l',
                's',
                'o',
                'n',
                '1',
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                '\r',
                's',
                'o',
                'n',
                '2',
                0x1B,
                0x08,
                'h',
                'n',
                'e',
                'l',
                's',
                'o',
                'n',
                '3',
        } );

        stream.flip();

        // Allocate a PrincipalName Container
        Asn1Container principalNameContainer = new PrincipalNameContainer();

        // Decode the PrincipalName PDU
        kerberosDecoder.decode( stream, principalNameContainer );
    }
View Full Code Here

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

        // Now, let's decode the KDC-REQ
        Asn1Decoder kdcReqDecoder = new Asn1Decoder();

        KdcReqContainer kdcReqContainer = new KdcReqContainer( tgsReqContainer.getStream() );

        // Store the created TGS-REQ object into the KDC-REQ container
        TgsReq tgsReq = new TgsReq();
        kdcReqContainer.setKdcReq( tgsReq );

        // Decode the KDC_REQ PDU
        try
        {
            kdcReqDecoder.decode( tgsReqContainer.getStream(), kdcReqContainer );
        }
        catch ( DecoderException de )
        {
            throw de;
        }
View Full Code Here

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

        // Now, let's decode the EncKdcRepPart
        Asn1Decoder encKdcRepPartDecoder = new Asn1Decoder();

        EncKdcRepPartContainer encKdcRepPartContainer = new EncKdcRepPartContainer( encAsRepPartContainer.getStream() );

        // Decode the EncKdcRepPart PDU
        try
        {
            encKdcRepPartDecoder.decode( encAsRepPartContainer.getStream(), encKdcRepPartContainer );
        }
        catch ( DecoderException de )
        {
            throw de;
        }
View Full Code Here

     * Test the decoding of a full TransitedEncoding
     */
    @Test
    public void testTransitedEncoding()
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();
        int len = 0x11;

        ByteBuffer stream = ByteBuffer.allocate( len );

        stream.put( new byte[]
            { 0x30, 0x0F,
                ( byte ) 0xA0, 0x03, // tr-type
                0x02,
                0x01,
                0x01, //
                ( byte ) 0xA1,
                0x08, // contents
                0x04,
                0x06,
                'a',
                'b',
                'c',
                'd',
                'e',
                'f'
        } );

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

        // Allocate a TransitedEncoding Container
        Asn1Container transitedEncodingContainer = new TransitedEncodingContainer();

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

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

        ByteBuffer stream = ByteBuffer.allocate( 0x02 );

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

        stream.flip();

        // Allocate a TransitedEncoding Container
        Asn1Container transitedEncodingContainer = new TransitedEncodingContainer();

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

     * Test the decoding of a TransitedEncoding with an empty tr-type tag
     */
    @Test(expected = DecoderException.class)
    public void testTransitedEncodingEmptyTrTypeTag() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x04 );

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

        stream.flip();

        // Allocate a TransitedEncoding Container
        Asn1Container transitedEncodingContainer = new TransitedEncodingContainer();

        // Decode the TransitedEncoding PDU
        kerberosDecoder.decode( stream, transitedEncodingContainer );
        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.