You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/10/02 01:07:49 UTC

svn commit: r451836 [6/11] - in /directory/branches/shared/0.9.5/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/abandon/ main/java/org/apache/directory/shared/ldap/codec/actions/ main/java/o...

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/MatchedDNAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/MatchedDNAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/MatchedDNAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/MatchedDNAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,123 @@
+/*
+ *  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;
+
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to set the LdapResult matched DN.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MatchedDNAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( MatchedDNAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public MatchedDNAction()
+    {
+        super( "Store matched DN" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        LdapResponse response = ldapMessage.getLdapResponse();
+        LdapResult ldapResult = response.getLdapResult();
+
+        // Get the Value and store it in the BindResponse
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // DN
+        if ( tlv.getLength() == 0 )
+        {
+            ldapResult.setMatchedDN( LdapDN.EMPTY_LDAPDN );
+        }
+        else
+        {
+            // A not null matchedDN is valid for resultCodes
+            // NoSuchObject, AliasProblem, InvalidDNSyntax and
+            // AliasDreferencingProblem.
+            int resultCode = ldapResult.getResultCode();
+
+            switch ( resultCode )
+            {
+                case LdapResultEnum.NO_SUCH_OBJECT :
+                case LdapResultEnum.ALIAS_PROBLEM :
+                case LdapResultEnum.INVALID_DN_SYNTAX :
+                case LdapResultEnum.ALIAS_DEREFERENCING_PROBLEM :
+                    byte[] dnBytes = tlv.getValue().getData();
+                    
+                    try
+                    {
+                        ldapResult.setMatchedDN( new LdapDN( dnBytes ) );
+                    }
+                    catch ( InvalidNameException ine )
+                    {
+                        // This is for the client side. We will never decode LdapResult on the server
+                        String msg = "Incorrect DN given : " + StringTools.utf8ToString( dnBytes ) + 
+                            " (" + StringTools.dumpBytes( dnBytes )
+                            + ") is invalid";
+                        log.error( "{} : {}", msg, ine.getMessage() );
+                    
+                        throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                    }
+                    
+                    break;
+                    
+                default :
+                    log.warn( "The matched DN should not be set when the result code is one of NoSuchObject, AliasProblem, InvalidDNSyntax or AliasDreferencingProblem" );
+                    ldapResult.setMatchedDN( LdapDN.EMPTY_LDAPDN );
+            }
+        }
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "The matchedDN is " + ldapResult.getMatchedDN() );
+        }
+
+        return;
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ModifyAttributeValueAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ModifyAttributeValueAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ModifyAttributeValueAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ModifyAttributeValueAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,93 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.modify.ModifyRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Value to an modifyRequest
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyAttributeValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ModifyAttributeValueAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ModifyAttributeValueAction()
+    {
+        super( "Stores AttributeValue" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container )
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        ModifyRequest modifyRequest = ldapMessage.getModifyRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value. It can't be null
+        Object value = StringTools.EMPTY_BYTES;
+
+        if ( tlv.getLength() == 0 )
+        {
+            modifyRequest.addAttributeValue( "" );
+        }
+        else
+        {
+            value = tlv.getValue().getData();
+
+            if ( ldapMessageContainer.isBinary( modifyRequest.getCurrentAttributeType() ) )
+            {
+                modifyRequest.addAttributeValue( value );
+            }
+            else
+            {
+                modifyRequest.addAttributeValue( StringTools.utf8ToString( ( byte[] ) value ) );
+            }
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Value modified : {}", value );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,124 @@
+/*
+ *  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;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
+import org.apache.directory.shared.ldap.codec.util.LdapURL;
+import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to add a referral to a LdapTresult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ReferralAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ReferralAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ReferralAction()
+    {
+        super( "Add a referral" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        LdapResponse response = ldapMessage.getLdapResponse();
+        LdapResult ldapResult = response.getLdapResult();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        if ( tlv.getLength() == 0 )
+        {
+            ldapResult.addReferral( LdapURL.EMPTY_URL );
+        }
+        else
+        {
+            if ( ldapResult.getResultCode() == LdapResultEnum.REFERRAL )
+            {
+                try
+                {
+                    ldapResult.addReferral( new LdapURL( tlv.getValue().getData() ) );
+                }
+                catch ( LdapURLEncodingException luee )
+                {
+                    String badUrl = new String( tlv.getValue().getData() );
+                    log.error( "The URL " + badUrl + " is not valid : " + luee.getMessage() );
+                    throw new DecoderException( "Invalid URL : " + luee.getMessage() );
+                }
+            }
+            else
+            {
+                log.warn( "The Referral error message is not allowed when havind an error code no equals to REFERRAL" );
+                ldapResult.addReferral( LdapURL.EMPTY_URL );
+            }
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            Iterator urls = ldapResult.getReferrals().iterator();
+
+            StringBuffer sb = new StringBuffer();
+            boolean isFirst = true;
+
+            while ( urls.hasNext() )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+
+                sb.append( urls.next() );
+            }
+
+            log.debug( "The referral error message is set to " + sb.toString() );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,88 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Response to an ExtendedResponse
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResponseAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResponseAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResponseAction()
+    {
+        super( "Store response" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+
+        // We can allocate the ExtendedResponse Object
+        ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+        // Get the Value and store it in the ExtendedResponse
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // OID
+        if ( tlv.getLength() == 0 )
+        {
+            extendedResponse.setResponse( StringTools.EMPTY_BYTES );
+        }
+        else
+        {
+            extendedResponse.setResponse( tlv.getValue().getData() );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Extended value : {}", extendedResponse.getResponse() );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,90 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Response Name to an ExtendedResponse
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResponseNameAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResponseNameAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResponseNameAction()
+    {
+        super( "Store response name" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+
+        // We can allocate the ExtendedResponse Object
+        ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+        // Get the Value and store it in the ExtendedResponse
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // OID
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The name must not be null" );
+            throw new DecoderException( "The name must not be null" );
+        }
+        else
+        {
+            extendedResponse
+                .setResponseName( new OID( StringTools.asciiBytesToString( tlv.getValue().getData() ) ) );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "OID read : {}", extendedResponse.getResponseName() );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,144 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.util.IntegerDecoder;
+import org.apache.directory.shared.asn1.util.IntegerDecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to set the LdapResult result code.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResultCodeAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResultCodeAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResultCodeAction()
+    {
+        super( "Store resultCode" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage message = ldapMessageContainer.getLdapMessage();
+        LdapResponse response = message.getLdapResponse();
+        LdapResult ldapResult = new LdapResult();
+        response.setLdapResult( ldapResult );
+
+        // We don't have to allocate a LdapResult first.
+
+        // The current TLV should be a integer
+        // We get it and store it in MessageId
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        Value value = tlv.getValue();
+        int resultCode = 0;
+
+        try
+        {
+            resultCode = IntegerDecoder.parse( value, 0, 90 );
+        }
+        catch ( IntegerDecoderException ide )
+        {
+            log.error( "The result code " + StringTools.dumpBytes( value.getData() ) + " is invalid : "
+                + ide.getMessage() + ". The result code must be between (0 .. 90)" );
+
+            throw new DecoderException( ide.getMessage() );
+        }
+
+        // Treat the 'normal' cases !
+        switch ( resultCode )
+        {
+            case LdapResultEnum.SUCCESS:
+            case LdapResultEnum.OPERATIONS_ERROR:
+            case LdapResultEnum.PROTOCOL_ERROR:
+            case LdapResultEnum.TIME_LIMIT_EXCEEDED:
+            case LdapResultEnum.SIZE_LIMIT_EXCEEDED:
+            case LdapResultEnum.COMPARE_FALSE:
+            case LdapResultEnum.COMPARE_TRUE:
+            case LdapResultEnum.AUTH_METHOD_NOT_SUPPORTED:
+            case LdapResultEnum.STRONG_AUTH_REQUIRED:
+            case LdapResultEnum.REFERRAL:
+            case LdapResultEnum.ADMIN_LIMIT_EXCEEDED:
+            case LdapResultEnum.UNAVAILABLE_CRITICAL_EXTENSION:
+            case LdapResultEnum.CONFIDENTIALITY_REQUIRED:
+            case LdapResultEnum.SASL_BIND_IN_PROGRESS:
+            case LdapResultEnum.NO_SUCH_ATTRIBUTE:
+            case LdapResultEnum.UNDEFINED_ATTRIBUTE_TYPE:
+            case LdapResultEnum.INAPPROPRIATE_MATCHING:
+            case LdapResultEnum.CONSTRAINT_VIOLATION:
+            case LdapResultEnum.ATTRIBUTE_OR_VALUE_EXISTS:
+            case LdapResultEnum.INVALID_ATTRIBUTE_SYNTAX:
+            case LdapResultEnum.NO_SUCH_OBJECT:
+            case LdapResultEnum.ALIAS_PROBLEM:
+            case LdapResultEnum.INVALID_DN_SYNTAX:
+            case LdapResultEnum.ALIAS_DEREFERENCING_PROBLEM:
+            case LdapResultEnum.INAPPROPRIATE_AUTHENTICATION:
+            case LdapResultEnum.INVALID_CREDENTIALS:
+            case LdapResultEnum.INSUFFICIENT_ACCESS_RIGHTS:
+            case LdapResultEnum.BUSY:
+            case LdapResultEnum.UNAVAILABLE:
+            case LdapResultEnum.UNWILLING_TO_PERFORM:
+            case LdapResultEnum.LOOP_DETECT:
+            case LdapResultEnum.NAMING_VIOLATION:
+            case LdapResultEnum.OBJECT_CLASS_VIOLATION:
+            case LdapResultEnum.NOT_ALLOWED_ON_NON_LEAF:
+            case LdapResultEnum.NOT_ALLOWED_ON_RDN:
+            case LdapResultEnum.ENTRY_ALREADY_EXISTS:
+            case LdapResultEnum.AFFECTS_MULTIPLE_DSAS:
+                ldapResult.setResultCode( resultCode );
+                break;
+
+            default:
+                log.warn( "The resultCode " + resultCode + " is unknown." );
+                ldapResult.setResultCode( LdapResultEnum.OTHER );
+        }
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "The result code is set to " + LdapResultEnum.errorCode( resultCode ) );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,97 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Value to an search result entry
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultAttributeValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( SearchResultAttributeValueAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public SearchResultAttributeValueAction()
+    {
+        super( "Stores AttributeValue" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container )
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchResultEntry searchResultEntry = ldapMessage.getSearchResultEntry();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value
+        Object value = null;
+
+        if ( tlv.getLength() == 0 )
+        {
+            searchResultEntry.addAttributeValue( "" );
+
+            log.debug( "The attribute value is null" );
+        }
+        else
+        {
+            if ( ldapMessageContainer.isBinary( searchResultEntry.getCurrentAttributeValueType() ) )
+            {
+                value = tlv.getValue().getData();
+
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Attribute value {}", StringTools.dumpBytes( ( byte[] ) value ) );
+                }
+            }
+            else
+            {
+                value = StringTools.utf8ToString( tlv.getValue().getData() );
+
+                log.debug( "Attribute value {}", value );
+            }
+
+            searchResultEntry.addAttributeValue( value );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,87 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a SASL credentials
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ServerSASLCredsAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ServerSASLCredsAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ServerSASLCredsAction()
+    {
+        super( "Store server sasl credentials value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+
+        BindResponse bindResponseMessage = ldapMessageContainer.getLdapMessage().getBindResponse();
+
+        // Get the Value and store it in the BindRequest
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length server
+        // sasl credentials
+        if ( tlv.getLength() == 0 )
+        {
+            bindResponseMessage.setServerSaslCreds( StringTools.EMPTY_BYTES );
+        }
+        else
+        {
+            bindResponseMessage.setServerSaslCreds( tlv.getValue().getData() );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "The SASL credentials value is : {}", bindResponseMessage.getServerSaslCreds()
+                .toString() );
+        }
+
+        return;
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,86 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a any value into a substring filter
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreAnyAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreAnyAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreAnyAction()
+    {
+        super( "Store a any value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The substring any filter is empty" );
+            throw new DecoderException( "The substring any filter is empty" );
+        }
+
+        String any = new String( tlv.getValue().getData() );
+        substringFilter.addAnySubstrings( any );
+
+        // We now have to get back to the nearest filter which is
+        // not terminal.
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a any substring : {}", any );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,86 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a final value into a substring filter
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreFinalAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreFinalAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreFinalAction()
+    {
+        super( "Store a final value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The substring final filter is empty" );
+            throw new DecoderException( "The substring final filter is empty" );
+        }
+
+        String finalValue = new String( tlv.getValue().getData() );
+        substringFilter.setFinalSubstrings( finalValue );
+
+        // We now have to get back to the nearest filter which is
+        // not terminal.
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a any substring : {}", finalValue );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,81 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a match value
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreMatchValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreMatchValueAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreMatchValueAction()
+    {
+        super( "Store match Value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
+            .getTerminalFilter();
+        
+        String value = StringTools.utf8ToString( tlv.getValue().getData() );
+        extensibleMatchFilter.setMatchValue( value );
+
+        // unstack the filters if needed
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a match value : {}", value );
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,101 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+import org.apache.directory.shared.ldap.codec.util.LdapURL;
+import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a reference into a searchResultReference
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreReferenceAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreReferenceAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreReferenceAction()
+    {
+        super( "Store a reference" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+
+        SearchResultReference searchResultReference = ldapMessageContainer.getLdapMessage()
+            .getSearchResultReference();
+
+        // Get the Value and store it in the BindRequest
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length server
+        // sasl credentials
+        LdapURL url = LdapURL.EMPTY_URL;
+
+        if ( tlv.getLength() == 0 )
+        {
+            searchResultReference.addSearchResultReference( url );
+        }
+        else
+        {
+            try
+            {
+                url = new LdapURL( tlv.getValue().getData() );
+                searchResultReference.addSearchResultReference( url );
+            }
+            catch ( LdapURLEncodingException luee )
+            {
+                String badUrl = new String( tlv.getValue().getData() );
+                log.error( "The URL {} is not valid : {}", badUrl, luee.getMessage() );
+                throw new DecoderException( "Invalid URL : " + luee.getMessage() );
+            }
+        }
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Search reference URL found : {}", url );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        return;
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,85 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a type matching rule
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreTypeMatchingRuleAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreTypeMatchingRuleAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreTypeMatchingRuleAction()
+    {
+        super( "Store matching type Value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The type cannot be null in a MacthingRuleAssertion" );
+            throw new DecoderException( "The type cannot be null in a MacthingRuleAssertion" );
+        }
+        else
+        {
+            // Store the value.
+            ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
+                .getTerminalFilter();
+
+            String type = new String( tlv.getValue().getData() );
+            extensibleMatchFilter.setType( type );
+
+            if ( IS_DEBUG )
+            {
+                log.debug( "Stored a type matching rule : {}", type );
+            }
+        }
+    }
+}

Added: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java?view=auto&rev=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java (added)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java Sun Oct  1 16:07:44 2006
@@ -0,0 +1,96 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Value to an AddRequest
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ValueAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ValueAction()
+    {
+        super( "Store a value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container )
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        AddRequest addRequest = ldapMessage.getAddRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value. It can't be null
+        Object value = null;
+
+        if ( tlv.getLength() == 0 )
+        {
+            addRequest.addAttributeValue( "" );
+        }
+        else
+        {
+            if ( ldapMessageContainer.isBinary( addRequest.getCurrentAttributeType() ) )
+            {
+                value = tlv.getValue().getData();
+
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Adding value {}", StringTools.dumpBytes( ( byte[] ) value ) );
+                }
+            }
+            else
+            {
+                value = StringTools.utf8ToString( tlv.getValue().getData() );
+
+                log.debug( "Adding value {}" + value );
+            }
+
+            addRequest.addAttributeValue( value );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+    }
+}

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Sun Oct  1 16:07:44 2006
@@ -20,13 +20,12 @@
 package org.apache.directory.shared.ldap.codec.add;
 
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
-import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -48,10 +47,16 @@
 
 
 /**
- * An AddRequest Message. Its syntax is : AddRequest ::= [APPLICATION 8]
- * SEQUENCE { entry LDAPDN, attributes AttributeList } AttributeList ::=
- * SEQUENCE OF SEQUENCE { type AttributeDescription, vals SET OF AttributeValue }
- * AttributeValue ::= OCTET STRING
+ * An AddRequest Message. Its syntax is : 
+ *   AddRequest ::= [APPLICATION 8] SEQUENCE {
+ *              entry           LDAPDN,
+ *              attributes      AttributeList }
+ *
+ *   AttributeList ::= SEQUENCE OF SEQUENCE {
+ *              type    AttributeDescription,
+ *              vals    SET OF AttributeValue }
+ * 
+ *   AttributeValue ::= OCTET STRING
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -136,32 +141,10 @@
         return attributes;
     }
 
-
-    /**
-     * Create a new attributeValue
-     * 
-     * @param type
-     *            The attribute's name (called 'type' in the grammar)
-     */
-    public void addAttributeType( LdapString type )
-    {
-        // do not create a new attribute if we have seen this attributeType before
-        if ( attributes.get( type.toString().toLowerCase() ) != null )
-        {
-            currentAttribute = attributes.get( type.toString().toLowerCase() );
-            return;
-        }
-        
-        // fix this to use LockableAttributeImpl(type.getString().toLowerCase())
-        currentAttribute = new BasicAttribute( type.getString().toLowerCase() );
-        attributes.put( currentAttribute );
-    }
-
     /**
      * Create a new attributeValue
      * 
-     * @param type
-     *            The attribute's name (called 'type' in the grammar)
+     * @param type The attribute's name (called 'type' in the grammar)
      */
     public void addAttributeType( String type )
     {
@@ -181,8 +164,7 @@
     /**
      * Add a new value to the current attribute
      * 
-     * @param value
-     *            The value to be added
+     * @param value The value to be added
      */
     public void addAttributeValue( Object value )
     {
@@ -204,8 +186,7 @@
     /**
      * Set the added DN.
      * 
-     * @param entry
-     *            The entry to set.
+     * @param entry The entry to set.
      */
     public void setEntry( LdapDN entry )
     {
@@ -214,19 +195,48 @@
 
 
     /**
-     * Compute the AddRequest length AddRequest : 0x68 L1 | +--> 0x04 L2 entry
-     * +--> 0x30 L3 (attributes) | +--> 0x30 L4-1 (attribute) | | | +--> 0x04
-     * L5-1 type | +--> 0x31 L6-1 (values) | | | +--> 0x04 L7-1-1 value | +-->
-     * ... | +--> 0x04 L7-1-n value | +--> 0x30 L4-2 (attribute) | | | +--> 0x04
-     * L5-2 type | +--> 0x31 L6-2 (values) | | | +--> 0x04 L7-2-1 value | +-->
-     * ... | +--> 0x04 L7-2-n value | +--> ... | +--> 0x30 L4-m (attribute) |
-     * +--> 0x04 L5-m type +--> 0x31 L6-m (values) | +--> 0x04 L7-m-1 value +-->
-     * ... +--> 0x04 L7-m-n value
+     * Compute the AddRequest length
+     * 
+     * AddRequest :
+     * 
+     * 0x68 L1
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x30 L3 (attributes)
+     *        |
+     *        +--> 0x30 L4-1 (attribute)
+     *        |     |
+     *        |     +--> 0x04 L5-1 type
+     *        |     +--> 0x31 L6-1 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-1-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-1-n value
+     *        |
+     *        +--> 0x30 L4-2 (attribute)
+     *        |     |
+     *        |     +--> 0x04 L5-2 type
+     *        |     +--> 0x31 L6-2 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-2-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-2-n value
+     *        |
+     *        +--> ...
+     *        |
+     *        +--> 0x30 L4-m (attribute)
+     *              |
+     *              +--> 0x04 L5-m type
+     *              +--> 0x31 L6-m (values)
+     *                    |
+     *                    +--> 0x04 L7-m-1 value
+     *                    +--> ...
+     *                    +--> 0x04 L7-m-n value
      */
     public int computeLength()
     {
         // The entry
-        addRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
+        addRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
 
         // The attributes sequence
         attributesLength = 0;
@@ -246,7 +256,7 @@
 
                 // Get the type length
                 int idLength = attribute.getID().getBytes().length;
-                localAttributeLength = 1 + Length.getNbBytes( idLength ) + idLength;
+                localAttributeLength = 1 + TLV.getNbBytes( idLength ) + idLength;
 
                 // The values
                 try
@@ -264,16 +274,16 @@
                             if ( value instanceof String )
                             {
                                 int valueLength = StringTools.getBytesUtf8( ( String ) value ).length;
-                                localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+                                localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
                             }
                             else
                             {
                                 int valueLength = ( ( byte[] ) value ).length;
-                                localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+                                localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
                             }
                         }
 
-                        localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength;
+                        localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                     }
 
                 }
@@ -283,17 +293,17 @@
                 }
 
                 // add the attribute length to the attributes length
-                attributesLength += 1 + Length.getNbBytes( localAttributeLength ) + localAttributeLength;
+                attributesLength += 1 + TLV.getNbBytes( localAttributeLength ) + localAttributeLength;
 
                 attributeLength.add( new Integer( localAttributeLength ) );
                 valuesLength.add( new Integer( localValuesLength ) );
             }
         }
 
-        addRequestLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength;
+        addRequestLength += 1 + TLV.getNbBytes( attributesLength ) + attributesLength;
 
         // Return the result.
-        int result = 1 + Length.getNbBytes( addRequestLength ) + addRequestLength;
+        int result = 1 + TLV.getNbBytes( addRequestLength ) + addRequestLength;
 
         if ( IS_DEBUG )
         {
@@ -305,15 +315,28 @@
 
 
     /**
-     * Encode the AddRequest message to a PDU. AddRequest : 0x68 LL 0x04 LL
-     * entry 0x30 LL attributesList 0x30 LL attributeList 0x04 LL
-     * attributeDescription 0x31 LL attributeValues 0x04 LL attributeValue ...
-     * 0x04 LL attributeValue ... 0x30 LL attributeList 0x04 LL
-     * attributeDescription 0x31 LL attributeValue 0x04 LL attributeValue ...
-     * 0x04 LL attributeValue
+     * Encode the AddRequest message to a PDU. 
+     * 
+     * AddRequest :
+     * 
+     * 0x68 LL
+     *   0x04 LL entry
+     *   0x30 LL attributesList
+     *     0x30 LL attributeList
+     *       0x04 LL attributeDescription
+     *       0x31 LL attributeValues
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue
+     *     ... 
+     *     0x30 LL attributeList
+     *       0x04 LL attributeDescription
+     *       0x31 LL attributeValue
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue 
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -327,14 +350,14 @@
         {
             // The AddRequest Tag
             buffer.put( LdapConstants.ADD_REQUEST_TAG );
-            buffer.put( Length.getBytes( addRequestLength ) );
+            buffer.put( TLV.getBytes( addRequestLength ) );
 
             // The entry
             Value.encode( buffer, LdapDN.getBytes( entry ) );
 
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );
-            buffer.put( Length.getBytes( attributesLength ) );
+            buffer.put( TLV.getBytes( attributesLength ) );
 
             // The partial attribute list
             if ( ( attributes != null ) && ( attributes.size() != 0 ) )
@@ -350,7 +373,7 @@
                     // The attributes list sequence
                     buffer.put( UniversalTag.SEQUENCE_TAG );
                     int localAttributeLength = ( ( Integer ) attributeLength.get( attributeNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localAttributeLength ) );
+                    buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
                     Value.encode( buffer, attribute.getID() );
@@ -358,7 +381,7 @@
                     // The values
                     buffer.put( UniversalTag.SET_TAG );
                     int localValuesLength = ( ( Integer ) valuesLength.get( attributeNumber ) ).intValue();
-                    buffer.put( Length.getBytes( localValuesLength ) );
+                    buffer.put( TLV.getBytes( localValuesLength ) );
 
                     try
                     {

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java Sun Oct  1 16:07:44 2006
@@ -23,15 +23,16 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 
 
 /**
- * An AddResponse Message. Its syntax is : AddResponse ::= [APPLICATION 9]
- * LDAPResult
+ * An AddResponse Message. Its syntax is : 
+ * 
+ * AddResponse ::= [APPLICATION 9] LDAPResult
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -64,22 +65,30 @@
 
 
     /**
-     * Compute the AddResponse length AddResponse : 0x69 L1 | +--> LdapResult L1 =
-     * Length(LdapResult) Length(AddResponse) = Length(0x69) + Length(L1) + L1
+     * Compute the AddResponse length 
+     * 
+     * AddResponse : 
+     * 
+     * 0x69 L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(AddResponse) = Length(0x69) + Length(L1) + L1
      */
     public int computeLength()
     {
         int ldapResponseLength = super.computeLength();
 
-        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+        return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength;
     }
 
 
     /**
      * Encode the AddResponse message to a PDU.
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -93,7 +102,7 @@
         {
             // The tag
             buffer.put( LdapConstants.ADD_RESPONSE_TAG );
-            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+            buffer.put( TLV.getBytes( getLdapResponseLength() ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java Sun Oct  1 16:07:44 2006
@@ -23,7 +23,7 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
@@ -55,10 +55,6 @@
     /** The bind request length */
     private transient int bindRequestLength;
 
-
-    // ~ Constructors
-    // -------------------------------------------------------------------------------
-
     /**
      * Creates a new BindRequest object.
      */
@@ -67,10 +63,6 @@
         super();
     }
 
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
      * Get the message type
      * 
@@ -118,8 +110,7 @@
     /**
      * Set the user authentication
      * 
-     * @param authentication
-     *            The user authentication
+     * @param authentication The user authentication
      */
     public void setAuthentication( LdapAuthentication authentication )
     {
@@ -141,8 +132,7 @@
     /**
      * Set the user name
      * 
-     * @param name
-     *            The user name
+     * @param name The user name
      */
     public void setName( LdapDN name )
     {
@@ -175,8 +165,7 @@
     /**
      * Set the protocol version
      * 
-     * @param version
-     *            The protocol version
+     * @param version The protocol version
      */
     public void setVersion( int version )
     {
@@ -185,34 +174,48 @@
 
 
     /**
-     * Compute the BindRequest length BindRequest : 0x60 L1 | +--> 0x02 0x01
-     * (1..127) version +--> 0x04 L2 name +--> authentication L2 = Length(name)
-     * L3/4 = Length(authentication) Length(BindRequest) = Length(0x60) +
-     * Length(L1) + L1 + Length(0x02) + 1 + 1 + Length(0x04) + Length(L2) + L2 +
-     * Length(authentication)
+     * Compute the BindRequest length 
+     * 
+     * BindRequest : 
+     * 0x60 L1 
+     *   | 
+     *   +--> 0x02 0x01 (1..127) version 
+     *   +--> 0x04 L2 name 
+     *   +--> authentication 
+     *   
+     * L2 = Length(name)
+     * L3/4 = Length(authentication) 
+     * Length(BindRequest) = Length(0x60) + Length(L1) + L1 + Length(0x02) + 1 + 1 + 
+     *      Length(0x04) + Length(L2) + L2 + Length(authentication)
      */
     public int computeLength()
     {
         bindRequestLength = 1 + 1 + 1; // Initialized with version
 
         // The name
-        bindRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( name ) ) + LdapDN.getNbBytes( name );
+        bindRequestLength += 1 + TLV.getNbBytes( LdapDN.getNbBytes( name ) ) + LdapDN.getNbBytes( name );
 
         // The authentication
         bindRequestLength += authentication.computeLength();
 
         // Return the result.
-        return 1 + Length.getNbBytes( bindRequestLength ) + bindRequestLength;
+        return 1 + TLV.getNbBytes( bindRequestLength ) + bindRequestLength;
     }
 
 
     /**
-     * Encode the BindRequest message to a PDU. BindRequest : 0x60 LL 0x02 LL
-     * version 0x04 LL name authentication.encode() 0x80 LL simple / \ 0x83 LL
-     * mechanism [0x04 LL credential]
+     * Encode the BindRequest message to a PDU. 
+     * 
+     * BindRequest : 
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * 0x60 LL 
+     *   0x02 LL version         0x80 LL simple 
+     *   0x04 LL name           /   
+     *   authentication.encode() 
+     *                          \ 0x83 LL mechanism [0x04 LL credential]
+     * 
+     * 
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -226,7 +229,7 @@
         {
             // The BindRequest Tag
             buffer.put( LdapConstants.BIND_REQUEST_TAG );
-            buffer.put( Length.getBytes( bindRequestLength ) );
+            buffer.put( TLV.getBytes( bindRequestLength ) );
 
         }
         catch ( BufferOverflowException boe )
@@ -280,4 +283,62 @@
 
         return sb.toString();
     }
+
+    /* Used only for test perfs
+    public static void main( String[] args ) throws Exception
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x52 );
+        stream.put( new byte[]
+             { 
+             0x30, 0x50,                 // LDAPMessage ::=SEQUENCE {
+               0x02, 0x01, 0x01,         // messageID MessageID
+               0x60, 0x2E,               // CHOICE { ..., bindRequest BindRequest, ...
+                                         // BindRequest ::= APPLICATION[0] SEQUENCE {
+                 0x02, 0x01, 0x03,       // version INTEGER (1..127),
+                 0x04, 0x1F,             // name LDAPDN,
+                 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+                 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 
+                 ( byte ) 0x80, 0x08,    // authentication AuthenticationChoice
+                                         // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING,
+                                         // ...
+                   'p', 'a', 's', 's', 'w', 'o', 'r', 'd', 
+               ( byte ) 0xA0, 0x1B, // A control
+                 0x30, 0x19, 
+                   0x04, 0x17, 
+                     0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31, 0x33, 0x37, 0x33, 
+                     0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 
+             } );
+
+        stream.flip();
+
+        // Allocate a LdapMessage Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode the BindRequest PDU
+        try
+        {
+            long t0 = System.currentTimeMillis();
+            for ( int i = 0; i < 10000000; i++ )
+            {
+                ldapDecoder.decode( stream, ldapMessageContainer );
+                ( ( LdapMessageContainer ) ldapMessageContainer).clean();
+                stream.flip();
+            }
+            long t1 = System.currentTimeMillis();
+            System.out.println( "Delta = " + ( t1 - t0 ) );
+            
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+        }
+        catch ( NamingException ne )
+        {
+            ne.printStackTrace();
+        }
+    }
+    */
 }

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java?view=diff&rev=451836&r1=451835&r2=451836
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java Sun Oct  1 16:07:44 2006
@@ -23,16 +23,21 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
-import org.apache.directory.shared.asn1.ber.tlv.Length;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapResponse;
 
 
 /**
- * A BindResponse Message. Its syntax is : BindResponse ::= [APPLICATION 1]
- * SEQUENCE { COMPONENTS OF LDAPResult, serverSaslCreds [7] OCTET STRING
- * OPTIONAL } LdapResult ::= resultCode matchedDN errorMessage (referrals)*
+ * A BindResponse Message. 
+ * 
+ * Its syntax is : 
+ * BindResponse ::= [APPLICATION 1] SEQUENCE { 
+ *   COMPONENTS OF LDAPResult, 
+ *   serverSaslCreds [7] OCTET STRING OPTIONAL } 
+ *   
+ * LdapResult ::= resultCode matchedDN errorMessage (referrals)*
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -86,8 +91,7 @@
     /**
      * Set the server sasl credentials
      * 
-     * @param serverSaslCreds
-     *            The serverSaslCreds to set.
+     * @param serverSaslCreds The serverSaslCreds to set.
      */
     public void setServerSaslCreds( byte[] serverSaslCreds )
     {
@@ -96,10 +100,16 @@
 
 
     /**
-     * Compute the BindResponse length BindResponse : 0x61 L1 | +--> LdapResult
-     * +--> [serverSaslCreds] L1 = Length(LdapResult) [ +
-     * Length(serverSaslCreds) ] Length(BindResponse) = Length(0x61) +
-     * Length(L1) + L1
+     * Compute the BindResponse length 
+     * 
+     * BindResponse : 
+     * 0x61 L1 
+     *   | 
+     *   +--> LdapResult
+     *   +--> [serverSaslCreds] 
+     *   
+     * L1 = Length(LdapResult) [ + Length(serverSaslCreds) ] 
+     * Length(BindResponse) = Length(0x61) + Length(L1) + L1
      */
     public int computeLength()
     {
@@ -109,11 +119,11 @@
 
         if ( serverSaslCreds != null )
         {
-            bindResponseLength += 1 + Length.getNbBytes( ( ( byte[] ) serverSaslCreds ).length )
+            bindResponseLength += 1 + TLV.getNbBytes( ( ( byte[] ) serverSaslCreds ).length )
                 + ( ( byte[] ) serverSaslCreds ).length;
         }
 
-        return 1 + Length.getNbBytes( bindResponseLength ) + bindResponseLength;
+        return 1 + TLV.getNbBytes( bindResponseLength ) + bindResponseLength;
     }
 
 
@@ -121,8 +131,7 @@
      * Encode the BindResponse message to a PDU. BindResponse :
      * LdapResult.encode [0x87 LL serverSaslCreds]
      * 
-     * @param buffer
-     *            The buffer where to put the PDU
+     * @param buffer The buffer where to put the PDU
      * @return The PDU.
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
@@ -136,7 +145,7 @@
         {
             // The BindResponse Tag
             buffer.put( LdapConstants.BIND_RESPONSE_TAG );
-            buffer.put( Length.getBytes( bindResponseLength ) );
+            buffer.put( TLV.getBytes( bindResponseLength ) );
 
             // The LdapResult
             super.encode( buffer );
@@ -146,7 +155,7 @@
             {
                 buffer.put( ( byte ) LdapConstants.SERVER_SASL_CREDENTIAL_TAG );
 
-                buffer.put( Length.getBytes( ( ( byte[] ) serverSaslCreds ).length ) );
+                buffer.put( TLV.getBytes( ( ( byte[] ) serverSaslCreds ).length ) );
 
                 if ( ( ( byte[] ) serverSaslCreds ).length != 0 )
                 {