directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r307431 [2/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
Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.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,11 +27,14 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.UniversalTag;
 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.LdapMessage;
 import org.apache.asn1new.ldap.pojo.ModifyRequest;
 import org.slf4j.Logger;
@@ -62,7 +67,7 @@
         name       = ModifyRequestGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_MODIFY_REQUEST_STATE][256];
 
         //============================================================================================
@@ -130,12 +135,25 @@
                         // Store the value.
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            modifyRequest.setObject( LdapDN.EMPTY_STRING );
+                            modifyRequest.setObject( LdapDN.EMPTY_LDAPDN );
                         }
                         else
                         {
-                            modifyRequest.setObject( new LdapDN(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                modifyRequest.setObject( new LdapDN(
+                                        tlv.getValue().getData() ) );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "Invalid DN " + StringUtils.dumpBytes( tlv.getValue().getData()
) + ", : " + ine.getMessage() );
+                                throw new DecoderException( "Invalid object DN : " + ine.getMessage()
);
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Modification of DN " + modifyRequest.getObject()
);
                         }
                     }
                 } );
@@ -247,10 +265,39 @@
                             ldapMessageContainer.getCurrentTLV();
 
                         // Decode the operation type
-                        int operation = IntegerDecoder.parse( tlv.getValue(), 0, 2 );
-
+                        int operation = 0;
+                        
+                        try
+                        {
+                            operation = IntegerDecoder.parse( tlv.getValue(), 0, 2 );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error( "Invalid operation (" + StringUtils.dumpBytes( tlv.getValue().getData()
) + ", it should be 0, 1 or 2 " );
+                            throw new DecoderException( "Invalid operation (" + StringUtils.dumpBytes(
tlv.getValue().getData() ) + ", it should be 0, 1 or 2 " );
+                        }
+                        
                         // Store the current operation.
                         modifyRequest.setCurrentOperation( operation );
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            switch ( operation )
+                            {
+                                case LdapConstants.OPERATION_ADD :
+                                    log.debug( "Modification operation : ADD" );
+                                    break;
+
+                                case LdapConstants.OPERATION_DELETE :
+                                    log.debug( "Modification operation : DELETE" );
+                                    break;
+                                
+                                case LdapConstants.OPERATION_REPLACE :
+                                    log.debug( "Modification operation : REPLACE" );
+                                    break;
+                            }
+                        }
+                          
                     }
                 } );
 
@@ -303,14 +350,29 @@
                             ldapMessageContainer.getCurrentTLV();
 
                         // Store the value. It can't be null
+                        LdapString type = null;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
                             throw new DecoderException( "The type can't be null" );
                         }
                         else
                         {
-                            modifyRequest.addAttributeTypeAndValues( new LdapString(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                type = new LdapString( tlv.getValue().getData() );
+                                modifyRequest.addAttributeTypeAndValues( type );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "Invalid type : " + StringUtils.dumpBytes( tlv.getValue().getData()
) );
+                                throw new DecoderException( "Invalid type : " + lsee.getMessage()
);
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Modification type : " + type );
                         }
                     }
                 } );
@@ -375,14 +437,21 @@
                             ldapMessageContainer.getCurrentTLV();
 
                         // Store the value. It can't be null
+                        OctetString value = OctetString.EMPTY_STRING;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            modifyRequest.addAttributeValue( OctetString.EMPTY_STRING );
+                            modifyRequest.addAttributeValue( value );
                         }
                         else
                         {
-                            modifyRequest.addAttributeValue( new OctetString(
-                                    tlv.getValue().getData() ) );
+                            value = new OctetString( tlv.getValue().getData() );
+                            modifyRequest.addAttributeValue( value );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Value modified : " + value );
                         }
                     }
                 } );

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

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.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;
@@ -27,10 +29,13 @@
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
 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.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapStringEncodingException;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.SearchRequest;
 import org.slf4j.Logger;
@@ -65,7 +70,7 @@
         name       = SearchRequestGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Initialisation of the transitions table
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_REQUEST_STATE][256];
 
         //============================================================================================
@@ -128,27 +133,30 @@
                         TLV                  tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to check that this is a correct DN
-                        LdapDN baseObject = null;
+                        LdapDN baseObject = LdapDN.EMPTY_LDAPDN;
                         
                         // We have to handle the special case of a 0 length base object,
-                        // which is not permitted
-                        if ( tlv.getLength().getLength() == 0 )
-                        {
-                            throw new DecoderException("The base object must not be null");
-                        }
-
-                        try
-                        {
-                            baseObject = new LdapDN(tlv.getValue().getData());
-                        }
-                        catch (DecoderException de)
+                        // which means that the search is done from the default root.
+                        if ( tlv.getLength().getLength() != 0 )
                         {
-                            log.error("The DN " + baseObject.toString() + " is invalid");
-                            throw de;
+                            try
+                            {
+                                baseObject = new LdapDN( tlv.getValue().getData() );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error( "The root DN " + baseObject.toString() + " is
invalid" );
+                                throw new DecoderException( "The root DN " + baseObject.toString()
+ " is invalid" );
+                            }
                         }
                         
                         searchRequest.setBaseObject(baseObject);
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Searching with root DN : " + baseObject );
+                        }
+                       
                         return;
                     }
                 } );
@@ -191,11 +199,38 @@
 
                         // We have to check that this is a correct scope
                         Value value   = tlv.getValue();
+                        int   scope = 0;
 
-                        int   scope = IntegerDecoder.parse( value, LdapConstants.SCOPE_BASE_OBJECT,
LdapConstants.SCOPE_WHOLE_SUBTREE );
+                        try
+                        {
+                            scope = IntegerDecoder.parse( value, LdapConstants.SCOPE_BASE_OBJECT,
LdapConstants.SCOPE_WHOLE_SUBTREE );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error( "The scope is not in [0..2] : " + value.toString()
);
+                            throw new DecoderException( "The scope is not in [0..2] : " +
value.toString() );
+                        }
                         
                         searchRequest.setScope(scope);
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            switch ( scope )
+                            {
+                                case LdapConstants.SCOPE_BASE_OBJECT :
+                                    log.debug( "Searching within BASE_OBJECT scope " );
+                                    break;
+                            
+                                case LdapConstants.SCOPE_SINGLE_LEVEL :
+                                    log.debug( "Searching within SINGLE_LEVEL scope " );
+                                    break;
+
+                                case LdapConstants.SCOPE_WHOLE_SUBTREE :
+                                    log.debug( "Searching within WHOLE_SUBTREE scope " );
+                                    break;
+                            }
+                        }
+
                         return;
                     }
                 } );
@@ -240,11 +275,41 @@
 
                         // We have to check that this is a correct derefAliases
                         Value value   = tlv.getValue();
+                        int   derefAliases = 0;
 
-                        int   derefAliases = IntegerDecoder.parse( value, LdapConstants.NEVER_DEREF_ALIASES,
LdapConstants.DEREF_ALWAYS );
+                        try
+                        {
+                            derefAliases = IntegerDecoder.parse( value, LdapConstants.NEVER_DEREF_ALIASES,
LdapConstants.DEREF_ALWAYS );
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error( "The derefAlias is not in [0..3] : " + value.toString()
);
+                            throw new DecoderException( "The derefAlias is not in [0..3]
: " + value.toString() );
+                        }
                         
                         searchRequest.setDerefAliases( derefAliases );
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            switch ( derefAliases )
+                            {
+                                case LdapConstants.NEVER_DEREF_ALIASES :
+                                    log.debug( "Handling object strategy : NEVER_DEREF_ALIASES"
);
+                                    break;
+                            
+                                case LdapConstants.DEREF_IN_SEARCHING :
+                                    log.debug( "Handling object strategy : DEREF_IN_SEARCHING"
);
+                                    break;
+
+                                case LdapConstants.DEREF_FINDING_BASE_OBJ :
+                                    log.debug( "Handling object strategy : DEREF_FINDING_BASE_OBJ"
);
+                                    break;
+
+                                case LdapConstants.DEREF_ALWAYS :
+                                    log.debug( "Handling object strategy : DEREF_ALWAYS"
);
+                                    break;
+                            }
+                        }
                         return;
                     }
                 } );
@@ -282,11 +347,25 @@
                         // The current TLV should be a integer
                         // We get it and store it in sizeLimit
                         Value value     = tlv.getValue();
+                        int   sizeLimit = 0;
 
-                        int   sizeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE
);
+                        try
+                        {
+                            sizeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE
);
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error( "The sizeLimit is not a valid Integer: " + value.toString()
);
+                            throw new DecoderException( "The sizeLimit is not a valid Integer:
" + value.toString() );
+                        }
 
                         searchRequest.setSizeLimit( sizeLimit );
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The sizeLimit value is set to " + sizeLimit + " objects"
);
+                        }
+
                         return;
                     }
                 } );
@@ -325,10 +404,25 @@
                         // We get it and store it in timeLimit
                         Value value     = tlv.getValue();
 
-                        int   timeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE
);
+                        int   timeLimit = 0;
 
+                        try
+                        {
+                            timeLimit = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE
);
+                        }
+                        catch ( IntegerDecoderException ide )
+                        {
+                            log.error( "The timeLimit is not a valid Integer: " + value.toString()
);
+                            throw new DecoderException( "The timeLimit is not a valid Integer:
" + value.toString() );
+                        }
+                        
                         searchRequest.setTimeLimit( timeLimit );
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The timeLimit value is set to " + timeLimit + " seconds"
);
+                        }
+
                         return;
                     }
                 } );
@@ -374,6 +468,12 @@
 
                         searchRequest.setTypesOnly( BooleanDecoder.parse( value ) );
 
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "The search will return " + ( searchRequest.isTypesOnly()
? 
+                                        "only attributs type" : 
+                                        "attributes types and values" ) );
+                        }
                         return;
                     }
                 } );
@@ -560,12 +660,8 @@
                 LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG, LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE,
                 null);
         
-        // ...
-        //    attributes      AttributeDescriptionList }
-        // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
-        //    ...
-        // We have to create an array of elements to store the list of attributes
-        // to retrieve. We don't know yet how many attributes we will read.
+        // AttributeDescription ::= LDAPString (Value)
+        // Decodes the attribute description and stores it.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE][UniversalTag.OCTET_STRING_TAG]
=
             new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_VALUE,
                 LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG,
@@ -573,7 +669,6 @@
                 {
                     public void action( IAsn1Container container ) throws DecoderException
                     {
-
                         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
                             container;
 
@@ -581,8 +676,23 @@
                             ldapMessageContainer.getLdapMessage().getSearchRequest();
 
                         TLV                  tlv = ldapMessageContainer.getCurrentTLV();
+                        LdapString attributeDescription = null;
+                        
+                        try
+                        {
+                            attributeDescription = new LdapString( tlv.getValue().getData()
);
+                            searchRequest.addAttribute( attributeDescription );
+                        }
+                        catch ( LdapStringEncodingException lsee )
+                        {
+                            log.error( "Cannot decode the attribute description : " + StringUtils.dumpBytes(
tlv.getValue().getData() ) );
+                            throw new DecoderException( "Cannot decode the attribute description"
);
+                        }
                         
-                        searchRequest.addAttribute( new LdapString(tlv.getValue().getData()));
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Decoded Attribute Description : " + attributeDescription.getString()
);
+                        }
 
                         return;
                     }

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

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.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.LdapMessage;
 import org.apache.asn1new.ldap.pojo.SearchResultEntry;
 import org.slf4j.Logger;
@@ -69,7 +73,7 @@
         name       = SearchResultEntryGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Intitialisation
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_RESULT_ENTRY_STATE][256];
 
         //============================================================================================
@@ -141,12 +145,24 @@
                         // Store the value.
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            searchResultEntry.setObjectName( LdapDN.EMPTY_STRING );
+                            searchResultEntry.setObjectName( LdapDN.EMPTY_LDAPDN );
                         }
                         else
                         {
-                            searchResultEntry.setObjectName( new LdapDN(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                searchResultEntry.setObjectName( new LdapDN( tlv.getValue().getData()
) );
+                            }
+                            catch ( InvalidNameException ine )
+                            {
+                                log.error(" The DN " + StringUtils.dumpBytes( tlv.getValue().getData()
) + "is invalid : " + ine.getMessage() );
+                                throw new DecoderException( "The Dn is invalid : " + ine.getMessage()
);
+                            }
+                        }
+
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Search Result Entry DN found : " + searchResultEntry.getObjectName()
);
                         }
                     }
                 } );
@@ -244,15 +260,30 @@
                         TLV                  tlv                  =
                             ldapMessageContainer.getCurrentTLV();
 
+                        LdapString type = LdapString.EMPTY_STRING;
+
                         // Store the name
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            searchResultEntry.addAttributeValues( LdapString.EMPTY_STRING
);
+                            searchResultEntry.addAttributeValues( type );
                         }
                         else
                         {
-                            searchResultEntry.addAttributeValues( new LdapString(
-                                    tlv.getValue().getData() ) );
+                            try
+                            {
+                                type = new LdapString( tlv.getValue().getData() );
+                                searchResultEntry.addAttributeValues( type );
+                            }
+                            catch ( LdapStringEncodingException lsee )
+                            {
+                                log.error( "Invalid attribute type : " + StringUtils.dumpBytes(
tlv.getValue().getData() ) );
+                                throw new DecoderException( "The attribute type is invalid
: " + lsee.getMessage() );
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Attribute type : " + type );
                         }
                     }
                 } );
@@ -316,15 +347,22 @@
                         TLV                  tlv                  =
                             ldapMessageContainer.getCurrentTLV();
 
-                        // Store the name
+                        // Store the value
+                        OctetString value = OctetString.EMPTY_STRING;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            searchResultEntry.addAttributeValue( OctetString.EMPTY_STRING
);
+                            searchResultEntry.addAttributeValue( value );
                         }
                         else
                         {
-                            searchResultEntry.addAttributeValue( new OctetString(
-                                    tlv.getValue().getData() ) );
+                            value = new OctetString( tlv.getValue().getData() );
+                            searchResultEntry.addAttributeValue( value );
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Attribute value : " + value );
                         }
                     }
                 } );

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java
Sun Oct  9 06:51:08 2005
@@ -27,6 +27,7 @@
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
 import org.apache.asn1new.ldap.codec.primitives.LdapURL;
+import org.apache.asn1new.ldap.codec.primitives.LdapURLEncodingException;
 import org.apache.asn1new.ldap.pojo.LdapMessage;
 import org.apache.asn1new.ldap.pojo.SearchResultReference;
 import org.slf4j.Logger;
@@ -61,7 +62,7 @@
         name       = SearchResultReferenceGrammar.class.getName();
         statesEnum = LdapStatesEnum.getInstance();
 
-        // Initialisation of the transitions table
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_RESULT_REFERENCE_STATE_STATE][256];
 
         //============================================================================================
@@ -126,13 +127,30 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length server sasl credentials
+                        LdapURL url = LdapURL.EMPTY_URL;
+                        
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            searchResultReference.addSearchResultReference( LdapURL.EMPTY_STRING
);
+                            searchResultReference.addSearchResultReference( url );
                         }
                         else
                         {
-                            searchResultReference.addSearchResultReference( new LdapURL(
tlv.getValue().getData() ) );
+                            try
+                            {
+                                url = new LdapURL( tlv.getValue().getData() );
+                                searchResultReference.addSearchResultReference( url );
+                            }
+                            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()
);
+                            }
+                        }
+                        
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Search reference URL found : " + url );
                         }
                         
                         return;

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java?rev=307431&r1=307430&r2=307431&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java
Sun Oct  9 06:51:08 2005
@@ -73,7 +73,7 @@
         
         statesEnum = LdapStatesEnum.getInstance();
 
-        // We have 3 differents states, so 2 transitions between states.
+        // Create the transitions table
         super.transitions = new GrammarTransition[LdapStatesEnum.LAST_UNBIND_REQUEST_STATE][256];
 
         //============================================================================================
@@ -108,9 +108,10 @@
                         int expectedLength = tlv.getLength().getLength();
                         
                         // If the length is not null, this is an error.
-                        if (expectedLength != 0)
+                        if ( expectedLength != 0 )
                         {
-                            throw new DecoderException("The length of a UnBindRequest must
be null");
+                            log.error( "The length of a UnBindRequest must be null, the actual
value is " + expectedLength );
+                            throw new DecoderException( "The length of a UnBindRequest must
be null" );
                         }
 
                         unBindRequest.setParent( ldapMessage );



Mime
View raw message