Package org.apache.directory.shared.asn1

Examples of org.apache.directory.shared.asn1.DecoderException


                    if ( tlv.getLength() == 0 )
                    {
                        // We can't have a void language !
                        String msg = I18n.err( I18n.ERR_04038 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        // Only this field's type is String by default
                        String language = Strings.utf8ToString(tlv.getValue().getData());

                        if ( LOG.isDebugEnabled() )
                        {
                            LOG.debug( "SP language found: " + language );
                        }

                        storedProcedure = new StoredProcedure();
                        storedProcedure.setLanguage( language );
                        storedProcedureContainer.setStoredProcedure( storedProcedure );
                    }
                }
            } );

        //    procedure OCTETSTRING, (Value)
        //    ...
        // Stores the procedure.
        super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition( StoredProcedureStatesEnum.LANGUAGE_STATE,
                                    StoredProcedureStatesEnum.PROCEDURE_STATE,
                                    UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction(
                "Stores the procedure" )
            {
                public void action( Asn1Container container ) throws DecoderException
                {

                    StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;

                    TLV tlv = storedProcedureContainer.getCurrentTLV();

                    StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        // We can't have a void procedure !
                        String msg = I18n.err( I18n.ERR_04039 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        byte[] procedure = tlv.getValue().getData();

                        storedProcedure.setProcedure( procedure );
                    }

                    if ( LOG.isDebugEnabled() )
                    {
                        LOG.debug( "Procedure found : " + Strings.utf8ToString(storedProcedure.getProcedure()) );
                    }
                }
            } );

        // parameters SEQUENCE OF Parameter { (Value)
        //    ...
        // The list of parameters will be created with the first parameter.
        // We can have an empty list of parameters, so the PDU can be empty
        super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
            new GrammarTransition( StoredProcedureStatesEnum.PROCEDURE_STATE,
                                    StoredProcedureStatesEnum.PARAMETERS_STATE,
                                    UniversalTag.SEQUENCE.getValue(),
            new GrammarAction(
                "Stores the parameters" )
            {
                public void action( Asn1Container container ) throws DecoderException
                {
                    StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
                    storedProcedureContainer.setGrammarEndAllowed( true );
                }
            } );
       
        // parameter SEQUENCE OF { (Value)
        //    ...
        // Nothing to do.
        super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
            new GrammarTransition( StoredProcedureStatesEnum.PARAMETERS_STATE,
                                    StoredProcedureStatesEnum.PARAMETER_STATE,
                                    UniversalTag.SEQUENCE.getValue(),
                                    null );

        // Parameter ::= {
        //    type OCTETSTRING, (Value)
        //    ...
        //
        // We can create a parameter, and store its type
        super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_STATE,
                                    StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
                                    UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction( "Store parameter type" )
            {
                public void action( Asn1Container container ) throws DecoderException
                {
                    StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;

                    TLV tlv = storedProcedureContainer.getCurrentTLV();
                    StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        // We can't have a void parameter type !
                        String msg = I18n.err( I18n.ERR_04040 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        StoredProcedureParameter parameter = new StoredProcedureParameter();

                        byte[] parameterType = tlv.getValue().getData();

                        parameter.setType( parameterType );

                        // We store the type in the current parameter.
                        storedProcedure.setCurrentParameter( parameter );

                        if ( LOG.isDebugEnabled() )
                        {
                            LOG.debug( "Parameter type found : " + Strings.dumpBytes(parameterType) );
                        }

                    }
                }
            } );

        // Parameter ::= {
        //    ...
        //    value OCTETSTRING (Tag)
        // }
        // Store the parameter value
        super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
            new GrammarTransition( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
                                    StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
                                    UniversalTag.OCTET_STRING.getValue(),
                new GrammarAction( "Store parameter value" )
            {
                public void action( Asn1Container container ) throws DecoderException
                {
                    StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;

                    TLV tlv = storedProcedureContainer.getCurrentTLV();
                    StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        // We can't have a void parameter value !
                        String msg = I18n.err( I18n.ERR_04041 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        byte[] parameterValue = tlv.getValue().getData();

                        if ( parameterValue.length != 0 )
                        {
                            StoredProcedureParameter parameter = storedProcedure.getCurrentParameter();
                            parameter.setValue( parameterValue );

                            // We can now add a new Parameter to the procedure
                            storedProcedure.addParameter( parameter );

                            if ( LOG.isDebugEnabled() )
                            {
                                LOG.debug( "Parameter value found : " + Strings.dumpBytes(parameterValue) );
                            }
                        }
                        else
                        {
                            String msg = I18n.err( I18n.ERR_04042 );
                            LOG.error( msg );
                            throw new DecoderException( msg );
                        }
                    }

                    // The only possible END state for the grammar is here
                    container.setGrammarEndAllowed( true );
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 ( Exception e )
        {
            String message = I18n.err( I18n.ERR_04060, e.getLocalizedMessage() );
            LOG.error( message );
            throw new DecoderException( message, e );
        }
    }
View Full Code Here

                return ldapMessageContainer.getMessage();
            }
            else
            {
                LOG.error( I18n.err( I18n.ERR_04062 ) );
                throw new DecoderException( I18n.err( I18n.ERR_04063 ) );
            }
        }
        else
        {
            try
            {
                // Synchronize on the input lock object to prevent concurrent
                // reads
                synchronized ( lock )
                {
                    digest( in );

                    // Notify/awaken threads waiting to read from input stream
                    lock.notifyAll();
                }
            }
            catch ( Exception e )
            {
                String message = I18n.err( I18n.ERR_04060, e.getLocalizedMessage() );
                LOG.error( message );
                throw new DecoderException( message, e );
            }

            if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
            {
                if ( IS_DEBUG )
                {
                    LOG.debug( "Decoded LdapMessage : " + ldapMessageContainer.getMessage() );
                }

                return ldapMessageContainer.getMessage();
            }
            else
            {
                LOG.error( I18n.err( I18n.ERR_04064 ) );
                throw new DecoderException( I18n.err( I18n.ERR_04063 ) );
            }
        }
    }
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

                }
                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
            {
                LOG.warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
View Full Code Here

        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 );
View Full Code Here

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

        SearchRequestDecorator searchRequestDecorator = container.getMessage();

        // We can allocate the SearchRequest
View Full Code Here

        // 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() );
View Full Code Here

        {
            String msg = I18n.err( I18n.ERR_04011 );
            LOG.error( msg );

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

        ResultResponse response = ( ResultResponse ) container.getMessage();
        LdapResult ldapResult = response.getLdapResult();
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.asn1.DecoderException

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.