Fix CodeQL note-severity alerts: calls to the deprecated Entry compatibility methods (#826)
| | |
| | | * 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; |
| | | |
| | |
| | | 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) { |
| | |
| | | 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); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public int getAttributeCount() { |
| | | return srvResultEntry.getAttributes().size(); |
| | | return Iterables.size(srvResultEntry.getAllAttributes()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | //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); |
| | | } |
| | | } |
| | | } |
| | |
| | | addEntryLevelRightsInfo(container, mask, retEntry, "proxy"); |
| | | if(hasAttrMask(mask, ACL_RIGHTS)) { |
| | | Attribute attr = Attributes.create(aclRightsEntryLevelStr, evalInfo.toString()); |
| | | retEntry.addAttribute(attr,null); |
| | | retEntry.addAttribute(attr); |
| | | } |
| | | } |
| | | |
| | |
| | | // not but it is possible. |
| | | if (!retEntry.hasAttribute(attr.getAttributeDescription().getAttributeType())) |
| | | { |
| | | retEntry.addAttribute(attr,null); |
| | | retEntry.addAttribute(attr); |
| | | } |
| | | } |
| | | } |
| | |
| | | if(hasAttrMask(mask,ACL_RIGHTS_INFO)) { |
| | | String typeStr = aclRightsInfoEntryLogsStr + ";" + rightStr; |
| | | Attribute attr = Attributes.create(typeStr, container.getEvalSummary()); |
| | | retEntry.addAttribute(attr,null); |
| | | retEntry.addAttribute(attr); |
| | | } |
| | | } |
| | | |
| | |
| | | * 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; |
| | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | |
| | | 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, |
| | |
| | | { |
| | | 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; |
| | | } |
| | | |
| | |
| | | |
| | | // 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()) { |
| | |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | |
| | | 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()) |
| | |
| | | mods.add(new Modification(ModificationType.REPLACE, attr)); |
| | | // - update the already modified entry |
| | | modifiedEntry.removeAttribute(attr.getAttributeDescription().getAttributeType()); |
| | | modifiedEntry.addAttribute(attr, null); |
| | | modifiedEntry.addAttribute(attr); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | 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; |
| | |
| | | // Now flush attribute values into entry |
| | | if (somethingToFlush) |
| | | { |
| | | List<ByteString> duplicateValues = new ArrayList<>(); |
| | | Collection<ByteString> duplicateValues = new ArrayList<>(); |
| | | entry.addAttribute(attrBuilder.toAttribute(), duplicateValues); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | switch (mod.getModificationType().asEnum()) |
| | | { |
| | | case ADD: |
| | | List<ByteString> duplicateValues = new LinkedList<>(); |
| | | Collection<ByteString> duplicateValues = new LinkedList<>(); |
| | | addAttribute(a, duplicateValues); |
| | | if (!duplicateValues.isEmpty() && !relaxConstraints) |
| | | { |
| | |
| | | break; |
| | | |
| | | case DELETE: |
| | | List<ByteString> missingValues = new LinkedList<>(); |
| | | Collection<ByteString> missingValues = new LinkedList<>(); |
| | | removeAttribute(a, missingValues); |
| | | if (!missingValues.isEmpty() && !relaxConstraints) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | |
| | | 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()) |
| | |
| | | ava.getAttributeName(), |
| | | ava.getAttributeValue()); |
| | | |
| | | List<ByteString> duplicateValues = new LinkedList<>(); |
| | | Collection<ByteString> duplicateValues = new LinkedList<>(); |
| | | newEntry.addAttribute(a, duplicateValues); |
| | | |
| | | if (duplicateValues.isEmpty()) |
| | |
| | | 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; |
| | | |
| | |
| | | * |
| | | * 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; |
| | |
| | | |
| | | // 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) |
| | | { |
| | |
| | | // 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(); |