directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1068496 - in /directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec: ./ actions/abandonRequest/ actions/bindRequest/ actions/delRequest/
Date Tue, 08 Feb 2011 17:58:42 GMT
Author: elecharny
Date: Tue Feb  8 17:58:41 2011
New Revision: 1068496

URL: http://svn.apache.org/viewvc?rev=1068496&view=rev
Log:
Moved some more actions in a dedicated location

Added:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/InitAbandonRequest.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitBindRequest.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreSimpleAuth.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreVersion.java
Modified:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/delRequest/InitDelRequest.java

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1068496&r1=1068495&r2=1068496&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Tue Feb  8 17:58:41 2011
@@ -68,6 +68,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.StoreReferenceAction;
 import org.apache.directory.shared.ldap.codec.actions.StoreTypeMatchingRuleAction;
 import org.apache.directory.shared.ldap.codec.actions.ValueAction;
+import org.apache.directory.shared.ldap.codec.actions.abandonRequest.InitAbandonRequest;
+import org.apache.directory.shared.ldap.codec.actions.bindRequest.InitBindRequest;
+import org.apache.directory.shared.ldap.codec.actions.bindRequest.InitSaslBind;
+import org.apache.directory.shared.ldap.codec.actions.bindRequest.StoreName;
+import org.apache.directory.shared.ldap.codec.actions.bindRequest.StoreSimpleAuth;
+import org.apache.directory.shared.ldap.codec.actions.bindRequest.StoreVersion;
 import org.apache.directory.shared.ldap.codec.actions.controls.ControlsInitAction;
 import org.apache.directory.shared.ldap.codec.actions.delRequest.InitDelRequest;
 import org.apache.directory.shared.ldap.codec.actions.ldapMessage.InitLdapMessage;
@@ -75,7 +81,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.unbindRequest.InitUnbindRequest;
 import org.apache.directory.shared.ldap.codec.api.LdapConstants;
 import org.apache.directory.shared.ldap.codec.api.ResponseCarryingException;
-import org.apache.directory.shared.ldap.codec.decorators.AbandonRequestDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.AddResponseDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
@@ -100,12 +105,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
-import org.apache.directory.shared.ldap.model.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.model.message.BindRequest;
-import org.apache.directory.shared.ldap.model.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.model.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.model.message.CompareRequest;
 import org.apache.directory.shared.ldap.model.message.CompareRequestImpl;
@@ -184,9 +187,12 @@ public final class LdapMessageGrammar<E>
         // The next state will be LDAP_MESSAGE_STATE
         //
         // We will just check that the length is not null
-        super.transitions[LdapStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition<LdapMessageContainer<MessageDecorator<? extends Message>>>(
-            LdapStatesEnum.START_STATE, LdapStatesEnum.LDAP_MESSAGE_STATE, UniversalTag.SEQUENCE.getValue(),
-            new InitLdapMessage() );
+        super.transitions[LdapStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+            new GrammarTransition<LdapMessageContainer<MessageDecorator<? extends Message>>>(
+                LdapStatesEnum.START_STATE,
+                LdapStatesEnum.LDAP_MESSAGE_STATE,
+                UniversalTag.SEQUENCE.getValue(),
+                new InitLdapMessage() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from LdapMessage to Message ID
@@ -201,9 +207,12 @@ public final class LdapMessageGrammar<E>
         //
         // The message ID will be temporarily stored in the container, because we can't store it
         // into an object.
-        super.transitions[LdapStatesEnum.LDAP_MESSAGE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
-            LdapStatesEnum.LDAP_MESSAGE_STATE, LdapStatesEnum.MESSAGE_ID_STATE, UniversalTag.INTEGER.getValue(),
-            new StoreMessageId() );
+        super.transitions[LdapStatesEnum.LDAP_MESSAGE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
+            new GrammarTransition<LdapMessageContainer<MessageDecorator<? extends Message>>>(
+                LdapStatesEnum.LDAP_MESSAGE_STATE,
+                LdapStatesEnum.MESSAGE_ID_STATE,
+                UniversalTag.INTEGER.getValue(),
+                new StoreMessageId() );
 
         // ********************************************************************************************
         // We have a ProtocolOp :
@@ -236,9 +245,12 @@ public final class LdapMessageGrammar<E>
         // --------------------------------------------------------------------------------------------
         // LdapMessage ::= ... UnBindRequest ...
         // unbindRequest ::= [APPLICATION 2] NULL
-        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.UNBIND_REQUEST_TAG] = new GrammarTransition(
-            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.UNBIND_REQUEST_STATE, LdapConstants.UNBIND_REQUEST_TAG,
-            new InitUnbindRequest() );
+        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.UNBIND_REQUEST_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.MESSAGE_ID_STATE,
+                LdapStatesEnum.UNBIND_REQUEST_STATE,
+                LdapConstants.UNBIND_REQUEST_TAG,
+                new InitUnbindRequest() );
 
         // --------------------------------------------------------------------------------------------
         // transition from UnBindRequest Message to Controls.
@@ -247,9 +259,12 @@ public final class LdapMessageGrammar<E>
         //         ... },
         //     controls       [0] Controls OPTIONAL }
         //
-        super.transitions[LdapStatesEnum.UNBIND_REQUEST_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
-            LdapStatesEnum.UNBIND_REQUEST_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
-            new ControlsInitAction() );
+        super.transitions[LdapStatesEnum.UNBIND_REQUEST_STATE.ordinal()][LdapConstants.CONTROLS_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.UNBIND_REQUEST_STATE,
+                LdapStatesEnum.CONTROLS_STATE,
+                LdapConstants.CONTROLS_TAG,
+                new ControlsInitAction() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from Message ID to DelRequest Message.
@@ -258,9 +273,12 @@ public final class LdapMessageGrammar<E>
         // delRequest ::= [APPLICATION 10] LDAPDN
         //
         // We store the Dn to bve deleted into the DelRequest object
-        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.DEL_REQUEST_TAG] = new GrammarTransition(
-            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.DEL_REQUEST_STATE, LdapConstants.DEL_REQUEST_TAG,
-            new InitDelRequest() );
+        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.DEL_REQUEST_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.MESSAGE_ID_STATE,
+                LdapStatesEnum.DEL_REQUEST_STATE,
+                LdapConstants.DEL_REQUEST_TAG,
+                new InitDelRequest() );
 
         // --------------------------------------------------------------------------------------------
         // transition from DelRequest Message to Controls.
@@ -269,9 +287,12 @@ public final class LdapMessageGrammar<E>
         //         ... },
         //     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() );
+        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.
@@ -280,59 +301,12 @@ public final class LdapMessageGrammar<E>
         // 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() );
-                    }
-                }
-            } );
+        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 InitAbandonRequest() );
 
         // --------------------------------------------------------------------------------------------
         // transition from AbandonRequest Message to Controls.
@@ -341,9 +315,12 @@ public final class LdapMessageGrammar<E>
         //         ... },
         //     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() );
+        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.
@@ -352,30 +329,12 @@ public final class LdapMessageGrammar<E>
         // 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 );
-                    }
-                }
-            } );
+        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 InitBindRequest() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from BindRequest to version
@@ -385,41 +344,12 @@ public final class LdapMessageGrammar<E>
         //     ....
         //
         // 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() );
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.BIND_REQUEST_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
+            new GrammarTransition(
+                LdapStatesEnum.BIND_REQUEST_STATE,
+                LdapStatesEnum.VERSION_STATE,
+                UniversalTag.INTEGER.getValue(),
+                new StoreVersion() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from version to name
@@ -429,52 +359,13 @@ public final class LdapMessageGrammar<E>
         //     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() );
-                    }
-                }
-            } );
+        // The Ldap name is 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 StoreName() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from name to Simple Authentication
@@ -488,38 +379,12 @@ public final class LdapMessageGrammar<E>
         //     ...
         //
         // 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()) );
-                    }
-                }
-            } );
+        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 StoreSimpleAuth() );
 
         // --------------------------------------------------------------------------------------------
         // transition from Simple Authentication to Controls.
@@ -528,9 +393,12 @@ public final class LdapMessageGrammar<E>
         //         ... },
         //     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() );
+        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
@@ -545,35 +413,12 @@ public final class LdapMessageGrammar<E>
         //     ...
         //
         // 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" );
-                    }
-                }
-            } );
+        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 InitSaslBind() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from SASL Authentication to Mechanism

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/InitAbandonRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/InitAbandonRequest.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/InitAbandonRequest.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/abandonRequest/InitAbandonRequest.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,114 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.abandonRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoder;
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoderException;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.AbandonRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.AbandonRequestImpl;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the AbandonRequest
+ * <pre>
+ * LdapMessage ::= ... AbandonRequest ...
+ * AbandonRequest ::= [APPLICATION 16] MessageID
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InitAbandonRequest extends GrammarAction<LdapMessageContainer<AbandonRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( InitAbandonRequest.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /**
+     * Instantiates a new action.
+     */
+    public InitAbandonRequest()
+    {
+        super( "Init Abandon Request" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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() );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitBindRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitBindRequest.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitBindRequest.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitBindRequest.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.bindRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.BindRequestImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the AbandonRequest
+ * <pre>
+ * LdapMessage ::= ... BindRequest ...
+ * BindRequest ::= [APPLICATION 0] SEQUENCE { ...
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InitBindRequest extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( InitBindRequest.class );
+
+    /**
+     * Instantiates a new action.
+     */
+    public InitBindRequest()
+    {
+        super( "Init BindRequest" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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 );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/InitSaslBind.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.bindRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.api.ResponseCarryingException;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.BindRequest;
+import org.apache.directory.shared.ldap.model.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the BindRequest version MessageID.
+ * <pre>
+ * BindRequest ::= [APPLICATION 0] SEQUENCE {
+ *     ....
+ *     authentication          AuthenticationChoice }
+ *
+ * AuthenticationChoice ::= CHOICE {
+ *     ...
+ *     sasl                  [3] SaslCredentials }
+ *     ...
+ *
+ * We have to create an Authentication Object to store the credentials.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InitSaslBind extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( InitSaslBind.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new action.
+     */
+    public InitSaslBind()
+    {
+        super( "Initialize Bind SASL Authentication" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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" );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreName.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.bindRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.api.ResponseCarryingException;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.message.BindRequest;
+import org.apache.directory.shared.ldap.model.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the BindRequest version MessageID.
+ * <pre>
+ * BindRequest ::= [APPLICATION 0] SEQUENCE {
+ *     ....
+ *     name                    LDAPDN,
+ *     ....
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreName extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreName.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new action.
+     */
+    public StoreName()
+    {
+        super( "Store BindRequest Name value" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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() );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreSimpleAuth.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreSimpleAuth.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreSimpleAuth.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreSimpleAuth.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.bindRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.BindRequest;
+import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the BindRequest version MessageID.
+ * <pre>
+ * BindRequest ::= [APPLICATION 0] SEQUENCE {
+ *     ....
+ *     authentication          AuthenticationChoice }
+ *
+ * AuthenticationChoice ::= CHOICE {
+ *     simple                  [0] OCTET STRING,
+ *     ...
+ *
+ * We have to create an Authentication Object to store the credentials.
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreSimpleAuth extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreSimpleAuth.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new action.
+     */
+    public StoreSimpleAuth()
+    {
+        super( "Store BindRequest Simple Authentication" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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()) );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreVersion.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreVersion.java?rev=1068496&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreVersion.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/bindRequest/StoreVersion.java Tue Feb  8 17:58:41 2011
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.bindRequest;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoder;
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoderException;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.BindRequest;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the BindRequest version MessageID.
+ * <pre>
+ * BindRequest ::= [APPLICATION 0] SEQUENCE {
+ *     version                 INTEGER (1 ..  127),
+ *     ....
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreVersion extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreVersion.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new action.
+     */
+    public StoreVersion()
+    {
+        super( "Store BindRequest Version" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    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() );
+        }
+    }
+}

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/delRequest/InitDelRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/delRequest/InitDelRequest.java?rev=1068496&r1=1068495&r2=1068496&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/delRequest/InitDelRequest.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/delRequest/InitDelRequest.java Tue Feb  8 17:58:41 2011
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * The action used to store the LdapMessage MessageID.
+ * The action used to initialize the DelRequest.
  * <pre>
  * LdapMessage ::= ... DelRequest ...
  * delRequest ::= [APPLICATION 10] LDAPDN



Mime
View raw message