Package org.apache.directory.api.asn1.util

Examples of org.apache.directory.api.asn1.util.BitString


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

        ByteBuffer stream = ByteBuffer.allocate( 0x06 );

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

        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 a wrong type
     */
    @Test(expected = DecoderException.class)
    public void testPrincipalNameBadType() throws DecoderException
    {
        Asn1Decoder kerberosDecoder = new Asn1Decoder();

        ByteBuffer stream = ByteBuffer.allocate( 0x0B );

        stream.put( new byte[]
            { 0x30, 0x09,
                ( byte ) 0xA0, 0x03, // name-type
                0x02,
                0x01,
                0x7F, // 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 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

    /**
     * {@inheritDoc}
     */
    public void action( KrbCredContainer krbCredContainer ) throws DecoderException
    {
        TLV tlv = krbCredContainer.getCurrentTLV();

        // The Length should not be null
        if ( tlv.getLength() == 0 )
        {
            LOG.error( I18n.err( I18n.ERR_04066 ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( KrbCredContainer krbCredContainer ) throws DecoderException
    {
        TLV tlv = krbCredContainer.getCurrentTLV();

        // The Length should not be null
        if ( tlv.getLength() == 0 )
        {
            LOG.error( I18n.err( I18n.ERR_04066 ) );

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

        // decoder for Ticket
        Asn1Decoder decoder = new Asn1Decoder();

        // Ticket container
        TicketContainer ticketContainer = new TicketContainer( krbCredContainer.getStream() );

        krbCredContainer.rewind();

        try
        {
            // decode Ticket
            decoder.decode( krbCredContainer.getStream(), ticketContainer );
        }
        catch ( DecoderException e )
        {
            throw e;
        }

        Ticket ticket = ticketContainer.getTicket();
        // add Ticket to the list of tickets
        krbCredContainer.getKrbCred().addTicket( ticket );

        // Update the expected length for the current TLV
        tlv.setExpectedLength( tlv.getExpectedLength() - tlv.getLength() );

        // Update the parent
        krbCredContainer.updateParent();

        if ( IS_DEBUG )
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( KdcReqBodyContainer kdcReqBodyContainer ) throws DecoderException
    {
        TLV tlv = kdcReqBodyContainer.getCurrentTLV();

        // The Length can be null, in this case, we can potentially exit from this grammar
        if ( tlv.getLength() == 0 )
        {
            kdcReqBodyContainer.setGrammarEndAllowed( true );
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( TicketContainer ticketContainer ) throws DecoderException
    {
        TLV tlv = ticketContainer.getCurrentTLV();

        // The Length should not be null
        if ( tlv.getLength() == 0 )
        {
            LOG.error( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
View Full Code Here

   
    @Test
    public void testEncodeBitString()
    {
        BitString bs = new BitString( 10 );
        bs.setBit( 9 );
       
        ByteBuffer buffer = ByteBuffer.allocate( 5 );
       
        try
        {
View Full Code Here

     */
    @Test
    public void testBitStringNull()
    {

        BitString bitString = new BitString( 1 );

        bitString.setData( null );

        try
        {
            bitString.getBit( 0 );
            fail( "Should not reach this point ..." );
        }
        catch ( IndexOutOfBoundsException ioobe )
        {
            assertTrue( true );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.asn1.util.BitString

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.