From 7469f277aaff12b15be7e8fbc302b216d5e1adf3 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 26 Sep 2007 02:19:37 +0000
Subject: [PATCH] Update the appropriate identity mappers and certificate mappers to use the new isIndexed API in the backend to ensure that all referenced attributes are indexed for equality.

---
 opends/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java b/opends/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java
index 9fe1fed..885b12d 100644
--- a/opends/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java
+++ b/opends/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java
@@ -34,6 +34,7 @@
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
@@ -41,6 +42,7 @@
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.RegularExpressionIdentityMapperCfg;
 import org.opends.server.admin.std.server.IdentityMapperCfg;
+import org.opends.server.api.Backend;
 import org.opends.server.api.IdentityMapper;
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.DirectoryServer;
@@ -53,6 +55,7 @@
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.DN;
 import org.opends.server.types.Entry;
+import org.opends.server.types.IndexType;
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.ResultCode;
 import org.opends.server.types.SearchFilter;
@@ -144,10 +147,32 @@
     }
 
 
-    // Get the attribute types to use for the searches.
+    // Get the attribute types to use for the searches.  Ensure that they are
+    // all indexed for equality.
     attributeTypes =
          currentConfig.getMatchAttribute().toArray(new AttributeType[0]);
 
+    Set<DN> cfgBaseDNs = configuration.getMatchBaseDN();
+    if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty())
+    {
+      cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
+    }
+
+    for (AttributeType t : attributeTypes)
+    {
+      for (DN baseDN : cfgBaseDNs)
+      {
+        Backend b = DirectoryServer.getBackend(baseDN);
+        if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY)))
+        {
+          throw new ConfigException(ERR_REGEXMAP_ATTR_UNINDEXED.get(
+                                         configuration.dn().toString(),
+                                         t.getNameOrOID(),
+                                         b.getBackendID()));
+        }
+      }
+    }
+
 
     // Create the attribute list to include in search requests.  We want to
     // include all user and operational attributes.
@@ -324,6 +349,30 @@
   {
     boolean configAcceptable = true;
 
+    // Make sure that all of the configured attributes are indexed for equality
+    // in all appropriate backends.
+    Set<DN> cfgBaseDNs = configuration.getMatchBaseDN();
+    if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty())
+    {
+      cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
+    }
+
+    for (AttributeType t : configuration.getMatchAttribute())
+    {
+      for (DN baseDN : cfgBaseDNs)
+      {
+        Backend b = DirectoryServer.getBackend(baseDN);
+        if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY)))
+        {
+          unacceptableReasons.add(ERR_REGEXMAP_ATTR_UNINDEXED.get(
+                                       configuration.dn().toString(),
+                                       t.getNameOrOID(),
+                                       b.getBackendID()));
+          configAcceptable = false;
+        }
+      }
+    }
+
     // Make sure that we can parse the match pattern.
     try
     {

--
Gitblit v1.10.0