directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r307431 [1/2] - /directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/
Date Sun, 09 Oct 2005 13:51:27 GMT
Author: elecharny
Date: Sun Oct  9 06:51:08 2005
New Revision: 307431

URL: http://svn.apache.org/viewcvs?rev=307431&view=rev
Log:
- suppressed the warning messages produced by the unused logger
- added some logs in each method
- fixed some doco
- fixed the code accordingly to the primitives and asn1 modifications

Modified:
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyResponseGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultDoneGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -25,6 +25,8 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.pojo.AbandonRequest;
@@ -63,7 +65,7 @@
 
         statesEnum = LdapStatesEnum.getInstance();
 
-        // The transitions table
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ABANDON_REQUEST_STATE][256];
 
         //--------------------------------------------------------------------------------------------
@@ -99,16 +101,10 @@
 
                         Value value     = tlv.getValue();
 
-                        int   abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
-
-                        if ( ( abandonnedMessageId < 0 ) || ( abandonnedMessageId > Integer.MAX_VALUE ) )
-                        {
-                            throw new DecoderException(
-                                "The message ID must be between (0 .. 2 147 483 647)" );
-                        }
-                        else
+                        try
                         {
-
+                            int   abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+    
                             // Ok, the Message ID is correct. We have to store it
                             // in the AbandonRequest object
                             // Object in the LDAPMessage
@@ -116,11 +112,22 @@
                             abandonRequest.setAbandonedMessageId( abandonnedMessageId );
                             ldapMessage.setProtocolOP( abandonRequest );
 
+                            if ( log.isDebugEnabled() )
+                            {
+                                log.debug( "AbandonMessage Id has been decoded : " + abandonnedMessageId );
+                            }
+
                             return;
                         }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error("The Abandonned Message Id " + StringUtils.dumpBytes( value.getData() ) + 
+                                        " is invalid : " + ide.getMessage() + ". The message ID must be between (0 .. 2 147 483 647)" );
+                            
+                            throw new DecoderException( ide.getMessage() );
+                        }
                     }
                 } );
-
     }
 
     //~ Methods ------------------------------------------------------------------------------------

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -25,10 +27,12 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
 import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.pojo.AddRequest;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.slf4j.Logger;
@@ -61,7 +65,7 @@
         name       = AddRequestGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ADD_REQUEST_STATE][256];
 
         //============================================================================================
@@ -129,8 +133,21 @@
                         }
                         else
                         {
-                            addRequest.setEntry( new LdapDN(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                addRequest.setEntry( new LdapDN(
+                                        tlv.getValue().getData() ) );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The DN is invalid : " + StringUtils.dumpBytes(tlv.getValue().getData()) + " : " + ine.getMessage() );
+                                throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Adding an entry with DN : " + addRequest.getEntry() );
                         }
                     }
                 } );
@@ -224,14 +241,31 @@
                         AddRequest           addRequest           = ldapMessage.getAddRequest();
 
                         // Store the type. It can't be null.
+                        LdapString type = null;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
+                            log.error( "Null types are not allowed" );
                             throw new DecoderException( "The type can't be null" );
                         }
                         else
                         {
-                            addRequest.addAttributeType( new LdapString(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                type = new LdapString( tlv.getValue().getData() );
+                                
+                                addRequest.addAttributeType( type );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "The type is invalid : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + lsee.getMessage() );
+                                throw new DecoderException( "Invalid attribute type : " + lsee.getMessage() );
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Adding type " + type );
                         }
                     }
                 } );
@@ -296,14 +330,21 @@
                             ldapMessageContainer.getCurrentTLV();
 
                         // Store the value. It can't be null
+                        OctetString value = OctetString.EMPTY_STRING;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            addRequest.addAttributeValue( OctetString.EMPTY_STRING );
+                            addRequest.addAttributeValue( value );
                         }
                         else
                         {
-                            addRequest.addAttributeValue( new OctetString(
-                                    tlv.getValue().getData() ) );
+                            value = new OctetString( tlv.getValue().getData() );
+                            addRequest.addAttributeValue( value );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Adding value " + value );
                         }
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -58,7 +58,7 @@
         name = AddResponseGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ADD_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -98,6 +98,11 @@
 
                         // And we associate it to the ldapMessage Object
                         ldapMessage.setProtocolOP( addResponse );
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Add Response" );
+                        }
                     }
                 } );
 

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -26,11 +28,14 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.primitives.OctetString;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
 import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.pojo.BindRequest;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.SaslCredentials;
@@ -81,7 +86,7 @@
         
         statesEnum = LdapStatesEnum.getInstance();
 
-        // We have 17 differents states, so 16 transitions between states.
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_BIND_REQUEST_STATE][256];
 
         //============================================================================================
@@ -138,9 +143,31 @@
 
                         Value value   = tlv.getValue();
 
-                        int   version = IntegerDecoder.parse( value, 1, 127 );
-
-                        bindRequestMessage.setVersion( version );
+                        try
+                        {
+                            int   version = IntegerDecoder.parse( value, 1, 127 );
+    
+                            if ( version != 3 )
+                            {
+                                log.error("The version " + version + " is invalid : it must be 3" );
+                            
+                                throw new DecoderException( "Ldap Version " + version + " is not supported" );
+                            }
+                            
+                            if ( log.isDebugEnabled() )
+                            {
+                                log.debug( "Ldap version " + version );
+                            }
+                            
+                            bindRequestMessage.setVersion( version );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error("The version " + StringUtils.dumpBytes( value.getData() ) + 
+                                    " is invalid : " + ide.getMessage() + ". The version must be between (0 .. 127)" );
+                        
+                            throw new DecoderException( ide.getMessage() );
+                        }
 
                         return;
                     }
@@ -174,13 +201,26 @@
                         // We have to handle the special case of a 0 length name
                         if (tlv.getLength().getLength() == 0)
                         {
-                            bindRequestMessage.setName( LdapDN.EMPTY_STRING );
+                            bindRequestMessage.setName( LdapDN.EMPTY_LDAPDN );
                         }
                         else
                         {
-                            bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+                            try
+                            {
+                                bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "Incorrect DN given : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + ine.getMessage() );
+                                throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                            }
                         }
                         
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( " The Bind name is " + bindRequestMessage.getName() );
+                        }
+
                         return;
                     }
                 } );
@@ -233,6 +273,11 @@
                         {
                             authentication.setSimple( new OctetString( tlv.getValue().getData() ) );
                         }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The simple authentication is : " + authentication.getSimple() );
+                        }
                     }
                 } );
 
@@ -288,7 +333,20 @@
                         }
                         else
                         {
-                            authentication.setMechanism( new LdapString(tlv.getValue().getData() ) );
+                            try
+                            {
+                                authentication.setMechanism( new LdapString(tlv.getValue().getData() ) );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "Invalid mechanism : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + lsee.getMessage() );
+                                throw new DecoderException( lsee.getMessage() );
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The mechanism is : " + authentication.getMechanism() );
                         }
 
                         return;
@@ -354,6 +412,11 @@
                         else
                         {
                             credentials.setCredentials( new OctetString( tlv.getValue().getData() ) );
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The credentials are : " + credentials.getCredentials() );
                         }
 
                         return;

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -61,7 +61,7 @@
         name       = BindResponseGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Initialisation of the transitions table
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_BIND_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -163,6 +163,11 @@
                         else
                         {
                             bindResponseMessage.setServerSaslCreds( new OctetString( tlv.getValue().getData() ) );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The SASL credentials value is : " + bindResponseMessage.getServerSaslCreds().toString() );
                         }
                         
                         return;

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -25,10 +27,12 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
 import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.pojo.CompareRequest;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.slf4j.Logger;
@@ -63,6 +67,7 @@
         name              = CompareRequestGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_COMPARE_REQUEST_STATE][256];
 
         //============================================================================================
@@ -122,6 +127,7 @@
 
                         // Get the Value and store it in the CompareRequest
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
+                        LdapDN entry = null;
 
                         // We have to handle the special case of a 0 length matched DN
                         if ( tlv.getLength().getLength() == 0 )
@@ -130,7 +136,21 @@
                         }
                         else
                         {
-                            compareRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+                            try
+                            {
+                                entry = new LdapDN( tlv.getValue().getData() );
+                                compareRequest.setEntry( entry );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The DN to compare  (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid DN " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Comparing DN " + entry );
                         }
                     }
                 } );
@@ -190,7 +210,21 @@
                         }
                         else
                         {
-                            compareRequest.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                            try
+                            {
+                                compareRequest.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "The attribute description (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid attribute description " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                                
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Comparing attribute description " + compareRequest.getAttributeDesc() );
                         }
                     }
                 } );
@@ -234,6 +268,11 @@
                         else
                         {
                             compareRequest.setAssertionValue( new OctetString( tlv.getValue().getData() ) );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Comparing attribute value " + compareRequest.getAssertionValue() );
                         }
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -57,7 +57,7 @@
         name = CompareResponseGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_COMPARE_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -88,6 +88,11 @@
                         // Now, we can allocate the CompareResponse Object
                         // And we associate it to the ldapMessage Object
                         ldapMessage.setProtocolOP( new CompareResponse() );
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Compare response " );
+                        }
                     }
                 } );
 

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -28,6 +30,7 @@
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
 import org.apache.asn1new.ldap.pojo.DelRequest;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.apache.asn1new.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,6 +63,7 @@
         name              = DelRequestGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_DEL_REQUEST_STATE][256];
 
         //============================================================================================
@@ -93,17 +97,33 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
+                        LdapDN entry = null;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             throw new DecoderException( "The entry must not be null" );
                         }
                         else
                         {
-                            delRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+                            try
+                            {
+                                entry = new LdapDN( tlv.getValue().getData() );
+                                delRequest.setEntry( entry );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The DN to delete  (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid DN " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            }
                         }
 
                         // then we associate it to the ldapMessage Object
                         ldapMessage.setProtocolOP( delRequest );
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Deleting DN " + entry );
+                        }
                     }
                 } );
 

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -57,7 +57,7 @@
         name = DelResponseGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_DEL_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -89,6 +89,11 @@
 
                         // And we associate it to the ldapMessage Object
                         ldapMessage.setProtocolOP( new DelResponse() );
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Del response " );
+                        }
                     }
                 } );
 

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -62,6 +62,7 @@
         name              = ExtendedRequestGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_EXTENDED_REQUEST_STATE][256];
 
         //============================================================================================
@@ -125,12 +126,18 @@
                         // We have to handle the special case of a 0 length matched OID
                         if ( tlv.getLength().getLength() == 0 )
                         {
+                            log.error( "The name must not be null");
                             throw new DecoderException( "The name must not be null" );
                         }
                         else
                         {
                             extendedRequest.setRequestName( new OID( tlv.getValue().getData() ) );
                         }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "OID read : " + extendedRequest.getRequestName() );
+                        }
                     }
                 } );
 
@@ -173,9 +180,13 @@
                         {
                             extendedRequest.setRequestValue( new OctetString( tlv.getValue().getData() ) );
                         }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Extended value : " + extendedRequest.getRequestValue() );
+                        }
                     }
                 } );
-
     }
 
     //~ Methods ------------------------------------------------------------------------------------

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -62,6 +62,7 @@
         name              = ExtendedResponseGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_EXTENDED_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -136,12 +137,18 @@
 			                // We have to handle the special case of a 0 length matched OID
 			                if ( tlv.getLength().getLength() == 0 )
 			                {
+                                log.error( "The name must not be null" );
 			                    throw new DecoderException( "The name must not be null" );
 			                }
 			                else
 			                {
 			                    extendedResponse.setResponseName( new OID( tlv.getValue().getData() ) );
 			                }
+                            
+                            if ( log.isDebugEnabled() )
+                            {
+                                log.debug( "OID read : " + extendedResponse.getResponseName() );
+                            }
 			            }
 			        } );
 
@@ -183,6 +190,11 @@
                         else
                         {
                             extendedResponse.setResponse( new OctetString( tlv.getValue().getData() ) );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Extended value : " + extendedResponse.getResponse() );
                         }
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java Sun Oct  9 06:51:08 2005
@@ -26,11 +26,12 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
-import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.primitives.OctetString;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.pojo.AttributeValueAssertion;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.SearchRequest;
@@ -75,6 +76,7 @@
         name              = FilterGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_FILTER_STATE][256];
 
         //============================================================================================
@@ -237,8 +239,6 @@
                             ldapMessageContainer.getLdapMessage();
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
                         // We can allocate the SearchRequest
                         Filter andFilter = new AndFilter();
                         
@@ -281,8 +281,6 @@
                             ldapMessageContainer.getLdapMessage();
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
                         // We can allocate the SearchRequest
                         Filter orFilter = new OrFilter();
                         
@@ -325,8 +323,6 @@
                             ldapMessageContainer.getLdapMessage();
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
                         // We can allocate the SearchRequest
                         Filter notFilter = new NotFilter();
                         
@@ -441,10 +437,18 @@
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
                         TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        LdapString attributeDesc = new LdapString(tlv.getValue().getData());
                         
                         AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc(attributeDesc);
+                        
+                        try
+                        {
+                            assertion.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The assertion description (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid assertion description " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
                         
                         AttributeValueAssertionFilter currentFilter = (AttributeValueAssertionFilter)searchRequest.getCurrentFilter();
                         currentFilter.setAssertion(assertion);
@@ -508,10 +512,18 @@
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
                         TLV tlv            = ldapMessageContainer.getCurrentTLV();
-                        LdapString attributeDesc = new LdapString(tlv.getValue().getData());
                         
                         AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc(attributeDesc);
+                        
+                        try
+                        {
+                            assertion.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The assertion value (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid assertion value " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
                         
                         AttributeValueAssertionFilter currentFilter = (AttributeValueAssertionFilter)searchRequest.getCurrentFilter();
                         currentFilter.setAssertion(assertion);
@@ -561,12 +573,19 @@
                             // No parent. This Filter will become the root.
                             //searchRequest.setCurrentFilter(presentFilter);
                             presentFilter.setParent( searchRequest );
-                            searchRequest.setFilter(presentFilter);
+                            searchRequest.setFilter( presentFilter );
                         }
 
                         // Store the value.
-                        presentFilter.setAttributeDescription(new LdapString(tlv.getValue().getData()));
-                        //searchRequest.setCurrentFilter(presentFilter);
+                        try
+                        {
+                            presentFilter.setAttributeDescription( new LdapString( tlv.getValue().getData() ) );
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "Present filter attribute description (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid present filter attribute description " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
                         
                         // We now have to get back to the nearest filter which is not terminal.
                         unstackFilters( container );
@@ -656,7 +675,16 @@
 
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        substringFilter.setType(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            substringFilter.setType(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The substring filter type (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid substring filter type " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
 
                         // We now have to get back to the nearest filter which is not terminal.
                         unstackFilters( container );
@@ -715,7 +743,16 @@
 
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        substringFilter.setInitialSubstrings(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            substringFilter.setInitialSubstrings(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The substring filter initial (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid substring filter initial " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
 
                         // We now have to get back to the nearest filter which is not terminal.
                         unstackFilters( container );
@@ -768,7 +805,16 @@
 
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        substringFilter.addAnySubstrings(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            substringFilter.addAnySubstrings(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The substring any filter (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid substring any filter " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
 
                         // We now have to get back to the nearest filter which is not terminal.
                         unstackFilters( container );
@@ -834,7 +880,16 @@
 
                         // Store the value.
                         SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
-                        substringFilter.setFinalSubstrings(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            substringFilter.setFinalSubstrings(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The substring final filter (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid substring final filter " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
 
                         // We now have to get back to the nearest filter which is not terminal.
                         unstackFilters( container );
@@ -976,8 +1031,6 @@
                             ldapMessageContainer.getLdapMessage();
                         SearchRequest searchRequest = ldapMessage.getSearchRequest();
 
-                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
-
                         // We can allocate the ExtensibleMatch Filter
                         Filter extensibleMatchFilter = new ExtensibleMatchFilter();
                         
@@ -1046,7 +1099,16 @@
 
                         // Store the value.
                         ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        extensibleMatchFilter.setMatchingRule(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            extensibleMatchFilter.setMatchingRule(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The matching rule (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid matching rule " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
                     }
                 });
                 
@@ -1087,7 +1149,16 @@
 
                         // Store the value.
                         ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
-                        extensibleMatchFilter.setType(new LdapString(tlv.getValue().getData()));
+                        
+                        try
+                        {
+                            extensibleMatchFilter.setType(new LdapString(tlv.getValue().getData()));
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "The match filter (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                            throw new DecoderException( "Invalid match filter " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
+                        }
                     }
                 });
                 
@@ -1234,8 +1305,6 @@
         LdapMessage      ldapMessage          =
             ldapMessageContainer.getLdapMessage();
         SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-        TLV tlv            = ldapMessageContainer.getCurrentTLV();
 
         // We can allocate the Attribute Value Assertion
         Filter filter = new AttributeValueAssertionFilter( filterType );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java Sun Oct  9 06:51:08 2005
@@ -26,7 +26,7 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
-import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.primitives.OID;
 import org.apache.asn1new.primitives.OctetString;
 import org.apache.asn1new.ldap.codec.LdapConstants;
@@ -74,6 +74,7 @@
         name = LdapControlGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_CONTROL_STATE][256];
 
         //============================================================================================
@@ -183,12 +184,18 @@
                         // We have to handle the special case of a 0 length OID
                         if ( tlv.getLength().getLength() == 0 )
                         {
+                            log.error( "The name must not be null" );
                             throw new DecoderException( "The name must not be null" );
                         }
                         else
                         {
                             control.setControlType( new OID( tlv.getValue().getData() ) );
                         }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Control OID : " + control.getControlType() );
+                        }
                     }
                 });
 
@@ -232,6 +239,11 @@
                         Value value        = tlv.getValue();
 
                         control.setCriticality( BooleanDecoder.parse( value) );
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Control criticality : " + control.getCriticality() );
+                        }
                     }
                 });
 
@@ -281,6 +293,11 @@
                         else
                         {
                             control.setControlValue( new OctetString( value.getData() ) );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Control value : " + StringUtils.dumpBytes( control.getControlValue() ) );
                         }
                     }
                 });

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java Sun Oct  9 06:51:08 2005
@@ -26,6 +26,8 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
@@ -62,7 +64,7 @@
         name       = LdapMessageGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // We have 9 differents states, so 8 transitions between states.
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_LDAP_MESSAGE_STATE][256];
 
         //============================================================================================
@@ -124,9 +126,24 @@
 
                         Value value     = tlv.getValue();
 
-                        int   messageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
-
-                        ldapMessage.setMessageId( messageId );
+                        try
+                        {
+                            int   messageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+                            
+                            ldapMessage.setMessageId( messageId );
+
+                            if ( log.isDebugEnabled() )
+                            {
+                                log.debug( "Ldap Message Id has been decoded : " + messageId );
+                            }
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error("The Message Id " + StringUtils.dumpBytes( value.getData() ) + 
+                                    " is invalid : " + ide.getMessage() + ". The message ID must be between (0 .. 2 147 483 647)" );
+                        
+                            throw new DecoderException( ide.getMessage() );
+                        }
 
                         return;
                     }

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,10 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import java.util.Iterator;
+
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -25,16 +29,20 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.util.IntegerDecoder;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
 import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.codec.primitives.LdapURL;
+import org.apache.asn1new.ldap.codec.primitives.LdapURLEncodingException;
 import org.apache.asn1new.ldap.codec.utils.LdapResultEnum;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.LdapResponse;
 import org.apache.asn1new.ldap.pojo.LdapResult;
+import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,6 +75,7 @@
         name              = LdapResultGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_LDAP_RESULT_STATE][256];
 
         //============================================================================================
@@ -152,13 +161,23 @@
                         TLV   tlv        = ldapMessageContainer.getCurrentTLV();
 
                         Value value      = tlv.getValue();
-
-                        int   resultCode = IntegerDecoder.parse( value, 0, 90 );
+                        int   resultCode  = 0;
+                        
+                        try
+                        {
+                            resultCode = IntegerDecoder.parse( value, 0, 90 );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error("The result code " + StringUtils.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 :
@@ -200,9 +219,13 @@
                                 break;
 
                             default :
-                                throw new DecoderException(
-                                    "Error <" + LdapResultEnum.errorCode( resultCode ) +
-                                    "> not allowed" );
+                                log.warn( "The resultCode " + resultCode + " is unknown." );
+                                ldapResult.setResultCode( LdapResultEnum.OTHER );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The result code is set to " + LdapResultEnum.errorCode( resultCode ) );
                         }
                     }
                 } );
@@ -242,11 +265,39 @@
                         // We have to handle the special case of a 0 length matched DN
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            ldapResult.setMatchedDN( LdapDN.EMPTY_STRING );
+                            ldapResult.setMatchedDN( LdapDN.EMPTY_LDAPDN );
                         }
                         else
                         {
-                            ldapResult.setMatchedDN( new LdapDN( tlv.getValue().getData() ) );
+                            // A not null matchedDN is valid for resultCodes
+                            // NoSuchObject, AliasProblem, InvalidDNSyntax and 
+                            // AliasDreferencingProblem.
+                            
+                            if ( ( ldapResult.getResultCode() == LdapResultEnum.NO_SUCH_OBJECT ) ||
+                                 ( ldapResult.getResultCode() == LdapResultEnum.ALIAS_PROBLEM ) ||
+                                 ( ldapResult.getResultCode() == LdapResultEnum.INVALID_DN_SYNTAX ) ||
+                                 ( ldapResult.getResultCode() == LdapResultEnum.ALIAS_DEREFERENCING_PROBLEM ) )
+                            {
+                                try
+                                {
+                                    ldapResult.setMatchedDN( new LdapDN( tlv.getValue().getData() ) );
+                                }
+                                catch ( InvalidNameException ine )
+                                {
+                                    log.error( "Incorrect DN given : " + StringUtils.dumpBytes( tlv.getValue().getData() ) );
+                                    throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                                }
+                            }
+                            else
+                            {
+                                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 ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The matchedDN is " + ldapResult.getMatchedDN() );
                         }
 
                         return;
@@ -291,10 +342,23 @@
                         }
                         else
                         {
-                            ldapResult.setErrorMessage( new LdapString(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                ldapResult.setErrorMessage( new LdapString(
+                                        tlv.getValue().getData() ) );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "The Error Message is invalid : " +StringUtils.dumpBytes( tlv.getValue().getData() ) );
+                                ldapResult.setErrorMessage( LdapString.EMPTY_STRING );
+                            }
                         }
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The error message is : " + ldapResult.getErrorMessage() );
+                        }
+                        
                         return;
                     }
                 } );
@@ -331,9 +395,12 @@
                 LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE, null );
 
         // Referral ::= SEQUENCE OF LDAPURL (Length)
-        // We may have other referrals, but wa may also have finished to read the LdapResult.
+        // We may have other referrals, but we may also have finished to read the LdapResult.
         // To handle those different cases, we have to transit to a special state, which
         // will do this brancing.
+        //
+        // The referral message exists only if the resultCode is REFERRAL.
+        //
         // Here, we store the referral in the ldapResult.
         super.transitions[LdapStatesEnum.LDAP_RESULT_REFERRAL_VALUE][UniversalTag.OCTET_STRING_TAG] =
             new GrammarTransition(
@@ -356,11 +423,52 @@
 
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            ldapResult.addReferral( LdapURL.EMPTY_STRING );
+                            ldapResult.addReferral( LdapURL.EMPTY_URL );
                         }
                         else
                         {
-                            ldapResult.addReferral( new LdapURL( tlv.getValue().getData() ) );
+                            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 );
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            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() );
                         }
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java Sun Oct  9 06:51:08 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1new.ldap.codec.grammar;
 
+import javax.naming.InvalidNameException;
+
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -26,10 +28,12 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapDN;
-import org.apache.asn1new.ldap.codec.primitives.RelativeLdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapRDN;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.ModifyDNRequest;
 import org.slf4j.Logger;
@@ -64,6 +68,7 @@
         name              = ModifyDNRequestGrammar.class.getName();
         statesEnum        = LdapStatesEnum.getInstance();
 
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_MODIFY_DN_REQUEST_STATE][256];
 
         //============================================================================================
@@ -129,13 +134,29 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
+                        LdapDN entry = null;
+
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             throw new DecoderException( "The entry must nut be null" );
                         }
                         else
                         {
-                            modifyDNRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+                            try
+                            {
+                                entry = new LdapDN( tlv.getValue().getData() );
+                                modifyDNRequest.setEntry( entry );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The DN to modify  (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid DN " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Modifying DN " + entry );
                         }
 
                         return;
@@ -178,14 +199,29 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched newDN
+                        LdapRDN newRdn = null;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             throw new DecoderException( "The newrdn must nut be null" );
                         }
                         else
                         {
-                            modifyDNRequest.setNewRDN( new RelativeLdapDN(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                newRdn = new LdapRDN( tlv.getValue().getData() );
+                                modifyDNRequest.setNewRDN( newRdn );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The new RDN (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid RDN " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Modifying with new RDN " + newRdn );
                         }
                     }
                 } );
@@ -228,8 +264,19 @@
                         // which is not 0, it will be interpreted as TRUE, but we
                         // will generate a warning.
                         Value value        = tlv.getValue();
+                        int   deleteOldRDN = 0;
 
-                        int   deleteOldRDN = IntegerDecoder.parse( value, 0, 255 );
+                        try
+                        {
+                            deleteOldRDN = IntegerDecoder.parse( value, 0, 255 );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error("The oldRDN flag " + StringUtils.dumpBytes( value.getData() ) + 
+                                    " is invalid : " + ide.getMessage() + ". It should be 0 or 255" );
+                        
+                            throw new DecoderException( ide.getMessage() );
+                        }
 
                         modifyDNRequest.setDeleteOldRDN( deleteOldRDN != 0 );
 
@@ -238,6 +285,17 @@
                             log.warn( "A boolean must be encoded with a 0x00 or a 0xFF value" );
                         }
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            if ( deleteOldRDN == 0 )
+                            {
+                                log.debug( " Old RDN attributes will be deleted" );
+                            }
+                            else
+                            {
+                                log.debug( " Old RDN attributes will be retained" );
+                            }
+                        }
                     }
                 } );
 
@@ -276,6 +334,8 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
+                        LdapDN newSuperior = LdapDN.EMPTY_LDAPDN;
+
                         if ( tlv.getLength().getLength() == 0 )
                         {
 
@@ -290,14 +350,27 @@
                                     "The new superior is null, so we will change the entry" );
                             }
 
-                            modifyDNRequest.setNewSuperior( LdapDN.EMPTY_STRING );
+                            modifyDNRequest.setNewSuperior( newSuperior );
                         }
                         else
                         {
-                            modifyDNRequest.setNewSuperior( new LdapDN(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                newSuperior = new LdapDN( tlv.getValue().getData() );
+                                modifyDNRequest.setNewSuperior( newSuperior );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The new superior DN (" + StringUtils.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
+                                throw new DecoderException( "Invalid DN " + StringUtils.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            }
                         }
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "New superior DN " + newSuperior );
+                        }
+                        
                         return;
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java (original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java Sun Oct  9 06:51:08 2005
@@ -57,7 +57,7 @@
         name = ModifyDNResponseGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_MODIFY_DN_RESPONSE_STATE][256];
 
         //============================================================================================
@@ -87,6 +87,11 @@
 
                         // And we associate it to the ldapMessage Object
                         ldapMessage.setProtocolOP( new ModifyDNResponse() );
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Modify DN response " );
+                        }
                     }
                 } );
 



Mime
View raw message