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

Valery Kharseko
14 hours ago ace0dc341cf3a206345702029165e44fb6e8efd9
Fix CodeQL note-severity alerts: calls to the deprecated Entry compatibility methods (#826)
13 files modified
75 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java 9 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java 19 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java 9 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
@@ -12,6 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2013-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.adapter.server3x;
@@ -94,7 +95,7 @@
            org.opends.server.types.Entry entry =
                new org.opends.server.types.Entry(sdkEntry.getName(), null, null, null);
            Schema schema = DirectoryServer.getInstance().getServerContext().getSchema();
            List<ByteString> duplicateValues = new ArrayList<>();
            Collection<ByteString> duplicateValues = new ArrayList<>();
            for (org.opends.server.types.Attribute attribute : toAttributes(sdkEntry.getAllAttributes())) {
                if (attribute.getAttributeDescription().getAttributeType().isObjectClass()) {
                    for (ByteString attrName : attribute) {
@@ -128,7 +129,7 @@
                new org.opends.server.types.Entry(value.getName(), null, null, null);
            org.opends.server.types.SearchResultEntry searchResultEntry =
                new org.opends.server.types.SearchResultEntry(entry, to(value.getControls()));
            List<ByteString> duplicateValues = new ArrayList<>();
            Collection<ByteString> duplicateValues = new ArrayList<>();
            for (org.opends.server.types.Attribute attribute : toAttributes(value.getAllAttributes())) {
                searchResultEntry.addAttribute(attribute, duplicateValues);
            }
@@ -672,7 +673,7 @@
            @Override
            public int getAttributeCount() {
                return srvResultEntry.getAttributes().size();
                return Iterables.size(srvResultEntry.getAllAttributes());
            }
            @Override
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2008 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.authorization.dseecompat;
@@ -382,7 +383,7 @@
        //Only try to add the attribute type if it already hasn't been added.
        if (!retEntry.hasAttribute(attr.getAttributeDescription().getAttributeType()))
        {
          retEntry.addAttribute(attr,null);
          retEntry.addAttribute(attr);
        }
      }
    }
@@ -508,7 +509,7 @@
    addEntryLevelRightsInfo(container, mask, retEntry, "proxy");
    if(hasAttrMask(mask, ACL_RIGHTS)) {
      Attribute attr = Attributes.create(aclRightsEntryLevelStr, evalInfo.toString());
      retEntry.addAttribute(attr,null);
      retEntry.addAttribute(attr);
    }
  }
@@ -610,7 +611,7 @@
      // not but it is possible.
      if (!retEntry.hasAttribute(attr.getAttributeDescription().getAttributeType()))
      {
        retEntry.addAttribute(attr,null);
        retEntry.addAttribute(attr);
      }
    }
  }
@@ -633,7 +634,7 @@
     if(hasAttrMask(mask,ACL_RIGHTS_INFO)) {
      String typeStr = aclRightsInfoEntryLogsStr + ";" + rightStr;
      Attribute attr = Attributes.create(typeStr, container.getEvalSummary());
       retEntry.addAttribute(attr,null);
       retEntry.addAttribute(attr);
     }
   }
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -14,7 +14,7 @@
 * Copyright 2008-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2013 Manuel Gaupp
 * Portions Copyright 2024 3A Systems, LLC.
 * Portions Copyright 2024-2026 3A Systems, LLC.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.authorization.dseecompat;
@@ -413,7 +413,7 @@
    builder.addAllStrings(reference.getReferralURLs());
    final Entry e = new Entry(dn, null, null, null);
    e.addAttribute(builder.toAttribute(), null);
    e.addAttribute(builder.toAttribute());
    final SearchResultEntry se = new SearchResultEntry(e);
    final AciContainer container =
        new AciLDAPOperationContainer(operation, ACI_READ, se);
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java
@@ -20,7 +20,6 @@
import static org.opends.messages.AccessControlMessages.*;
import static org.opends.server.authorization.dseecompat.Aci.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -408,7 +407,7 @@
                                              SearchFilter filter) {
        Attribute attr = Attributes.create(attrType, value);
        Entry e = new Entry(DN.rootDN(), null, null, null);
        e.addAttribute(attr, new ArrayList<ByteString>());
        e.addAttribute(attr);
        try {
            return filter.matchesEntry(e);
        } catch(DirectoryException ex) {
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -1534,7 +1534,7 @@
  private static void addAttribute(final Entry e, final String attrType, final String attrValue)
  {
    e.addAttribute(Attributes.create(attrType, attrValue), null);
    e.addAttribute(Attributes.create(attrType, attrValue));
  }
  private static void addAttributeByType(String attrName, String attrValue,
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1053,7 +1053,7 @@
  {
    Attribute attr = Attributes.create(ATTR_DEBUG_SEARCH_INDEX, debugBuffer.toString());
    Entry entry = new Entry(DN.valueOf("cn=debugsearch"), null, null, null);
    entry.addAttribute(attr, new ArrayList<ByteString>());
    entry.addAttribute(attr);
    return entry;
  }
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -598,14 +598,14 @@
        // Add the key ID attribute.
        final Attribute keyIDAttr = Attributes.create(attrKeyID, distinguishedValue);
        entry.addAttribute(keyIDAttr, new ArrayList<ByteString>(0));
        entry.addAttribute(keyIDAttr);
        // Add the public key certificate attribute.
        AttributeBuilder builder = new AttributeBuilder(attrPublicKeyCertificate);
        builder.setOption("binary");
        builder.add(ByteString.wrap(instanceKeyCertificate));
        final Attribute certificateAttr = builder.toAttribute();
        entry.addAttribute(certificateAttr, new ArrayList<ByteString>(0));
        entry.addAttribute(certificateAttr);
        AddOperation addOperation = icc.processAdd(entry);
        if (ResultCode.SUCCESS != addOperation.getResultCode()) {
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2006-2009 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.protocols.internal;
@@ -807,7 +808,7 @@
    Entry e = newEntry(addRecord.getDN());
    Schema schema = DirectoryServer.getInstance().getServerContext().getSchema();
    ArrayList<ByteString> duplicateValues = new ArrayList<>();
    Collection<ByteString> duplicateValues = new ArrayList<>();
    for (Attribute a : addRecord.getAttributes())
    {
      if (a.getAttributeDescription().getAttributeType().isObjectClass())
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -234,7 +234,7 @@
    mods.add(new Modification(ModificationType.REPLACE, attr));
    // - update the already modified entry
    modifiedEntry.removeAttribute(attr.getAttributeDescription().getAttributeType());
    modifiedEntry.addAttribute(attr, null);
    modifiedEntry.addAttribute(attr);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2009 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.replication.plugin;
@@ -20,6 +21,7 @@
import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -452,7 +454,7 @@
      // Now flush attribute values into entry
      if (somethingToFlush)
      {
        List<ByteString> duplicateValues = new ArrayList<>();
        Collection<ByteString> duplicateValues = new ArrayList<>();
        entry.addAttribute(attrBuilder.toAttribute(), duplicateValues);
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -1031,6 +1031,21 @@
  /**
   * Ensures that this entry contains the provided attribute and its
   * values, ignoring any duplicate value.
   *
   * @param attribute
   *          The attribute to add or merge with this entry.
   * @see #addAttribute(Attribute, Collection)
   */
  public void addAttribute(Attribute attribute)
  {
    setAttribute(attribute, null, false /* merge */);
  }
  /**
   * Puts the provided attribute into this entry. If an attribute with
   * the provided type and options already exists, then it will be
   * replaced. If the provided attribute is empty then any existing
@@ -1438,7 +1453,7 @@
    switch (mod.getModificationType().asEnum())
    {
    case ADD:
      List<ByteString> duplicateValues = new LinkedList<>();
      Collection<ByteString> duplicateValues = new LinkedList<>();
      addAttribute(a, duplicateValues);
      if (!duplicateValues.isEmpty() && !relaxConstraints)
      {
@@ -1448,7 +1463,7 @@
      break;
    case DELETE:
      List<ByteString> missingValues = new LinkedList<>();
      Collection<ByteString> missingValues = new LinkedList<>();
      removeAttribute(a, missingValues);
      if (!missingValues.isEmpty() && !relaxConstraints)
      {
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -18,6 +18,7 @@
 */
package org.opends.server.workflowelement.localbackend;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -629,7 +630,7 @@
              ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getAttributeDescription()));
        }
        List<ByteString> missingValues = new LinkedList<>();
        Collection<ByteString> missingValues = new LinkedList<>();
        newEntry.removeAttribute(a, missingValues);
        if (missingValues.isEmpty())
@@ -648,7 +649,7 @@
          ava.getAttributeName(),
          ava.getAttributeValue());
      List<ByteString> duplicateValues = new LinkedList<>();
      Collection<ByteString> duplicateValues = new LinkedList<>();
      newEntry.addAttribute(a, duplicateValues);
      if (duplicateValues.isEmpty())
@@ -723,12 +724,12 @@
      switch (m.getModificationType().asEnum())
      {
        case ADD:
          List<ByteString> duplicateValues = new LinkedList<>();
          Collection<ByteString> duplicateValues = new LinkedList<>();
          newEntry.addAttribute(a, duplicateValues);
          break;
        case DELETE:
          List<ByteString> missingValues = new LinkedList<>();
          Collection<ByteString> missingValues = new LinkedList<>();
          newEntry.removeAttribute(a, missingValues);
          break;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -13,12 +13,13 @@
 *
 * Copyright 2008-2011 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2024-2025 3A Systems,LLC.
 * Portions Copyright 2024-2026 3A Systems,LLC.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.workflowelement.localbackend;
import java.math.BigInteger;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -1186,7 +1187,7 @@
    // Add the provided attribute or merge an existing attribute with
    // the values of the new attribute. If there are any duplicates, then fail.
    List<ByteString> duplicateValues = new LinkedList<>();
    Collection<ByteString> duplicateValues = new LinkedList<>();
    modifiedEntry.addAttribute(attr, duplicateValues);
    if (!duplicateValues.isEmpty() && !permissiveModify)
    {
@@ -1301,7 +1302,7 @@
    // Remove the specified attribute values or the entire attribute from the value.
    // If there are any specified values that were not present, then fail.
    // If the RDN attribute value would be removed, then fail.
    List<ByteString> missingValues = new LinkedList<>();
    Collection<ByteString> missingValues = new LinkedList<>();
    boolean attrExists = modifiedEntry.removeAttribute(attr, missingValues);
    AttributeDescription attrDesc = attr.getAttributeDescription();