Examples of DeleteResponseImpl


Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        DeleteResponse resp = new DeleteResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );

        try
        {
            session.delete( deleteRequest );
        }
        catch ( LdapException e )
        {
            LOG.warn( e.getMessage(), e );

            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
        }

        addResponseControls( deleteRequest, resp );

        return resp;
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        DeleteResponse resp = new DeleteResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );

        try
        {
            session.delete( deleteRequest );
        }
        catch ( LdapException e )
        {
            LOG.warn( e.getMessage(), e );

            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
        }

        addResponseControls( deleteRequest, resp );

        return resp;
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        DeleteResponse resp = new DeleteResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );

        try
        {
            session.delete( deleteRequest );
        }
        catch ( LdapException e )
        {
            LOG.warn( e.getMessage(), e );

            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
        }

        addResponseControls( deleteRequest, resp );

        return resp;
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

            throw new IllegalArgumentException( msg );
        }

        int newId = messageId.incrementAndGet();

        DeleteResponse resp = new DeleteResponseImpl( newId );
        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );

        try
        {
            session.delete( deleteRequest );
        }
        catch ( LdapException e )
        {
            LOG.warn( e.getMessage(), e );

            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
        }

        addResponseControls( deleteRequest, resp );

        return resp;
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

    /**
     * Creates a new getDecoratedMessage() of DelResponseDsml.
     */
    public DelResponseDsml( LdapApiService codec )
    {
        super( codec, new DeleteResponseImpl() );
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

     */
    public void action( LdapMessageContainer<DeleteResponseDecorator> container )
    {
        // Now, we can allocate the DelResponse Object
        DeleteResponseDecorator delResponse = new DeleteResponseDecorator(
            container.getLdapCodecService(), new DeleteResponseImpl( container.getMessageId() ) );
        container.setMessage( delResponse );

        LOG.debug( "Del response " );
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.DeleteResponseImpl

            {
                String msg = I18n.err( I18n.ERR_04074, dnStr, Strings.dumpBytes( dnBytes ), ine
                    .getLocalizedMessage() );
                LOG.error( msg );

                DeleteResponseImpl response = new DeleteResponseImpl( delRequest.getMessageId() );
                throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                    Dn.EMPTY_DN, ine );
            }

            delRequest.setName( entry );
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.DeleteResponseImpl

    /**
     * Creates a new getDecoratedMessage() of DelResponseDsml.
     */
    public DelResponseDsml( LdapCodecService codec )
    {
        super( codec, new DeleteResponseImpl() );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.DeleteResponseImpl

    /**
     * Creates a new getDecoratedMessage() of DelResponseDsml.
     */
    public DelResponseDsml( LdapCodecService codec )
    {
        super( codec, new DeleteResponseImpl() );
    }
View Full Code Here

Examples of org.apache.directory.shared.ldap.model.message.DeleteResponseImpl

                        {
                            String msg = I18n.err( I18n.ERR_04074, dnStr, Strings.dumpBytes(dnBytes), ine
                                .getLocalizedMessage() );
                            LOG.error( msg );

                            DeleteResponseImpl response = new DeleteResponseImpl( delRequest.getMessageId() );
                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                Dn.EMPTY_DN, ine );
                        }

                        delRequest.setName( entry );
                    }

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

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Deleting Dn {}", entry );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // transition from DelRequest Message to Controls.
        // --------------------------------------------------------------------------------------------
        //         delRequest   DelRequest,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.DEL_REQUEST_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.DEL_REQUEST_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Message ID to AbandonRequest Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... AbandonRequest ...
        // AbandonRequest ::= [APPLICATION 16] MessageID
        //
        // Create the AbandonRequest object, and store the ID in it
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.ABANDON_REQUEST_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.ABANDON_REQUEST_STATE, LdapConstants.ABANDON_REQUEST_TAG,
            new GrammarAction<LdapMessageContainer<AbandonRequestDecorator>>( "Init Abandon Request" )
            {
                public void action( LdapMessageContainer<AbandonRequestDecorator> container ) throws DecoderException
                {
                    // Create the AbandonRequest LdapMessage instance and store it in the container
                    AbandonRequestDecorator abandonRequest = new AbandonRequestDecorator(
                        container.getLdapCodecService(), new AbandonRequestImpl( container.getMessageId() ) );
                    container.setMessage( abandonRequest );

                    // 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() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // transition from AbandonRequest Message to Controls.
        // --------------------------------------------------------------------------------------------
        //         abandonRequest   AbandonRequest,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.ABANDON_REQUEST_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ABANDON_REQUEST_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Message ID to BindRequest Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... BindRequest ...
        // BindRequest ::= [APPLICATION 0] SEQUENCE { ...
        //
        // We have to allocate a BindRequest
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.BIND_REQUEST_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.BIND_REQUEST_STATE, LdapConstants.BIND_REQUEST_TAG,
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Init BindRequest" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    // Create the BindRequest LdapMessage instance and store it in the container
                    BindRequestDecorator bindRequest = new BindRequestDecorator(
                        container.getLdapCodecService(), new BindRequestImpl( container.getMessageId() ) );
                    container.setMessage( bindRequest );

                    // We will check that the request is not null
                    TLV tlv = container.getCurrentTLV();

                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04077 );
                        LOG.error( msg );

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

        // --------------------------------------------------------------------------------------------
        // Transition from BindRequest to version
        // --------------------------------------------------------------------------------------------
        // BindRequest ::= [APPLICATION 0] SEQUENCE {
        //     version                 INTEGER (1 ..  127),
        //     ....
        //
        // The Ldap version is parsed and stored into the BindRequest object
        super.transitions[LdapStatesEnum.BIND_REQUEST_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
            LdapStatesEnum.BIND_REQUEST_STATE, LdapStatesEnum.VERSION_STATE, UniversalTag.INTEGER.getValue(),
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Store version" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    BindRequest bindRequestMessage = container.getMessage();

                    // 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() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from version to name
        // --------------------------------------------------------------------------------------------
        // BindRequest ::= [APPLICATION 0] SEQUENCE {
        //     ....
        //     name                    LDAPDN,
        //     ....
        //
        // The Ldap version is parsed and stored into the BindRequest object
        super.transitions[LdapStatesEnum.VERSION_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.VERSION_STATE, LdapStatesEnum.NAME_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Store Bind Name value" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    BindRequest bindRequestMessage = container.getMessage();

                    // Get the Value and store it in the BindRequest
                    TLV tlv = container.getCurrentTLV();

                    // We have to handle the special case of a 0 length name
                    if ( tlv.getLength() == 0 )
                    {
                        bindRequestMessage.setName( Dn.EMPTY_DN );
                    }
                    else
                    {
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

                        try
                        {
                            Dn dn = new Dn( dnStr );
                            bindRequestMessage.setName( dn );
                        }
                        catch ( LdapInvalidDnException ine )
                        {
                            String msg = "Incorrect Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes)
                                + ") is invalid";
                            LOG.error( "{} : {}", msg, ine.getMessage() );

                            BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );

                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                Dn.EMPTY_DN, ine );
                        }
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( " The Bind name is {}", bindRequestMessage.getName() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from name to Simple Authentication
        // --------------------------------------------------------------------------------------------
        // BindRequest ::= [APPLICATION 0] SEQUENCE {
        //     ....
        //     authentication          AuthenticationChoice }
        //
        // AuthenticationChoice ::= CHOICE {
        //     simple                  [0] OCTET STRING,
        //     ...
        //
        // We have to create an Authentication Object to store the credentials.
        super.transitions[LdapStatesEnum.NAME_STATE.ordinal()][LdapConstants.BIND_REQUEST_SIMPLE_TAG] = new GrammarTransition(
            LdapStatesEnum.NAME_STATE, LdapStatesEnum.SIMPLE_STATE, LdapConstants.BIND_REQUEST_SIMPLE_TAG,
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Store Bind Simple Authentication value" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    BindRequest bindRequestMessage = container.getMessage();
                    TLV tlv = container.getCurrentTLV();

                    // Allocate the Authentication Object
                    bindRequestMessage.setSimple( true );

                    // We have to handle the special case of a 0 length simple
                    if ( tlv.getLength() == 0 )
                    {
                        bindRequestMessage.setCredentials( StringConstants.EMPTY_BYTES );
                    }
                    else
                    {
                        bindRequestMessage.setCredentials( tlv.getValue().getData() );
                    }

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

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "The simple authentication is : {}", Strings.dumpBytes(bindRequestMessage
                                .getCredentials()) );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // transition from Simple Authentication to Controls.
        // --------------------------------------------------------------------------------------------
        //         bindRequest   BindRequest,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.SIMPLE_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.SIMPLE_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from name to SASL Authentication
        // --------------------------------------------------------------------------------------------
        // BindRequest ::= [APPLICATION 0] SEQUENCE {
        //     ....
        //     authentication          AuthenticationChoice }
        //
        // AuthenticationChoice ::= CHOICE {
        //     ...
        //     sasl                  [3] SaslCredentials }
        //     ...
        //
        // We have to create an Authentication Object to store the credentials.
        super.transitions[LdapStatesEnum.NAME_STATE.ordinal()][LdapConstants.BIND_REQUEST_SASL_TAG] = new GrammarTransition(
            LdapStatesEnum.NAME_STATE, LdapStatesEnum.SASL_STATE, LdapConstants.BIND_REQUEST_SASL_TAG,
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Initialize Bind SASL Authentication" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    BindRequest bindRequestMessage = container.getMessage();
                    TLV tlv = container.getCurrentTLV();

                    // We will check that the sasl is not null
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04079 );
                        LOG.error( msg );

                        BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );

                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS,
                            bindRequestMessage.getName(), null );
                    }

                    bindRequestMessage.setSimple( false );

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "The SaslCredential has been created" );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from SASL Authentication to Mechanism
        // --------------------------------------------------------------------------------------------
        // SaslCredentials ::= SEQUENCE {
        //     mechanism   LDAPSTRING,
        //     ...
        //
        // We have to store the mechanism.
        super.transitions[LdapStatesEnum.SASL_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.SASL_STATE, LdapStatesEnum.MECHANISM_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Store SASL mechanism" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
                {
                    BindRequest bindRequestMessage = container.getMessage();
                    TLV tlv = container.getCurrentTLV();

                    // We have to handle the special case of a 0 length
                    // mechanism
                    if ( tlv.getLength() == 0 )
                    {
                        bindRequestMessage.setSaslMechanism( "" );
                    }
                    else
                    {
                        bindRequestMessage.setSaslMechanism( Strings.utf8ToString(tlv.getValue().getData()) );
                    }

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

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "The mechanism is : {}", bindRequestMessage.getSaslMechanism() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Mechanism to Credentials
        // --------------------------------------------------------------------------------------------
        // SaslCredentials ::= SEQUENCE {
        //     ...
        //     credentials OCTET STRING OPTIONAL }
        //
        // We have to store the mechanism.
        super.transitions[LdapStatesEnum.MECHANISM_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.MECHANISM_STATE, LdapStatesEnum.CREDENTIALS_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<BindRequestDecorator>>( "Store SASL credentials" )
            {
                public void action( LdapMessageContainer<BindRequestDecorator> container )
                {
                    BindRequest bindRequestMessage = container.getMessage();

                    // Get the Value and store it in the BindRequest
                    TLV tlv = container.getCurrentTLV();

                    // We have to handle the special case of a 0 length
                    // credentials
                    if ( tlv.getLength() == 0 )
                    {
                        bindRequestMessage.setCredentials( StringConstants.EMPTY_BYTES );
                    }
                    else
                    {
                        bindRequestMessage.setCredentials( tlv.getValue().getData() );
                    }

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

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "The credentials are : {}", Strings.dumpBytes(bindRequestMessage
                                .getCredentials()) );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // transition from from Mechanism to Controls.
        // --------------------------------------------------------------------------------------------
        //         bindRequest   BindRequest,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.MECHANISM_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.MECHANISM_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // transition from credentials to Controls.
        // --------------------------------------------------------------------------------------------
        //         bindRequest   BindRequest,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.CREDENTIALS_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.CREDENTIALS_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from MessageId to BindResponse message
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... BindResponse ...
        // BindResponse ::= [APPLICATION 1] SEQUENCE { ...
        // We have to switch to the BindResponse grammar
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.BIND_RESPONSE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.BIND_RESPONSE_STATE, LdapConstants.BIND_RESPONSE_TAG,
            new GrammarAction<LdapMessageContainer<BindResponseDecorator>>( "Init BindReponse" )
            {
                public void action( LdapMessageContainer<BindResponseDecorator> container )
                {
                    // Now, we can allocate the BindResponse Object
                    BindResponseDecorator bindResponse = new BindResponseDecorator(
                        container.getLdapCodecService(), new BindResponseImpl( container.getMessageId() ) );
                    container.setMessage( bindResponse );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from BindResponse message to Result Code BR
        // --------------------------------------------------------------------------------------------
        // BindResponse ::= [APPLICATION 1] SEQUENCE {
        //     COMPONENTS OF LDAPResult,
        //     ...
        //
        // LDAPResult ::= SEQUENCE {
        //     resultCode ENUMERATED {
        //         ...
        //
        // Stores the result code into the Bind Response object
        super.transitions[LdapStatesEnum.BIND_RESPONSE_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
            LdapStatesEnum.BIND_RESPONSE_STATE, LdapStatesEnum.RESULT_CODE_BR_STATE, UniversalTag.ENUMERATED.getValue(),
            new ResultCodeAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Result Code BR to Matched Dn BR
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     matchedDN LDAPDN,
        //     ...
        //
        // Stores the matched Dn
        super.transitions[LdapStatesEnum.RESULT_CODE_BR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.RESULT_CODE_BR_STATE, LdapStatesEnum.MATCHED_DN_BR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new MatchedDNAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Matched Dn BR to Error Message BR
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     errorMessage LDAPString,
        //     ...
        //
        // Stores the error message
        super.transitions[LdapStatesEnum.MATCHED_DN_BR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.MATCHED_DN_BR_STATE, LdapStatesEnum.ERROR_MESSAGE_BR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ErrorMessageAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Error Message BR to Server SASL credentials
        // --------------------------------------------------------------------------------------------
        // BindResponse ::= APPLICATION 1] SEQUENCE {
        //     ...
        //     serverSaslCreds [7] OCTET STRING OPTIONAL }
        //
        // Stores the sasl credentials
        super.transitions[LdapStatesEnum.ERROR_MESSAGE_BR_STATE.ordinal()][LdapConstants.SERVER_SASL_CREDENTIAL_TAG] = new GrammarTransition(
            LdapStatesEnum.ERROR_MESSAGE_BR_STATE, LdapStatesEnum.SERVER_SASL_CREDENTIALS_STATE,
            LdapConstants.SERVER_SASL_CREDENTIAL_TAG, new ServerSASLCredsAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Error Message BR to Referrals BR
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     referral   [3] Referral OPTIONNAL }
        //
        // Initialiaze the referrals list
        super.transitions[LdapStatesEnum.ERROR_MESSAGE_BR_STATE.ordinal()][LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG] = new GrammarTransition(
            LdapStatesEnum.ERROR_MESSAGE_BR_STATE, LdapStatesEnum.REFERRALS_BR_STATE,
            LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG, new InitReferralsAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referrals BR to Referral BR
        // --------------------------------------------------------------------------------------------
        // Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI (RFC 4511)
        // URI ::= LDAPString
        //
        // Add a first Referral
        super.transitions[LdapStatesEnum.REFERRALS_BR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.REFERRALS_BR_STATE, LdapStatesEnum.REFERRAL_BR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ReferralAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referral BR to Referral BR
        // --------------------------------------------------------------------------------------------
        // Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI (RFC 4511)
        // URI ::= LDAPString
        //
        // Adda new Referral
        super.transitions[LdapStatesEnum.REFERRAL_BR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.REFERRAL_BR_STATE, LdapStatesEnum.REFERRAL_BR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ReferralAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referral BR to Server SASL Credentials
        // --------------------------------------------------------------------------------------------
        // Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI (RFC 4511)
        // URI ::= LDAPString
        //
        // Adda new Referral
        super.transitions[LdapStatesEnum.REFERRAL_BR_STATE.ordinal()][LdapConstants.SERVER_SASL_CREDENTIAL_TAG] = new GrammarTransition(
            LdapStatesEnum.REFERRAL_BR_STATE, LdapStatesEnum.SERVER_SASL_CREDENTIALS_STATE,
            LdapConstants.SERVER_SASL_CREDENTIAL_TAG, new ServerSASLCredsAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referral BR to Controls
        // --------------------------------------------------------------------------------------------
        //         bindResponse   BindResponse,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        // Adda new Referral
        super.transitions[LdapStatesEnum.REFERRAL_BR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.REFERRAL_BR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Error Message BR to controls
        // --------------------------------------------------------------------------------------------
        //         bindResponse   BindResponse,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        // 
        super.transitions[LdapStatesEnum.ERROR_MESSAGE_BR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ERROR_MESSAGE_BR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Server SASL credentials to Controls
        // --------------------------------------------------------------------------------------------
        //         bindResponse   BindResponse,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        super.transitions[LdapStatesEnum.SERVER_SASL_CREDENTIALS_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.SERVER_SASL_CREDENTIALS_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Result Code to Matched Dn
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     matchedDN LDAPDN,
        //     ...
        //
        // Stores the matched Dn
        super.transitions[LdapStatesEnum.RESULT_CODE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.RESULT_CODE_STATE, LdapStatesEnum.MATCHED_DN_STATE, UniversalTag.OCTET_STRING.getValue(),
            new MatchedDNAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Matched Dn to Error Message
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     errorMessage LDAPString,
        //     ...
        //
        // Stores the error message
        super.transitions[LdapStatesEnum.MATCHED_DN_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.MATCHED_DN_STATE, LdapStatesEnum.ERROR_MESSAGE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ErrorMessageAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Error Message to Referrals
        // --------------------------------------------------------------------------------------------
        // LDAPResult ::= SEQUENCE {
        //     ...
        //     referral   [3] Referral OPTIONNAL }
        //
        // Initialize the referrals list
        super.transitions[LdapStatesEnum.ERROR_MESSAGE_STATE.ordinal()][LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG] = new GrammarTransition(
            LdapStatesEnum.ERROR_MESSAGE_STATE, LdapStatesEnum.REFERRALS_STATE,
            LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG, new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Init referrals list" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
                {
                    TLV tlv = container.getCurrentTLV();

                    // If we have a Referrals sequence, then it should not be empty
                    // sasl credentials
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04080 );
                        LOG.error( msg );

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

                    Message response = container.getMessage();
                    LdapResult ldapResult = ( ( ResultResponse ) response ).getLdapResult();

                    Referral referral = new ReferralImpl();

                    ldapResult.setReferral( referral );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Referrals to Referral
        // --------------------------------------------------------------------------------------------
        // Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI (RFC 4511)
        // URI ::= LDAPString
        //
        // Add a first Referral
        super.transitions[LdapStatesEnum.REFERRALS_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.REFERRALS_STATE, LdapStatesEnum.REFERRAL_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ReferralAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referral to Referral
        // --------------------------------------------------------------------------------------------
        // Referral ::= SEQUENCE SIZE (1..MAX) OF uri URI (RFC 4511)
        // URI ::= LDAPString
        //
        // Adda new Referral
        super.transitions[LdapStatesEnum.REFERRAL_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.REFERRAL_STATE, LdapStatesEnum.REFERRAL_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ReferralAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Referral to Controls
        // --------------------------------------------------------------------------------------------
        //         xxxResponse   xxxResponse,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        // Adda new Referral
        super.transitions[LdapStatesEnum.REFERRAL_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.REFERRAL_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Error Message to controls
        // --------------------------------------------------------------------------------------------
        //         xxxResponse   xxxResponse,
        //         ... },
        //     controls       [0] Controls OPTIONAL }
        //
        // 
        super.transitions[LdapStatesEnum.ERROR_MESSAGE_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ERROR_MESSAGE_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from MessageId to SearchResultEntry Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... SearchResultEntry ...
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        //
        // Initialize the searchResultEntry object
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.SEARCH_RESULT_ENTRY_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE,
            LdapConstants.SEARCH_RESULT_ENTRY_TAG, new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Init SearchResultEntry" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container )
                {
                    // Now, we can allocate the SearchResultEntry Object
                    SearchResultEntryDecorator searchResultEntry = new SearchResultEntryDecorator(
                        container.getLdapCodecService(), new SearchResultEntryImpl( container.getMessageId() ) );
                    container.setMessage( searchResultEntry );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from SearchResultEntry Message to ObjectName
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // objectName LDAPDN,
        // ...
        //
        // Store the object name.
        super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE, LdapStatesEnum.OBJECT_NAME_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
            {
                public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
                {
                    SearchResultEntryDecorator searchResultEntry = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    Dn objectName = Dn.EMPTY_DN;

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        searchResultEntry.setObjectName( objectName );
                    }
                    else
                    {
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

                        try
                        {
                            objectName = new Dn( dnStr );
                        }
                        catch ( LdapInvalidDnException ine )
                        {
                            // This is for the client side. We will never decode LdapResult on the server
                            String msg = "The Dn " + Strings.dumpBytes(dnBytes) + "is invalid : "
                                + ine.getMessage();
                            LOG.error( "{} : {}", msg, ine.getMessage() );
                            throw new DecoderException( msg, ine );
                        }

                        searchResultEntry.setObjectName( objectName );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Search Result Entry Dn found : {}", searchResultEntry.getObjectName() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from ObjectName to AttributesSR
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= *SEQUENCE* OF SEQUENCE {
        // ...
        //
        // We may have no attributes. Just allows the grammar to end
        super.transitions[LdapStatesEnum.OBJECT_NAME_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.OBJECT_NAME_STATE, LdapStatesEnum.ATTRIBUTES_SR_STATE, UniversalTag.SEQUENCE.getValue(),
            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Pop and end allowed" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
                {
                    container.setGrammarEndAllowed( true );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributesSR to PartialAttributesList
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= SEQUENCE OF *SEQUENCE* {
        // ...
        //
        // nothing to do
        super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE,
            UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributesSR to Controls
        // --------------------------------------------------------------------------------------------
        //     searchResultEntry SearchResultEntry,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Initialize the controls
        super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from PartialAttributesList to typeSR
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     type  AttributeDescription,
        //     ...
        //
        // Store the attribute's name.
        super.transitions[LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE, LdapStatesEnum.TYPE_SR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
            {
                public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
                {
                    SearchResultEntryDecorator searchResultEntry = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    String type = "";

                    // Store the name
                    if ( tlv.getLength() == 0 )
                    {
                        // The type can't be null
                        String msg = I18n.err( I18n.ERR_04081 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }
                    else
                    {
                        type = getType(tlv.getValue().getData());

                        try
                        {
                            searchResultEntry.addAttribute( type );
                        }
                        catch ( LdapException ine )
                        {
                            // This is for the client side. We will never decode LdapResult on the server
                            String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
                            LOG.error( "{} : {}", msg, ine.getMessage() );
                            throw new DecoderException( msg, ine );
                        }
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Attribute type : {}", type );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from typeSR to ValsSR
        // --------------------------------------------------------------------------------------------
        // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
        // ...
        // attributes PartialAttributeList }
        //
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // We may have no value. Just allows the grammar to end
        super.transitions[LdapStatesEnum.TYPE_SR_STATE.ordinal()][UniversalTag.SET.getValue()] = new GrammarTransition(
            LdapStatesEnum.TYPE_SR_STATE, LdapStatesEnum.VALS_SR_STATE, UniversalTag.SET.getValue(),
            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Grammar end allowed" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
                {
                    container.setGrammarEndAllowed( true );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from ValsSR to AttributeValueSR
        // --------------------------------------------------------------------------------------------
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Store the attribute value
        super.transitions[LdapStatesEnum.VALS_SR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALS_SR_STATE, LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE, UniversalTag.OCTET_STRING.getValue(),
            new SearchResultAttributeValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from ValsSR to PartialAttributesList
        // --------------------------------------------------------------------------------------------
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // Loop when we don't have any attribute value. Nothing to do
        super.transitions[LdapStatesEnum.VALS_SR_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALS_SR_STATE, LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from ValsSR to Controls
        // --------------------------------------------------------------------------------------------
        //     searchResultEntry SearchResultEntry,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Initialize the controls
        super.transitions[LdapStatesEnum.VALS_SR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.VALS_SR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributeValueSR to AttributeValueSR
        // --------------------------------------------------------------------------------------------
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Store the attribute value
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE, LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE,
            UniversalTag.OCTET_STRING.getValue(), new SearchResultAttributeValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributeValueSR to PartialAttributesList
        // --------------------------------------------------------------------------------------------
        // PartialAttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // Loop when we don't have any attribute value. Nothing to do
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE, LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE,
            UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from AttributeValueSR to Controls
        // --------------------------------------------------------------------------------------------
        //     searchResultEntry SearchResultEntry,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Initialize the controls
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_SR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // SearchResultDone Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... SearchResultDone ...
        // SearchResultDone ::= [APPLICATION 5] SEQUENCE { ...
        //
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.SEARCH_RESULT_DONE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.SEARCH_RESULT_DONE_STATE,
            LdapConstants.SEARCH_RESULT_DONE_TAG, new GrammarAction<LdapMessageContainer<SearchResultDoneDecorator>>( "Init search Result Done" )
            {
                public void action( LdapMessageContainer<SearchResultDoneDecorator> container )
                {
                    // Now, we can allocate the SearchResultDone Object
                    SearchResultDoneDecorator searchResultDone = new SearchResultDoneDecorator(
                        container.getLdapCodecService(), new SearchResultDoneImpl( container.getMessageId() ) );
                    container.setMessage( searchResultDone );

                    LOG.debug( "Search Result Done found" );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // SearchResultDone Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... SearchResultDone ...
        // SearchResultDone ::= [APPLICATION 5] LDAPResult
        //
        // LDAPResult ::= SEQUENCE {
        //     resultCode    ENUMERATED {
        //         ...
        //
        // Stores the result code
        super.transitions[LdapStatesEnum.SEARCH_RESULT_DONE_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
            LdapStatesEnum.SEARCH_RESULT_DONE_STATE, LdapStatesEnum.RESULT_CODE_STATE, UniversalTag.ENUMERATED.getValue(),
            new ResultCodeAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Message ID to ModifyRequest Message
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... ModifyRequest ...
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE { ...
        //
        // Creates the Modify Request object
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.MODIFY_REQUEST_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.MODIFY_REQUEST_STATE, LdapConstants.MODIFY_REQUEST_TAG,
            new GrammarAction<LdapMessageContainer<ModifyRequestDecorator>>( "Init ModifyRequest" )
            {
                public void action( LdapMessageContainer<ModifyRequestDecorator> container )
                {
                    // Now, we can allocate the ModifyRequest Object
                    ModifyRequest modifyRequest = new ModifyRequestImpl( container.getMessageId() );
                    ModifyRequestDecorator modifyRequestDecorator = new ModifyRequestDecorator(
                        container.getLdapCodecService(), modifyRequest );
                    container.setMessage( modifyRequestDecorator );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from ModifyRequest Message to Object
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     object    LDAPDN,
        //     ...
        //
        // Stores the object Dn
        super.transitions[LdapStatesEnum.MODIFY_REQUEST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.MODIFY_REQUEST_STATE, LdapStatesEnum.OBJECT_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<ModifyRequestDecorator>>( "Store Modify request object Value" )
            {
                public void action( LdapMessageContainer<ModifyRequestDecorator> container ) throws DecoderException
                {
                    ModifyRequestDecorator modifyRequestDecorator = container.getMessage();
                    ModifyRequest modifyRequest = modifyRequestDecorator.getDecorated();

                    TLV tlv = container.getCurrentTLV();

                    Dn object = Dn.EMPTY_DN;

                    // Store the value.
                    if ( tlv.getLength() == 0 )
                    {
                        ((ModifyRequest)modifyRequestDecorator.getDecorated()).setName( object );
                    }
                    else
                    {
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

                        try
                        {
                            object = new Dn( dnStr );
                        }
                        catch ( LdapInvalidDnException ine )
                        {
                            String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes)
                                + ") is invalid";
                            LOG.error( "{} : {}", msg, ine.getMessage() );

                            ModifyResponseImpl response = new ModifyResponseImpl( modifyRequest.getMessageId() );
                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                Dn.EMPTY_DN, ine );
                        }

                        modifyRequest.setName( object );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Modification of Dn {}", modifyRequest.getName() );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Object to modifications
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification *SEQUENCE OF* SEQUENCE {
        //     ...
        //
        // Initialize the modifications list
        super.transitions[LdapStatesEnum.OBJECT_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.OBJECT_STATE, LdapStatesEnum.MODIFICATIONS_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from modifications to modification sequence
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF *SEQUENCE* {
        //     ...
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.MODIFICATIONS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.MODIFICATIONS_STATE, LdapStatesEnum.MODIFICATIONS_SEQ_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from modification sequence to operation
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //         operation  ENUMERATED {
        //             ...
        //
        // Store operation type
        super.transitions[LdapStatesEnum.MODIFICATIONS_SEQ_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
            LdapStatesEnum.MODIFICATIONS_SEQ_STATE, LdapStatesEnum.OPERATION_STATE, UniversalTag.ENUMERATED.getValue(),
            new GrammarAction<LdapMessageContainer<ModifyRequestDecorator>>( "Store operation type" )
            {
                public void action( LdapMessageContainer<ModifyRequestDecorator> container ) throws DecoderException
                {
                    ModifyRequestDecorator modifyRequestDecorator = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    // Decode the operation type
                    int operation = 0;

                    try
                    {
                        operation = IntegerDecoder.parse( tlv.getValue(), 0, 2 );
                    }
                    catch ( IntegerDecoderException ide )
                    {
                        String msg = I18n.err( I18n.ERR_04082, Strings.dumpBytes(tlv.getValue().getData()) );
                        LOG.error( msg );

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

                    // Store the current operation.
                    modifyRequestDecorator.setCurrentOperation( operation );

                    if ( IS_DEBUG )
                    {
                        switch ( operation )
                        {
                            case LdapConstants.OPERATION_ADD:
                                LOG.debug( "Modification operation : ADD" );
                                break;

                            case LdapConstants.OPERATION_DELETE:
                                LOG.debug( "Modification operation : DELETE" );
                                break;

                            case LdapConstants.OPERATION_REPLACE:
                                LOG.debug( "Modification operation : REPLACE" );
                                break;
                        }
                    }

                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from operation to modification
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.OPERATION_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.OPERATION_STATE, LdapStatesEnum.MODIFICATION_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from modification to TypeMod
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     type AttributeDescription,
        //     ...
        //
        // Stores the type
        super.transitions[LdapStatesEnum.MODIFICATION_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.MODIFICATION_STATE, LdapStatesEnum.TYPE_MOD_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<ModifyRequestDecorator>>( "Store type" )
            {
                public void action( LdapMessageContainer<ModifyRequestDecorator> container ) throws DecoderException
                {
                    ModifyRequestDecorator modifyRequestDecorator = container.getMessage();
                    ModifyRequest modifyRequest = modifyRequestDecorator.getDecorated();

                    TLV tlv = container.getCurrentTLV();

                    // Store the value. It can't be null
                    String type = null;

                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04083 );
                        LOG.error( msg );

                        ModifyResponseImpl response = new ModifyResponseImpl( modifyRequest.getMessageId() );
                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            modifyRequest.getName(), null );
                    }
                    else
                    {
                        type = getType(tlv.getValue().getData());
                        modifyRequestDecorator.addAttributeTypeAndValues( type );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Modifying type : {}", type );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from TypeMod to vals
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // Initialize the list of values
        super.transitions[LdapStatesEnum.TYPE_MOD_STATE.ordinal()][UniversalTag.SET.getValue()] = new GrammarTransition(
            LdapStatesEnum.TYPE_MOD_STATE, LdapStatesEnum.VALS_STATE, UniversalTag.SET.getValue(),
            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Init Attribute vals" )
            {
                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container )
                {
                    TLV tlv = container.getCurrentTLV();

                    // If the length is null, we store an empty value
                    if ( tlv.getLength() == 0 )
                    {
                        LOG.debug( "No vals for this attribute" );
                    }

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

                    LOG.debug( "Some vals are to be decoded" );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from vals to Attribute Value
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Stores a value
        super.transitions[LdapStatesEnum.VALS_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALS_STATE, LdapStatesEnum.ATTRIBUTE_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ModifyAttributeValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from vals to ModificationsSeq
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF *SEQUENCE* {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.VALS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALS_STATE, LdapStatesEnum.MODIFICATIONS_SEQ_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from vals to Controls
        // --------------------------------------------------------------------------------------------
        //     modifyRequest ModifyRequest,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.VALS_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.VALS_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Attribute Value to Attribute Value
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF SEQUENCE {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Stores a value
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_STATE, LdapStatesEnum.ATTRIBUTE_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new ModifyAttributeValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Attribute Value to ModificationsSeq
        // --------------------------------------------------------------------------------------------
        // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
        //     ...
        //     modification SEQUENCE OF *SEQUENCE* {
        //             ...
        //         modification   AttributeTypeAndValues }
        //
        // AttributeTypeAndValues ::= SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue ::= OCTET STRING
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_STATE, LdapStatesEnum.MODIFICATIONS_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
            null );

        // --------------------------------------------------------------------------------------------
        // Transition from Attribute Value to Controls
        // --------------------------------------------------------------------------------------------
        //     modifyRequest ModifyRequest,
        //     ... },
        // controls   [0] Controls OPTIONAL }
        //
        // Nothing to do
        super.transitions[LdapStatesEnum.ATTRIBUTE_VALUE_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_VALUE_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // ModifyResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... ModifyResponse ...
        // ModifyResponse ::= [APPLICATION 7] SEQUENCE { ...
        // We have to switch to the ModifyResponse grammar
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.MODIFY_RESPONSE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.MODIFY_RESPONSE_STATE, LdapConstants.MODIFY_RESPONSE_TAG,
            new GrammarAction<LdapMessageContainer<ModifyResponseDecorator>>( "Init ModifyResponse" )
            {
                public void action( LdapMessageContainer<ModifyResponseDecorator> container )
                {
                    // Now, we can allocate the ModifyResponse Object
                    ModifyResponseDecorator modifyResponse = new ModifyResponseDecorator(
                        container.getLdapCodecService(), new ModifyResponseImpl( container.getMessageId() ) );
                    container.setMessage( modifyResponse );

                    LOG.debug( "Modify response" );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // ModifyResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... ModifyResponse ...
        // ModifyResponse ::= [APPLICATION 7] LDAPResult
        //
        // LDAPResult ::= SEQUENCE {
        //     resultCode    ENUMERATED {
        //         ...
        //
        // Stores the result code
        super.transitions[LdapStatesEnum.MODIFY_RESPONSE_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
            LdapStatesEnum.MODIFY_RESPONSE_STATE, LdapStatesEnum.RESULT_CODE_STATE, UniversalTag.ENUMERATED.getValue(),
            new ResultCodeAction() );

        // --------------------------------------------------------------------------------------------
        // AddRequest Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... AddRequest ...
        // AddRequest ::= [APPLICATION 8] SEQUENCE { ...
        //
        // Initialize the AddRequest object
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.ADD_REQUEST_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.ADD_REQUEST_STATE, LdapConstants.ADD_REQUEST_TAG,
            new GrammarAction<LdapMessageContainer<AddRequestDecorator>>( "Init addRequest" )
            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    // Now, we can allocate the AddRequest Object
                    int messageId = container.getMessageId();
                    AddRequestDecorator addRequest = new AddRequestDecorator(
                        container.getLdapCodecService(), new AddRequestImpl( messageId ) );
                    container.setMessage( addRequest );

                    // We will check that the request is not null
                    TLV tlv = container.getCurrentTLV();

                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04084 );
                        LOG.error( msg );

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

        // --------------------------------------------------------------------------------------------
        // Transition from Add Request to Entry
        // --------------------------------------------------------------------------------------------
        // AddRequest ::= [APPLICATION 8] SEQUENCE {
        //     entry           LDAPDN,
        //     ...
        //
        // Stores the Dn
        super.transitions[LdapStatesEnum.ADD_REQUEST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ADD_REQUEST_STATE, LdapStatesEnum.ENTRY_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<AddRequestDecorator>>( "Store add request object Value" )
            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    AddRequestDecorator addRequest = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    // Store the entry. It can't be null
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04085 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

                        // I guess that trying to add an entry which Dn is empty is a naming violation...
                        // Not 100% sure though ...
                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.NAMING_VIOLATION,
                            Dn.EMPTY_DN, null );
                    }
                    else
                    {
                        Dn entryDn = null;
                        byte[] dnBytes = tlv.getValue().getData();
                        String dnStr = Strings.utf8ToString(dnBytes);

                        try
                        {
                            entryDn = new Dn( dnStr );
                        }
                        catch ( LdapInvalidDnException ine )
                        {
                            String msg = "Invalid Dn given : " + dnStr + " (" + Strings.dumpBytes(dnBytes)
                                + ") is invalid";
                            LOG.error( "{} : {}", msg, ine.getMessage() );

                            AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
                                Dn.EMPTY_DN, ine );
                        }

                        addRequest.setEntryDn( entryDn );
                    }

                    LOG.debug( "Adding an entry with Dn : {}", addRequest.getEntry() );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from Entry to Attributes
        // --------------------------------------------------------------------------------------------
        // AddRequest ::= [APPLICATION 8] SEQUENCE {
        //     ...
        //    attributes AttributeList }
        //
        // AttributeList ::= SEQUENCE OF ...
        //
        // Initialize the attribute list
        super.transitions[LdapStatesEnum.ENTRY_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ENTRY_STATE, LdapStatesEnum.ATTRIBUTES_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from Attributes to Attribute
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //
        // We don't do anything in this transition. The attribute will be created when we met the type
        super.transitions[LdapStatesEnum.ATTRIBUTES_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTES_STATE, LdapStatesEnum.ATTRIBUTE_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from Attribute to type
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //     type    AttributeDescription,
        //     ...
        //
        // AttributeDescription LDAPString
        //
        // We store the type in the current attribute
        super.transitions[LdapStatesEnum.ATTRIBUTE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.ATTRIBUTE_STATE, LdapStatesEnum.TYPE_STATE, UniversalTag.OCTET_STRING.getValue(),
            new GrammarAction<LdapMessageContainer<AddRequestDecorator>>( "Store attribute type" )
            {
                public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
                {
                    AddRequestDecorator addRequest = container.getMessage();

                    TLV tlv = container.getCurrentTLV();

                    // Store the type. It can't be null.
                    if ( tlv.getLength() == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04086 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );

                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            addRequest.getEntry().getDn(), null );
                    }

                    String type = getType(tlv.getValue().getData());

                    try
                    {
                        addRequest.addAttributeType( type );
                    }
                    catch ( LdapException ne )
                    {
                        String msg = I18n.err( I18n.ERR_04087 );
                        LOG.error( msg );

                        AddResponseImpl response = new AddResponseImpl( addRequest.getMessageId() );
                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
                            addRequest.getEntry().getDn(), ne );
                    }

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Adding type {}", type );
                    }
                }
            } );

        // --------------------------------------------------------------------------------------------
        // Transition from type to vals
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // Nothing to do here.
        super.transitions[LdapStatesEnum.TYPE_STATE.ordinal()][UniversalTag.SET.getValue()] = new GrammarTransition(
            LdapStatesEnum.TYPE_STATE, LdapStatesEnum.VALUES_STATE, UniversalTag.SET.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from vals to Value
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue OCTET STRING
        //
        // Store the value into the current attribute
        super.transitions[LdapStatesEnum.VALUES_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALUES_STATE, LdapStatesEnum.VALUE_STATE, UniversalTag.OCTET_STRING.getValue(), new ValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Value to Value
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //     ...
        //     vals SET OF AttributeValue }
        //
        // AttributeValue OCTET STRING
        //
        // Store the value into the current attribute
        super.transitions[LdapStatesEnum.VALUE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALUE_STATE, LdapStatesEnum.VALUE_STATE, UniversalTag.OCTET_STRING.getValue(), new ValueAction() );

        // --------------------------------------------------------------------------------------------
        // Transition from Value to Attribute
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //
        // Nothing to do here.
        super.transitions[LdapStatesEnum.VALUE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
            LdapStatesEnum.VALUE_STATE, LdapStatesEnum.ATTRIBUTE_STATE, UniversalTag.SEQUENCE.getValue(), null );

        // --------------------------------------------------------------------------------------------
        // Transition from Value to Controls
        // --------------------------------------------------------------------------------------------
        // AttributeList ::= SEQUENCE OF SEQUENCE {
        //
        // Initialize the controls
        super.transitions[LdapStatesEnum.VALUE_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
            LdapStatesEnum.VALUE_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
            new ControlsInitAction() );

        // --------------------------------------------------------------------------------------------
        // AddResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... AddResponse ...
        // AddResponse ::= [APPLICATION 9] LDAPResult
        //
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.ADD_RESPONSE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.ADD_RESPONSE_STATE, LdapConstants.ADD_RESPONSE_TAG,
            new GrammarAction<LdapMessageContainer<AddResponseDecorator>>( "Init AddResponse" )
            {
                public void action( LdapMessageContainer<AddResponseDecorator> container ) throws DecoderException
                {
                    // Now, we can allocate the AddResponse Object
                    AddResponseDecorator addResponse = new AddResponseDecorator(
                        container.getLdapCodecService(), new AddResponseImpl( container.getMessageId() ) );
                    container.setMessage( addResponse );

                    // We will check that the request is not null
                    TLV tlv = container.getCurrentTLV();

                    int expectedLength = tlv.getLength();

                    if ( expectedLength == 0 )
                    {
                        String msg = I18n.err( I18n.ERR_04088 );
                        LOG.error( msg );
                        throw new DecoderException( msg );
                    }

                    LOG.debug( "Add Response" );
                }
            } );

        // --------------------------------------------------------------------------------------------
        // AddResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... AddResponse ...
        // AddResponse ::= [APPLICATION 9] LDAPResult
        //
        // LDAPResult ::= SEQUENCE {
        //     resultCode    ENUMERATED {
        //         ...
        //
        // Stores the result code
        super.transitions[LdapStatesEnum.ADD_RESPONSE_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] = new GrammarTransition(
            LdapStatesEnum.ADD_RESPONSE_STATE, LdapStatesEnum.RESULT_CODE_STATE, UniversalTag.ENUMERATED.getValue(),
            new ResultCodeAction() );

        // --------------------------------------------------------------------------------------------
        // DelResponse Message.
        // --------------------------------------------------------------------------------------------
        // LdapMessage ::= ... DelResponse ...
        // DelResponse ::= [APPLICATION 11] LDAPResult
        // We have to switch to the DelResponse grammar
        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.DEL_RESPONSE_TAG] = new GrammarTransition(
            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.DEL_RESPONSE_STATE, LdapConstants.DEL_RESPONSE_TAG,
            new GrammarAction<LdapMessageContainer<DeleteResponseDecorator>>( "Init DelResponse" )
            {
                public void action( LdapMessageContainer<DeleteResponseDecorator> container )
                {
                    // Now, we can allocate the DelResponse Object
                    DeleteResponseDecorator delResponse = new DeleteResponseDecorator(
                        container.getLdapCodecService(), new DeleteResponseImpl( container.getMessageId() ) );
                    container.setMessage( delResponse );

                    LOG.debug( "Del response " );
                }
            } );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.