directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r438859 [1/4] - in /directory/trunks/shared/ldap: ./ src/main/java/org/apache/directory/shared/ldap/codec/ src/main/java/org/apache/directory/shared/ldap/codec/abandon/ src/main/java/org/apache/directory/shared/ldap/codec/add/ src/main/java...
Date Thu, 31 Aug 2006 10:33:48 GMT
Author: elecharny
Date: Thu Aug 31 03:33:43 2006
New Revision: 438859

URL: http://svn.apache.org/viewvc?rev=438859&view=rev
Log:
- Merged the code with 1.0 modification done to fix DIRSERVER-711
- Removed the RDN bad hashcode() method
- Merged the modification of EMPTY_BYTES done in 1.0

Added:
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
      - copied unchanged from r438665, directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapControlTest.java
Modified:
    directory/trunks/shared/ldap/pom.xml
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ResponseCarryingException.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapString.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ManageDsaITControl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/bind/BindRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java

Modified: directory/trunks/shared/ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/pom.xml?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/pom.xml (original)
+++ directory/trunks/shared/ldap/pom.xml Thu Aug 31 03:33:43 2006
@@ -66,7 +66,7 @@
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>nlog4j</artifactId>
-      <version>1.2.24</version>
+      <version>1.2.25</version>
       <scope>provided</scope>
     </dependency>
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java Thu Aug 31 03:33:43 2006
@@ -57,10 +57,6 @@
     /** The control length */
     private transient int controlLength;
 
-    private static final byte[] EMPTY_BYTES = new byte[]
-        {};
-
-
     // ~ Methods
     // ------------------------------------------------------------------------------------
 
@@ -96,7 +92,7 @@
     {
         if ( controlValue == null )
         {
-            return EMPTY_BYTES;
+            return StringTools.EMPTY_BYTES;
         }
         else if ( controlValue instanceof String )
         {
@@ -130,7 +126,7 @@
     {
         if ( encodedValue == null )
         {
-            return EMPTY_BYTES;
+            return StringTools.EMPTY_BYTES;
         }
 
         return encodedValue;

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapControlGrammar.java Thu Aug 31 03:33:43 2006
@@ -181,6 +181,8 @@
                     if ( tlv.getLength().getLength() == 0 )
                     {
                         log.error( "The OID must not be null" );
+                        
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The OID must not be null" );
                     }
                     else
@@ -195,6 +197,7 @@
                             log.error( "The control type " + StringTools.dumpBytes( tlv.getValue().getData() )
                                 + " is not a valid OID : " + de.getMessage() );
 
+                            // This will generate a PROTOCOL_ERROR
                             throw de;
                         }
 
@@ -207,6 +210,7 @@
                             log.error( "The control type " + StringTools.dumpBytes( tlv.getValue().getData() )
                                 + " is invalid : " + lsee.getMessage() );
 
+                            // This will generate a PROTOCOL_ERROR
                             throw new DecoderException( lsee.getMessage() );
                         }
                     }
@@ -267,6 +271,7 @@
                         log.error( "The control criticality flag " + StringTools.dumpBytes( value.getData() )
                             + " is invalid : " + bde.getMessage() + ". It should be 0 or 255" );
 
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( bde.getMessage() );
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Thu Aug 31 03:33:43 2006
@@ -99,6 +99,7 @@
                     if ( tlv.getLength().getLength() == 0 )
                     {
                         log.error( "The LdapMessage has a zero length. This is not allowed" );
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The LdapMessage should not be empty" );
                     }
 
@@ -142,6 +143,8 @@
                     if ( tlv.getLength().getLength() == 0 )
                     {
                         log.error( "The messageId has a zero length. This is not allowed" );
+                        
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The messageId should not be null" );
                     }
 
@@ -163,6 +166,7 @@
                         log.error( "The Message Id " + StringTools.dumpBytes( value.getData() ) + " is invalid : "
                             + ide.getMessage() + ". The message ID must be between (0 .. 2 147 483 647)" );
 
+                        // This will generate a PROTOCOL_ERROR                        
                         throw new DecoderException( ide.getMessage() );
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ResponseCarryingException.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ResponseCarryingException.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ResponseCarryingException.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ResponseCarryingException.java Thu Aug 31 03:33:43 2006
@@ -22,6 +22,9 @@
 
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.ResultResponse;
+import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
@@ -63,9 +66,15 @@
      * @param cause
      *            The Exception which caused the error
      */
-    public ResponseCarryingException(String message, Throwable cause)
+    public ResponseCarryingException(String message, ResultResponse response, ResultCodeEnum code, LdapDN matchedDn, Throwable cause)
     {
         super( message, cause );
+
+        response.getLdapResult().setErrorMessage( message );
+        response.getLdapResult().setResultCode( code );
+        response.getLdapResult().setMatchedDn( matchedDn );
+    
+        this.response = response; 
     }
     
     /**

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -113,6 +113,8 @@
                     {
                         String msg = "The AbandonRequest messageId must not be null";
                         log.error( msg );
+
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
 
@@ -143,6 +145,7 @@
                                 "The Abandonned Message Id {} is invalid : {}. The message ID must be between (0 .. 2 147 483 647)",
                                 StringTools.dumpBytes( value.getData() ), ide.getMessage() );
 
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( ide.getMessage() );
                     }
                 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -112,6 +112,8 @@
                     {
                         String msg = "The AddRequest must not be null";
                         log.error( msg );
+                        
+                        // Will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
 
@@ -148,7 +150,14 @@
                     // Store the entry. It can't be null
                     if ( tlv.getLength().getLength() == 0 )
                     {
-                        throw new DecoderException( "The DN can't be null" );
+                        String msg = "Empty entry DN given";
+                        log.error( msg );
+                
+                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                
+                        // I guess that trying to add an entry which DN is empty is a naming violation...
+                        // Not 100% sure though ...
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.NAMINGVIOLATION, LdapDN.EMPTY_LDAPDN, null );
                     }
                     else
                     {
@@ -166,16 +175,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
                 
-                            AddResponseImpl message = new AddResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-                
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-                
-                            exception.setResponse( message );
-                
-                            throw exception;
+                            AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         addRequest.setEntry( entry );
@@ -261,8 +262,12 @@
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
-                        log.error( "Null types are not allowed" );
-                        throw new DecoderException( "The type can't be null" );
+                        String msg = "Null or empty types are not allowed"; 
+                        log.error( msg );
+
+                        AddResponseImpl response = new AddResponseImpl( ldapMessage.getMessageId() );
+                        
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX, addRequest.getEntry(), null );
                     }
                     else
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -130,6 +130,8 @@
                     {
                         String msg = "The BindRequest must not be null";
                         log.error( msg );
+                     
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
 
@@ -165,13 +167,6 @@
                     {
                         int version = IntegerDecoder.parse( value, 1, 127 );
 
-                        // will handle this in higher layers: bind handler
-//                        if ( version != 3 )
-//                        {
-//                            log.error( "The version {} is invalid : it must be 3", new Integer( version ) );
-//                            throw new DecoderException( "Ldap Version " + version + " is not supported" );
-//                        }
-
                         if ( IS_DEBUG )
                         {
                             log.debug( "Ldap version ", new Integer( version ) );
@@ -184,6 +179,7 @@
                         log.error( "The version {} is invalid : {}. The version must be between (0 .. 127)",
                             StringTools.dumpBytes( value.getData() ), ide.getMessage() );
 
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( ide.getMessage() );
                     }
 
@@ -235,16 +231,9 @@
                                 + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
                         
-                            BindResponseImpl message = new BindResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-                        
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-                        
-                            exception.setResponse( message );
+                            BindResponseImpl response = new BindResponseImpl( ldapMessage.getMessageId() );
                         
-                            throw exception;
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         bindRequestMessage.setName( name );
@@ -360,7 +349,8 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    BindRequest bindRequestMessage = ldapMessageContainer.getLdapMessage().getBindRequest();
+                    LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+                    BindRequest bindRequestMessage = ldapMessage.getBindRequest();
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // We will check that the sasl is not null
@@ -368,7 +358,11 @@
                     {
                         String msg = "The SaslCredential must not be null";
                         log.error( msg );
-                        throw new DecoderException( msg );
+                        
+                        BindResponseImpl response = new BindResponseImpl( ldapMessage.getMessageId() );
+                    
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDCREDENTIALS, 
+                            bindRequestMessage.getName(), null );
                     }
 
                     // Create the SaslCredentials Object
@@ -415,7 +409,8 @@
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    BindRequest bindRequestMessage = ldapMessageContainer.getLdapMessage().getBindRequest();
+                    LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+                    BindRequest bindRequestMessage = ldapMessage.getBindRequest();
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Get the SaslCredentials Object
@@ -435,9 +430,12 @@
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
-                            log.error( "Invalid mechanism : {} : {}",
-                                StringTools.dumpBytes( tlv.getValue().getData() ), lsee.getMessage() );
-                            throw new DecoderException( lsee.getMessage() );
+                            String msg = "Invalid mechanism : " + StringTools.dumpBytes( tlv.getValue().getData() );
+                            log.error( "{} : {}", msg, lsee.getMessage() );
+                            BindResponseImpl response = new BindResponseImpl( ldapMessage.getMessageId() );
+                            
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INAPPROPRIATEAUTHENTICATION, 
+                                bindRequestMessage.getName(), lsee );
                         }
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -21,6 +21,7 @@
 
 
 import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
 
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
@@ -37,6 +38,7 @@
 import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
 import org.apache.directory.shared.ldap.codec.util.LdapString;
 import org.apache.directory.shared.ldap.codec.util.LdapStringEncodingException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -139,6 +141,7 @@
                     // DN
                     if ( tlv.getLength().getLength() == 0 )
                     {
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The entry must not be null" );
                     }
                     else
@@ -156,16 +159,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
             
-                            CompareResponseImpl message = new CompareResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-            
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-            
-                            exception.setResponse( message );
-            
-                            throw exception;
+                            CompareResponseImpl response = new CompareResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         compareRequest.setEntry( entry );
@@ -210,7 +205,7 @@
             LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_VALUE, LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_TAG,
             new GrammarAction( "Store attribute desc" )
             {
-                public void action( IAsn1Container container ) throws DecoderException
+                public void action( IAsn1Container container ) throws DecoderException, NamingException
                 {
 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
@@ -226,7 +221,11 @@
                     // DN
                     if ( tlv.getLength().getLength() == 0 )
                     {
-                        throw new DecoderException( "The attribute description must not be null" );
+                        String msg = "The attribute description must not be null";
+                        log.error( msg );
+                        CompareResponseImpl response = new CompareResponseImpl( ldapMessage.getMessageId() );
+                        
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX, compareRequest.getEntry(), null );
                     }
                     else
                     {
@@ -239,9 +238,7 @@
                         {
                             log.error( "The attribute description ({}) is invalid.", StringTools.dumpBytes( tlv
                                 .getValue().getData() ) );
-                            throw new DecoderException( "Invalid attribute description "
-                                + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + lsee.getMessage() );
-
+                            throw new LdapInvalidAttributeIdentifierException( "Invalid attribute type : " + lsee.getMessage() );
                         }
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -110,6 +110,7 @@
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The entry must not be null" );
                     }
                     else
@@ -127,16 +128,8 @@
                                 + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
                             
-                            DeleteResponseImpl message = new DeleteResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-                            
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-                            
-                            exception.setResponse( message );
-                            
-                            throw exception;
+                            DeleteResponseImpl response = new DeleteResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         delRequest.setEntry( entry );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -131,12 +131,28 @@
                     if ( tlv.getLength().getLength() == 0 )
                     {
                         log.error( "The name must not be null" );
+                        // This will generate a PROTOCOL_ERROR                        
                         throw new DecoderException( "The name must not be null" );
                     }
                     else
                     {
-                        extendedRequest
-                            .setRequestName( new OID( StringTools.utf8ToString( tlv.getValue().getData() ) ) );
+                        byte[] requestNameBytes = tlv.getValue().getData();
+                        
+                        try
+                        {
+                            OID oid = new OID( StringTools.utf8ToString( requestNameBytes ) );
+                            extendedRequest.setRequestName( oid );
+                        }
+                        catch ( DecoderException de )
+                        {
+                            String msg = "The Request name is not a valid OID : " + StringTools.utf8ToString( requestNameBytes ) + 
+                            " (" + StringTools.dumpBytes( requestNameBytes )
+                            + ") is invalid";
+                            log.error( "{} : {}", msg, de.getMessage() );
+
+                            // Rethrow the exception, we will get a PROTOCOL_ERROR
+                            throw de;
+                        }
                     }
 
                     // We can have an END transition

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -159,16 +159,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
                     
-                            ModifyResponseImpl message = new ModifyResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-                    
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-                    
-                            exception.setResponse( message );
-                    
-                            throw exception;
+                            ModifyResponseImpl response = new ModifyResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         modifyRequest.setObject( object );
@@ -283,6 +275,8 @@
                         String msg = "Invalid operation ( " + StringTools.dumpBytes( tlv.getValue().getData() )
                             + "), it should be 0, 1 or 2";
                         log.error( msg );
+                        
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( msg );
                     }
 
@@ -355,7 +349,11 @@
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
-                        throw new DecoderException( "The type can't be null" );
+                        String msg = "The type can't be null";
+                        log.error( msg );
+                        
+                        ModifyResponseImpl response = new ModifyResponseImpl( ldapMessage.getMessageId() );
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX, modifyRequest.getObject(), null );
                     }
                     else
                     {
@@ -366,8 +364,11 @@
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
-                            log.error( "Invalid type : {}", StringTools.dumpBytes( tlv.getValue().getData() ) );
-                            throw new DecoderException( "Invalid type : " + lsee.getMessage() );
+                            String msg = "Invalid type : " + StringTools.dumpBytes( tlv.getValue().getData() );
+                            log.error( msg );
+
+                            ModifyResponseImpl response = new ModifyResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX, modifyRequest.getObject(), lsee );
                         }
                     }
 
@@ -461,8 +462,7 @@
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Store the value. It can't be null
-                    Object value = new byte[]
-                        {};
+                    Object value = StringTools.EMPTY_BYTES;
 
                     if ( tlv.getLength().getLength() == 0 )
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -143,6 +143,7 @@
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The entry must nut be null" );
                     }
                     else
@@ -160,16 +161,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
         
-                            ModifyDnResponseImpl message = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-        
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-        
-                            exception.setResponse( message );
-        
-                            throw exception;
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
 
                         modifyDNRequest.setEntry( entry );
@@ -221,7 +214,11 @@
 
                     if ( tlv.getLength().getLength() == 0 )
                     {
-                        throw new DecoderException( "The newrdn must nut be null" );
+                        String msg = "The newrdn must not be null";
+                        log.error(  msg  );
+                        
+                        ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, modifyDNRequest.getEntry(), null );
                     }
                     else
                     {
@@ -239,16 +236,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
     
-                            ModifyDnResponseImpl message = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-    
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-    
-                            exception.setResponse( message );
-    
-                            throw exception;
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, modifyDNRequest.getEntry(), ine );
                         }
 
                         modifyDNRequest.setNewRDN( newRdn );
@@ -307,6 +296,7 @@
                         log.error( "The oldRDN flag {} is invalid : {}. It should be 0 or 255", StringTools
                             .dumpBytes( value.getData() ), bde.getMessage() );
 
+                        // This will generate a PROTOCOL_ERROR                        
                         throw new DecoderException( bde.getMessage() );
                     }
 
@@ -369,6 +359,7 @@
 
                         if ( modifyDNRequest.isDeleteOldRDN() )
                         {
+                            // This will generate a PROTOCOL_ERROR
                             throw new DecoderException(
                                 "The new superior must nut be null if the flag 'delete old DN' is set to true" );
                         }
@@ -394,16 +385,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
     
-                            ModifyDnResponseImpl message = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-    
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-    
-                            exception.setResponse( message );
-    
-                            throw exception;
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, modifyDNRequest.getEntry(), ine );
                         }
 
                         modifyDNRequest.setNewSuperior( newSuperior );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/FilterGrammar.java Thu Aug 31 03:33:43 2006
@@ -415,21 +415,29 @@
 
                     AttributeValueAssertion assertion = new AttributeValueAssertion();
 
-                    try
+                    if ( tlv.getLength().getLength() == 0 )
                     {
-                        LdapString type = new LdapString( tlv.getValue().getData() );
-                        assertion.setAttributeDesc( type );
+                        log.error( "The attribute description is empty " );
+                        throw new DecoderException( "The type can't be null" );
                     }
-                    catch ( LdapStringEncodingException lsee )
+                    else
                     {
-                        String msg = StringTools.dumpBytes( tlv.getValue().getData() );
-                        log.error( "The assertion description ({}) is invalid", msg );
-                        throw new DecoderException( "Invalid assertion description " + msg + ", : " + lsee.getMessage() );
-                    }
+                        try
+                        {
+                            LdapString type = new LdapString( tlv.getValue().getData() );
+                            assertion.setAttributeDesc( type );
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            String msg = StringTools.dumpBytes( tlv.getValue().getData() );
+                            log.error( "The assertion value ({}) is invalid", msg );
+                            throw new DecoderException( "Invalid assertion value " + msg + ", : " + lsee.getMessage() );
+                        }
 
-                    AttributeValueAssertionFilter comparisonFilter = ( AttributeValueAssertionFilter ) searchRequest
-                        .getTerminalFilter();
-                    comparisonFilter.setAssertion( assertion );
+                        AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) searchRequest
+                            .getTerminalFilter();
+                        terminalFilter.setAssertion( assertion );
+                    }
                 }
             } );
 
@@ -485,52 +493,6 @@
                     searchRequest.unstackFilters( container );
 
                     container.grammarPopAllowed( true );
-                }
-            } );
-
-        // AttributeValueAssertion ::= SEQUENCE {
-        //    attributeDesc   AttributeDescription, (VALUE)
-        //     ...
-        // We have to set the attribute description in the current filter.
-        // It could be an equalityMatch, greaterOrEqual, lessOrEqual or an
-        // approxMatch filter.
-        super.transitions[LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
-            LdapStatesEnum.FILTER_ATTRIBUTE_DESC_VALUE, LdapStatesEnum.FILTER_ASSERTION_VALUE_TAG, new GrammarAction(
-                "Init attributeDesc Value" )
-            {
-                public void action( IAsn1Container container ) throws DecoderException
-                {
-                    LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
-                    SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                    TLV tlv = ldapMessageContainer.getCurrentTLV();
-
-                    AttributeValueAssertion assertion = new AttributeValueAssertion();
-
-                    if ( tlv.getLength().getLength() == 0 )
-                    {
-                        log.error( "The attribute description is empty " );
-                        throw new DecoderException( "The type can't be null" );
-                    }
-                    else
-                    {
-                        try
-                        {
-                            LdapString type = new LdapString( tlv.getValue().getData() );
-                            assertion.setAttributeDesc( type );
-                        }
-                        catch ( LdapStringEncodingException lsee )
-                        {
-                            String msg = StringTools.dumpBytes( tlv.getValue().getData() );
-                            log.error( "The assertion value ({}) is invalid", msg );
-                            throw new DecoderException( "Invalid assertion value " + msg + ", : " + lsee.getMessage() );
-                        }
-
-                        AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) searchRequest
-                            .getTerminalFilter();
-                        terminalFilter.setAssertion( assertion );
-                    }
                 }
             } );
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/MatchingRuleAssertionGrammar.java Thu Aug 31 03:33:43 2006
@@ -105,23 +105,6 @@
                     // We can allocate the ExtensibleMatch Filter
                     Filter extensibleMatchFilter = new ExtensibleMatchFilter();
 
-                    // Get the parent, if any
-                    Filter currentFilter = searchRequest.getCurrentFilter();
-
-                    if ( currentFilter != null )
-                    {
-                        // Ok, we have a parent. The new Filter will be added to
-                        // this parent, then.
-                        ( ( ConnectorFilter ) currentFilter ).addFilter( extensibleMatchFilter );
-                        extensibleMatchFilter.setParent( currentFilter );
-                    }
-                    else
-                    {
-                        // No parent. This Filter will become the root.
-                        searchRequest.setFilter( extensibleMatchFilter );
-                        extensibleMatchFilter.setParent( searchRequest );
-                    }
-
                     searchRequest.addCurrentFilter( extensibleMatchFilter );
                     searchRequest.setTerminalFilter( extensibleMatchFilter );
                 }
@@ -159,6 +142,8 @@
                     if ( tlv.getLength().getLength() == 0 )
                     {
                         log.error( "The matching rule is empty" );
+                        
+                        // It will generate a PROTOCOL_ERROR
                         throw new DecoderException( "Invalid matching rule : it can't be empty" );
                     }
                     else
@@ -171,6 +156,8 @@
                         {
                             String msg = StringTools.dumpBytes( tlv.getValue().getData() );
                             log.error( "The matching rule ({}) is invalid", msg );
+
+                            // It will generate a PROTOCOL_ERROR
                             throw new DecoderException( "Invalid matching rule " + msg + ", : " + lsee.getMessage() );
                         }
                     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java Thu Aug 31 03:33:43 2006
@@ -440,37 +440,6 @@
                 // We can stop the recursion, we have reached the searchResult Object
                 break;
             }
-            
-            /*
-            if ( filterParent instanceof Filter )
-            {
-                // The terminalfilter set has been completed
-                // we can get its parent and add the terminal to it
-                // but onlyu if it's not a connector filter
-                if ( ! (filter instanceof ConnectorFilter ) )
-                {
-                    addCurrentFilter( filter );
-                }
-                
-                // and update the current filter with the parent
-                Asn1Object parentFilter = currentFilter.getParent();
-                
-                if ( parentFilter instanceof Filter )
-                {
-                    searchRequest.setCurrentFilter( (Filter)parentFilter );
-                }
-                
-                parent = parent.getParent();
-                filter = currentFilter;
-            }
-            else
-            {
-                // We have reached the top level, we can stop
-                // the loop after having updated the currentFilter
-                //searchRequest.setCurrentFilter( filter );
-                break;
-            }
-            */
         }
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -162,16 +162,8 @@
                                 ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
                     
-                            SearchResponseDoneImpl message = new SearchResponseDoneImpl( ldapMessage.getMessageId() );
-                            message.getLdapResult().setErrorMessage( msg );
-                            message.getLdapResult().setResultCode( ResultCodeEnum.INVALIDDNSYNTAX );
-                            message.getLdapResult().setMatchedDn( LdapDN.EMPTY_LDAPDN );
-                    
-                            ResponseCarryingException exception = new ResponseCarryingException( msg, ine );
-                    
-                            exception.setResponse( message );
-                    
-                            throw exception;
+                            SearchResponseDoneImpl response = new SearchResponseDoneImpl( ldapMessage.getMessageId() );
+                            throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDDNSYNTAX, LdapDN.EMPTY_LDAPDN, ine );
                         }
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SubstringFilterGrammar.java Thu Aug 31 03:33:43 2006
@@ -79,10 +79,8 @@
             LdapStatesEnum.SUBSTRINGS_FILTER_TAG, LdapStatesEnum.SUBSTRINGS_FILTER_VALUE, null );
 
         // Here we are dealing with substrings. LDAP grammar is not very
-        // explicit about
-        // what is allowed (-- at least one must be present !!!), while RFC 2254
-        // is
-        // really clear. But LDAP grammar is the one to follow...
+        // explicit about what is allowed (-- at least one must be present !!!), while RFC 2254
+        // is really clear. But LDAP grammar is the one to follow...
         //
         // substring ::= attr "=" [AttributeValue] any [AttributeValue]
         // any ::= "*" *(AttributeValue "*")
@@ -193,8 +191,7 @@
         // substrings SEQUENCE OF CHOICE { (Value)
         // ...
         // Here, we may have three possibilities. We may have an "initial"
-        // value,
-        // or an "any" value, or a "final" value. Any other option is an error.
+        // value, or an "any" value, or a "final" value. Any other option is an error.
         // We must have at least one of those three.
         super.transitions[LdapStatesEnum.SUBSTRINGS_FILTER_SUBSTRINGS_SEQ_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
             LdapStatesEnum.SUBSTRINGS_FILTER_SUBSTRINGS_SEQ_VALUE,

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControlGrammar.java Thu Aug 31 03:33:43 2006
@@ -98,6 +98,7 @@
                         log.error( "The visibility flag {} is invalid : {}. It should be 0 or 255", StringTools
                             .dumpBytes( value.getData() ), bde.getMessage() );
 
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( bde.getMessage() );
                     }
                 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestGrammar.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestGrammar.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestGrammar.java Thu Aug 31 03:33:43 2006
@@ -120,6 +120,8 @@
                     {
                         log.error( "The length of a UnBindRequest must be null, the actual value is {}", new Integer(
                             expectedLength ) );
+                        
+                        // This will generate a PROTOCOL_ERROR
                         throw new DecoderException( "The length of a UnBindRequest must be null" );
                     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapString.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapString.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapString.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapString.java Thu Aug 31 03:33:43 2006
@@ -22,6 +22,8 @@
 
 import java.io.UnsupportedEncodingException;
 
+import org.apache.directory.shared.ldap.util.StringTools;
+
 
 /**
  * Decodes a LdapString, and checks that the character set used comply the ISO
@@ -34,10 +36,6 @@
     /** A null LdapString */
     public transient static final LdapString EMPTY_STRING = new LdapString();
 
-    /** A null LdapString */
-    public transient static final byte[] EMPTY_BYTES = new byte[]
-        {};
-
     /** The inner String containing the LdapString */
     protected String string;
 
@@ -50,7 +48,7 @@
      */
     public LdapString()
     {
-        bytes = EMPTY_BYTES;
+        bytes = StringTools.EMPTY_BYTES;
         string = "";
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ManageDsaITControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ManageDsaITControl.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ManageDsaITControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ManageDsaITControl.java Thu Aug 31 03:33:43 2006
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+import org.apache.directory.shared.ldap.util.StringTools;
+
 
 /**
  * Control which allows for the management of referrals and other DSA specific
@@ -64,15 +66,12 @@
 
     private static final long serialVersionUID = -8844249964346248321L;
 
-    private final static byte[] EMPTY_BYTES = new byte[0];
-
-
     /**
      * Returns an empty byte[] everytime.
      */
     public byte[] getEncodedValue()
     {
-        return EMPTY_BYTES;
+        return StringTools.EMPTY_BYTES;
     }
 
 
@@ -81,7 +80,7 @@
      */
     public byte[] getValue()
     {
-        return EMPTY_BYTES;
+        return StringTools.EMPTY_BYTES;
     }
 
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java Thu Aug 31 03:33:43 2006
@@ -33,7 +33,6 @@
 import javax.naming.directory.BasicAttributes;
 
 import org.apache.commons.collections.MultiHashMap;
-import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
@@ -858,20 +857,6 @@
        }
 
        return compareTo( ( Rdn ) rdn ) == EQUALS;
-   }
-
-
-   /**
-    * Returns the hash code of this RDN. Two RDNs that are equal (according to
-    * the equals method) will have the same hash code.
-    *
-    * @returnAn int representing the hash code of this Rdn
-    */
-   public int hashcode()
-   {
-       // We compute the hashcode using the string, which is a
-       // normalized form of a rdn. unescapeValue
-       return 37 * 17 + string.hashCode();
    }
 
 

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/LdapMessageTest.java Thu Aug 31 03:33:43 2006
@@ -56,7 +56,8 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
         stream.put( new byte[]
-            { 0x30, 0x00, // LDAPMessage ::=SEQUENCE {
+            { 
+            0x30, 0x00,                 // LDAPMessage ::=SEQUENCE {
             } );
 
         stream.flip();
@@ -94,8 +95,9 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x04 );
         stream.put( new byte[]
-            { 0x30, 0x02, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x00 // messageID MessageID
+            { 
+            0x30, 0x02,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x00                // messageID MessageID
             } );
 
         stream.flip();
@@ -133,8 +135,9 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x05 );
         stream.put( new byte[]
-            { 0x30, 0x03, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, ( byte ) 0xff // messageID MessageID = -1
+            { 
+            0x30, 0x03,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x01, ( byte ) 0xff // messageID MessageID = -1
             } );
 
         stream.flip();
@@ -163,7 +166,7 @@
 
 
     /**
-     * Test the decoding of null length messageId
+     * Test the decoding of messageId which value is -1
      */
     public void testDecodeMessageIdMaxInt()
     {
@@ -172,10 +175,10 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x08 );
         stream.put( new byte[]
-            { 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x04, ( byte ) 0x7f, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff // messageID
-                                                                                        // MessageID
-                                                                                        // = -1
+            { 
+            0x30, 0x06,                 // LDAPMessage ::=SEQUENCE {
+                                        // messageID MessageID = -1
+              0x02, 0x04, ( byte ) 0x7f, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff
             } );
 
         stream.flip();
@@ -204,15 +207,16 @@
 
 
     /**
-     * Test the decoding of null length messageId
+     * Test the decoding of a message with a wrong protocol operation
      */
     public void testDecodeWrongProtocolOpMaxInt()
     {
 
         byte[] buffer = new byte[]
-            { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID = 1
-                0x42, 0x00 // ProtocolOp
+            { 
+            0x30, 0x05,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x01, 0x01,         // messageID MessageID = 1
+              0x42, 0x00                // ProtocolOp
             };
 
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -299,10 +303,11 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x08 );
         stream.put( new byte[]
-            { 0x30, 0x06, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x02, 0x01, ( byte ) 0xF4, // messageID MessageID (500)
-                0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
-            // UnbindRequest ::= [APPLICATION 2] NULL
+            { 
+            0x30, 0x06,                         // LDAPMessage ::=SEQUENCE {
+              0x02, 0x02, 0x01, ( byte ) 0xF4,  // messageID MessageID (500)
+              0x42, 0x00,                       // CHOICE { ..., unbindRequest UnbindRequest,...
+                                                // UnbindRequest ::= [APPLICATION 2] NULL
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequestTest.java Thu Aug 31 03:33:43 2006
@@ -55,37 +55,35 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x64 );
         stream.put( new byte[]
-            { 0x30, 0x62, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x03, // messageID MessageID
-                0x50, 0x01, 0x02, // CHOICE { ..., abandonRequest
-                                    // AbandonRequest,...
-                ( byte ) 0xA0, 0x5A, // controls [0] Controls OPTIONAL }
-                0x30, 0x1A, // Control ::= SEQUENCE {
-                // controlType LDAPOID,
-                0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1', 0x01, 0x01, ( byte ) 0xFF, // criticality
-                                                                                                                        // BOOLEAN
-                                                                                                                        // DEFAULT
-                                                                                                                        // FALSE,
-                // controlValue OCTET STRING OPTIONAL }
-                0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', 0x30, 0x17, // Control
-                                                                        // ::=
-                                                                        // SEQUENCE
-                                                                        // {
-                // controlType LDAPOID,
-                0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
-                // controlValue OCTET STRING OPTIONAL }
-                0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l', 0x30, 0x12, // Control
-                                                                        // ::=
-                                                                        // SEQUENCE
-                                                                        // {
-                // controlType LDAPOID,
-                0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3', 0x01, 0x01, ( byte ) 0xFF, // criticality
-                                                                                                                        // BOOLEAN
-                                                                                                                        // DEFAULT
-                                                                                                                        // FALSE}
-                0x30, 0x0F, // Control ::= SEQUENCE {
-                // controlType LDAPOID}
-                0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' } );
+            { 
+            0x30, 0x62,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x01, 0x03,         // messageID MessageID
+              0x50, 0x01, 0x02,         // CHOICE { ..., abandonRequest
+                                        // AbandonRequest,...
+                ( byte ) 0xA0, 0x5A,    // controls [0] Controls OPTIONAL }
+                  0x30, 0x1A,           // Control ::= SEQUENCE {
+                                        // controlType LDAPOID,
+                    0x04, 0x0D, 
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '1',
+                                        // criticality BOOLEAN DEFAULT FALSE,
+                    0x01, 0x01, ( byte ) 0xFF, 
+                                        // controlValue OCTET STRING OPTIONAL }
+                    0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f', 
+                    0x30, 0x17,         // Control ::= SEQUENCE {
+                                        // controlType LDAPOID,
+                    0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                                        // controlValue OCTET STRING OPTIONAL }
+                    0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l', 
+                  0x30, 0x12,           // Control ::= SEQUENCE {
+                                        // controlType LDAPOID,
+                    0x04, 0x0D, 
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '3',
+                                        // criticality BOOLEAN DEFAULT FALSE }
+                    0x01, 0x01, ( byte ) 0xFF, 
+                  0x30, 0x0F,           // Control ::= SEQUENCE {
+                                        // controlType LDAPOID}
+                    0x04, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '4' 
+            } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -170,11 +168,13 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0A );
         stream.put( new byte[]
-            { 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x03, 0x00, ( byte ) 0x80, 0x13, // messageID MessageID
-                0x50, 0x01, 0x02 // CHOICE { ..., abandonRequest
-                                    // AbandonRequest,...
-            // AbandonRequest ::= [APPLICATION 16] MessageID
+            { 
+            0x30, 0x08,                 // LDAPMessage ::=SEQUENCE {
+                                        // messageID MessageID
+              0x02, 0x03, 0x00, ( byte ) 0x80, 0x13, 
+              0x50, 0x01, 0x02          // CHOICE { ..., abandonRequest
+                                        // AbandonRequest,...
+                                        // AbandonRequest ::= [APPLICATION 16] MessageID
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -227,7 +227,7 @@
 
 
     /**
-     * Test the decoding of a AbandonRequest with no controls
+     * Test the decoding of a AbandonRequest with a null messageId
      */
     public void testDecodeAbandonRequestNoMessageId()
     {
@@ -235,10 +235,51 @@
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0A );
         stream.put( new byte[]
-            { 0x30, 0x08, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x50, 0x00 // CHOICE { ..., abandonRequest AbandonRequest,...
-            // AbandonRequest ::= [APPLICATION 16] MessageID
+            { 
+            0x30, 0x08,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x01, 0x01,         // messageID MessageID
+              0x50, 0x00                // CHOICE { ..., abandonRequest AbandonRequest,...
+                                        // AbandonRequest ::= [APPLICATION 16] MessageID
+            } );
+
+        stream.flip();
+
+        // Allocate a LdapMessageContainer Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        // Decode the PDU
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            assertTrue( true );
+            return;
+        }
+        catch ( NamingException ne )
+        {
+            ne.printStackTrace();
+            fail( ne.getMessage() );
+        }
+
+        fail( "We should not reach this point" );
+    }
+
+    /**
+     * Test the decoding of a AbandonRequest with a bad Message Id
+     */
+    public void testDecodeAbandonRequestBadMessageId()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x0B );
+        stream.put( new byte[]
+            { 
+            0x30, 0x09,                 // LDAPMessage ::=SEQUENCE {
+              0x02, 0x01, 0x01,         // messageID MessageID
+              0x50, 0x01, (byte)0xFF    // CHOICE { ..., abandonRequest AbandonRequest,...
+                                        // AbandonRequest ::= [APPLICATION 16] MessageID
             } );
 
         stream.flip();



Mime
View raw message