From aae7a119d2b8daa9b190e7ee532efb18634b04f5 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 28 Oct 2014 16:13:16 +0000
Subject: [PATCH] OPENDJ-1585 Remove DN equality matching rule usage to prevent indirect usage of DN.toNormalizedString() in ReferentialIntegrityPlugin
---
opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java | 46 ++++++++++++++--------------------------------
1 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index 6da82a6..b171073 100644
--- a/opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -57,7 +57,6 @@
import org.opends.server.admin.std.server.ReferentialIntegrityPluginCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.DirectoryThread;
-import org.opends.server.api.MatchingRule;
import org.opends.server.api.ServerShutdownListener;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
@@ -335,7 +334,7 @@
for (DN baseDN : cfgBaseDNs)
{
- Backend b = DirectoryServer.getBackend(baseDN);
+ Backend<?> b = DirectoryServer.getBackend(baseDN);
if ((b != null) && (!b.isIndexed(type, IndexType.EQUALITY)))
{
isAcceptable = false;
@@ -666,14 +665,11 @@
*/
private Set<DN> getBaseDNsToSearch()
{
- if(baseDNs.isEmpty())
+ if (baseDNs.isEmpty())
{
return DirectoryServer.getPublicNamingContexts().keySet();
}
- else
- {
- return baseDNs;
- }
+ return baseDNs;
}
/**
@@ -1232,31 +1228,22 @@
* @return The SUCCESS if the integrity is maintained or
* CONSTRAINT_VIOLATION otherwise
*/
- private PluginResult.PreOperation isIntegrityMaintained(Attribute attr,
- DN entryDN,
- DN entryBaseDN)
+ private PluginResult.PreOperation isIntegrityMaintained(Attribute attr, DN entryDN, DN entryBaseDN)
{
- final MatchingRule rule = attr.getAttributeType().getEqualityMatchingRule();
try
{
for (ByteString attrVal : attr)
{
- DN valueEntryDN = DN.decode(rule.normalizeAttributeValue(attrVal));
+ DN valueEntryDN = DN.decode(attrVal);
final Entry valueEntry;
- if (currentConfiguration.getCheckReferencesScopeCriteria()
- == CheckReferencesScopeCriteria.NAMING_CONTEXT)
+ if (currentConfiguration.getCheckReferencesScopeCriteria() == CheckReferencesScopeCriteria.NAMING_CONTEXT)
{
- if (valueEntryDN.matchesBaseAndScope(entryBaseDN,
- SearchScope.SUBORDINATES))
+ if (valueEntryDN.matchesBaseAndScope(entryBaseDN, SearchScope.SUBORDINATES))
{
- return PluginResult.PreOperation.stopProcessing(
- ResultCode.CONSTRAINT_VIOLATION,
- ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(
- valueEntryDN, attr.getName(), entryDN)
- );
+ return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION,
+ ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attr.getName(), entryDN));
}
-
valueEntry = DirectoryServer.getEntry(valueEntryDN);
}
else
@@ -1267,27 +1254,22 @@
// Verify that the value entry exists in the backend.
if (valueEntry == null)
{
- return PluginResult.PreOperation.stopProcessing(
- ResultCode.CONSTRAINT_VIOLATION,
- ERR_PLUGIN_REFERENT_ENTRY_MISSING.get(
- valueEntryDN, attr.getName(), entryDN));
+ return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION,
+ ERR_PLUGIN_REFERENT_ENTRY_MISSING.get(valueEntryDN, attr.getName(), entryDN));
}
// Verify that the value entry conforms to the filter.
SearchFilter filter = attrFiltMap.get(attr.getAttributeType());
if (filter != null && !filter.matchesEntry(valueEntry))
{
- return PluginResult.PreOperation.stopProcessing(
- ResultCode.CONSTRAINT_VIOLATION,
- ERR_PLUGIN_REFERENT_FILTER_MISMATCH.get(
- valueEntry.getName(), attr.getName(), entryDN, filter));
+ return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION,
+ ERR_PLUGIN_REFERENT_FILTER_MISMATCH.get(valueEntry.getName(), attr.getName(), entryDN, filter));
}
}
}
catch (Exception de)
{
- return PluginResult.PreOperation.stopProcessing(
- ResultCode.OTHER,
+ return PluginResult.PreOperation.stopProcessing(ResultCode.OTHER,
ERR_PLUGIN_REFERENT_EXCEPTION.get(de.getLocalizedMessage()));
}
--
Gitblit v1.10.0