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

Valery Kharseko
14 hours ago 7243c66412f9bc84f84d83d84487ad44e40bd223
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
@@ -13,10 +13,16 @@
 *
 * Copyright 2008-2010 Sun Microsystems, Inc.
 * Portions Copyright 2012-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.admin.ads.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.forgerock.opendj.ldap.Attribute;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.Entry;
/**
@@ -44,4 +50,30 @@
    Attribute attr = entry.getAttribute(attrDesc);
    return (attr != null && !attr.isEmpty()) ? attr.firstValueAsString() : null;
  }
  /**
   * Returns all the values of this attribute decoded as UTF-8 strings, in the order they were
   * returned by the server.
   *
   * @param entry
   *          the entry
   * @param attrDesc
   *          the attribute description
   * @return all the values of this attribute decoded as UTF-8 strings, an empty list if the
   *         attribute is not present.
   */
  public static List<String> allValuesAsStrings(Entry entry, String attrDesc)
  {
    Attribute attr = entry.getAttribute(attrDesc);
    if (attr == null || attr.isEmpty())
    {
      return Collections.emptyList();
    }
    List<String> values = new ArrayList<>(attr.size());
    for (ByteString value : attr)
    {
      values.add(value.toString());
    }
    return values;
  }
}