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

Examples of org.apache.directory.api.asn1.ber.tlv.BerValue


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

        BerValue value = tlv.getValue();

        try
        {
            int number = IntegerDecoder.parse( value, minValue, maxValue );

            if ( IS_DEBUG )
            {
                LOG.debug( "read integer value : {}", number );
            }

            setIntegerValue( number, container );
        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n.err( I18n.ERR_04070, Strings.dumpBytes( value.getData() ), ide
                .getLocalizedMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( ide.getMessage(), ide );
        }
View Full Code Here


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

        BerValue value = tlv.getValue();

        // The data should not be null
        if ( ( value.getData() == null ) && ( !canBeNull ) )
        {
            LOG.error( I18n.err( I18n.ERR_04066 ) );

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

        setOctetString( value.getData(), container );
    }
View Full Code Here

            }

            parent = parent.getParent();
        }

        BerValue value = current.getValue();

        if ( ( value != null ) && ( value.getData() != null ) )
        {
            return ( current.getExpectedLength() == value.getData().length );
        }
        else
        {
            return current.getExpectedLength() == 0;
        }
View Full Code Here

        // The current TLV should be a integer
        // We get it and store it in MessageId
        TLV tlv = container.getCurrentTLV();

        BerValue value = tlv.getValue();

        if ( ( value == null ) || ( value.getData() == null ) )
        {
            String msg = I18n.err( I18n.ERR_04075 );
            LOG.error( msg );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( msg );
        }

        try
        {
            int abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );

            abandonRequest.setAbandoned( abandonnedMessageId );

            if ( IS_DEBUG )
            {
                LOG
                    .debug( "AbandonMessage Id has been decoded : {}", Integer
                        .valueOf( abandonnedMessageId ) );
            }

            container.setGrammarEndAllowed( true );

            return;
        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n
                .err( I18n.ERR_04076, Strings.dumpBytes( value.getData() ), ide.getMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( ide.getMessage(), ide );
        }
    }
View Full Code Here

                UniversalTag.INTEGER.getValue(),
                new GrammarAction<PagedResultsContainer>( "Set PagedSearchControl size" )
                {
                    public void action( PagedResultsContainer container ) throws DecoderException
                    {
                        BerValue value = container.getCurrentTLV().getValue();

                        try
                        {
                            // Check that the value is into the allowed interval
                            int size = IntegerDecoder.parse( value, Integer.MIN_VALUE, Integer.MAX_VALUE );

                            // We allow negative value to absorb a bug in some M$ client.
                            // Those negative values will be transformed to Integer.MAX_VALUE.
                            if ( size < 0 )
                            {
                                size = Integer.MAX_VALUE;
                            }

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "size = " + size );
                            }

                            container.getDecorator().setSize( size );
                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04050 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from size to cookie
         * realSearchControlValue ::= SEQUENCE OF {
         *     ...
         *     cookie   OCTET STRING
         * }
         *    
         * Stores the cookie flag
         */
        super.transitions[PagedResultsStates.SIZE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<PagedResultsContainer>( PagedResultsStates.SIZE_STATE,
                PagedResultsStates.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<PagedResultsContainer>( "Set PagedSearchControl cookie" )
                {
                    public void action( PagedResultsContainer container ) throws DecoderException
                    {
                        BerValue value = container.getCurrentTLV().getValue();

                        if ( container.getCurrentTLV().getLength() == 0 )
                        {
                            container.getDecorator().setCookie( StringConstants.EMPTY_BYTES );
                        }
                        else
                        {
                            container.getDecorator().setCookie( value.getData() );
                        }

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

                UniversalTag.INTEGER.getValue(),
                new GrammarAction<PersistentSearchContainer>( "Set PSearchControl changeTypes" )
                {
                    public void action( PersistentSearchContainer container ) throws DecoderException
                    {
                        BerValue value = container.getCurrentTLV().getValue();

                        try
                        {
                            // Check that the value is into the allowed interval
                            int changeTypes = IntegerDecoder.parse( value,
                                PersistentSearch.CHANGE_TYPES_MIN,
                                PersistentSearch.CHANGE_TYPES_MAX );

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "changeTypes = " + changeTypes );
                            }

                            container.getPersistentSearchDecorator().setChangeTypes( changeTypes );
                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04051 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from Change types to Changes only
         * PSearch ::= SEQUENCE OF {
         *     ...
         *     changeOnly   BOOLEAN,
         *     ...
         *    
         * Stores the change only flag
         */
        super.transitions[PersistentSearchStates.CHANGE_TYPES_STATE.ordinal()][UniversalTag.BOOLEAN.getValue()] =
            new GrammarTransition<PersistentSearchContainer>( PersistentSearchStates.CHANGE_TYPES_STATE,
                PersistentSearchStates.CHANGES_ONLY_STATE, UniversalTag.BOOLEAN.getValue(),
                new GrammarAction<PersistentSearchContainer>( "Set PSearchControl changesOnly" )
                {
                    public void action( PersistentSearchContainer container ) throws DecoderException
                    {
                        BerValue value = container.getCurrentTLV().getValue();

                        try
                        {
                            boolean changesOnly = BooleanDecoder.parse( value );

                            if ( IS_DEBUG )
                            {
                                LOG.debug( "changesOnly = " + changesOnly );
                            }

                            container.getPersistentSearchDecorator().setChangesOnly( changesOnly );
                        }
                        catch ( BooleanDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04052 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from Change types to Changes only
         * PSearch ::= SEQUENCE OF {
         *     ...
         *     returnECs    BOOLEAN
         * }
         *    
         * Stores the return ECs flag
         */
        super.transitions[PersistentSearchStates.CHANGES_ONLY_STATE.ordinal()][UniversalTag.BOOLEAN.getValue()] =
            new GrammarTransition<PersistentSearchContainer>( PersistentSearchStates.CHANGES_ONLY_STATE,
                PersistentSearchStates.RETURN_ECS_STATE, UniversalTag.BOOLEAN.getValue(),
                new GrammarAction<PersistentSearchContainer>( "Set PSearchControl returnECs" )
                {
                    public void action( PersistentSearchContainer container ) throws DecoderException
                    {
                        BerValue value = container.getCurrentTLV().getValue();

                        try
                        {
                            boolean returnECs = BooleanDecoder.parse( value );

View Full Code Here

        // a FF, it's a TRUE. Any other value should be an error,
        // but we could relax this constraint. So if we have
        // something
        // which is not 0, it will be interpreted as TRUE, but we
        // will generate a warning.
        BerValue value = tlv.getValue();

        try
        {
            control.setCritical( BooleanDecoder.parse( value ) );
        }
        catch ( BooleanDecoderException bde )
        {
            LOG.error( I18n
                .err( I18n.ERR_04100, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( bde.getMessage() );
        }
View Full Code Here

        TLV tlv = container.getCurrentTLV();

        // The current TLV should be a integer
        // We get it and store it in sizeLimit
        BerValue value = tlv.getValue();
        long sizeLimit = 0;

        try
        {
            sizeLimit = LongDecoder.parse( value, 0, Integer.MAX_VALUE );
        }
        catch ( LongDecoderException lde )
        {
            String msg = I18n.err( I18n.ERR_04103, value.toString() );
            LOG.error( msg );
            throw new DecoderException( msg );
        }

        searchRequest.setSizeLimit( sizeLimit );
View Full Code Here

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

        BerValue value = tlv.getValue();

        try
        {
            int messageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );

            container.setMessageId( messageId );

            if ( IS_DEBUG )
            {
                LOG.debug( "Ldap Message Id has been decoded : " + messageId );
            }
        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n.err( I18n.ERR_04070, Strings.dumpBytes( value.getData() ), ide
                .getLocalizedMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( ide.getMessage() );
        }
View Full Code Here

        SearchRequest searchRequest = container.getMessage().getDecorated();

        TLV tlv = container.getCurrentTLV();

        // We have to check that this is a correct scope
        BerValue value = tlv.getValue();
        int scope = 0;

        try
        {
            scope = IntegerDecoder.parse( value, LdapConstants.SCOPE_BASE_OBJECT,
                LdapConstants.SCOPE_WHOLE_SUBTREE );
        }
        catch ( IntegerDecoderException ide )
        {
            String msg = I18n.err( I18n.ERR_04101, value.toString() );
            LOG.error( msg );
            throw new DecoderException( msg );
        }

        searchRequest.setScope( SearchScope.getSearchScope( scope ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.asn1.ber.tlv.BerValue

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.