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

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


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

        Value 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


        // 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.
        Value 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

        // 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.
        Value value = tlv.getValue();

        try
        {
            modifyDnRequest.setDeleteOldRdn( BooleanDecoder.parse( value ) );
        }
        catch ( BooleanDecoderException bde )
        {
            LOG.error( I18n
                .err( I18n.ERR_04091, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

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

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

        Value 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

        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
        {
            control.setValue( value.getData() );

            if ( control != null )
            {
                control.decode( value.getData() );
            }
        }

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

            }

            parent = parent.getParent();
        }

        Value value = current.getValue();

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

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

        Value 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

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

        Value value = tlv.getValue();

        try
        {
            int version = IntegerDecoder.parse( value, 1, 127 );

            if ( IS_DEBUG )
            {
                LOG.debug( "Ldap version ", Integer.valueOf( version ) );
            }

            bindRequestMessage.setVersion3( version == 3 );
        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n
                .err( I18n.ERR_04078, Strings.dumpBytes( value.getData() ), ide.getMessage() ) );

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

                CertGenerationStatesEnum.TARGETDN_STATE, UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<CertGenerationContainer>( "Set Cert Generation target Dn value" )
                {
                    public void action( CertGenerationContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        String targetDN = Strings.utf8ToString( value.getData() );

                        if ( IS_DEBUG )
                        {
                            LOG.debug( "Target Dn = " + targetDN );
                        }

                        if ( ( targetDN != null ) && ( targetDN.trim().length() > 0 ) )
                        {
                            if ( !Dn.isValid( targetDN ) )
                            {
                                String msg = I18n.err( I18n.ERR_04032, targetDN );
                                LOG.error( msg );
                                throw new DecoderException( msg );
                            }

                            container.getCertGenerationObject().setTargetDN( targetDN );
                        }
                        else
                        {
                            String msg = I18n.err( I18n.ERR_04033, Strings.dumpBytes( value.getData() ) );
                            LOG.error( msg );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from targetDN state to issuerDN
         *
         * CertGenerationObject ::= SEQUENCE {
         *     ...
         *     issuerDN IA5String,
         *     ...
         *    
         * Set the issuerDN value into the CertGenerationObject instance.
         */
        super.transitions[CertGenerationStatesEnum.TARGETDN_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.TARGETDN_STATE,
                CertGenerationStatesEnum.ISSUER_STATE, UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<CertGenerationContainer>( "Set Cert Generation issuer Dn value" )
                {
                    public void action( CertGenerationContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        String issuerDN = Strings.utf8ToString( value.getData() );

                        if ( IS_DEBUG )
                        {
                            LOG.debug( "Issuer Dn = " + issuerDN );
                        }

                        if ( ( issuerDN != null ) && ( issuerDN.trim().length() > 0 ) )
                        {
                            if ( !Dn.isValid( issuerDN ) )
                            {
                                String msg = I18n.err( I18n.ERR_04034, issuerDN );
                                LOG.error( msg );
                                throw new DecoderException( msg );
                            }

                            container.getCertGenerationObject().setIssuerDN( issuerDN );
                        }
                    }
                } );

        /**
         * Transition from issuerDN state to subjectDN
         *
         * CertGenerationObject ::= SEQUENCE {
         *     ...
         *     subjectDN IA5String,
         *     ...
         *    
         * Set the subjectDN value into the CertGenerationObject instance.
         */
        super.transitions[CertGenerationStatesEnum.ISSUER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.ISSUER_STATE,
                CertGenerationStatesEnum.SUBJECT_STATE, UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<CertGenerationContainer>( "Set Cert Generation subject Dn value" )
                {
                    public void action( CertGenerationContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        String subjectDN = Strings.utf8ToString( value.getData() );

                        if ( IS_DEBUG )
                        {
                            LOG.debug( "subject Dn = " + subjectDN );
                        }

                        if ( ( subjectDN != null ) && ( subjectDN.trim().length() > 0 ) )
                        {
                            if ( !Dn.isValid( subjectDN ) )
                            {
                                String msg = I18n.err( I18n.ERR_04035, subjectDN );
                                LOG.error( msg );
                                throw new DecoderException( msg );
                            }

                            container.getCertGenerationObject().setSubjectDN( subjectDN );
                        }
                        else
                        {
                            String msg = I18n.err( I18n.ERR_04033, Strings.dumpBytes( value.getData() ) );
                            LOG.error( msg );
                            throw new DecoderException( msg );
                        }
                    }
                } );

        /**
         * Transition from subjectDN state to keyAlgo
         *
         * CertGenerationObject ::= SEQUENCE {
         *     ...
         *     keyAlgorithm IA5String
         *    
         * Set the key algorithm value into the CertGenerationObject instance.
         */
        super.transitions[CertGenerationStatesEnum.SUBJECT_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition<CertGenerationContainer>( CertGenerationStatesEnum.SUBJECT_STATE,
                CertGenerationStatesEnum.KEY_ALGORITHM_STATE,
                UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction<CertGenerationContainer>( "Set Cert Generation key algorithm value" )
                {
                    public void action( CertGenerationContainer container ) throws DecoderException
                    {
                        Value value = container.getCurrentTLV().getValue();

                        String keyAlgorithm = Strings.utf8ToString( value.getData() );

                        if ( IS_DEBUG )
                        {
                            LOG.debug( "key algorithm = " + keyAlgorithm );
                        }
View Full Code Here

     */
    public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
    {
        try
        {
            return extended( new Oid( oid ), value );
        }
        catch ( DecoderException e )
        {
            String msg = "Failed to decode the OID " + oid;
            LOG.error( msg );
View Full Code Here

TOP

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

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.