From f571f9d7e26584b4e25ad6f113d090ba9e86d0ac Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 14 Sep 2011 09:35:42 +0000
Subject: [PATCH] Fix OPENDJ-280: Add support for the LDAP sub-entry control as defined in draft-ietf-ldup-subentry
---
opends/src/server/org/opends/server/core/DirectoryServer.java | 1 +
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java | 5 +++++
opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java | 25 +++++++++++++++++++++++++
opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java | 5 +++++
opends/src/server/org/opends/server/util/ServerConstants.java | 13 +++++++++++--
5 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 24dc1f4..ffe7f06 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -2607,6 +2607,7 @@
supportedControls.add(OID_AUTHZID_REQUEST);
supportedControls.add(OID_MATCHED_VALUES);
supportedControls.add(OID_LDAP_SUBENTRIES);
+ supportedControls.add(OID_LDUP_SUBENTRIES);
supportedControls.add(OID_PASSWORD_POLICY_CONTROL);
supportedControls.add(OID_PERMISSIVE_MODIFY_CONTROL);
supportedControls.add(OID_REAL_ATTRS_ONLY);
diff --git a/opends/src/server/org/opends/server/util/ServerConstants.java b/opends/src/server/org/opends/server/util/ServerConstants.java
index 24b5afc..c5b9d10 100644
--- a/opends/src/server/org/opends/server/util/ServerConstants.java
+++ b/opends/src/server/org/opends/server/util/ServerConstants.java
@@ -2273,14 +2273,23 @@
/**
- * The OID for the LDAP subentries control used to indicate that matching
- * subentries should be returned.
+ * The OID for the LDAP subentries control as defined in RFC 3672, which is
+ * used to indicate that matching subentries should be returned.
*/
public static final String OID_LDAP_SUBENTRIES = "1.3.6.1.4.1.4203.1.10.1";
/**
+ * The OID for the LDAP subentries control as defined in the legacy
+ * draft-ietf-ldup-subentry internet draft, which is used to indicate that
+ * matching subentries should be returned.
+ */
+ public static final String OID_LDUP_SUBENTRIES = "1.3.6.1.4.1.7628.5.101.1";
+
+
+
+ /**
* The OID for the matched values control used to specify which particular
* attribute values should be returned in a search result entry.
*/
diff --git a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index fff83a7..ebee95b 100644
--- a/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -547,6 +547,11 @@
getRequestControl(SubentriesControl.DECODER);
setReturnSubentriesOnly(subentriesControl.getVisibility());
}
+ else if (oid.equals(OID_LDUP_SUBENTRIES))
+ {
+ // Support for legacy draft-ietf-ldup-subentry.
+ setReturnSubentriesOnly(true);
+ }
else if (oid.equals(OID_MATCHED_VALUES))
{
MatchedValuesControl matchedValuesControl =
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
index 7ae0f00..352502b 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
@@ -515,6 +515,11 @@
getRequestControl(SubentriesControl.DECODER);
setReturnSubentriesOnly(subentriesControl.getVisibility());
}
+ else if (oid.equals(OID_LDUP_SUBENTRIES))
+ {
+ // Support for legacy draft-ietf-ldup-subentry.
+ setReturnSubentriesOnly(true);
+ }
else if (oid.equals(OID_MATCHED_VALUES))
{
MatchedValuesControl matchedValuesControl =
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
index 89f5504..fe17ab2 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -28,6 +28,7 @@
package org.opends.server.core;
+import static org.opends.server.util.ServerConstants.OID_LDUP_SUBENTRIES;
import static org.testng.Assert.*;
import java.io.IOException;
@@ -946,6 +947,30 @@
}
@Test
+ public void testSearchInternalLegacySubEntryControl() throws Exception
+ {
+ InvocationCounterPlugin.resetAllCounters();
+
+ InternalClientConnection conn =
+ InternalClientConnection.getRootConnection();
+
+ InternalSearchOperation searchOperation = new InternalSearchOperation(conn,
+ InternalClientConnection.nextOperationID(),
+ InternalClientConnection.nextMessageID(),
+ Collections.singletonList((Control) new LDAPControl(
+ OID_LDUP_SUBENTRIES, true)), ByteString.valueOf(BASE),
+ SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES,
+ Integer.MAX_VALUE, Integer.MAX_VALUE, false,
+ LDAPFilter.decode("(objectclass=*)"), null, null);
+
+ searchOperation.run();
+
+ assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
+ assertEquals(searchOperation.getEntriesSent(), 1);
+ assertEquals(searchOperation.getErrorMessage().length(), 0);
+ }
+
+ @Test
public void testSearchInternalSubEntryAndFilter() throws Exception
{
InvocationCounterPlugin.resetAllCounters();
--
Gitblit v1.10.0