mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
16.49.2015 b527ea7303ceca17afba69b6081e0a5811403707
Code  review: Matthew Swift

SevenBitCleanPlugin.java:
In doLDIFImport(), fixed a bug.
1 files modified
50 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java 50 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -130,24 +130,10 @@
    // processing an LDIF import, we don't have access to the set of public
    // naming contexts defined in the server, so if no explicit set of base DNs
    // is defined, then assume that the entry is in scope.
    Set<DN> baseDNs = config.getBaseDN();
    if ((baseDNs != null) && (! baseDNs.isEmpty()))
    if (!isDescendantOfAny(entry.getName(), config.getBaseDN()))
    {
      boolean found = true;
      for (DN baseDN : baseDNs)
      {
        if (baseDN.isAncestorOf(entry.getName()))
        {
          found = true;
          break;
        }
      }
      if (! found)
      {
        // The entry is out of scope, so we won't process it.
        return PluginResult.ImportLDIF.continueEntryProcessing();
      }
      // The entry is out of scope, so we won't process it.
      return PluginResult.ImportLDIF.continueEntryProcessing();
    }
@@ -164,8 +150,7 @@
            if (!is7BitClean(v))
            {
              LocalizableMessage rejectMessage =
                   ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(
                        a.getNameWithOptions());
                   ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions());
              return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage);
            }
          }
@@ -277,7 +262,7 @@
            // These are modification types that we will process.
            break;
          default:
            // This is not a modifiation type that we will process.
            // This is not a modification type that we will process.
            continue;
        }
@@ -394,22 +379,26 @@
  private final boolean isInScope(SevenBitCleanPluginCfg config, DN dn)
  {
    Set<DN> baseDNs = config.getBaseDN();
    if ((baseDNs == null) || baseDNs.isEmpty())
    if (baseDNs == null || baseDNs.isEmpty())
    {
      baseDNs = DirectoryServer.getPublicNamingContexts().keySet();
    }
    return isDescendantOfAny(dn, baseDNs);
  }
    boolean found = false;
    for (DN baseDN: baseDNs)
  private boolean isDescendantOfAny(DN dn, Set<DN> baseDNs)
  {
    if (baseDNs != null)
    {
      if (dn.isDescendantOf(baseDN))
      for (DN baseDN: baseDNs)
      {
        found = true;
        break;
        if (dn.isDescendantOf(baseDN))
        {
          return true;
        }
      }
    }
    return found;
    return false;
  }
@@ -424,16 +413,14 @@
   */
  private final boolean is7BitClean(ByteSequence value)
  {
    byte b;
    for (int i = 0; i < value.length(); i++)
    {
      b = value.byteAt(i);
      byte b = value.byteAt(i);
      if ((b & MASK) != b)
      {
        return false;
      }
    }
    return true;
  }
@@ -491,4 +478,3 @@
    return new ConfigChangeResult();
  }
}