directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 76216 - in incubator/directory: eve/trunk/protocol/src/java/org/apache/eve/protocol ldap/trunk/common/src/java/org/apache/ldap/common/message snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/decoder/search
Date Thu, 18 Nov 2004 07:40:13 GMT
Author: akarasulu
Date: Wed Nov 17 23:40:12 2004
New Revision: 76216

Modified:
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestProcessing.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestRule.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/AttributeEncoder.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/decoder/search/SearchRequestTest.java
Log:
Changes ...

 o found a bug in LockableAttributeImpl where serialized values for the keyMap
   were not being stored; we made the keyMap a non-transient field and made
   sure the keyMap is not null
 o found a bug in the Decoder where the state was not being reset; now the
   search decoder rule makes sure it resets the state of processing in finish()




Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
Wed Nov 17 23:40:12 2004
@@ -19,6 +19,8 @@
 
 import java.util.*;
 
+import javax.naming.Context;
+
 import org.apache.seda.protocol.ProtocolProvider;
 import org.apache.seda.protocol.RequestHandler;
 import org.apache.seda.listener.ClientKey;
@@ -116,6 +118,8 @@
     public LdapProtocolProvider( Hashtable env ) throws LdapNamingException
     {
         this.handlers = new HashMap();
+
+        env.put( Context.PROVIDER_URL, "" );
         SessionRegistry.getSingleton( env );
 
         Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
Wed Nov 17 23:40:12 2004
@@ -22,6 +22,7 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.Name;
 import javax.naming.ldap.LdapContext;
 import javax.naming.directory.SearchResult;
 import javax.naming.directory.SearchControls;
@@ -33,6 +34,7 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.common.util.ArrayUtils;
 import org.apache.ldap.common.message.*;
+import org.apache.ldap.common.name.LdapName;
 
 
 /**
@@ -167,7 +169,7 @@
                      * local variable for the following call to next()
                      */
                     Attribute ref = result.getAttributes().get( "ref" );
-                    if ( ref == null && ref.size() > 0 )
+                    if ( ref == null || ref.size() > 0 )
                     {
                         SearchResponseEntry respEntry;
                         respEntry = new SearchResponseEntryImpl( req.getMessageId() );
@@ -270,7 +272,7 @@
              * local variable for the following call to next()
              */
             Attribute ref = result.getAttributes().get( "ref" );
-            if ( ref == null && ref.size() > 0 )
+            if ( ref == null || ref.size() > 0 )
             {
                 SearchResponseEntry respEntry = new SearchResponseEntryImpl( req.getMessageId()
);
                 respEntry.setAttributes( result.getAttributes() );

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
Wed Nov 17 23:40:12 2004
@@ -19,6 +19,7 @@
 
 import java.util.*;
 import javax.naming.InitialContext;
+import javax.naming.Context;
 
 import org.apache.seda.listener.ClientKey;
 
@@ -68,10 +69,13 @@
         if ( env == null )
         {
             this.env = new Hashtable();
+            this.env.put( Context.PROVIDER_URL, "" );
+            this.env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory"
);
         }
         else
         {
             this.env = env;
+            this.env.put( Context.PROVIDER_URL, "" );
         }
     }
 

Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LockableAttributesImpl.java
Wed Nov 17 23:40:12 2004
@@ -44,7 +44,7 @@
     /** Map of user provided String ids to Attributes */
     private final Map map = new HashMap();
     /** Cache of lowercase id Strings to mixed cased user provided String ids */
-    private final transient Map keyMap;
+    private Map keyMap;
 
 
     // ------------------------------------------------------------------------
@@ -85,19 +85,19 @@
     {
         super( parent, false );
 
-        Iterator list = map.values().iterator();
-        while ( list.hasNext() )
-        {
-            Attribute attr = ( Attribute ) list.next();
-            this.map.put( attr.getID(), attr.clone() );
-        }
-
         this.keyMap = new HashMap();
 
         if ( keyMap != null )
         {
             this.keyMap.putAll( keyMap );
         }
+
+        Iterator list = map.values().iterator();
+        while ( list.hasNext() )
+        {
+            Attribute attr = ( Attribute ) list.next();
+            this.map.put( attr.getID(), attr.clone() );
+        }
     }
 
 
@@ -235,7 +235,11 @@
         if ( l_old != null )
         {
             map.remove( l_old.getID() );
-            keyMap.remove( l_old.getID().toLowerCase() );
+
+            if ( keyMap != null )
+            {
+                keyMap.remove( l_old.getID().toLowerCase() );
+            }
         }
 
         map.put( attr.getID(), attr );
@@ -263,7 +267,11 @@
         if ( l_old != null )
         {
             map.remove( l_old.getID() );
-            keyMap.remove( l_old.getID().toLowerCase() );
+
+            if ( keyMap != null )
+            {
+                keyMap.remove( l_old.getID().toLowerCase() );
+            }
         }
 
         return l_old;
@@ -386,6 +394,13 @@
      */
     private void setUserProvidedId( String userProvidedId )
     {
+        if ( keyMap == null )
+        {
+            keyMap = new HashMap();
+            keyMap.put( userProvidedId.toLowerCase(), userProvidedId );
+            return;
+        }
+
         if ( keyMap.get( userProvidedId ) == null )
         {
             keyMap.put( userProvidedId.toLowerCase(), userProvidedId );
@@ -407,6 +422,12 @@
         if ( map.containsKey( attrId ) )
         {
             return attrId;
+        }
+
+        if ( keyMap == null )
+        {
+            keyMap = new HashMap();
+            return null;
         }
 
         return ( String ) keyMap.get( attrId.toLowerCase() );

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestProcessing.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestProcessing.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestProcessing.java
Wed Nov 17 23:40:12 2004
@@ -93,6 +93,11 @@
         {
             state = SCOPE_STATE ;
         }
+
+        public String toString()
+        {
+            return "BaseObject";
+        }
     }
 
 
@@ -105,6 +110,11 @@
         {
             state = DEREF_ALIAS_STATE ;
         }
+
+        public String toString()
+        {
+            return "Scope";
+        }
     }
 
 
@@ -117,6 +127,11 @@
         {
             state = SIZE_LIMIT_STATE ;
         }
+
+        public String toString()
+        {
+            return "DerefAliasState";
+        }
     }
 
 
@@ -129,6 +144,11 @@
         {
             state = TIME_LIMIT_STATE ;
         }
+
+        public String toString()
+        {
+            return "SizeLimit";
+        }
     }
 
 
@@ -141,6 +161,11 @@
         {
             state = TYPES_ONLY_STATE ;
         }
+
+        public String toString()
+        {
+            return "TimeLimit";
+        }
     }
 
 
@@ -153,6 +178,11 @@
         {
             state = FILTER_STATE ;
         }
+
+        public String toString()
+        {
+            return "TypesOnly";
+        }
     }
 
 
@@ -165,6 +195,11 @@
         {
             state = ATTRIBUTES_STATE ;
         }
+
+        public String toString()
+        {
+            return "Filter";
+        }
     }
 
 
@@ -177,6 +212,11 @@
         {
             state = CONTROLS_STATE ;
         }
+
+        public String toString()
+        {
+            return "Attributes";
+        }
     }
 
 
@@ -188,6 +228,11 @@
         protected void next()
         {
             state = BASE_OBJECT_STATE ;
+        }
+
+        public String toString()
+        {
+            return "Controls";
         }
     }
 }

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestRule.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/decoder/search/SearchRequestRule.java
Wed Nov 17 23:40:12 2004
@@ -72,5 +72,6 @@
         super.finish();
         getDigester().pop();
         getDigester().pop();
+        this.processing.reset();
     }
 }

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/AttributeEncoder.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/AttributeEncoder.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/AttributeEncoder.java
Wed Nov 17 23:40:12 2004
@@ -83,8 +83,18 @@
 
         while ( list.hasMoreElements() )
         {
-            child = ( DefaultMutableTupleNode )
-                EncoderUtils.encode( ( String ) list.nextElement() );
+            Object next = list.nextElement();
+
+            if ( next instanceof String )
+            {
+                child = ( DefaultMutableTupleNode )
+                    EncoderUtils.encode( ( String ) next );
+            }
+            else
+            {
+                child = ( DefaultMutableTupleNode )
+                    EncoderUtils.encode( ( byte[] ) next );
+            }
             setOf.addFront( child );
             child.setParent( setOf );
         }

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/decoder/search/SearchRequestTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/decoder/search/SearchRequestTest.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/decoder/search/SearchRequestTest.java
Wed Nov 17 23:40:12 2004
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.nio.ByteBuffer;
 
 import org.apache.ldap.common.message.*;
 import org.apache.ldap.common.filter.*;
@@ -52,6 +53,70 @@
     {
         super.tearDown();
         normalizer = null;
+    }
+
+
+    private byte[] failingRequest0 = {
+    0x30, 0x2e, 0x02, 0x01, 0x03, 0x63, 0x29, 0x04,
+    0x09, 0x6f, 0x75, 0x3d, 0x73, 0x79, 0x73, 0x74,
+    0x65, 0x6d, 0x0a, 0x01, 0x00, 0x0a, 0x01, 0x03,
+    0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01,
+    0x00, (byte) 0x87, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+    0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x30, 0x00 };
+
+
+    public void testFailingRequest0() throws Exception
+    {
+        ByteBuffer buf = ByteBuffer.wrap( failingRequest0 );
+
+        SearchRequest req = ( SearchRequest ) super.snickersDecode( buf );
+        assertEquals( 3, req.getMessageId() );
+        assertEquals( MessageTypeEnum.SEARCHREQUEST, req.getType() );
+        assertEquals( 0, req.getSizeLimit() );
+        assertEquals( 0, req.getTimeLimit() );
+        assertEquals( "ou=system", req.getBase() );
+        assertEquals( ScopeEnum.BASEOBJECT, req.getScope() );
+        assertEquals( DerefAliasesEnum.DEREFALWAYS, req.getDerefAliases() );
+        assertEquals( false, req.getTypesOnly() );
+
+        assertTrue( req.getControls().isEmpty() );
+        assertTrue( req.getAttributes().isEmpty() );
+        assertEquals( "(objectClass=*)", req.getFilter().toString().trim() );
+    }
+
+
+    public void testFailingRequest0Twice() throws Exception
+    {
+        ByteBuffer buf = ByteBuffer.wrap( failingRequest0 );
+
+        SearchRequest req = ( SearchRequest ) super.snickersDecode( buf );
+        assertEquals( 3, req.getMessageId() );
+        assertEquals( MessageTypeEnum.SEARCHREQUEST, req.getType() );
+        assertEquals( 0, req.getSizeLimit() );
+        assertEquals( 0, req.getTimeLimit() );
+        assertEquals( "ou=system", req.getBase() );
+        assertEquals( ScopeEnum.BASEOBJECT, req.getScope() );
+        assertEquals( DerefAliasesEnum.DEREFALWAYS, req.getDerefAliases() );
+        assertEquals( false, req.getTypesOnly() );
+
+        assertTrue( req.getControls().isEmpty() );
+        assertTrue( req.getAttributes().isEmpty() );
+        assertEquals( "(objectClass=*)", req.getFilter().toString().trim() );
+
+        buf.rewind();
+        req = ( SearchRequest ) super.snickersDecode( buf );
+        assertEquals( 3, req.getMessageId() );
+        assertEquals( MessageTypeEnum.SEARCHREQUEST, req.getType() );
+        assertEquals( 0, req.getSizeLimit() );
+        assertEquals( 0, req.getTimeLimit() );
+        assertEquals( "ou=system", req.getBase() );
+        assertEquals( ScopeEnum.BASEOBJECT, req.getScope() );
+        assertEquals( DerefAliasesEnum.DEREFALWAYS, req.getDerefAliases() );
+        assertEquals( false, req.getTypesOnly() );
+
+        assertTrue( req.getControls().isEmpty() );
+        assertTrue( req.getAttributes().isEmpty() );
+        assertEquals( "(objectClass=*)", req.getFilter().toString().trim() );
     }
 
 

Mime
View raw message