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

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


        catch ( BooleanDecoderException bde )
        {
            LOG.error( I18n
                .err( I18n.ERR_04110, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

            throw new DecoderException( bde.getMessage() );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( "Dn Attributes : {}", Boolean.valueOf( extensibleMatchFilter.isDnAttributes() ) );
View Full Code Here


                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04031, Strings.dumpBytes( value.getData() ) );
                            LOG.error( msg );
                            throw new DecoderException( msg );
                        }
                    }
                } );
    }
View Full Code Here

                        catch ( BooleanDecoderException bde )
                        {
                            LOG.error( I18n.err( I18n.ERR_04054, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

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

                                    break;

                                default:
                                    String msg = I18n.err( I18n.ERR_04044 );
                                    LOG.error( msg );
                                    throw new DecoderException( msg );
                            }

                            // We can have an END transition
                            container.setGrammarEndAllowed( true );
                        }
                        catch ( IntegerDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04044 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                        catch ( IllegalArgumentException e )
                        {
                            throw new DecoderException( e.getLocalizedMessage() );
                        }
                    }
                } );

        // ============================================================================================
        // Transition from Change Type to Previous Dn
        // ============================================================================================
        // EntryChangeNotification ::= SEQUENCE {
        //     ...
        //     previousDN LDAPDN OPTIONAL,
        //     ...
        //
        // Set the previousDN into the structure. We first check that it's a
        // valid Dn
        super.transitions[EntryChangeStates.CHANGE_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<EntryChangeContainer>( EntryChangeStates.CHANGE_TYPE_STATE,
                EntryChangeStates.PREVIOUS_DN_STATE,
                UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<EntryChangeContainer>( "Set EntryChangeControl previousDN" )
                {
                    public void action( EntryChangeContainer container ) throws DecoderException
                    {
                        ChangeType changeType = container.getEntryChangeDecorator().getChangeType();

                        if ( changeType != ChangeType.MODDN )
                        {
                            LOG.error( I18n.err( I18n.ERR_04045 ) );
                            throw new DecoderException( I18n.err( I18n.ERR_04046 ) );
                        }
                        else
                        {
                            Value value = container.getCurrentTLV().getValue();
                            Dn previousDn;

                            try
                            {
                                previousDn = new Dn( Strings.utf8ToString( value.getData() ) );
                            }
                            catch ( LdapInvalidDnException ine )
                            {
                                LOG.error( I18n.err( I18n.ERR_04047, Strings.dumpBytes( value.getData() ) ) );
                                throw new DecoderException( I18n.err( I18n.ERR_04048 ) );
                            }

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

                            container.getEntryChangeDecorator().setPreviousDn( previousDn );

                            // We can have an END transition
                            container.setGrammarEndAllowed( true );
                        }
                    }
                } );

        // Change Number action
        GrammarAction<EntryChangeContainer> setChangeNumberAction = new GrammarAction<EntryChangeContainer>(
            "Set EntryChangeControl changeNumber" )
        {
            public void action( EntryChangeContainer container ) throws DecoderException
            {
                Value value = container.getCurrentTLV().getValue();

                try
                {
                    long changeNumber = LongDecoder.parse( value );

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

                    container.getEntryChangeDecorator().setChangeNumber( changeNumber );

                    // We can have an END transition
                    container.setGrammarEndAllowed( true );
                }
                catch ( LongDecoderException e )
                {
                    String msg = I18n.err( I18n.ERR_04049 );
                    LOG.error( msg, e );
                    throw new DecoderException( msg );
                }
            }
        };

        // ============================================================================================
View Full Code Here

                        }
                        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
                    {
                        Value 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
                    {
                        Value value = container.getCurrentTLV().getValue();

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

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

                            container.getPersistentSearchDecorator().setReturnECs( returnECs );

                            // We can have an END transition
                            container.setGrammarEndAllowed( true );
                        }
                        catch ( BooleanDecoderException e )
                        {
                            String msg = I18n.err( I18n.ERR_04053 );
                            LOG.error( msg, e );
                            throw new DecoderException( msg );
                        }
                    }
                } );
    }
View Full Code Here

                if ( expectedLength > 4 )
                {
                    String msg = I18n.err( I18n.ERR_00005_LENGTH_OVERFLOW );
                    LOG.error( msg );
                    throw new DecoderException( msg );
                }

                tlv.setLength( 0 );
                tlv.setLengthNbBytes( 1 + expectedLength );
                tlv.setLengthBytesRead( 1 );
                container.setState( TLVStateEnum.LENGTH_STATE_PENDING );
            }
            else
            {
                String msg = I18n.err( I18n.ERR_00006_LENGTH_EXTENSION_RESERVED );
                LOG.error( msg );
                throw new DecoderException( msg );
            }

            return MORE;
        }
        else
View Full Code Here

        if ( tlv == null )
        {
            String msg = I18n.err( I18n.ERR_00007_TLV_NULL );
            LOG.error( msg );
            throw new DecoderException( msg );
        }

        int length = tlv.getLength();

        // We will check the length here. What we must control is
        // that the enclosing constructed TLV expected length is not
        // exceeded by the current TLV.
        TLV parentTLV = container.getParentTLV();

        if ( IS_DEBUG )
        {
            LOG.debug( "Parent length : {}", getParentLength( parentTLV ) );
        }

        if ( parentTLV == null )
        {
            // This is the first TLV, so we can't check anything. We will
            // just store this TLV as the root of the PDU
            tlv.setExpectedLength( length );
            container.setParentTLV( tlv );

            if ( IS_DEBUG )
            {
                LOG.debug( "Root TLV[{}]", Integer.valueOf( length ) );
            }
        }
        else
        {
            // We have a parent, so we will check that its expected length is
            // not exceeded.
            int expectedLength = parentTLV.getExpectedLength();
            int currentLength = tlv.getSize();

            if ( expectedLength < currentLength )
            {
                // The expected length is lower than the Value length of the
                // current TLV. This is an error...
                LOG.debug( "tlv[{}, {}]", Integer.valueOf( expectedLength ), Integer.valueOf( currentLength ) );
                throw new DecoderException( I18n.err( I18n.ERR_00008_VALUE_LENGTH_ABOVE_EXPECTED_LENGTH, Integer
                    .valueOf( currentLength ), Integer.valueOf( expectedLength ) ) );
            }

            // deal with the particular case where expected length equal
            // the current length, which means that the parentTLV has been
View Full Code Here

                    container.setState( TLVStateEnum.PDU_DECODED );
                }
                else
                {
                    LOG.error( I18n.err( I18n.ERR_00009_MORE_TLV_EXPECTED ) );
                    throw new DecoderException( I18n.err( I18n.ERR_00010_TRUNCATED_PDU ) );
                }
            }
        }
        else
        {
View Full Code Here

        if ( container.getDecodeBytes() > container.getMaxPDUSize() )
        {
            String message = I18n.err( I18n.ERR_00042_PDU_SIZE_TOO_LONG, container.getDecodeBytes(), container
                .getMaxPDUSize() );
            LOG.error( message );
            throw new DecoderException( message );
        }

        if ( IS_DEBUG )
        {
            LOG.debug( ">>>==========================================" );
View Full Code Here

     */
    public void setMaxLengthLength( int maxLengthLength ) throws DecoderException
    {
        if ( ( this.indefiniteLengthAllowed ) && ( maxLengthLength > 126 ) )
        {
            throw new DecoderException( I18n.err( I18n.ERR_00011_LENGTH_TOO_LONG_FOR_DEFINITE_FORM ) );
        }

        this.maxLengthLength = maxLengthLength;
    }
View Full Code Here

TOP

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

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.