harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r650909 - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/org/apache/harmony/jndi/provider/ldap/ test/java/org/apache/harmony/jndi/provider/ldap/ test/java/org/apache/harmony/jndi/provider/ldap/mock/
Date Wed, 23 Apr 2008 15:35:20 GMT
Author: tellison
Date: Wed Apr 23 08:35:17 2008
New Revision: 650909

URL: http://svn.apache.org/viewvc?rev=650909&view=rev
Log:
Apply patch HARMONY-5782 ([classlib][jndi][ldap] - LdapContextImpl process federal name is
not correct)

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ExtendedOp.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ExtendedOp.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ExtendedOp.java?rev=650909&r1=650908&r2=650909&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ExtendedOp.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ExtendedOp.java
Wed Apr 23 08:35:17 2008
@@ -61,7 +61,7 @@
         return request;
     }
 
-    public ExtendedResponse getExtendedResponse() {
+    public ExtendedResponse getExtendedResponse() throws NamingException {
 
         if (result != null && result.getResultCode() == 0
                 && responseValues != null) {
@@ -74,13 +74,9 @@
             if (value != null) {
                 length = value.length;
             }
-            
-            try {
-                response = request.createExtendedResponse(id, value, 0, length);
-            } catch (NamingException e) {
-                // FIXME: how to deal with this exception
-                e.printStackTrace();
-            }
+
+            response = request.createExtendedResponse(id, value, 0, length);
+
         }
         return response;
     }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java?rev=650909&r1=650908&r2=650909&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapContextImpl.java
Wed Apr 23 08:35:17 2008
@@ -114,7 +114,7 @@
     /**
      * name of the context
      */
-    protected Name contextDn;
+    protected LdapName contextDn;
 
     private Control[] requestControls;
 
@@ -364,7 +364,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * contex
@@ -525,7 +525,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -694,10 +694,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
-            if (!(name.getPrefix(0) instanceof LdapName)) {
-                throw new InvalidNameException(Messages.getString("ldap.26")); //$NON-NLS-1$
-            }
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -916,8 +913,10 @@
 
     /*
      * Sample schema value from Openldap server is ( 2.5.13.8 NAME
-     * 'numericStringMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 ) TODO check
-     * with RFC to see whether all the schema definition has been catered for
+     * 'numericStringMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )
+     * 
+     * TODO check with RFC to see whether all the schema definition has been
+     * catered for
      */
     private static void parseValue(String schemaType, String value,
             Hashtable<String, Hashtable<String, Object>> schemaDefs) {
@@ -1161,7 +1160,7 @@
             throw new NullPointerException(Messages.getString("ldap.27")); //$NON-NLS-1$
         }
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1172,6 +1171,10 @@
             return;
         }
 
+        if (modificationItems.length == 0) {
+            return;
+        }
+
         /*
          * there is only one ldap ns
          */
@@ -1257,7 +1260,7 @@
             Attributes attributes, String[] as) throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1332,7 +1335,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1692,10 +1695,7 @@
     public void destroySubcontext(Name name) throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
-            if (!(name.getPrefix(0) instanceof LdapName)) {
-                throw new InvalidNameException(Messages.getString("ldap.26")); //$NON-NLS-1$
-            }
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1739,10 +1739,7 @@
     }
 
     public NameParser getNameParser(Name name) throws NamingException {
-        if (name instanceof CompositeName && name.size() > 1) {
-            if (!(name.getPrefix(0) instanceof LdapName)) {
-                throw new InvalidNameException(Messages.getString("ldap.26")); //$NON-NLS-1$
-            }
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1763,10 +1760,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
-            if (!(name.getPrefix(0) instanceof LdapName)) {
-                throw new InvalidNameException(Messages.getString("ldap.26")); //$NON-NLS-1$
-            }
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -1836,6 +1830,21 @@
         return target.toString();
     }
 
+    protected boolean hasMultiNamingSpace(Name name) {
+        if (name instanceof CompositeName) {
+            // name '/'
+            if (name.size() == 1 && "".equals(name.get(0))) {
+                return true;
+            }
+
+            if (name.size() > 1) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     protected Context findNnsContext(Name name) throws NamingException {
         CannotProceedException cpe = null;
         if (env.containsKey(NamingManager.CPE)) {
@@ -1844,35 +1853,40 @@
             cpe = new CannotProceedException();
         }
 
-        Name remainingName = name.getSuffix(1);
-        Name altName = name.getPrefix(0);
-        Name targetName = composeName(altName, contextDn);
+        String dn = name.get(0);
+
+        // seems altName always is "/"
+        Name altName = new CompositeName();
+        altName.add("");
+
+        // if the dn doesn't exist, throw NameNotFoundException
+        lookup(dn);
 
         Name resolvedName = cpe.getResolvedName();
         if (resolvedName == null) {
             resolvedName = new CompositeName();
 
-        } else if (resolvedName.size() >= 2
-                && resolvedName.get(resolvedName.size() - 1).equals("")) {
-            // remove the last component if it is ""
-            // (the sign of the next naming system), so there must be at least
-            // one name before "".
-            resolvedName.remove(resolvedName.size() - 1);
         }
 
-        resolvedName.add(targetName.toString());
-        // add empty component name to indicate nns pointer
-        resolvedName.add("");
+        resolvedName.add(dn);
+
+        Name remainingName = name.getSuffix(1);
+        if (remainingName.size() == 1 && remainingName.get(0).equals("")) {
+            remainingName = new CompositeName();
+            if (!resolvedName.get(resolvedName.size() - 1).equals("")) {
+                resolvedName.add("");
+            }
+        }
+
+        final LdapContextImpl context = new LdapContextImpl(this, env,
+                composeName(new LdapName(dn), contextDn).toString());
 
         cpe.setAltName(altName);
-        cpe.setAltNameCtx(this);
+        cpe.setAltNameCtx(context);
         cpe.setEnvironment((Hashtable<Object, Object>) env.clone());
         cpe.setRemainingName(remainingName);
         cpe.setResolvedName(resolvedName);
 
-        final LdapContextImpl context = new LdapContextImpl(this, env,
-                composeName(altName, contextDn).toString());
-
         RefAddr addr = new RefAddr("nns") { //$NON-NLS-1$
 
             private static final long serialVersionUID = -5428706819217461955L;
@@ -1884,7 +1898,9 @@
 
         };
 
-        Reference ref = new Reference(context.getClass().getName(), addr);
+        // class name is always java.lang.Object in RI
+        Reference ref = new Reference(Object.class.getName(), addr);
+
         cpe.setResolvedObj(ref);
 
         return DirectoryManager.getContinuationDirContext(cpe);
@@ -1899,7 +1915,7 @@
             throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * contex
@@ -1945,7 +1961,7 @@
     public Object lookup(Name name) throws NamingException {
         checkName(name);
 
-        if (name instanceof CompositeName && name.size() > 1) {
+        if (hasMultiNamingSpace(name)) {
             /*
              * multi ns, find next ns context, delegate operation to the next
              * context
@@ -2161,8 +2177,7 @@
             throw new InvalidNameException(Messages.getString("ldap.2A")); //$NON-NLS-1$
         }
 
-        if (nOld instanceof CompositeName && nOld.size() > 1
-                && nNew instanceof CompositeName && nNew.size() > 1) {
+        if (hasMultiNamingSpace(nOld) && hasMultiNamingSpace(nNew)) {
             Context context = findNnsContext(nOld);
             context.rename(nOld.getSuffix(1), nNew.getSuffix(1));
             return;
@@ -2308,10 +2323,19 @@
         return controls;
     }
 
-    private void checkName(Name name) {
+    private void checkName(Name name) throws InvalidNameException {
         if (name == null) {
             // jndi.2E=The name is null
             throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
+        }
+
+        if (!(name instanceof LdapName) && !(name instanceof CompositeName)) {
+            throw new InvalidNameException(Messages.getString("ldap.26")); //$NON-NLS-1$
+        }
+
+        // the first part of CompositeName must be ldap name
+        if (name instanceof CompositeName && name.size() > 0) {
+            new LdapName(name.get(0));
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java?rev=650909&r1=650908&r2=650909&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/LdapMessage.java
Wed Apr 23 08:35:17 2008
@@ -196,7 +196,8 @@
         // ABANDON, UNBIND and DELETE request are ASN.1 primitive
         if (opIndex == LdapASN1Constant.OP_ABANDON_REQUEST
                 || opIndex == LdapASN1Constant.OP_DEL_REQUEST
-                || opIndex == LdapASN1Constant.OP_UNBIND_REQUEST) {
+                || opIndex == LdapASN1Constant.OP_UNBIND_REQUEST
+                || opIndex == LdapASN1Constant.OP_SEARCH_RESULT_REF) {
             Object[] objs = new Object[1];
             requestOp.encodeValues(objs);
             values[1] = new ChosenValue(opIndex, objs[0]);

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java?rev=650909&r1=650908&r2=650909&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/LdapContextServerMockedTest.java
Wed Apr 23 08:35:17 2008
@@ -17,10 +17,18 @@
 
 package org.apache.harmony.jndi.provider.ldap;
 
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 
+import javax.naming.CannotProceedException;
+import javax.naming.CompositeName;
 import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
 import javax.naming.PartialResultException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
 import javax.naming.ReferralException;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
@@ -32,7 +40,9 @@
 
 import junit.framework.TestCase;
 
+import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Encodable;
 import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
+import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
 import org.apache.harmony.jndi.provider.ldap.mock.BindResponse;
 import org.apache.harmony.jndi.provider.ldap.mock.EncodableLdapResult;
 import org.apache.harmony.jndi.provider.ldap.mock.MockLdapServer;
@@ -46,8 +56,14 @@
     public void setUp() throws Exception {
         server = new MockLdapServer();
         server.start();
-        env.put(Context.INITIAL_CONTEXT_FACTORY,
-                "org.apache.harmony.jndi.provider.ldap.LdapContextFactory");
+        try {
+            Class.forName("com.sun.jndi.ldap.LdapCtxFactory");
+            env.put(Context.INITIAL_CONTEXT_FACTORY,
+                    "com.sun.jndi.ldap.LdapCtxFactory");
+        } catch (Exception e) {
+            env.put(Context.INITIAL_CONTEXT_FACTORY,
+                    "org.apache.harmony.jndi.provider.ldap.LdapContextFactory");
+        }
         env.put(Context.PROVIDER_URL, server.getURL());
         env.put(Context.SECURITY_AUTHENTICATION, "simple");
         env.put(Context.SECURITY_PRINCIPAL, "");
@@ -304,6 +320,41 @@
         }
     }
 
+    public void testSearchReferralFollow() throws Exception {
+        env.put(Context.REFERRAL, "follow");
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        DirContext context = new InitialDirContext(env);
+
+        final MockLdapServer referralServer = new MockLdapServer();
+        referralServer.start();
+
+        ASN1Encodable ref = new ASN1Encodable() {
+
+            public void encodeValues(Object[] values) {
+                List<byte[]> list = new ArrayList<byte[]>();
+                list.add(Utils.getBytes(referralServer.getURL()));
+                values[0] = list;
+            }
+
+        };
+
+        server.setResponseSeq(new LdapMessage[] {
+                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_REF, ref,
+                        null),
+                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                        new EncodableLdapResult(), null) });
+
+        referralServer.setResponseSeq(new LdapMessage[] {
+                new LdapMessage(LdapASN1Constant.OP_BIND_RESPONSE,
+                        new BindResponse(), null),
+                new LdapMessage(LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                        new EncodableLdapResult(), null) });
+
+        context.search("cn=test", null);
+        
+    }
+
     public void testReferralFollow() throws Exception {
         env.put(Context.REFERRAL, "follow");
         server.setResponseSeq(new LdapMessage[] { new LdapMessage(
@@ -465,4 +516,101 @@
         another.reconnect(null);
     }
 
+    public void testFederation() throws Exception {
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
+        LdapContext context = new InitialLdapContext(env, null);
+
+        /*
+         * test invalid name 'test'
+         */
+        try {
+            context.getAttributes(new CompositeName("test"));
+            fail("Should throw InvalidNameException");
+        } catch (InvalidNameException e) {
+            // expected
+        }
+
+        /*
+         * test name '/usr/bin/cn=test'
+         */
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                new EncodableLdapResult(), null) });
+        try {
+            context.lookup("/usr/bin/cn=test");
+            fail("Should throw CannotProceedException");
+        } catch (CannotProceedException e) {
+            assertEquals("/", e.getAltName().toString());
+            assertEquals("usr/bin/cn=test", e.getRemainingName().toString());
+            assertNull(e.getRemainingNewName());
+            assertTrue(e.getResolvedName() instanceof CompositeName);
+            assertEquals(1, e.getResolvedName().size());
+            assertEquals("/", e.getResolvedName().toString());
+            assertTrue(e.getAltNameCtx() instanceof LdapContext);
+            assertEquals(context.getNameInNamespace(), e
+                    .getAltNameCtx().getNameInNamespace());
+            assertTrue(e.getResolvedObj() instanceof Reference);
+
+            Reference ref = (Reference) e.getResolvedObj();
+            assertEquals(Object.class.getName(), ref.getClassName());
+            assertNull(ref.getFactoryClassLocation());
+            assertNull(ref.getFactoryClassName());
+
+            assertEquals(1, ref.size());
+            RefAddr addr = ref.get(0);
+            assertTrue(addr.getContent() instanceof LdapContext);
+            assertEquals(context.getNameInNamespace(),
+                    ((LdapContext) addr.getContent()).getNameInNamespace());
+            assertEquals("nns", addr.getType());
+        }
+
+        /*
+         * test name 'usr/bin/cn=test'
+         */
+        try {
+            context.getAttributes("usr/bin/cn=test");
+            fail("Should throw InvalidNameException");
+        } catch (InvalidNameException e) {
+            // expected
+        }
+
+        /*
+         * test name '/'
+         */
+        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
+                LdapASN1Constant.OP_SEARCH_RESULT_DONE,
+                new EncodableLdapResult(), null) });
+        try {
+            Name name = new CompositeName();
+            name.add("");
+            context.getAttributes(name);
+            fail("Should throw CannotProceedException");
+        } catch (CannotProceedException e) {
+            assertEquals("/", e.getAltName().toString());
+            assertTrue(e.getRemainingName() instanceof CompositeName);
+            assertEquals(0, e.getRemainingName().size());
+            assertEquals("", e.getRemainingName().toString());
+            assertNull(e.getRemainingNewName());
+            assertTrue(e.getResolvedName() instanceof CompositeName);
+            assertEquals(1, e.getResolvedName().size());
+            assertEquals("/", e.getResolvedName().toString());
+            assertTrue(e.getAltNameCtx() instanceof LdapContext);
+            assertEquals(context.getNameInNamespace(), e
+                    .getAltNameCtx().getNameInNamespace());
+            assertTrue(e.getResolvedObj() instanceof Reference);
+
+            Reference ref = (Reference) e.getResolvedObj();
+            assertEquals(Object.class.getName(), ref.getClassName());
+            assertNull(ref.getFactoryClassLocation());
+            assertNull(ref.getFactoryClassName());
+
+            assertEquals(1, ref.size());
+            RefAddr addr = ref.get(0);
+            assertTrue(addr.getContent() instanceof LdapContext);
+            assertEquals(context.getNameInNamespace(),
+                    ((LdapContext) addr.getContent()).getNameInNamespace());
+            assertEquals("nns", addr.getType());
+        }
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java?rev=650909&r1=650908&r2=650909&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/mock/MockLdapServer.java
Wed Apr 23 08:35:17 2008
@@ -25,6 +25,7 @@
 import java.util.LinkedList;
 
 import org.apache.harmony.jndi.provider.ldap.LdapMessage;
+import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
 import org.apache.harmony.security.asn1.ASN1Integer;
 
 /**
@@ -49,8 +50,6 @@
 
     private boolean isStopped;
 
-    private static int DEFAULT_PORT = 1024;
-
     public MockLdapServer() {
         // do nothing
     }
@@ -113,12 +112,14 @@
     public void run() {
         InputStream in = null;
         OutputStream out = null;
+        int searchID = -1;
+
         try {
             socket = server.accept();
             in = socket.getInputStream();
             out = socket.getOutputStream();
             while (!isStopped) {
-				if (responses.size() == 0) {
+                if (responses.size() == 0) {
                     try {
                         synchronized (lock) {
                             lock.wait();
@@ -128,28 +129,47 @@
                     }
                 } else {
 
-					while (true) {
-						LdapMessage temp = null;
-						synchronized (responses) {
-							if (responses.size() == 0) {
-								break;
-							}
-							temp = responses.removeFirst();
-						}
-						
+                    boolean isContinue = false;
+
+                    while (true) {
+                        LdapMessage temp = null;
+                        synchronized (responses) {
+                            if (responses.size() == 0) {
+                                break;
+                            }
+                            temp = responses.removeFirst();
+                        }
+
                         final MockLdapMessage response = new MockLdapMessage(
-								temp);
-                        LdapMessage request = new LdapMessage(null) {
-                            public void decodeValues(Object[] values) {
-                                response.setMessageId(ASN1Integer
-                                        .toIntValue(values[0]));
+                                temp);
+
+                        if (!isContinue) {
+                            LdapMessage request = new LdapMessage(null) {
+                                public void decodeValues(Object[] values) {
+                                    response.setMessageId(ASN1Integer
+                                            .toIntValue(values[0]));
+                                }
+                            };
+
+                            request.decode(in);
+
+                            if (response.getOperationIndex() == LdapASN1Constant.OP_SEARCH_RESULT_ENTRY
+                                    || response.getOperationIndex() == LdapASN1Constant.OP_SEARCH_RESULT_REF)
{
+                                isContinue = true;
+                                searchID = response.getMessageId();
+                            } else {
+                                isContinue = false;
                             }
-                        };
-                        request.decode(in);
+                        }
+
                         try {
                             Thread.sleep(10);
                         } catch (InterruptedException e) {
-                            //ignore
+                            // ignore
+                        }
+
+                        if (isContinue) {
+                            response.setMessageId(searchID);
                         }
                         out.write(response.encode());
                     }



Mime
View raw message