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

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


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

        Value 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


                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

                                    UniversalTag.INTEGER.getValue(),
                new GrammarAction<GracefulShutdownContainer>( "Set Graceful Shutdown time offline" )
            {
                public void action( GracefulShutdownContainer container ) throws DecoderException
                {
                    Value value = container.getCurrentTLV().getValue();

                    try
                    {
                        int timeOffline = IntegerDecoder.parse( value, 0, 720 );

                        if ( IS_DEBUG )
                        {
                            LOG.debug( "Time Offline = " + timeOffline );
                        }

                        container.getGracefulShutdown().setTimeOffline( timeOffline );
                        container.setGrammarEndAllowed( true );
                    }
                    catch ( IntegerDecoderException e )
                    {
                        String msg = I18n.err( I18n.ERR_04037, Strings.dumpBytes(value.getData()) );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                }
            } );

        /**
         * Transition from time offline to delay
         *
         * GracefulShutdown ::= SEQUENCE {
         *     ...
         *     delay [0] INTEGER (0..86400) DEFAULT 0 }
         *
         * Set the delay value into the GracefulShutdown
         * object.
         */
        super.transitions[GracefulShutdownStatesEnum.TIME_OFFLINE_STATE.ordinal()][GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] =
            new GrammarTransition<GracefulShutdownContainer>( GracefulShutdownStatesEnum.TIME_OFFLINE_STATE,
                                    GracefulShutdownStatesEnum.DELAY_STATE,
                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG,

                new GrammarAction<GracefulShutdownContainer>( "Set Graceful Shutdown Delay" )
            {
                public void action( GracefulShutdownContainer container ) throws DecoderException
                {
                    Value value = container.getCurrentTLV().getValue();

                    try
                    {
                        int delay = IntegerDecoder.parse( value, 0, 86400 );

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

                        container.getGracefulShutdown().setDelay( delay );
                        container.setGrammarEndAllowed( true );
                    }
                    catch ( IntegerDecoderException e )
                    {
                        String msg = I18n.err( I18n.ERR_04036, Strings.dumpBytes(value.getData()) );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                }
            } );
       
        /**
         * Transition from graceful shutdown to delay
         *
         * GracefulShutdown ::= SEQUENCE {
         *     ...
         *     delay [0] INTEGER (0..86400) DEFAULT 0 }
         *
         * Set the delay value into the GracefulShutdown
         * object.
         */
        super.transitions[GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE.ordinal()]
                         [GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG] =
            new GrammarTransition<GracefulShutdownContainer>( GracefulShutdownStatesEnum.GRACEFUL_SHUTDOWN_SEQUENCE_STATE,
                                    GracefulShutdownStatesEnum.DELAY_STATE,
                                    GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG,

                new GrammarAction<GracefulShutdownContainer>( "Set Graceful Shutdown Delay" )
            {
                public void action( GracefulShutdownContainer container ) throws DecoderException
                {
                    GracefulShutdownContainer gracefulShutdownContainer = ( GracefulShutdownContainer ) container;
                    Value value = gracefulShutdownContainer.getCurrentTLV().getValue();

                    try
                    {
                        int delay = IntegerDecoder.parse( value, 0, 86400 );

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

                        gracefulShutdownContainer.getGracefulShutdown().setDelay( delay );
                        gracefulShutdownContainer.setGrammarEndAllowed( true );
                    }
                    catch ( IntegerDecoderException e )
                    {
                        String msg = I18n.err( I18n.ERR_04036, Strings.dumpBytes(value.getData()) );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                }
            } );
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
        {
            extensibleMatchFilter.setDnAttributes( BooleanDecoder.parse( value ) );
        }
        catch ( BooleanDecoderException bde )
        {
            LOG.error( I18n
                .err( I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage() ) );

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

        if ( IS_DEBUG )
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        // The current TLV should be a integer
        // We get it and store it in sizeLimit
        Value 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

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

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

        Value value = tlv.getValue();
        ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS;

        try
        {
            resultCode = ResultCodeEnum.getResultCode( IntegerDecoder.parse(value, 0, ResultCodeEnum.E_SYNC_REFRESH_REQUIRED
                    .getResultCode()) );
        }
        catch ( IntegerDecoderException ide )
        {
            LOG.error( I18n.err( I18n.ERR_04018, Strings.dumpBytes(value.getData()), ide.getMessage() ) );

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

        if ( IS_DEBUG )
View Full Code Here

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

        TLV tlv = container.getCurrentTLV();

        // We have to check that this is a correct scope
        Value 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

        TLV tlv = container.getCurrentTLV();

        // The current TLV should be a integer
        // We get it and store it in timeLimit
        Value value = tlv.getValue();

        int timeLimit = 0;

        try
        {
            timeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
        }
        catch ( IntegerDecoderException ide )
        {
            String msg = I18n.err( I18n.ERR_04104, value.toString() );
            LOG.error( msg );
            throw new DecoderException( msg );
        }

        searchRequest.setTimeLimit( timeLimit );
View Full Code Here

TOP

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

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.