Package org.apache.directory.shared.asn1.ber.tlv

Examples of org.apache.directory.shared.asn1.ber.tlv.TLV


    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
    {
        TLV tlv = container.getCurrentTLV();

        Message response = container.getMessage();
        LdapResult ldapResult = ( (ResultResponse) response ).getLdapResult();
        Referral referral = ldapResult.getReferral();

        if ( tlv.getLength() == 0 )
        {
            referral.addLdapUrl( "" );
        }
        else
        {
            if ( ldapResult.getResultCode() == ResultCodeEnum.REFERRAL )
            {
                try
                {
                    referral.addLdapUrl( new LdapURL( tlv.getValue().getData() ).toString() );
                }
                catch ( LdapURLEncodingException luee )
                {
                    String badUrl = Strings.utf8ToString(tlv.getValue().getData());
                    LOG.error( I18n.err( I18n.ERR_04015, badUrl, luee.getMessage() ) );
                    throw new DecoderException( I18n.err( I18n.ERR_04016, luee.getMessage() ) );
                }
            }
            else
View Full Code Here


     */
    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
    {
        SearchRequestDecorator decorator = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the value.
        SubstringFilter substringFilter = ( SubstringFilter ) decorator.getTerminalFilter();

        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04019 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }

        String any = Strings.utf8ToString(tlv.getValue().getData());
        substringFilter.addAnySubstrings( any );

        // We now have to get back to the nearest filter which is
        // not terminal.
        decorator.unstackFilters( container );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
    {
        TLV tlv = container.getCurrentTLV();

        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04009 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
View Full Code Here

    public void unstackFilters( Asn1Container container )
    {
        LdapMessageContainer<MessageDecorator<Message>> ldapMessageContainer =
            ( LdapMessageContainer<MessageDecorator<Message>> ) container;

        TLV tlv = ldapMessageContainer.getCurrentTLV();
        TLV localParent = tlv.getParent();
        Filter localFilter = terminalFilter;

        // The parent has been completed, so fold it
        while ( ( localParent != null ) && ( localParent.getExpectedLength() == 0 ) )
        {
            int parentTlvId = localFilter.getParent() != null ? localFilter.getParent().getTlvId() : localFilter
                .getParentTlvId();

            if ( localParent.getId() != parentTlvId )
            {
                localParent = localParent.getParent();
            }
            else
            {
                Filter filterParent = localFilter.getParent();

                // We have a special case with PresentFilter, which has not been
                // pushed on the stack, so we need to get its parent's parent
                if ( localFilter instanceof PresentFilter )
                {
                    if ( filterParent == null )
                    {
                        // We don't have parent, get out
                        break;
                    }

                    filterParent = filterParent.getParent();
                }
                else if ( filterParent instanceof Filter )
                {
                    filterParent = filterParent.getParent();
                }

                if ( filterParent instanceof Filter )
                {
                    // The parent is a filter ; it will become the new currentFilter
                    // and we will loop again.
                    currentFilter = ( Filter ) filterParent;
                    localFilter = currentFilter;
                    localParent = localParent.getParent();
                }
                else
                {
                    // We can stop the recursion, we have reached the searchResult Object
                    break;
View Full Code Here

     */
    public void action( LdapMessageContainer<SearchResultEntryDecorator> container )
    {
        SearchResultEntryDecorator searchResultEntry = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        // Store the value
        Object value = null;

        if ( tlv.getLength() == 0 )
        {
            searchResultEntry.addAttributeValue( "" );

            LOG.debug( "The attribute value is null" );
        }
        else
        {
            if ( container.isBinary( searchResultEntry.getCurrentAttribute().getId() ) )
            {
                value = tlv.getValue().getData();

                if ( IS_DEBUG )
                {
                    LOG.debug( "Attribute value {}", Strings.dumpBytes((byte[]) value) );
                }
            }
            else
            {
                value = Strings.utf8ToString(tlv.getValue().getData());

                LOG.debug( "Attribute value {}", value );
            }

            searchResultEntry.addAttributeValue( value );
View Full Code Here

    {
        // We can allocate the ExtendedResponse Object
        ExtendedResponse extendedResponse = container.getMessage();

        // Get the Value and store it in the ExtendedResponse
        TLV tlv = container.getCurrentTLV();

        // We have to handle the special case of a 0 length matched
        // OID
        if ( tlv.getLength() == 0 )
        {
            extendedResponse.setResponseValue( StringConstants.EMPTY_BYTES );
        }
        else
        {
            extendedResponse.setResponseValue( tlv.getValue().getData() );
        }

        // We can have an END transition
        container.setGrammarEndAllowed( true );
View Full Code Here

    {
        // We can allocate the ExtendedResponse Object
        ExtendedResponse extendedResponse = container.getMessage();

        // Get the Value and store it in the ExtendedResponse
        TLV tlv = container.getCurrentTLV();

        // We have to handle the special case of a 0 length matched
        // OID
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04017 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
        else
        {
            extendedResponse.setResponseName( new OID( Strings.asciiBytesToString(tlv.getValue().getData()) )
                .toString() );
        }

        // We can have an END transition
        container.setGrammarEndAllowed( true );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
    {
        TLV tlv = container.getCurrentTLV();

        // If we hae a Referrals sequence, then it should not be empty
        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04011 );
            LOG.error( msg );

            // This will generate a PROTOCOL_ERROR
View Full Code Here

     */
    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
    {
        SearchRequestDecorator searchRequest = container.getMessage();

        TLV tlv = container.getCurrentTLV();

        if ( tlv.getLength() == 0 )
        {
            String msg = I18n.err( I18n.ERR_04022 );
            LOG.error( msg );
            throw new DecoderException( msg );
        }
        else
        {
            // Store the value.
            ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest.getTerminalFilter();

            String type = Strings.utf8ToString(tlv.getValue().getData());
            extensibleMatchFilter.setType( type );

            if ( IS_DEBUG )
            {
                LOG.debug( "Stored a type matching rule : {}", type );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
    {
        TLV tlv = container.getCurrentTLV();

        MessageDecorator<?> message = container.getMessage();
        CodecControl<? extends Control> control = message.getCurrentControl();

        // Get the current control
        Value value = tlv.getValue();

        // Store the value - have to handle the special case of a 0 length value
        if ( tlv.getLength() == 0 )
        {
            control.setValue( StringConstants.EMPTY_BYTES );
        }
        else
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.asn1.ber.tlv.TLV

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.