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

Jean-Noel Rouvignac
19.30.2014 47b4be2e6877fe6c24b5fe0e707d2ebcbe55d424
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -49,8 +49,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -359,9 +357,7 @@
          {
            bs = ByteString.valueOf(value.toString());
          }
          AttributeValue attributeValue =
            AttributeValues.create(attrType, bs);
          builder.add(attributeValue);
          builder.add(bs);
        }
        List<org.opends.server.types.Attribute> attrList =
          new ArrayList<org.opends.server.types.Attribute>(1);
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -46,6 +46,8 @@
import javax.swing.SwingUtilities;
import javax.swing.tree.TreePath;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
@@ -59,15 +61,12 @@
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.AdminToolMessages;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
/**
 * The task that is called when we must modify an entry.
 *
 */
public class ModifyEntryTask extends Task
{
@@ -512,8 +511,8 @@
        attrType = DirectoryServer.getDefaultAttributeType(
            attr.getName().toLowerCase());
      }
      List<AttributeValue> newValues = new ArrayList<AttributeValue>();
      Iterator<AttributeValue> it = attr.iterator();
      List<ByteString> newValues = new ArrayList<ByteString>();
      Iterator<ByteString> it = attr.iterator();
      while (it.hasNext())
      {
        newValues.add(it.next());
@@ -521,7 +520,7 @@
      List<Object> oldValues = oldEntry.getAttributeValues(attrName);
      boolean isAttributeInNewRdn = false;
      AttributeValue rdnValue = null;
      ByteString rdnValue = null;
      RDN rdn = newEntry.getName().rdn();
      for (int i=0; i<rdn.getNumValues() && !isAttributeInNewRdn; i++)
      {
@@ -537,13 +536,13 @@
       * will be deleted.  Check that they are on the new entry but not in
       * the new RDN. If it is the case we must add them after the renaming.
       */
      AttributeValue oldRdnValueToAdd = null;
      ByteString oldRdnValueToAdd = null;
      /* Check the value in the RDN that will be deleted.  If the value was
       * on the previous RDN but not in the new entry it will be deleted.  So
       * we must avoid to include it as a delete modification in the
       * modifications.
       */
      AttributeValue oldRdnValueDeleted = null;
      ByteString oldRdnValueDeleted = null;
      RDN oldRDN = null;
      try
      {
@@ -558,7 +557,7 @@
      {
        if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName))
        {
          AttributeValue value = oldRDN.getAttributeValue(i);
          ByteString value = oldRDN.getAttributeValue(i);
          boolean containsValue = false;
          it = attr.iterator();
          while (it.hasNext())
@@ -585,8 +584,7 @@
      }
      if (oldValues == null)
      {
        Set<AttributeValue> vs = new HashSet<AttributeValue>();
        vs.addAll(newValues);
        Set<ByteString> vs = new HashSet<ByteString>(newValues);
        if (rdnValue != null)
        {
          vs.remove(rdnValue);
@@ -598,14 +596,12 @@
              createAttribute(attrName, newValues)));
        }
      } else {
        List<AttributeValue> toDelete = getValuesToDelete(oldValues, newValues,
            attrType);
        List<ByteString> toDelete = getValuesToDelete(oldValues, newValues);
        if (oldRdnValueDeleted != null)
        {
          toDelete.remove(oldRdnValueDeleted);
        }
        List<AttributeValue> toAdd = getValuesToAdd(oldValues, newValues,
            attrType);
        List<ByteString> toAdd = getValuesToAdd(oldValues, newValues);
        if (oldRdnValueToAdd != null)
        {
          toAdd.add(oldRdnValueToAdd);
@@ -627,8 +623,7 @@
          }
          if (toAdd.size() > 0)
          {
            List<AttributeValue> vs = new ArrayList<AttributeValue>();
            vs.addAll(toAdd);
            List<ByteString> vs = new ArrayList<ByteString>(toAdd);
            if (rdnValue != null)
            {
              vs.remove(rdnValue);
@@ -685,56 +680,47 @@
   * @param values the values.
   * @return a JNDI attribute using an attribute name and a set of values.
   */
  private static Attribute createAttribute(String attrName,
      List<AttributeValue> values) {
  private static Attribute createAttribute(String attrName, List<ByteString> values) {
    Attribute attribute = new BasicAttribute(attrName);
    for (AttributeValue value : values)
    for (ByteString value : values)
    {
      attribute.add(value.getValue().toByteArray());
      attribute.add(value.toByteArray());
    }
    return attribute;
  }
  /**
   * Creates an AttributeValue for an attribute and a value (the one we got
   * Creates an ByteString for an attribute and a value (the one we got
   * using JNDI).
   * @param attrType the attribute type.
   * @param value the value found using JNDI.
   * @return an AttributeValue object.
   * @return an ByteString object.
   */
  private static AttributeValue createAttributeValue(AttributeType attrType,
      Object value)
  private static ByteString createAttributeValue(Object value)
  {
    ByteString v;
    if (value instanceof String)
    {
      v = ByteString.valueOf((String)value);
      return ByteString.valueOf((String) value);
    }
    else if (value instanceof byte[])
    {
      v = ByteString.wrap((byte[])value);
      return ByteString.wrap((byte[]) value);
    }
    else
    {
      v = ByteString.valueOf(String.valueOf(value));
    }
    return AttributeValues.create(attrType, v);
    return ByteString.valueOf(String.valueOf(value));
  }
  /**
   * Returns the set of AttributeValue that must be deleted.
   * Returns the set of ByteString that must be deleted.
   * @param oldValues the old values of the entry.
   * @param newValues the new values of the entry.
   * @param attrType the attribute type.
   * @return the set of AttributeValue that must be deleted.
   * @return the set of ByteString that must be deleted.
   */
  private static List<AttributeValue> getValuesToDelete(List<Object> oldValues,
      List<AttributeValue> newValues, AttributeType attrType)
  private static List<ByteString> getValuesToDelete(List<Object> oldValues,
      List<ByteString> newValues)
  {
    List<AttributeValue> valuesToDelete = new ArrayList<AttributeValue>();
    List<ByteString> valuesToDelete = new ArrayList<ByteString>();
    for (Object o : oldValues)
    {
      AttributeValue oldValue = createAttributeValue(attrType, o);
      ByteString oldValue = createAttributeValue(o);
      if (!newValues.contains(oldValue))
      {
        valuesToDelete.add(oldValue);
@@ -744,32 +730,34 @@
  }
  /**
   * Returns the set of AttributeValue that must be added.
   * Returns the set of ByteString that must be added.
   * @param oldValues the old values of the entry.
   * @param newValues the new values of the entry.
   * @param attrType the attribute type.
   * @return the set of AttributeValue that must be added.
   * @return the set of ByteString that must be added.
   */
  private static List<AttributeValue> getValuesToAdd(List<Object> oldValues,
    List<AttributeValue> newValues, AttributeType attrType)
  private static List<ByteString> getValuesToAdd(List<Object> oldValues,
    List<ByteString> newValues)
  {
    List<AttributeValue> valuesToAdd = new ArrayList<AttributeValue>();
    for (AttributeValue newValue : newValues)
    List<ByteString> valuesToAdd = new ArrayList<ByteString>();
    for (ByteString newValue : newValues)
    {
      boolean found = false;
      for (Object o : oldValues)
      {
        found = newValue.equals(createAttributeValue(attrType, o));
        if (found)
        {
          break;
        }
      }
      if (!found)
      if (!contains(oldValues, newValue))
      {
        valuesToAdd.add(newValue);
      }
    }
    return valuesToAdd;
  }
  private static boolean contains(List<Object> oldValues, ByteString newValue)
  {
    for (Object o : oldValues)
    {
      if (createAttributeValue(o).equals(newValue))
      {
        return true;
      }
    }
    return false;
  }
}
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/NewEntryTask.java
@@ -54,7 +54,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -214,16 +214,16 @@
      for (org.opends.server.types.Attribute attr : newEntry.getAttributes())
      {
        String attrName = attr.getNameWithOptions();
        Set<AttributeValue> values = new LinkedHashSet<AttributeValue>();
        Iterator<AttributeValue> it = attr.iterator();
        Set<ByteString> values = new LinkedHashSet<ByteString>();
        Iterator<ByteString> it = attr.iterator();
        while (it.hasNext())
        {
          values.add(it.next());
        }
        BasicAttribute a = new BasicAttribute(attrName);
        for (AttributeValue value : values)
        for (ByteString value : values)
        {
          a.add(value.getValue().toByteArray());
          a.add(value.toByteArray());
        }
        attrs.put(a);
      }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -98,6 +98,7 @@
import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.quicksetup.UserDataCertificateException;
import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.quicksetup.util.UIKeyStore;
@@ -876,8 +877,7 @@
            getInfo().getServerDescriptor().getSchema().getAttributeType(
                attr.toString().toLowerCase());
          LDAPFilter ldapFilter =
            new LDAPFilter(SearchFilter.createEqualityFilter(
              attrType, AttributeValues.create(attrType, s)));
            new LDAPFilter(SearchFilter.createEqualityFilter( attrType, ByteString.valueOf(s)));
          returnValue = ldapFilter.toString();
        }
      }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -79,8 +79,6 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -738,9 +736,7 @@
          {
            bs = ByteString.valueOf(value.toString());
          }
          AttributeValue attributeValue =
            AttributeValues.create(attrType, bs);
          builder.add(attributeValue);
          builder.add(bs);
        }
        List<Attribute> attrList = new ArrayList<Attribute>(1);
        attrList.add(builder.toAttribute());
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -102,7 +102,7 @@
import org.opends.server.tools.ImportLDIF;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.makeldif.MakeLDIF;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
@@ -1381,12 +1381,10 @@
          Attributes attrs = new BasicAttributes();
          BasicAttribute oc = new BasicAttribute("objectClass");
          Iterator<AttributeValue> it =
            indexEntry.getObjectClassAttribute().iterator();
          Iterator<ByteString> it = indexEntry.getObjectClassAttribute().iterator();
          while (it.hasNext())
          {
            oc.add(it.next().getValue().toString());
            oc.add(it.next().toString());
          }
          attrs.put(oc);
@@ -1399,16 +1397,14 @@
            it = odsAttr.iterator();
            while (it.hasNext())
            {
              attr.add(it.next().getValue().toString());
              attr.add(it.next().toString());
            }
            attrs.put(attr);
            if (attrName.equalsIgnoreCase("ds-cfg-attribute"))
            {
              args.add("--index-name");
              AttributeValue value =
                odsAttr.iterator().next();
              args.add(value.getValue().toString());
              args.add(odsAttr.iterator().next().toString());
            }
            else if (attrName.equalsIgnoreCase("ds-cfg-index-type"))
            {
@@ -1416,7 +1412,7 @@
              while (it.hasNext())
              {
                args.add("--set");
                args.add("index-type:"+it.next().getValue().toString());
                args.add("index-type:" + it.next().toString());
              }
            }
          }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -69,7 +69,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
@@ -81,7 +81,6 @@
/**
 * Panel that appears when the user defines a new index.
 *
 */
public class NewIndexPanel extends AbstractIndexPanel
{
@@ -353,18 +352,9 @@
  private String getAttributeName()
  {
    String attrName;
    CategorizedComboBoxElement o =
      (CategorizedComboBoxElement)attributes.getSelectedItem();
    if (o != null)
    {
      attrName = o.getValue().toString();
    }
    else
    {
      attrName = null;
    }
    return attrName;
    return o != null ? o.toString() : null;
  }
  /**
@@ -623,11 +613,11 @@
        Attributes attrs = new BasicAttributes();
        BasicAttribute oc = new BasicAttribute("objectClass");
        Iterator<AttributeValue> it =
        Iterator<ByteString> it =
          indexEntry.getObjectClassAttribute().iterator();
        while (it.hasNext())
        {
          oc.add(it.next().getValue().toString());
          oc.add(it.next().toString());
        }
        attrs.put(oc);
@@ -639,7 +629,7 @@
          it = odsAttr.iterator();
          while (it.hasNext())
          {
            attr.add(it.next().getValue().toString());
            attr.add(it.next().toString());
          }
          attrs.put(attr);
        }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -24,7 +24,6 @@
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -89,6 +88,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.*;
import org.opends.server.util.Base64;
@@ -1616,16 +1616,14 @@
        RDN rdn = oldDN.rdn();
        List<AttributeType> attributeTypes = new ArrayList<AttributeType>();
        List<String> attributeNames = new ArrayList<String>();
        List<AttributeValue> attributeValues = new ArrayList<AttributeValue>();
        List<ByteString> attributeValues = new ArrayList<ByteString>();
        for (int i=0; i<rdn.getNumValues(); i++)
        {
          String attrName = rdn.getAttributeName(i);
          AttributeValue value = rdn.getAttributeValue(i);
          String sValue = value.getValue().toString();
          ByteString value = rdn.getAttributeValue(i);
          List<String> values = getDisplayedStringValues(attrName);
          if (!values.contains(sValue))
          if (!values.contains(value.toString()))
          {
            if (values.size() > 0)
            {
@@ -1644,8 +1642,7 @@
                AttributeType attr = rdn.getAttributeType(i);
                attributeTypes.add(attr);
                attributeNames.add(rdn.getAttributeName(i));
                attributeValues.add(AttributeValues.create(
                    attr, firstNonEmpty));
                attributeValues.add(ByteString.valueOf(firstNonEmpty));
              }
            }
          }
@@ -1684,8 +1681,7 @@
                  {
                    attributeTypes.add(attr);
                    attributeNames.add(attrName);
                    attributeValues.add(
                        AttributeValues.create(attr, (String)o));
                    attributeValues.add(ByteString.valueOf((String) o));
                  }
                  break;
                }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -24,7 +24,6 @@
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -64,15 +63,14 @@
import org.opends.guitools.controlpanel.ui.renderer.LDAPEntryTableCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ServerConstants;
/**
 * The panel displaying a table view of an LDAP entry.
 *
 */
public class TableViewEntryPanel extends ViewEntryPanel
{
  private static final long serialVersionUID = 2135331526526472175L;
@@ -303,16 +301,14 @@
        RDN rdn = oldDN.rdn();
        List<AttributeType> attributeTypes = new ArrayList<AttributeType>();
        List<String> attributeNames = new ArrayList<String>();
        List<AttributeValue> attributeValues = new ArrayList<AttributeValue>();
        List<ByteString> attributeValues = new ArrayList<ByteString>();
        for (int i=0; i<rdn.getNumValues(); i++)
        {
          String attrName = rdn.getAttributeName(i);
          AttributeValue value = rdn.getAttributeValue(i);
          String sValue = value.getValue().toString();
          ByteString value = rdn.getAttributeValue(i);
          Set<String> values = getDisplayedStringValues(attrName);
          if (!values.contains(sValue))
          if (!values.contains(value.toString()))
          {
            if (values.size() > 0)
            {
@@ -331,8 +327,7 @@
                AttributeType attr = rdn.getAttributeType(i);
                attributeTypes.add(attr);
                attributeNames.add(rdn.getAttributeName(i));
                attributeValues.add(AttributeValues.create(
                    attr, firstNonEmpty));
                attributeValues.add(ByteString.valueOf(firstNonEmpty));
              }
            }
          }
@@ -371,8 +366,7 @@
                {
                  attributeTypes.add(attr);
                  attributeNames.add(attrName);
                  attributeValues.add(AttributeValues.create(
                      attr, (String)o));
                  attributeValues.add(ByteString.valueOf((String) o));
                }
                break;
              }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -56,7 +56,7 @@
import org.opends.server.replication.plugin.EntryHistorical;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
@@ -346,7 +346,7 @@
    for (int i=0; i<rdn.getNumValues(); i++)
    {
      String attrName = rdn.getAttributeName(i);
      AttributeValue value = rdn.getAttributeValue(i);
      ByteString value = rdn.getAttributeValue(i);
      List<org.opends.server.types.Attribute> attrs =
        entry.getAttribute(attrName.toLowerCase());
      boolean done = false;
@@ -356,9 +356,8 @@
        {
          if (attr.getNameWithOptions().equals(attrName))
          {
            ArrayList<AttributeValue> newValues =
              new ArrayList<AttributeValue>();
            Iterator<AttributeValue> it = attr.iterator();
            ArrayList<ByteString> newValues = new ArrayList<ByteString>();
            Iterator<ByteString> it = attr.iterator();
            while (it.hasNext())
            {
              newValues.add(it.next());
@@ -374,8 +373,7 @@
      {
        org.opends.server.types.Attribute attr =
          Attributes.create(rdn.getAttributeType(i), value);
        ArrayList<AttributeValue> newValues =
          new ArrayList<AttributeValue>();
        ArrayList<ByteString> newValues = new ArrayList<ByteString>();
        newValues.add(value);
        entry.addAttribute(attr, newValues);
      }
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java
@@ -419,7 +419,7 @@
          }
          else
          {
            result = rdn.getAttributeValue(0).getValue().toString();
            result = rdn.getAttributeValue(0).toString();
          }
        }
        else {
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -112,6 +112,7 @@
 AccessibleTableHeaderRenderer;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.util.Utils;
@@ -1541,9 +1542,7 @@
  public static String getRDNString(String attrName, String attrValue)
  {
    AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName);
    AttributeValue value =
        AttributeValues.create(attrType, attrValue);
    RDN rdn = new RDN(attrType, attrName, value);
    RDN rdn = new RDN(attrType, attrName, ByteString.valueOf(attrValue));
    return rdn.toString();
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/ManagedObjectPath.java
@@ -24,24 +24,21 @@
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.admin;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.admin.std.meta.RootCfgDefn;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
/**
 * A path which can be used to determine the location of a managed
 * object instance.
@@ -157,7 +154,7 @@
      String type = profile.getRelationChildRDNType(r);
      AttributeType atype = DirectoryServer.getAttributeType(
          type.toLowerCase(), true);
      AttributeValue avalue = AttributeValues.create(atype, name);
      ByteString avalue = ByteString.valueOf(name);
      dn = dn.child(RDN.create(atype, avalue));
    }
@@ -177,7 +174,7 @@
      String type = profile.getRelationChildRDNType(r);
      AttributeType atype = DirectoryServer.getAttributeType(
          type.toLowerCase(), true);
      AttributeValue avalue = AttributeValues.create(atype, d.getName());
      ByteString avalue = ByteString.valueOf(d.getName());
      dn = dn.child(RDN.create(atype, avalue));
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/Reference.java
@@ -28,7 +28,7 @@
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.RDN;
@@ -98,13 +98,13 @@
          + s + "\"");
    }
    AttributeValue av = rdn.getAttributeValue(0);
    ByteString av = rdn.getAttributeValue(0);
    if (av == null) {
      throw new IllegalArgumentException("Unabled to decode the DN string: \""
          + s + "\"");
    }
    String name = av.getValue().toString();
    String name = av.toString();
    // Check that the DN was valid.
    DN expected = p.child(rd, name).toDN();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/server/ConfigAddListenerAdaptor.java
@@ -47,7 +47,7 @@
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.ResultCode;
@@ -206,8 +206,8 @@
  public boolean configAddIsAcceptable(ConfigEntry configEntry,
      LocalizableMessageBuilder unacceptableReason) {
    DN dn = configEntry.getDN();
    AttributeValue av = dn.rdn().getAttributeValue(0);
    String name = av.getValue().toString().trim();
    ByteString av = dn.rdn().getAttributeValue(0);
    String name = av.toString().trim();
    try {
      ManagedObjectPath<?, ? extends S> childPath;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/server/ConfigDeleteListenerAdaptor.java
@@ -48,7 +48,7 @@
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.ResultCode;
@@ -207,8 +207,8 @@
  public boolean configDeleteIsAcceptable(ConfigEntry configEntry,
      LocalizableMessageBuilder unacceptableReason) {
    DN dn = configEntry.getDN();
    AttributeValue av = dn.rdn().getAttributeValue(0);
    String name = av.getValue().toString().trim();
    ByteString av = dn.rdn().getAttributeValue(0);
    String name = av.toString().trim();
    try {
      ManagedObjectPath<?, ? extends S> childPath;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/server/ServerManagementContext.java
@@ -79,7 +79,7 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValueIterable;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
/**
@@ -264,7 +264,7 @@
          throw new PropertyNotFoundException(propertyName);
        }
        List<AttributeValue> values = getAttribute(mod, pd2, configEntry);
        List<ByteString> values = getAttribute(mod, pd2, configEntry);
        if (values.isEmpty()) {
          // Recursively retrieve this property's default values.
          Collection<T> tmp = find(target, pd2);
@@ -276,7 +276,7 @@
          return pvalues;
        } else {
          Collection<T> pvalues = new ArrayList<T>(values.size());
          for (AttributeValue value : values) {
          for (ByteString value : values) {
            pvalues.add(ValueDecoder.decode(pd1, value));
          }
          return pvalues;
@@ -346,9 +346,8 @@
     *           was invalid.
     */
    public static <PD> PD decode(PropertyDefinition<PD> pd,
        AttributeValue value) throws PropertyException {
      String s = value.getValue().toString();
      return pd.castValue(pd.accept(new ValueDecoder(), s));
        ByteString value) throws PropertyException {
      return pd.castValue(pd.accept(new ValueDecoder(), value.toString()));
    }
@@ -579,7 +578,7 @@
    // definition.
    pd = (PropertyDefinition<PD>) mod.getPropertyDefinition(pd.getName());
    List<AttributeValue> values = getAttribute(mod, pd, configEntry);
    List<ByteString> values = getAttribute(mod, pd, configEntry);
    return decodeProperty(path.asSubType(mod), pd, values, null);
  }
@@ -654,8 +653,8 @@
    ArrayList<String> names = new ArrayList<String>(children.size());
    for (DN child : children) {
      // Assume that RDNs are single-valued and can be trimmed.
      AttributeValue av = child.rdn().getAttributeValue(0);
      names.add(av.getValue().toString().trim());
      ByteString av = child.rdn().getAttributeValue(0);
      names.add(av.toString().trim());
    }
    return names.toArray(new String[names.size()]);
@@ -706,7 +705,7 @@
    ArrayList<String> names = new ArrayList<String>(children.size());
    for (DN child : children) {
      // Assume that RDNs are single-valued and can be trimmed.
      AttributeValue av = child.rdn().getAttributeValue(0);
      ByteString av = child.rdn().getAttributeValue(0);
      names.add(av.toString().trim());
    }
@@ -811,7 +810,7 @@
    Map<PropertyDefinition<?>, SortedSet<?>> properties =
      new HashMap<PropertyDefinition<?>, SortedSet<?>>();
    for (PropertyDefinition<?> pd : mod.getAllPropertyDefinitions()) {
      List<AttributeValue> values = getAttribute(mod, pd, configEntry);
      List<ByteString> values = getAttribute(mod, pd, configEntry);
      try {
        SortedSet<?> pvalues = decodeProperty(path, pd, values, newConfigEntry);
        properties.put(pd, pvalues);
@@ -848,14 +847,14 @@
  // Create a property using the provided string values.
  private <T> SortedSet<T> decodeProperty(ManagedObjectPath<?, ?> path,
      PropertyDefinition<T> pd, List<AttributeValue> values,
      PropertyDefinition<T> pd, List<ByteString> values,
      ConfigEntry newConfigEntry) throws PropertyException {
    PropertyException exception = null;
    SortedSet<T> pvalues = new TreeSet<T>(pd);
    if (!values.isEmpty()) {
      // The property has values defined for it.
      for (AttributeValue value : values) {
      for (ByteString value : values) {
        try {
          pvalues.add(ValueDecoder.decode(pd, value));
        } catch (PropertyException e) {
@@ -896,7 +895,7 @@
  // Gets the attribute associated with a property from a ConfigEntry.
  private List<AttributeValue> getAttribute(ManagedObjectDefinition<?, ?> d,
  private List<ByteString> getAttribute(ManagedObjectDefinition<?, ?> d,
      PropertyDefinition<?> pd, ConfigEntry configEntry) {
    // TODO: we create a default attribute type if it is
    // undefined. We should log a warning here if this is the case
@@ -905,8 +904,8 @@
    AttributeType type = DirectoryServer.getAttributeType(attrID, true);
    List<Attribute> attributes = configEntry.getEntry().getAttribute(type, true);
    List<AttributeValue> results = new LinkedList<AttributeValue>();
    for (AttributeValue v : new AttributeValueIterable(attributes))
    List<ByteString> results = new LinkedList<ByteString>();
    for (ByteString v : new AttributeValueIterable(attributes))
    {
      results.add(v);
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/AuthenticationPolicy.java
@@ -33,6 +33,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
@@ -83,32 +84,30 @@
      {
        if (a.isEmpty()) continue;
        AttributeValue v = a.iterator().next();
        ByteString v = a.iterator().next();
        DN subentryDN;
        try
        {
          subentryDN = DN.decode(v.getValue());
          subentryDN = DN.decode(v);
        }
        catch (Exception e)
        {
          logger.traceException(e);
          logger.trace(
              "Could not parse password policy subentry DN %s for user %s", v
                  .getValue(), userDNString, e);
          logger.trace("Could not parse password policy subentry DN %s for user %s",
              v, userDNString, e);
          if (useDefaultOnError)
          {
            logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN,
                v.getValue(), userDNString, e.getMessage());
                v, userDNString, e.getMessage());
            return DirectoryServer.getDefaultPasswordPolicy();
          }
          else
          {
            LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN
                .get(v.getValue(), userDNString, e.getMessage());
            throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message,
                e);
                .get(v, userDNString, e.getMessage());
            throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e);
          }
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/AuthenticationPolicyState.java
@@ -115,8 +115,7 @@
          continue;
        }
        final String valueString = toLowerCase(a.iterator().next().getValue()
            .toString());
        final String valueString = toLowerCase(a.iterator().next().toString());
        if (valueString.equals("true") || valueString.equals("yes")
            || valueString.equals("on") || valueString.equals("1"))
@@ -198,20 +197,20 @@
          continue;
        }
        final AttributeValue v = a.iterator().next();
        final ByteString v = a.iterator().next();
        try
        {
          MatchingRule rule = attributeType.getEqualityMatchingRule();
          ByteString normValue = rule.normalizeAttributeValue(v.getValue());
          ByteString normValue = rule.normalizeAttributeValue(v);
          timeValue = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue);
        }
        catch (final Exception e)
        {
          logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
              v.getValue(), attributeType.getNameOrOID(), entry.getName());
              v, attributeType.getNameOrOID(), entry.getName());
          final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME
              .get(v.getValue(), attributeType.getNameOrOID(), entry.getName(), e);
              .get(v, attributeType.getNameOrOID(), entry.getName(), e);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
              message, e);
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/ClientConnection.java
@@ -50,7 +50,7 @@
import org.opends.server.core.networkgroups.NetworkGroup;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
@@ -1192,9 +1192,9 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          String privName = toLowerCase(v.getValue().toString());
          String privName = toLowerCase(v.toString());
          // If the name of the privilege is prefixed with a minus
          // sign, then we will take away that privilege from the
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/CompressedSchema.java
@@ -46,11 +46,9 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Attributes;
import org.forgerock.opendj.ldap.ByteSequenceReader;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ObjectClass;
@@ -143,8 +141,7 @@
      final int valueLength = reader.getBERLength();
      final ByteString valueBytes = reader.getByteSequence(valueLength)
          .toByteString();
      return Attributes.create(attrType,
          AttributeValues.create(attrType, valueBytes));
      return Attributes.create(attrType, valueBytes);
    }
    else
    {
@@ -157,7 +154,7 @@
        final int valueLength = reader.getBERLength();
        final ByteString valueBytes = reader.getByteSequence(valueLength)
            .toByteString();
        builder.add(AttributeValues.create(attrType, valueBytes));
        builder.add(valueBytes);
      }
      return builder.toAttribute();
    }
@@ -251,10 +248,10 @@
    builder.appendBERLength(idBytes.length);
    builder.append(idBytes);
    builder.appendBERLength(attribute.size());
    for (final AttributeValue v : attribute)
    for (final ByteString v : attribute)
    {
      builder.appendBERLength(v.getValue().length());
      builder.append(v.getValue());
      builder.appendBERLength(v.length());
      builder.append(v);
    }
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/VirtualAttributeProvider.java
@@ -29,7 +29,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -40,7 +39,7 @@
import org.forgerock.opendj.ldap.ConditionResult;
import org.opends.server.admin.std.server.VirtualAttributeCfg;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.Attribute;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.VirtualAttributeRule;
@@ -140,18 +139,17 @@
  /**
   * Generates an unmodifiable set of values for the provided entry.
   * Generates an unmodifiable attribute with the values for the provided entry.
   *
   * @param entry
   *          The entry for which the values are to be generated.
   * @param rule
   *          The virtual attribute rule which defines the constraints
   *          for the virtual attribute.
   * @return The unmodifiable set of values generated for the provided
   *         entry. It may be empty, but it must not be {@code null}.
   * @return The unmodifiable attribute with the values generated for the
   *         provided entry. It may be empty, but it must not be {@code null}.
   */
  public abstract Set<AttributeValue> getValues(
      Entry entry, VirtualAttributeRule rule);
  public abstract Attribute getValues(Entry entry, VirtualAttributeRule rule);
@@ -169,7 +167,7 @@
   */
  public boolean hasValue(Entry entry, VirtualAttributeRule rule)
  {
    return (! getValues(entry, rule).isEmpty());
    return !getValues(entry, rule).isEmpty();
  }
@@ -187,8 +185,7 @@
   *          generate the specified value for the provided entry, or
   *          {@code false} if not.
   */
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    return getValues(entry, rule).contains(value);
  }
@@ -211,41 +208,9 @@
   *          them.
   */
  public boolean hasAllValues(Entry entry, VirtualAttributeRule rule,
                              Collection<AttributeValue> values)
                              Collection<ByteString> values)
  {
    Set<AttributeValue> virtualValues = getValues(entry, rule);
    return virtualValues.containsAll(values);
  }
  /**
   * Indicates whether this virtual attribute provider will generate
   * any of the values in the provided collection.
   *
   * @param  entry   The entry for which to make the determination.
   * @param  rule    The virtual attribute rule which defines the
   *                 constraints for the virtual attribute.
   * @param  values  The set of values for which to make the
   *                 determination.
   *
   * @return  {@code true} if this attribute provider will generate
   *          at least one of the values in the provided collection,
   *          or {@code false} if it will not generate any of them.
   */
  public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule,
                             Collection<AttributeValue> values)
  {
    Set<AttributeValue> virtualValues = getValues(entry, rule);
    for (AttributeValue value : values)
    {
      if (virtualValues.contains(value))
      {
        return true;
      }
    }
    return false;
    return getValues(entry, rule).containsAll(values);
  }
@@ -356,11 +321,11 @@
    ConditionResult result = ConditionResult.FALSE;
    for (AttributeValue value : getValues(entry, rule))
    for (ByteString value : getValues(entry, rule))
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(value.getValue());
        ByteString nv = matchingRule.normalizeAttributeValue(value);
        if (matchingRule.valueMatchesSubstring(
                              nv,
                              normalizedSubInitial,
@@ -404,7 +369,7 @@
   */
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    OrderingMatchingRule matchingRule =
         rule.getAttributeType().getOrderingMatchingRule();
@@ -416,7 +381,7 @@
    ByteString normalizedValue;
    try
    {
      normalizedValue = matchingRule.normalizeAttributeValue(value.getValue());
      normalizedValue = matchingRule.normalizeAttributeValue(value);
    }
    catch (Exception e)
    {
@@ -427,11 +392,11 @@
    }
    ConditionResult result = ConditionResult.FALSE;
    for (AttributeValue v : getValues(entry, rule))
    for (ByteString v : getValues(entry, rule))
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
        ByteString nv = matchingRule.normalizeAttributeValue(v);
        if (matchingRule.compareValues(nv, normalizedValue) >= 0)
        {
          return ConditionResult.TRUE;
@@ -471,7 +436,7 @@
   */
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    OrderingMatchingRule matchingRule =
         rule.getAttributeType().getOrderingMatchingRule();
@@ -483,7 +448,7 @@
    ByteString normalizedValue;
    try
    {
      normalizedValue = matchingRule.normalizeAttributeValue(value.getValue());
      normalizedValue = matchingRule.normalizeAttributeValue(value);
    }
    catch (Exception e)
    {
@@ -494,11 +459,11 @@
    }
    ConditionResult result = ConditionResult.FALSE;
    for (AttributeValue v : getValues(entry, rule))
    for (ByteString v : getValues(entry, rule))
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
        ByteString nv = matchingRule.normalizeAttributeValue(v);
        if (matchingRule.compareValues(nv, normalizedValue) <= 0)
        {
          return ConditionResult.TRUE;
@@ -538,7 +503,7 @@
   */
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    MatchingRule matchingRule = rule.getAttributeType().getApproximateMatchingRule();
    if (matchingRule == null)
@@ -549,7 +514,7 @@
    Assertion assertion = null;
    try
    {
      assertion = matchingRule.getAssertion(value.getValue());
      assertion = matchingRule.getAssertion(value);
    }
    catch (Exception e)
    {
@@ -558,12 +523,11 @@
    }
    ConditionResult result = ConditionResult.FALSE;
    for (AttributeValue v : getValues(entry, rule))
    for (ByteString v : getValues(entry, rule))
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
        result = assertion.matches(nv);
        result = assertion.matches(matchingRule.normalizeAttributeValue(v));
      }
      catch (Exception e)
      {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/AciContainer.java
@@ -36,6 +36,7 @@
import java.util.HashMap;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.Group;
import org.opends.server.controls.GetEffectiveRightsRequestControl;
@@ -67,7 +68,7 @@
     * The attribute type value in the resource entry currently being
     * evaluated.
     */
    private AttributeValue attributeValue;
    private ByteString attributeValue;
    /**
     * True if this is the first attribute type in the resource entry being
@@ -557,7 +558,7 @@
    * {@inheritDoc}
    */
    @Override
    public AttributeValue getCurrentAttributeValue() {
    public ByteString getCurrentAttributeValue() {
        return attributeValue;
    }
@@ -573,7 +574,7 @@
    * {@inheritDoc}
    */
    @Override
    public void setCurrentAttributeValue(AttributeValue value) {
    public void setCurrentAttributeValue(ByteString value) {
        attributeValue=value;
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -28,6 +28,7 @@
import static org.opends.server.authorization.dseecompat.Aci.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import java.util.LinkedList;
@@ -377,17 +378,17 @@
      //Write right is more complicated. Create a dummy value and set that as
      //the attribute's value. Call the special writeRightsString method, rather
      //than rightsString.
      AttributeValue val= AttributeValues.create(a, "dum###Val");
      ByteString val= ByteString.valueOf("dum###Val");
      container.setCurrentAttributeValue(val);
      evalInfo.append(attributeLevelWriteRights(container, handler, skipCheck));
      addAttrLevelRightsInfo(container, mask, a, retEntry, "write");
      evalInfo.append(',');
      //Perform both selfwrite_add and selfwrite_delete and append results.
      AttributeValue val1=
          AttributeValues.create(a,
              container.getClientDN().toString());
      ByteString val1 = ByteString.valueOf(container.getClientDN().toString());
      if(!specificAttr)
      {
        container.setCurrentAttributeType(dnAttributeType);
      }
      container.setCurrentAttributeValue(val1);
      container.setRights(ACI_WRITE_ADD | ACI_SKIP_PROXY_CHECK);
      evalInfo.append(rightsString(container, handler, skipCheck,
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -32,6 +32,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
@@ -365,11 +366,8 @@
      baseName = toLowerCase(rawAttributeType);
    }
    AttributeType attributeType = getAttributeType(baseName);
    AttributeValue attributeValue =
        AttributeValues.create(attributeType, operation.getAssertionValue());
    container.setCurrentAttributeType(attributeType);
    container.setCurrentAttributeValue(attributeValue);
    container.setCurrentAttributeType(getAttributeType(baseName));
    container.setCurrentAttributeValue(operation.getAssertionValue());
    return isAllowed(container, operation);
  }
@@ -527,7 +525,7 @@
    final List<String> URLStrings = reference.getReferralURLs();
    for (String URLString : URLStrings)
    {
      builder.add(AttributeValues.create(refAttrType, URLString));
      builder.add(URLString);
    }
    final Entry e = new Entry(dn, null, null, null);
@@ -620,12 +618,11 @@
        && container.hasRights(ACI_WRITE)
        && isAttributeDN(container.getCurrentAttributeType()))
    {
      String DNString = null;
      String dnString = null;
      try
      {
        DNString =
            container.getCurrentAttributeValue().getValue().toString();
        DN tmpDN = DN.valueOf(DNString);
        dnString = container.getCurrentAttributeValue().toString();
        DN tmpDN = DN.valueOf(dnString);
        // Have a valid DN, compare to clientDN to see if the ACI_SELF
        // right should be set.
        if (tmpDN.equals(container.getClientDN()))
@@ -636,7 +633,7 @@
      catch (DirectoryException ex)
      {
        // Log a message and keep going.
        logger.warn(WARN_ACI_NOT_VALID_DN, DNString);
        logger.warn(WARN_ACI_NOT_VALID_DN, dnString);
      }
    }
@@ -847,7 +844,7 @@
          {
            for (Attribute a : attrList)
            {
              for (AttributeValue v : a)
              for (ByteString v : a)
              {
                container.setCurrentAttributeValue(v);
                container.setRights(ACI_WRITE_DELETE);
@@ -863,7 +860,7 @@
      if (!modAttr.isEmpty())
      {
        for (AttributeValue v : modAttr)
        for (ByteString v : modAttr)
        {
          container.setCurrentAttributeType(modAttrType);
          switch (m.getModificationType().asEnum())
@@ -893,7 +890,7 @@
            {
              for (Attribute attr : modifiedAttrs)
              {
                for (AttributeValue val : attr)
                for (ByteString val : attr)
                {
                  container.setCurrentAttributeValue(val);
                  container.setRights(ACI_WRITE_ADD);
@@ -922,7 +919,8 @@
              {
                dn = DN.rootDN();
              }
              Aci.decode(v.getValue(), dn);
              // validate ACI syntax
              Aci.decode(v, dn);
            }
            catch (AciException ex)
            {
@@ -1456,11 +1454,12 @@
          entry.getOperationalAttribute(aciType, null);
      for (Attribute attribute : attributeList)
      {
        for (AttributeValue value : attribute)
        for (ByteString value : attribute)
        {
          try
          {
            Aci.decode(value.getValue(), entry.getName());
            // validate ACI syntax
            Aci.decode(value, entry.getName());
          }
          catch (AciException ex)
          {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/AciList.java
@@ -255,18 +255,16 @@
    int validAcis=0;
    ArrayList<Aci> acis = new ArrayList<Aci>();
    for (Attribute attribute : attributeList) {
      for (AttributeValue value : attribute) {
      for (ByteString value : attribute) {
        try {
          Aci aci= Aci.decode(value.getValue(),dn);
          acis.add(aci);
          acis.add(Aci.decode(value, dn));
          validAcis++;
        } catch (AciException ex) {
          DN msgDN=dn;
          if(dn == DN.rootDN()) {
            msgDN=configDN;
          }
          failedACIMsgs.add(WARN_ACI_ADD_LIST_FAILED_DECODE.get(
              value.getValue(), msgDN, ex.getMessage()));
          failedACIMsgs.add(WARN_ACI_ADD_LIST_FAILED_DECODE.get(value, msgDN, ex.getMessage()));
        }
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/AciTargetMatchContext.java
@@ -22,11 +22,12 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import java.util.List;
@@ -69,7 +70,7 @@
     * The current attribute type value being evaluated.
     * @return The current attribute type value being evaluated.
     */
    public AttributeValue getCurrentAttributeValue();
    public ByteString getCurrentAttributeValue();
    /**
     * True if the first attribute of the resource entry is being evaluated.
@@ -95,7 +96,7 @@
     * Set the attribute value to be evaluated.
     * @param v The current attribute value to set to.
     */
    public void setCurrentAttributeValue(AttributeValue v);
    public void setCurrentAttributeValue(ByteString v);
    /**
     * True if the target matching code found an entry test rule. An
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/GroupDN.java
@@ -35,6 +35,7 @@
import java.util.regex.Pattern;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.GroupManager;
@@ -142,12 +143,13 @@
                                           DN suffixDN) {
        EnumEvalResult matched= EnumEvalResult.FALSE;
        List<Attribute> attrs = e.getAttribute(attributeType);
        for(AttributeValue v : attrs.get(0)) {
        for(ByteString v : attrs.get(0)) {
            try {
                DN groupDN=DN.valueOf(v.getValue().toString());
                if(suffixDN != null &&
                   !groupDN.isDescendantOf(suffixDN))
                        continue;
                DN groupDN = DN.valueOf(v.toString());
                if(suffixDN != null && !groupDN.isDescendantOf(suffixDN))
                {
                  continue;
                }
                Group<?> group = getGroupManager().getGroupInstance(groupDN);
                if((group != null) && (evalCtx.isMemberOf(group))) {
                    matched=EnumEvalResult.TRUE;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -212,8 +212,7 @@
    // Sort the attribute-value pairs by attribute type.
    TreeMap<String,ArrayList<ByteString>> patternMap =
         new TreeMap<String, ArrayList<ByteString>>();
    TreeMap<String,AttributeValue> rdnMap =
         new TreeMap<String, AttributeValue>();
    TreeMap<String, ByteString> rdnMap = new TreeMap<String, ByteString>();
    for (int i = 0; i < rdn.getNumValues(); i++)
    {
@@ -264,7 +263,7 @@
   */
  private boolean matchValuePattern(List<ByteString> pattern,
                                    AttributeType type,
                                    AttributeValue value)
                                    ByteString value)
  {
    if (pattern == null)
    {
@@ -277,7 +276,7 @@
      {
        // Handle this just like an equality filter.
        MatchingRule rule = type.getEqualityMatchingRule();
        ByteString thatNormValue = rule.normalizeAttributeValue(value.getValue());
        ByteString thatNormValue = rule.normalizeAttributeValue(value);
        return rule.getAssertion(pattern.get(0)).matches(thatNormValue).toBoolean();
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/TargAttrFilters.java
@@ -35,6 +35,7 @@
import java.util.regex.Pattern;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.*;
/**
@@ -319,7 +320,7 @@
        // If the filter list does not contain the attribute type skip the
        // attribute type.
        if((attrType != null) && (filterList.containsKey(attrType))) {
            AttributeValue value=matchCtx.getCurrentAttributeValue();
            ByteString value = matchCtx.getCurrentAttributeValue();
            SearchFilter filter = filterList.get(attrType);
            attrMatched=matchFilterAttributeValue(attrType, value, filter);
            //This flag causes any targattr checks to be bypassed in AciTargets.
@@ -405,7 +406,7 @@
                                               AttributeType attrType,
                                               SearchFilter filter) {
        //Iterate through each value and apply the filter against it.
        for (AttributeValue value : a) {
        for (ByteString value : a) {
            if (!matchFilterAttributeValue(attrType, value, filter)) {
                return false;
            }
@@ -424,11 +425,11 @@
     * @return  True if the value matches the filter.
     */
    private boolean matchFilterAttributeValue(AttributeType attrType,
                                              AttributeValue value,
                                              ByteString value,
                                              SearchFilter filter) {
        Attribute attr = Attributes.create(attrType, value);
        Entry e = new Entry(DN.rootDN(), null, null, null);
        e.addAttribute(attr, new ArrayList<AttributeValue>());
        e.addAttribute(attr, new ArrayList<ByteString>());
        try {
            return filter.matchesEntry(e);
        } catch(DirectoryException ex) {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/UserAttr.java
@@ -31,6 +31,7 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.core.DirectoryServer;
@@ -215,12 +216,14 @@
                        filter, null);
        LinkedList<SearchResultEntry> result = op.getSearchEntries();
        if (!result.isEmpty()) {
            AttributeValue val= AttributeValues.create(attrType, attrVal);
            ByteString val= ByteString.valueOf(attrVal);
            SearchResultEntry resultEntry = result.getFirst();
            if(resultEntry.hasValue(attrType, null, val)) {
                Entry e=evalCtx.getResourceEntry();
                if(e.hasValue(attrType, null, val))
                {
                    matched=EnumEvalResult.TRUE;
                }
            }
        }
        return matched.getRet(type, undefined);
@@ -277,21 +280,25 @@
        List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType);
        if(!attrs.isEmpty()) {
            for(Attribute a : attrs) {
                for(AttributeValue v : a) {
                    String urlStr=v.getValue().toString();
                for(ByteString v : a) {
                    LDAPURL url;
                    try {
                       url=LDAPURL.decode(urlStr, true);
                       url = LDAPURL.decode(v.toString(), true);
                    } catch (DirectoryException e) {
                        break;
                    }
                    matched=UserDN.evalURL(evalCtx, url);
                    if(matched != EnumEvalResult.FALSE)
                    {
                        break;
                    }
                }
                if(matched == EnumEvalResult.TRUE)
                if (matched == EnumEvalResult.TRUE)
                {
                    break;
                if(matched == EnumEvalResult.ERR) {
                }
                if (matched == EnumEvalResult.ERR)
                {
                    undefined=true;
                    break;
                }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/UserDN.java
@@ -31,6 +31,7 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
@@ -346,7 +347,7 @@
     * TODO Evaluate making this method more efficient.
     *
     * The evalDNEntryAttr method isn't as efficient as it could be.  It would
     * probably be faster to to convert the clientDN to an AttributeValue and
     * probably be faster to to convert the clientDN to an ByteString and
     * see if the entry has that value than to decode each value as a DN and
     * see if it matches the clientDN.
     */
@@ -363,9 +364,9 @@
                                           AttributeType attrType) {
        EnumEvalResult matched= EnumEvalResult.FALSE;
        List<Attribute> attrs =  e.getAttribute(attrType);
        for(AttributeValue v : attrs.get(0)) {
        for(ByteString v : attrs.get(0)) {
            try {
                DN dn=DN.valueOf(v.getValue().toString());
                DN dn = DN.valueOf(v.toString());
                if(dn.equals(clientDN)) {
                    matched=EnumEvalResult.TRUE;
                    break;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/BackupBackend.java
@@ -31,15 +31,16 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.util.Reject;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.BackupBackendCfg;
import org.opends.server.api.Backend;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -49,7 +50,6 @@
import org.opends.server.schema.BooleanSyntax;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -396,13 +396,12 @@
      List<Attribute> attrList = backupDirEntry.getAttribute(t);
      if ((attrList != null) && (! attrList.isEmpty()))
      {
        for (AttributeValue v : attrList.get(0))
        for (ByteString v : attrList.get(0))
        {
          try
          {
            BackupDirectory backupDirectory =
                BackupDirectory.readBackupDirectoryDescriptor(
                    v.getValue().toString());
                BackupDirectory.readBackupDirectoryDescriptor(v.toString());
            count += backupDirectory.getBackups().keySet().size();
          }
          catch (Exception e)
@@ -495,7 +494,7 @@
    // Make sure that the DN specifies a backup directory.
    AttributeType t =
         DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true);
    AttributeValue v = entryDN.rdn().getAttributeValue(t);
    ByteString v = entryDN.rdn().getAttributeValue(t);
    if (v == null)
    {
      LocalizableMessage message =
@@ -510,9 +509,7 @@
    BackupDirectory backupDirectory;
    try
    {
      backupDirectory =
           BackupDirectory.readBackupDirectoryDescriptor(
               v.getValue().toString());
      backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.toString());
    }
    catch (ConfigException ce)
    {
@@ -552,8 +549,7 @@
    t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true);
    attrList = new ArrayList<Attribute>(1);
    attrList.add(Attributes.create(t, AttributeValues.create(t,
        backupDirectory.getConfigEntryDN().toString())));
    attrList.add(Attributes.create(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString())));
    userAttrs.put(t, attrList);
    Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
@@ -581,12 +577,12 @@
    // First, get the backup ID from the entry DN.
    AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
        true);
    AttributeValue idValue = entryDN.rdn().getAttributeValue(idType);
    ByteString idValue = entryDN.rdn().getAttributeValue(idType);
    if (idValue == null) {
      LocalizableMessage message = ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    String backupID = idValue.getValue().toString();
    String backupID = idValue.toString();
    // Next, get the backup directory from the parent DN.
    DN parentDN = entryDN.getParentDNInSuffix();
@@ -597,7 +593,7 @@
    AttributeType t = DirectoryServer.getAttributeType(
        ATTR_BACKUP_DIRECTORY_PATH, true);
    AttributeValue v = parentDN.rdn().getAttributeValue(t);
    ByteString v = parentDN.rdn().getAttributeValue(t);
    if (v == null) {
      LocalizableMessage message = ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
@@ -605,8 +601,7 @@
    BackupDirectory backupDirectory;
    try {
      backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v
          .getValue().toString());
      backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.toString());
    } catch (ConfigException ce) {
      logger.traceException(ce);
@@ -658,8 +653,7 @@
    if (backupDate != null) {
      t = DirectoryServer.getAttributeType(ATTR_BACKUP_DATE, true);
      attrList = new ArrayList<Attribute>(1);
      attrList.add(Attributes.create(t, AttributeValues.create(t,
          GeneralizedTimeSyntax.format(backupDate))));
      attrList.add(Attributes.create(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate))));
      userAttrs.put(t, attrList);
    }
@@ -686,7 +680,7 @@
      t = DirectoryServer.getAttributeType(ATTR_BACKUP_DEPENDENCY, true);
      AttributeBuilder builder = new AttributeBuilder(t);
      for (String s : dependencies) {
        builder.add(AttributeValues.create(t, s));
        builder.add(s);
      }
      attrList = new ArrayList<Attribute>(1);
      attrList.add(builder.toAttribute());
@@ -697,9 +691,7 @@
    if (signedHash != null) {
      t = DirectoryServer.getAttributeType(ATTR_BACKUP_SIGNED_HASH, true);
      attrList = new ArrayList<Attribute>(1);
      attrList.add(Attributes.create(t,
          AttributeValues.create(t,
              ByteString.wrap(signedHash))));
      attrList.add(Attributes.create(t, ByteString.wrap(signedHash)));
      userAttrs.put(t, attrList);
    }
@@ -707,9 +699,7 @@
    if (unsignedHash != null) {
      t = DirectoryServer.getAttributeType(ATTR_BACKUP_UNSIGNED_HASH, true);
      attrList = new ArrayList<Attribute>(1);
      attrList.add(Attributes.create(t,
          AttributeValues.create(t,
              ByteString.wrap(unsignedHash))));
      attrList.add(Attributes.create(t, ByteString.wrap(unsignedHash)));
      userAttrs.put(t, attrList);
    }
@@ -718,8 +708,7 @@
      for (Map.Entry<String, String> e : properties.entrySet()) {
        t = DirectoryServer.getAttributeType(toLowerCase(e.getKey()), true);
        attrList = new ArrayList<Attribute>(1);
        attrList.add(Attributes.create(t, AttributeValues.create(
            t, e.getValue())));
        attrList.add(Attributes.create(t, ByteString.valueOf(e.getValue())));
        userAttrs.put(t, attrList);
      }
    }
@@ -854,13 +843,12 @@
                 backupDirEntry.getAttribute(backupPathType);
            if ((attrList != null) && (! attrList.isEmpty()))
            {
              for (AttributeValue v : attrList.get(0))
              for (ByteString v : attrList.get(0))
              {
                try
                {
                  BackupDirectory backupDirectory =
                       BackupDirectory.readBackupDirectoryDescriptor(
                            v.getValue().toString());
                       BackupDirectory.readBackupDirectoryDescriptor(v.toString());
                  AttributeType idType =
                       DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
                                                        true);
@@ -908,13 +896,12 @@
        List<Attribute> attrList = backupDirEntry.getAttribute(t);
        if ((attrList != null) && (! attrList.isEmpty()))
        {
          for (AttributeValue v : attrList.get(0))
          for (ByteString v : attrList.get(0))
          {
            try
            {
              BackupDirectory backupDirectory =
                   BackupDirectory.readBackupDirectoryDescriptor(
                        v.getValue().toString());
                   BackupDirectory.readBackupDirectoryDescriptor(v.toString());
              AttributeType idType =
                   DirectoryServer.getAttributeType(ATTR_BACKUP_ID,
                                                    true);
@@ -1171,8 +1158,7 @@
  public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType,
                               String rdnStringValue)
  {
    AttributeValue attrValue =
        AttributeValues.create(rdnAttrType, rdnStringValue);
    ByteString attrValue = ByteString.valueOf(rdnStringValue);
    return parentDN.child(RDN.create(rdnAttrType, attrValue));
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/MonitorBackend.java
@@ -30,6 +30,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.util.Reject;
@@ -1000,7 +1001,7 @@
      for (int i = 0; i < rdn.getNumValues(); i++)
      {
        final AttributeType attributeType = rdn.getAttributeType(i);
        final AttributeValue value = rdn.getAttributeValue(attributeType);
        final ByteString value = rdn.getAttributeValue(attributeType);
        final Attribute attr = Attributes.create(attributeType, value);
        final List<Attribute> attrList = new ArrayList<Attribute>(1);
        attrList.add(attr);
@@ -1114,7 +1115,7 @@
    // Make sure to include the RDN attribute.
    final RDN entryRDN = entryDN.rdn();
    final AttributeType rdnType = entryRDN.getAttributeType(0);
    final AttributeValue rdnValue = entryRDN.getAttributeValue(0);
    final ByteString rdnValue = entryRDN.getAttributeValue(0);
    final Attribute rdnAttr = Attributes.create(rdnType, rdnValue);
    final ArrayList<Attribute> rdnList = new ArrayList<Attribute>(1);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/RootDSEBackend.java
@@ -44,7 +44,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.util.Reject;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -52,7 +54,6 @@
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -61,7 +62,6 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.core.WorkflowTopologyNode;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.LDIFWriter;
import static org.opends.messages.BackendMessages.*;
@@ -946,10 +946,8 @@
    AttributeBuilder builder = new AttributeBuilder(type, name);
    for (DN dn : values) {
      builder.add(
          AttributeValues.create(type, dn.toString()));
      builder.add(dn.toString());
    }
    return builder.toAttribute();
  }
@@ -980,9 +978,8 @@
    AttributeBuilder builder = new AttributeBuilder(type, name);
    builder.setInitialCapacity(values.size());
    for (String s : values) {
      builder.add(AttributeValues.create(type, s));
      builder.add(s);
    }
    return builder.toAttribute();
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
@@ -56,6 +56,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
@@ -194,20 +195,20 @@
  /**
   * The value containing DN of the user we'll say created the configuration.
   */
  private AttributeValue creatorsName;
  private ByteString creatorsName;
  /**
   * The value containing the DN of the last user to modify the configuration.
   */
  private AttributeValue modifiersName;
  private ByteString modifiersName;
  /** The timestamp that will be used for the schema creation time. */
  private AttributeValue createTimestamp;
  private ByteString createTimestamp;
  /**
   * The timestamp that will be used for the latest schema modification time.
   */
  private AttributeValue modifyTimestamp;
  private ByteString modifyTimestamp;
  /**
   * Indicates whether the attributes of the schema entry should always be
@@ -330,10 +331,8 @@
    cfg.getBaseDN().toArray(newBaseDNs);
    this.baseDNs = newBaseDNs;
    creatorsName  = AttributeValues.create(
        creatorsNameType, newBaseDNs[0].toString());
    modifiersName = AttributeValues.create(
        modifiersNameType, newBaseDNs[0].toString());
    creatorsName  = ByteString.valueOf(newBaseDNs[0].toString());
    modifiersName = ByteString.valueOf(newBaseDNs[0].toString());
    long createTime = DirectoryServer.getSchema().getOldestModificationTime();
    createTimestamp =
@@ -974,20 +973,19 @@
        case ADD:
          if (at.equals(attributeTypesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              AttributeType type;
              try
              {
                type = AttributeTypeSyntax.decodeAttributeType(v.getValue(),
                    newSchema, false);
                type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -997,20 +995,19 @@
          }
          else if (at.equals(objectClassesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              ObjectClass oc;
              try
              {
                oc = ObjectClassSyntax.decodeObjectClass(v.getValue(),
                    newSchema, false);
                oc = ObjectClassSyntax.decodeObjectClass(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS.
                    get(v.getValue(), de.getMessageObject());
                    get(v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1020,20 +1017,19 @@
          }
          else if (at.equals(nameFormsType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              NameForm nf;
              try
              {
                nf = NameFormSyntax.decodeNameForm(v.getValue(), newSchema,
                    false);
                nf = NameFormSyntax.decodeNameForm(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1043,20 +1039,19 @@
          }
          else if (at.equals(ditContentRulesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              DITContentRule dcr;
              try
              {
                dcr = DITContentRuleSyntax.decodeDITContentRule(v.getValue(),
                    newSchema, false);
                dcr = DITContentRuleSyntax.decodeDITContentRule(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DCR.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1066,20 +1061,19 @@
          }
          else if (at.equals(ditStructureRulesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              DITStructureRule dsr;
              try
              {
                dsr = DITStructureRuleSyntax.decodeDITStructureRule(
                    v.getValue(), newSchema, false);
                dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1089,20 +1083,19 @@
          }
          else if (at.equals(matchingRuleUsesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              MatchingRuleUse mru;
              try
              {
                mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v.getValue(),
                    newSchema, false);
                mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_MR_USE.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1112,21 +1105,19 @@
          }
          else if (at.equals(ldapSyntaxesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              LDAPSyntaxDescription lsd;
              try
              {
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(
                    v.getValue(), newSchema, false);
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message =
                    ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get(
                        v.getValue(), de.getMessageObject());
                    ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get(v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1155,20 +1146,19 @@
          if (at.equals(attributeTypesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              AttributeType type;
              try
              {
                type = AttributeTypeSyntax.decodeAttributeType(v.getValue(),
                    newSchema, false);
                type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1179,20 +1169,19 @@
          }
          else if (at.equals(objectClassesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              ObjectClass oc;
              try
              {
                oc = ObjectClassSyntax.decodeObjectClass(v.getValue(),
                    newSchema, false);
                oc = ObjectClassSyntax.decodeObjectClass(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS.
                    get(v.getValue(), de.getMessageObject());
                    get(v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1202,20 +1191,19 @@
          }
          else if (at.equals(nameFormsType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              NameForm nf;
              try
              {
                nf = NameFormSyntax.decodeNameForm(v.getValue(), newSchema,
                    false);
                nf = NameFormSyntax.decodeNameForm(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1225,20 +1213,19 @@
          }
          else if (at.equals(ditContentRulesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              DITContentRule dcr;
              try
              {
                dcr = DITContentRuleSyntax.decodeDITContentRule(v.getValue(),
                    newSchema, false);
                dcr = DITContentRuleSyntax.decodeDITContentRule(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DCR.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1248,20 +1235,19 @@
          }
          else if (at.equals(ditStructureRulesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              DITStructureRule dsr;
              try
              {
                dsr = DITStructureRuleSyntax.decodeDITStructureRule(
                    v.getValue(), newSchema, false);
                dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1272,20 +1258,19 @@
          }
          else if (at.equals(matchingRuleUsesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              MatchingRuleUse mru;
              try
              {
                mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v.getValue(),
                    newSchema, false);
                mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_MR_USE.get(
                    v.getValue(), de.getMessageObject());
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1295,13 +1280,12 @@
          }
          else if (at.equals(ldapSyntaxesType))
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              LDAPSyntaxDescription lsd;
              try
              {
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(
                    v.getValue(), newSchema, false);
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
@@ -1309,7 +1293,7 @@
                LocalizableMessage message =
                    ERR_SCHEMA_MODIFY_CANNOT_DECODE_LDAP_SYNTAX.get(
                        v.getValue(), de.getMessageObject());
                        v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
@@ -1371,8 +1355,7 @@
      authzDN = DN.rootDN();
    }
    modifiersName = AttributeValues.create(
        modifiersNameType, authzDN.toString());
    modifiersName = ByteString.valueOf(authzDN.toString());
    modifyTimestamp = GeneralizedTimeSyntax.createGeneralizedTimeValue(
                           System.currentTimeMillis());
  }
@@ -1665,23 +1648,21 @@
        continue;
      }
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        AttributeType at;
        try
        {
          at = AttributeTypeSyntax.decodeAttributeType(v.getValue(), schema,
                                                       true);
          at = AttributeTypeSyntax.decodeAttributeType(v, schema, true);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
              v.getValue(), de.getMessageObject());
              v, de.getMessageObject());
          throw new DirectoryException(
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message,
                         de);
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
        }
        if (attributeType.getOID().equals(at.getOID()))
@@ -1961,22 +1942,21 @@
        continue;
      }
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        ObjectClass oc;
        try
        {
          oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, true);
          oc = ObjectClassSyntax.decodeObjectClass(v, schema, true);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_OBJECTCLASS.get(
              v.getValue(), de.getMessageObject());
              v, de.getMessageObject());
          throw new DirectoryException(
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message,
                         de);
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
        }
        if (objectClass.getOID().equals(oc.getOID()))
@@ -2230,22 +2210,21 @@
        continue;
      }
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        NameForm nf;
        try
        {
          nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, true);
          nf = NameFormSyntax.decodeNameForm(v, schema, true);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_NAME_FORM.get(
              v.getValue(), de.getMessageObject());
              v, de.getMessageObject());
          throw new DirectoryException(
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message,
                         de);
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
        }
        if (nameForm.getOID().equals(nf.getOID()))
@@ -2700,23 +2679,21 @@
        continue;
      }
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        DITStructureRule dsr;
        try
        {
          dsr = DITStructureRuleSyntax.decodeDITStructureRule(
                     v.getValue(), schema, true);
          dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, schema, true);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_DSR.get(
              v.getValue(), de.getMessageObject());
              v, de.getMessageObject());
          throw new DirectoryException(
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message,
                         de);
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
        }
        if (ditStructureRule.getRuleID() == dsr.getRuleID())
@@ -3082,14 +3059,13 @@
     * this only for the real part of the ldapsyntaxes attribute. The real part
     * is read and write to/from the schema files.
     */
    Set<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    Set<ByteString> values = new LinkedHashSet<ByteString>();
    for (LDAPSyntaxDescription ldapSyntax :
                                   schema.getLdapSyntaxDescriptions().values())
    {
      if (schemaFile.equals(getSchemaFile(ldapSyntax)))
      {
        values.add(AttributeValues.create(ldapSyntaxesType,
                ldapSyntax.toString()));
        values.add(ByteString.valueOf(ldapSyntax.toString()));
      }
    }
@@ -3106,7 +3082,7 @@
    // to be careful of the ordering to ensure that any superior types in the
    // same file are written before the subordinate types.
    Set<AttributeType> addedTypes = new HashSet<AttributeType>();
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (AttributeType at : schema.getAttributeTypes().values())
    {
      if (schemaFile.equals(getSchemaFile(at)))
@@ -3129,7 +3105,7 @@
    // to be careful of the ordering to ensure that any superior classes in the
    // same file are written before the subordinate classes.
    Set<ObjectClass> addedClasses = new HashSet<ObjectClass>();
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (ObjectClass oc : schema.getObjectClasses().values())
    {
      if (schemaFile.equals(getSchemaFile(oc)))
@@ -3152,14 +3128,14 @@
    // Add all of the appropriate name forms to the schema entry.  Since there
    // is no hierarchical relationship between name forms, we don't need to
    // worry about ordering.
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (List<NameForm> forms : schema.getNameFormsByObjectClass().values())
    {
      for(NameForm nf : forms)
      {
        if (schemaFile.equals(getSchemaFile(nf)))
        {
          values.add(AttributeValues.create(nameFormsType, nf.toString()));
          values.add(ByteString.valueOf(nf.toString()));
        }
      }
    }
@@ -3177,13 +3153,12 @@
    // Add all of the appropriate DIT content rules to the schema entry.  Since
    // there is no hierarchical relationship between DIT content rules, we don't
    // need to worry about ordering.
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (DITContentRule dcr : schema.getDITContentRules().values())
    {
      if (schemaFile.equals(getSchemaFile(dcr)))
      {
        values.add(AttributeValues.create(ditContentRulesType,
                                      dcr.toString()));
        values.add(ByteString.valueOf(dcr.toString()));
      }
    }
@@ -3201,7 +3176,7 @@
    // need to be careful of the ordering to ensure that any superior rules in
    // the same file are written before the subordinate rules.
    Set<DITStructureRule> addedDSRs = new HashSet<DITStructureRule>();
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (DITStructureRule dsr : schema.getDITStructureRulesByID().values())
    {
      if (schemaFile.equals(getSchemaFile(dsr)))
@@ -3224,13 +3199,12 @@
    // Add all of the appropriate matching rule uses to the schema entry.  Since
    // there is no hierarchical relationship between matching rule uses, we
    // don't need to worry about ordering.
    values = new LinkedHashSet<AttributeValue>();
    values = new LinkedHashSet<ByteString>();
    for (MatchingRuleUse mru : schema.getMatchingRuleUses().values())
    {
      if (schemaFile.equals(getSchemaFile(mru)))
      {
        values.add(AttributeValues.create(matchingRuleUsesType,
                                      mru.toString()));
        values.add(ByteString.valueOf(mru.toString()));
      }
    }
@@ -3287,7 +3261,7 @@
   */
  private void addAttrTypeToSchemaFile(Schema schema, String schemaFile,
                                       AttributeType attributeType,
                                       Set<AttributeValue> values,
                                       Set<ByteString> values,
                                       Set<AttributeType> addedTypes,
                                       int depth)
          throws DirectoryException
@@ -3313,8 +3287,7 @@
                              addedTypes, depth+1);
    }
    values.add(AttributeValues.create(attributeTypesType,
                                  attributeType.toString()));
    values.add(ByteString.valueOf(attributeType.toString()));
    addedTypes.add(attributeType);
  }
@@ -3338,7 +3311,7 @@
   */
  private void addObjectClassToSchemaFile(Schema schema, String schemaFile,
                                          ObjectClass objectClass,
                                          Set<AttributeValue> values,
                                          Set<ByteString> values,
                                          Set<ObjectClass> addedClasses,
                                          int depth)
          throws DirectoryException
@@ -3364,8 +3337,7 @@
                                   addedClasses, depth+1);
      }
    }
    values.add(AttributeValues.create(objectClassesType,
                                  objectClass.toString()));
    values.add(ByteString.valueOf(objectClass.toString()));
    addedClasses.add(objectClass);
  }
@@ -3390,7 +3362,7 @@
   */
  private void addDITStructureRuleToSchemaFile(Schema schema, String schemaFile,
                    DITStructureRule ditStructureRule,
                    Set<AttributeValue> values,
                    Set<ByteString> values,
                    Set<DITStructureRule> addedDSRs, int depth)
          throws DirectoryException
  {
@@ -3415,8 +3387,7 @@
      }
    }
    values.add(AttributeValues.create(ditStructureRulesType,
                                  ditStructureRule.toString()));
    values.add(ByteString.valueOf(ditStructureRule.toString()));
    addedDSRs.add(ditStructureRule);
  }
@@ -3951,11 +3922,10 @@
      {
        // Look for attributetypes that could have been added to the schema
        // or modified in the schema
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the attribute type.
          AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(
              v.getValue(), schema, false);
          AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
          String schemaFile = getSchemaFile(attrType);
          if ((schemaFile != null) &&
              (schemaFile.equals(CONFIG_SCHEMA_ELEMENTS_FILE)))
@@ -4058,12 +4028,11 @@
    {
      for (Attribute a : ocList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // It IS important here to allow the unknown elements that could
          // appear in the new config schema.
          ObjectClass newObjectClass = ObjectClassSyntax.decodeObjectClass(
              v.getValue(), newSchema, true);
          ObjectClass newObjectClass = ObjectClassSyntax.decodeObjectClass(v, newSchema, true);
          String schemaFile = getSchemaFile(newObjectClass);
          if ((schemaFile != null) &&
              (schemaFile.equals(CONFIG_SCHEMA_ELEMENTS_FILE)))
@@ -4077,8 +4046,7 @@
          // Now we know we are not in the config schema, let's check
          // the unknown elements ... sadly but simply by redoing the
          // whole decoding.
          newObjectClass = ObjectClassSyntax.decodeObjectClass(
              v.getValue(), newSchema, false);
          newObjectClass = ObjectClassSyntax.decodeObjectClass(v, newSchema, false);
          oidList.add(newObjectClass.getOID());
          try
          {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -519,14 +519,14 @@
    // Make sure that the DN specifies a certificate alias.
    AttributeType t =
         DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true);
    AttributeValue v = entryDN.rdn().getAttributeValue(t);
    ByteString v = entryDN.rdn().getAttributeValue(t);
    if (v == null)
    {
      LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null);
    }
    String certAlias = v.getValue().toString();
    String certAlias = v.toString();
    ByteString certValue;
    try
    {
@@ -571,7 +571,7 @@
        true);
    AttributeBuilder builder = new AttributeBuilder(t);
    builder.setOption("binary");
    builder.add(AttributeValues.create(t, certValue));
    builder.add(certValue);
    attrList = new ArrayList<Attribute>(1);
    attrList.add(builder.toAttribute());
    userAttrs.put(t, attrList);
@@ -1249,8 +1249,7 @@
  public static DN makeChildDN(DN parentDN, AttributeType rdnAttrType,
                               String rdnStringValue)
  {
    AttributeValue attrValue =
        AttributeValues.create(rdnAttrType, rdnStringValue);
    ByteString attrValue = ByteString.valueOf(rdnStringValue);
    return parentDN.child(RDN.create(rdnAttrType, attrValue));
  }
@@ -1440,14 +1439,14 @@
    // Make sure that the DN specifies a certificate alias.
    AttributeType t =
         DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true);
    AttributeValue v = entryDN.rdn().getAttributeValue(t);
    ByteString v = entryDN.rdn().getAttributeValue(t);
    if (v == null)
    {
      LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null);
    }
    String certAlias = v.getValue().toString();
    String certAlias = v.toString();
    try
    {
      if (certificateManager.aliasInUse(certAlias))
@@ -1495,7 +1494,7 @@
        }
        Attribute certAttr = certAttrs.get(0);
        Iterator<AttributeValue> i = certAttr.iterator();
        Iterator<ByteString> i = certAttr.iterator();
        if (!i.hasNext())
        {
@@ -1505,7 +1504,7 @@
               DirectoryServer.getServerErrorResultCode(), message);
        }
        ByteString certBytes = i.next().getValue();
        ByteString certBytes = i.next();
        if (i.hasNext())
        {
@@ -1566,14 +1565,14 @@
    // Make sure that the DN specifies a certificate alias.
    AttributeType t =
         DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true);
    AttributeValue v = entryDN.rdn().getAttributeValue(t);
    ByteString v = entryDN.rdn().getAttributeValue(t);
    if (v == null)
    {
      LocalizableMessage message = ERR_TRUSTSTORE_DN_DOES_NOT_SPECIFY_CERTIFICATE.get(entryDN);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, baseDN, null);
    }
    String certAlias = v.getValue().toString();
    String certAlias = v.toString();
    try
    {
      if (!certificateManager.aliasInUse(certAlias))
@@ -1591,7 +1590,6 @@
      throw new DirectoryException(
           DirectoryServer.getServerErrorResultCode(), message, e);
    }
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -803,8 +803,8 @@
      // Make a key from the normalized assertion value.
      MatchingRule equalityRule = equalityFilter.getAttributeType().
        getEqualityMatchingRule();
      byte[] keyBytes = equalityRule.normalizeAssertionValue(equalityFilter.
        getAssertionValue().getValue()).toByteArray();
      byte[] keyBytes = equalityRule.normalizeAssertionValue(
          equalityFilter.getAssertionValue()).toByteArray();
      DatabaseEntry key = new DatabaseEntry(keyBytes);
      if(debugBuffer != null)
@@ -979,7 +979,7 @@
           filter.getAttributeType().getOrderingMatchingRule();
      // FIXME JNR this looks wrong, it should use normalizeAssertionValue()
      byte[] normalizedValue = orderingRule.normalizeAttributeValue(
          filter.getAssertionValue().getValue()).toByteArray();
          filter.getAssertionValue()).toByteArray();
      // Set the lower and upper bounds for a range search.
      byte[] lower;
@@ -1233,8 +1233,7 @@
   * @param upperValue The upper bound value
   * @return The candidate entry IDs.
   */
  public EntryIDSet evaluateBoundedRange(AttributeValue lowerValue,
                                          AttributeValue upperValue)
  public EntryIDSet evaluateBoundedRange(ByteString lowerValue, ByteString upperValue)
  {
    if (orderingIndex == null)
    {
@@ -1247,13 +1246,9 @@
      OrderingMatchingRule orderingRule =
           getAttributeType().getOrderingMatchingRule();
      // Set the lower bound for a range search.
      byte[] lower =
          orderingRule.normalizeAttributeValue(lowerValue.getValue()).toByteArray();
      // Set the upper bound for a range search.
      byte[] upper =
          orderingRule.normalizeAttributeValue(upperValue.getValue()).toByteArray();
      // Set the lower and upper bounds for a range search.
      byte[] lower = orderingRule.normalizeAttributeValue(lowerValue).toByteArray();
      byte[] upper = orderingRule.normalizeAttributeValue(upperValue).toByteArray();
      // Read the range: lower <= keys <= upper.
      return orderingIndex.readRange(lower, upper, true, true);
@@ -1398,9 +1393,8 @@
          approximateFilter.getAttributeType().getApproximateMatchingRule();
      // Make a key from the normalized assertion value.
      // FIXME JNR this looks wrong, it should use normalizeAssertionValue()
      byte[] keyBytes =
           approximateMatchingRule.normalizeAttributeValue(
               approximateFilter.getAssertionValue().getValue()).toByteArray();
      byte[] keyBytes = approximateMatchingRule.normalizeAttributeValue(
          approximateFilter.getAssertionValue()).toByteArray();
      DatabaseEntry key = new DatabaseEntry(keyBytes);
      if(debugBuffer != null)
@@ -2278,7 +2272,7 @@
        // Make a key from the normalized assertion value.
        MatchingRule rule =
            extensibleFilter.getAttributeType().getEqualityMatchingRule();
        ByteString value = extensibleFilter.getAssertionValue().getValue();
        ByteString value = extensibleFilter.getAssertionValue();
        byte[] keyBytes = rule.normalizeAssertionValue(value).toByteArray();
        DatabaseEntry key = new DatabaseEntry(keyBytes);
@@ -2357,8 +2351,7 @@
        }
        debugBuffer.append("]");
      }
      ByteString assertionValue =
              extensibleFilter.getAssertionValue().getValue();
      ByteString assertionValue = extensibleFilter.getAssertionValue();
      IndexQuery expression = rule.createIndexQuery(assertionValue, factory);
      List<LocalizableMessage> debugMessages =
          monitor.isFilterUseEnabled() ? new ArrayList<LocalizableMessage>() : null;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2URI.java
@@ -31,6 +31,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.core.DirectoryServer;
@@ -295,9 +296,9 @@
          case ADD:
            if (a != null)
            {
              for (AttributeValue v : a)
              for (ByteString v : a)
              {
                insert(txn, entryDN, v.getValue().toString());
                insert(txn, entryDN, v.toString());
              }
            }
            break;
@@ -309,9 +310,9 @@
            }
            else
            {
              for (AttributeValue v : a)
              for (ByteString v : a)
              {
                delete(txn, entryDN, v.getValue().toString());
                delete(txn, entryDN, v.toString());
              }
            }
            break;
@@ -324,9 +325,9 @@
            delete(txn, entryDN);
            if (a != null)
            {
              for (AttributeValue v : a)
              for (ByteString v : a)
              {
                insert(txn, entryDN, v.getValue().toString());
                insert(txn, entryDN, v.toString());
              }
            }
            break;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -1086,7 +1086,7 @@
      Entry debugEntry =
          new Entry(DN.valueOf("cn=debugsearch"), null, null, null);
      debugEntry.addAttribute(attr, new ArrayList<AttributeValue>());
      debugEntry.addAttribute(attr, new ArrayList<ByteString>());
      searchOperation.returnEntry(debugEntry, null);
      return;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EntryIDSetSorter.java
@@ -32,6 +32,8 @@
import java.util.TreeMap;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.controls.VLVRequestControl;
import org.opends.server.controls.VLVResponseControl;
@@ -39,7 +41,6 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import com.sleepycat.je.LockMode;
@@ -197,10 +198,7 @@
      }
      else
      {
        AttributeValue assertionValue =
            AttributeValues.create(
                sortOrder.getSortKeys()[0].getAttributeType(),
                vlvRequest.getGreaterThanOrEqualAssertion());
        ByteString assertionValue = vlvRequest.getGreaterThanOrEqualAssertion();
        boolean targetFound     = false;
        int targetOffset        = 0;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java
@@ -36,11 +36,10 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.MatchingRule;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.opends.server.types.Attribute;
/**
 *This class implements an Indexer for extensible matching rules in JE Backend.
@@ -158,11 +157,11 @@
    {
      if (!attr.isVirtual())
      {
        for (AttributeValue value : attr)
        for (ByteString value : attr)
        {
          try
          {
            extensibleIndexer.createKeys(null, value.getValue(), null, keys);
            extensibleIndexer.createKeys(null, value, null, keys);
          }
          catch (DecodeException e)
          {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SortValues.java
@@ -30,7 +30,7 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.types.SortKey;
import org.opends.server.types.SortOrder;
@@ -51,7 +51,7 @@
       implements Comparable<SortValues>
{
  /** The set of sort keys (attribute values) in this sort order. */
  private AttributeValue[] values;
  private ByteString[] values;
  /**
   * The types of sort keys.
   *
@@ -75,7 +75,7 @@
   * @param values     The attribute values for this sort values.
   * @param sortOrder  The sort order to use to obtain the necessary values.
   */
  public SortValues(EntryID entryID, AttributeValue[] values,
  public SortValues(EntryID entryID, ByteString[] values,
                    SortOrder sortOrder)
  {
    this.entryID = entryID;
@@ -105,7 +105,7 @@
    this.sortOrder = sortOrder;
    SortKey[] sortKeys = sortOrder.getSortKeys();
    this.values = new AttributeValue[sortKeys.length];
    this.values = new ByteString[sortKeys.length];
    this.types = new AttributeType[sortKeys.length];
    for (int i=0; i < sortKeys.length; i++)
    {
@@ -114,7 +114,7 @@
      List<Attribute> attrList = entry.getAttribute(types[i]);
      if (attrList != null)
      {
        AttributeValue sortValue = null;
        ByteString sortValue = null;
        // There may be multiple versions of this attribute in the target entry
        // (e.g., with different sets of options), and it may also be a
@@ -125,7 +125,7 @@
        // handled by the SortKey.compareValues method.
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (sortValue == null)
            {
@@ -207,7 +207,7 @@
   *          is equal to the first sort value, or a positive value if the
   *          provided assertion value should come after the first sort value.
   */
  public int compareTo(AttributeValue assertionValue)
  public int compareTo(ByteString assertionValue)
  {
    SortKey sortKey = sortOrder.getSortKeys()[0];
    return sortKey.compareValues(values[0], assertionValue);
@@ -265,7 +265,7 @@
      }
      else
      {
        buffer.append(values[i].getValue().toString());
        buffer.append(values[i].toString());
      }
    }
@@ -279,7 +279,7 @@
   *
   * @return The array of attribute values for this sort values.
   */
  public AttributeValue[] getValues()
  public ByteString[] getValues()
  {
    return values;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/SortValuesSet.java
@@ -31,7 +31,9 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.opends.server.types.*;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.SortKey;
import com.sleepycat.je.DatabaseException;
@@ -104,8 +106,8 @@
   * @throws DirectoryException If a Directory Server error occurs.
   * @throws DatabaseException If an error occurs in the JE database.
   */
  public boolean add(long entryID, AttributeValue[] values,
      AttributeType[] types) throws DatabaseException, DirectoryException
  public boolean add(long entryID, ByteString[] values, AttributeType[] types)
      throws DatabaseException, DirectoryException
  {
    if(values == null)
    {
@@ -224,7 +226,7 @@
   * @throws DirectoryException If a Directory Server error occurs.
   * @throws DatabaseException If an error occurs in the JE database.
   */
  public boolean remove(long entryID, AttributeValue[] values, AttributeType[] types)
  public boolean remove(long entryID, ByteString[] values, AttributeType[] types)
      throws DatabaseException, DirectoryException
  {
    if(entryIDs == null || entryIDs.length == 0)
@@ -417,7 +419,7 @@
   * @throws DirectoryException If a Directory Server error occurs.
   * @throws DatabaseException If an error occurs in the JE database.
   */
  int binarySearch(long entryID, AttributeValue[] values, AttributeType[] types)
  int binarySearch(long entryID, ByteString[] values, AttributeType[] types)
      throws DatabaseException, DirectoryException
  {
    if(entryIDs == null || entryIDs.length == 0)
@@ -472,7 +474,7 @@
    return entryIDs;
  }
  private byte[] attributeValuesToDatabase(AttributeValue[] values,
  private byte[] attributeValuesToDatabase(ByteString[] values,
      AttributeType[] types) throws DirectoryException
  {
    try
@@ -481,7 +483,7 @@
      for (int i = 0; i < values.length; i++)
      {
        final AttributeValue v = values[i];
        final ByteString v = values[i];
        if (v == null)
        {
          builder.appendBERLength(0);
@@ -489,7 +491,7 @@
        else
        {
          final MatchingRule eqRule = types[i].getEqualityMatchingRule();
          final ByteString nv = eqRule.normalizeAttributeValue(v.getValue());
          final ByteString nv = eqRule.normalizeAttributeValue(v);
          builder.appendBERLength(nv.length());
          builder.append(nv);
        }
@@ -569,15 +571,12 @@
    EntryID id = new EntryID(entryIDs[entryIDs.length - 1]);
    SortKey[] sortKeys = vlvIndex.sortOrder.getSortKeys();
    int numValues = sortKeys.length;
    AttributeValue[] values =
        new AttributeValue[numValues];
    ByteString[] values = new ByteString[numValues];
    for (int i = (entryIDs.length - 1) * numValues, j = 0;
         i < entryIDs.length * numValues;
         i++, j++)
    {
      values[j] = AttributeValues.create(
          sortKeys[j].getAttributeType(),
          getValue(i));
      values[j] = getValue(i);
    }
    return new SortValues(id, values, vlvIndex.sortOrder);
@@ -603,18 +602,12 @@
    EntryID id = new EntryID(entryIDs[index]);
    SortKey[] sortKeys = vlvIndex.sortOrder.getSortKeys();
    int numValues = sortKeys.length;
    AttributeValue[] values = new AttributeValue[numValues];
    ByteString[] values = new ByteString[numValues];
    for (int i = index * numValues, j = 0;
         i < (index + 1) * numValues;
         i++, j++)
    {
      ByteString value = getValue(i);
      if(value != null)
      {
        values[j] = AttributeValues.create(
            sortKeys[j].getAttributeType(), value);
      }
      values[j] = getValue(i);
    }
    return new SortValues(id, values, vlvIndex.sortOrder);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVIndex.java
@@ -664,7 +664,7 @@
   * @throws DirectoryException If a Directory Server error occurs.
   */
  public SortValuesSet getSortValuesSet(Transaction txn, long entryID,
      AttributeValue[] values, AttributeType[] types) throws DatabaseException,
      ByteString[] values, AttributeType[] types) throws DatabaseException,
      DirectoryException
  {
    SortValuesSet sortValuesSet = null;
@@ -733,7 +733,7 @@
   * @throws DirectoryException If a Directory Server error occurs.
   */
  public boolean containsValues(Transaction txn, long entryID,
      AttributeValue[] values, AttributeType[] types) throws JebException,
      ByteString[] values, AttributeType[] types) throws JebException,
      DatabaseException, DirectoryException
  {
    SortValuesSet valuesSet = getSortValuesSet(txn, entryID, values, types);
@@ -744,7 +744,7 @@
  private boolean insertValues(Transaction txn, long entryID, Entry entry)
      throws JebException, DatabaseException, DirectoryException
  {
    AttributeValue[] values = getSortValues(entry);
    ByteString[] values = getSortValues(entry);
    AttributeType[] types = getSortTypes();
    DatabaseEntry key = new DatabaseEntry();
    OperationStatus status;
@@ -855,8 +855,7 @@
  private boolean removeValues(Transaction txn, long entryID, Entry entry)
      throws JebException, DatabaseException, DirectoryException
  {
    SortValuesSet sortValuesSet;
    AttributeValue[] values = getSortValues(entry);
    ByteString[] values = getSortValues(entry);
    AttributeType[] types = getSortTypes();
    DatabaseEntry key = new DatabaseEntry();
    OperationStatus status;
@@ -889,8 +888,7 @@
                            searchKeyHex,
                            foundKeyHex);
      }
      sortValuesSet = new SortValuesSet(key.getData(), data.getData(),
                                        this);
      SortValuesSet sortValuesSet = new SortValuesSet(key.getData(), data.getData(), this);
      boolean success = sortValuesSet.remove(entryID, values, types);
      byte[] after = sortValuesSet.toDatabase();
@@ -1350,12 +1348,12 @@
            }
            SortValuesSet sortValuesSet =
                new SortValuesSet(key.getData(), data.getData(), this);
            AttributeType type = sortOrder.getSortKeys()[0].getAttributeType();
            AttributeValue[] assertionValue = new AttributeValue[] {
                AttributeValues.create(
                    type, vlvRequest.getGreaterThanOrEqualAssertion())
            ByteString[] assertionValue = new ByteString[] {
                vlvRequest.getGreaterThanOrEqualAssertion()
            };
            AttributeType[] assertionType = new AttributeType[] { type };
            AttributeType[] assertionType = new AttributeType[] {
                sortOrder.getSortKeys()[0].getAttributeType()
            };
            int adjustedTargetOffset =
                sortValuesSet.binarySearch(-1, assertionValue, assertionType);
@@ -1559,10 +1557,10 @@
   * @param entry The entry to get the values from.
   * @return The attribute values to sort on.
   */
  AttributeValue[] getSortValues(Entry entry)
  ByteString[] getSortValues(Entry entry)
  {
    SortKey[] sortKeys = sortOrder.getSortKeys();
    AttributeValue[] values = new AttributeValue[sortKeys.length];
    ByteString[] values = new ByteString[sortKeys.length];
    for (int i=0; i < sortKeys.length; i++)
    {
      SortKey sortKey = sortKeys[i];
@@ -1570,7 +1568,7 @@
      List<Attribute> attrList = entry.getAttribute(attrType);
      if (attrList != null)
      {
        AttributeValue sortValue = null;
        ByteString sortValue = null;
        // There may be multiple versions of this attribute in the target entry
        // (e.g., with different sets of options), and it may also be a
@@ -1581,7 +1579,7 @@
        // handled by the SortKey.compareValues method.
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (sortValue == null)
            {
@@ -1609,7 +1607,7 @@
   * @return The encoded bytes.
   * @throws DirectoryException If a Directory Server error occurs.
   */
  byte[] encodeKey(long entryID, AttributeValue[] values, AttributeType[] types)
  byte[] encodeKey(long entryID, ByteString[] values, AttributeType[] types)
      throws DirectoryException
  {
    try
@@ -1618,7 +1616,7 @@
      for (int i = 0; i < values.length; i++)
      {
        final AttributeValue v = values[i];
        final ByteString v = values[i];
        if (v == null)
        {
          builder.appendBERLength(0);
@@ -1626,7 +1624,7 @@
        else
        {
          final MatchingRule eqRule = types[i].getEqualityMatchingRule();
          final ByteString nv = eqRule.normalizeAttributeValue(v.getValue());
          final ByteString nv = eqRule.normalizeAttributeValue(v);
          builder.appendBERLength(nv.length());
          builder.append(nv);
        }
@@ -1658,8 +1656,7 @@
      return null;
    }
    AttributeValue[] attributeValues =
        new AttributeValue[sortOrder.getSortKeys().length];
    ByteString[] attributeValues = new ByteString[sortOrder.getSortKeys().length];
    int vBytesPos = 0;
    for(int i = 0; i < attributeValues.length; i++)
@@ -1683,10 +1680,7 @@
      {
        byte[] valueBytes = new byte[valueLength];
        System.arraycopy(keyBytes, vBytesPos, valueBytes, 0, valueLength);
        attributeValues[i] =
            AttributeValues.create(
                sortOrder.getSortKeys()[i].getAttributeType(),
                ByteString.wrap(valueBytes));
        attributeValues[i] = ByteString.wrap(valueBytes);
      }
      vBytesPos += valueLength;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java
@@ -35,7 +35,6 @@
import org.opends.server.api.MatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DirectoryException;
import com.sleepycat.je.DatabaseException;
@@ -279,7 +278,7 @@
   *                              associated equality matching rule).
   */
  public int compare(SortValuesSet set, int index, long entryID,
      AttributeValue[] values, AttributeType[] types) throws DatabaseException,
      ByteString[] values, AttributeType[] types) throws DatabaseException,
      DirectoryException
  {
    for (int j=0; j < orderingRules.length; j++)
@@ -297,7 +296,7 @@
        try
        {
          final MatchingRule eqRule = types[j].getEqualityMatchingRule();
          b2Bytes = eqRule.normalizeAttributeValue(values[j].getValue());
          b2Bytes = eqRule.normalizeAttributeValue(values[j]);
        }
        catch (DecodeException e)
        {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -1631,10 +1631,9 @@
    {
      final AttributeType attrType = attr.getAttributeType();
      MatchingRule equalityRule = attrType.getEqualityMatchingRule();
      for (AttributeValue value : attr)
      for (ByteString value : attr)
      {
        final ByteString bsValue = value.getValue();
        byte[] normalizedBytes = normalize(equalityRule, bsValue);
        byte[] normalizedBytes = normalize(equalityRule, value);
        if (equalityIndex != null)
        {
@@ -1653,13 +1652,13 @@
        if (orderingIndex != null)
        {
          key.setData(normalize(attrType.getOrderingMatchingRule(), bsValue));
          key.setData(normalize(attrType.getOrderingMatchingRule(), value));
          verifyAttributeInIndex(orderingIndex, txn, key, entryID);
        }
        if (approximateIndex != null)
        {
          key.setData(normalize(attrType.getApproximateMatchingRule(), bsValue));
          key.setData(normalize(attrType.getApproximateMatchingRule(), value));
          verifyAttributeInIndex(approximateIndex, txn, key, entryID);
        }
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/RecurringTask.java
@@ -41,7 +41,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -183,8 +183,8 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    Iterator<AttributeValue> iterator = attr.iterator();
    AttributeValue value = iterator.next();
    Iterator<ByteString> iterator = attr.iterator();
    ByteString value = iterator.next();
    if (iterator.hasNext())
    {
      LocalizableMessage message =
@@ -192,7 +192,7 @@
      throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message);
    }
    recurringTaskID = value.getValue().toString();
    recurringTaskID = value.toString();
    // Get the schedule for this task.
@@ -288,7 +288,7 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    taskClassName = value.getValue().toString();
    taskClassName = value.toString();
    // Make sure that the specified class can be loaded.
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/Task.java
@@ -42,6 +42,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.messages.Severity;
import org.opends.server.core.DirectoryServer;
@@ -383,7 +384,7 @@
      throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName()));
    }
    Iterator<AttributeValue> iterator = attrList.get(0).iterator();
    Iterator<ByteString> iterator = attrList.get(0).iterator();
    if (! iterator.hasNext())
    {
      if (isRequired)
@@ -396,13 +397,12 @@
      }
    }
    AttributeValue value = iterator.next();
    ByteString value = iterator.next();
    if (iterator.hasNext())
    {
      throw new InitializationException(ERR_TASK_MULTIPLE_VALUES_FOR_ATTR.get(attributeName, taskEntry.getName()));
    }
    return value.getValue().toString();
    return value.toString();
  }
@@ -437,12 +437,11 @@
      throw new InitializationException(ERR_TASK_MULTIPLE_ATTRS_FOR_TYPE.get(attributeName, taskEntry.getName()));
    }
    Iterator<AttributeValue> iterator = attrList.get(0).iterator();
    Iterator<ByteString> iterator = attrList.get(0).iterator();
    while (iterator.hasNext())
    {
      valueStrings.add(iterator.next().getValue().toString());
      valueStrings.add(iterator.next().toString());
    }
    return valueStrings;
  }
@@ -981,7 +980,7 @@
      }
      List<Attribute> attrList = taskEntry.getAttribute(type);
      AttributeValue value = AttributeValues.create(type, messageString);
      ByteString value = ByteString.valueOf(messageString);
      if (attrList == null)
      {
        attrList = new ArrayList<Attribute>();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskBackend.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.backends.task;
import java.io.*;
import java.net.InetAddress;
import java.security.MessageDigest;
@@ -42,6 +40,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.SearchScope;
@@ -65,8 +64,6 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class provides an implementation of a Directory Server backend that may
 * be used to execute various kinds of administrative tasks on a one-time or
@@ -788,13 +785,13 @@
        break;
      }
      Iterator<AttributeValue> iterator = a.iterator();
      Iterator<ByteString> iterator = a.iterator();
      if (!iterator.hasNext()) {
        acceptable = false;
        break;
      }
      AttributeValue v = iterator.next();
      ByteString v = iterator.next();
      String valueString = toLowerCase(v.toString());
      if (!(valueString.startsWith("cancel") ||
        valueString.startsWith("stop"))) {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/task/TaskScheduler.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.backends.task;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -47,14 +45,13 @@
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.TimeThread;
/**
 * This class defines a task scheduler for the Directory Server that will
 * control the execution of scheduled tasks and other administrative functions
@@ -1897,8 +1894,8 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    Iterator<AttributeValue> iterator = attr.iterator();
    AttributeValue value = iterator.next();
    Iterator<ByteString> iterator = attr.iterator();
    ByteString value = iterator.next();
    if (iterator.hasNext())
    {
      LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_VALUES.get(ATTR_TASK_ID);
@@ -1906,7 +1903,7 @@
    }
    // Try to load the specified class.
    String taskClassName = value.getValue().toString();
    String taskClassName = value.toString();
    Class<?> taskClass;
    try
    {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/BooleanConfigAttribute.java
@@ -25,10 +25,9 @@
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.config;
import org.forgerock.i18n.LocalizableMessage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -41,16 +40,12 @@
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.ServerConstants.*;
/**
 * This class defines a Boolean configuration attribute, which can hold a single
 * Boolean value of <CODE>true</CODE> or <CODE>false</CODE>.  Boolean
@@ -236,23 +231,11 @@
   *
   * @return  The value set constructed from the provided value.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(boolean booleanValue)
  private static LinkedHashSet<ByteString> getValueSet(boolean booleanValue)
  {
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    if (booleanValue)
    {
      valueSet.add(AttributeValues.create(
          ByteString.valueOf(CONFIG_VALUE_TRUE),
          ByteString.valueOf(CONFIG_VALUE_TRUE)));
    }
    else
    {
      valueSet.add(AttributeValues.create(
          ByteString.valueOf(CONFIG_VALUE_FALSE),
          ByteString.valueOf(CONFIG_VALUE_FALSE)));
    }
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(
        booleanValue ? CONFIG_VALUE_TRUE : CONFIG_VALUE_FALSE));
    return valueSet;
  }
@@ -288,10 +271,10 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
    String stringValue = value.getValue().toString();
    String stringValue = value.toString();
    if (stringValue.equalsIgnoreCase(CONFIG_VALUE_TRUE) ||
        stringValue.equalsIgnoreCase(CONFIG_VALUE_FALSE))
    {
@@ -324,10 +307,8 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
         throws ConfigException
  public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings,
      boolean allowFailures) throws ConfigException
  {
    if ((valueStrings == null) || valueStrings.isEmpty())
    {
@@ -466,9 +447,8 @@
          else
          {
            // Get the value and parse it as a Boolean.
            Iterator<AttributeValue> iterator = a.iterator();
            String valueString =
                iterator.next().getValue().toString().toLowerCase();
            Iterator<ByteString> iterator = a.iterator();
            String valueString = iterator.next().toString().toLowerCase();
            if (valueString.equals("true") || valueString.equals("yes") ||
                valueString.equals("on") || valueString.equals("1"))
@@ -529,9 +509,8 @@
        else
        {
          // Get the value and parse it as a Boolean.
          Iterator<AttributeValue> iterator = a.iterator();
          String valueString =
              iterator.next().getValue().toString().toLowerCase();
          Iterator<ByteString> iterator = a.iterator();
          String valueString = iterator.next().toString().toLowerCase();
          if (valueString.equals("true") || valueString.equals("yes") ||
              valueString.equals("on") || valueString.equals("1"))
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/ConfigAttribute.java
@@ -38,7 +38,7 @@
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.messages.ConfigMessages.*;
/**
@@ -69,11 +69,11 @@
  // The value or set of values that are currently in effect for this
  // configuration attribute.
  private LinkedHashSet<AttributeValue> activeValues;
  private LinkedHashSet<ByteString> activeValues;
  // The value or set of values that will be in effect once the appropriate
  // administrative action has been taken.
  private LinkedHashSet<AttributeValue> pendingValues;
  private LinkedHashSet<ByteString> pendingValues;
  // The description for this configuration attribute.
  private LocalizableMessage description;
@@ -110,7 +110,7 @@
    this.requiresAdminAction = requiresAdminAction;
    hasPendingValues = false;
    activeValues     = new LinkedHashSet<AttributeValue>();
    activeValues     = new LinkedHashSet<ByteString>();
    pendingValues    = activeValues;
  }
@@ -135,7 +135,7 @@
  protected ConfigAttribute(String name, LocalizableMessage description,
                            boolean isRequired, boolean isMultiValued,
                            boolean requiresAdminAction,
                            LinkedHashSet<AttributeValue> activeValues)
                            LinkedHashSet<ByteString> activeValues)
  {
    this.name                = name;
    this.description         = description;
@@ -146,7 +146,7 @@
    if (activeValues == null)
    {
      this.activeValues = new LinkedHashSet<AttributeValue>();
      this.activeValues = new LinkedHashSet<ByteString>();
    }
    else
    {
@@ -185,9 +185,9 @@
  protected ConfigAttribute(String name, LocalizableMessage description,
                            boolean isRequired, boolean isMultiValued,
                            boolean requiresAdminAction,
                            LinkedHashSet<AttributeValue> activeValues,
                            LinkedHashSet<ByteString> activeValues,
                            boolean hasPendingValues,
                            LinkedHashSet<AttributeValue> pendingValues)
                            LinkedHashSet<ByteString> pendingValues)
  {
    this.name                = name;
    this.description         = description;
@@ -198,7 +198,7 @@
    if (activeValues == null)
    {
      this.activeValues = new LinkedHashSet<AttributeValue>();
      this.activeValues = new LinkedHashSet<ByteString>();
    }
    else
    {
@@ -213,7 +213,7 @@
    {
      if (pendingValues == null)
      {
        this.pendingValues = new LinkedHashSet<AttributeValue>();
        this.pendingValues = new LinkedHashSet<ByteString>();
      }
      else
      {
@@ -318,7 +318,7 @@
   *
   * @return  The set of active values for this configuration attribute.
   */
  public LinkedHashSet<AttributeValue> getActiveValues()
  public LinkedHashSet<ByteString> getActiveValues()
  {
    return activeValues;
  }
@@ -349,7 +349,7 @@
   * @return  The set of values that this configuration attribute will have
   *          after any appropriate administrative action is taken.
   */
  public LinkedHashSet<AttributeValue> getPendingValues()
  public LinkedHashSet<ByteString> getPendingValues()
  {
    if (requiresAdminAction)
    {
@@ -375,7 +375,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public abstract boolean valueIsAcceptable(AttributeValue value,
  public abstract boolean valueIsAcceptable(ByteString value,
                                            StringBuilder rejectReason);
@@ -394,7 +394,7 @@
   * @throws  ConfigException  If the provided set of values is not acceptable
   *                           for some reason.
   */
  protected void setValues(LinkedHashSet<AttributeValue> values)
  protected void setValues(LinkedHashSet<ByteString> values)
         throws ConfigException
  {
    // If no values are provided, then check to see if this is a required
@@ -412,7 +412,7 @@
        {
          if (values == null)
          {
            pendingValues = new LinkedHashSet<AttributeValue>();
            pendingValues = new LinkedHashSet<ByteString>();
          }
          else
          {
@@ -425,7 +425,7 @@
        {
          if (values == null)
          {
            activeValues = new LinkedHashSet<AttributeValue>();
            activeValues = new LinkedHashSet<ByteString>();
          }
          else
          {
@@ -442,14 +442,14 @@
    // We know that we have at least one value, so get it and see if it is OK.
    Iterator<AttributeValue> iterator     = values.iterator();
    AttributeValue           value        = iterator.next();
    Iterator<ByteString>     iterator     = values.iterator();
    ByteString               value        = iterator.next();
    StringBuilder            rejectReason = new StringBuilder();
    if (! valueIsAcceptable(value, rejectReason))
    {
      throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get(
          value.getValue(), name, rejectReason));
          value, name, rejectReason));
    }
@@ -469,7 +469,7 @@
      if (! valueIsAcceptable(value, rejectReason))
      {
        throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get(
            value.getValue(), name, rejectReason));
            value, name, rejectReason));
      }
    }
@@ -499,7 +499,7 @@
   *
   * @param  values  The set of active values for this configuration attribute.
   */
  protected void setActiveValues(LinkedHashSet<AttributeValue> values)
  protected void setActiveValues(LinkedHashSet<ByteString> values)
  {
    activeValues = values;
  }
@@ -513,7 +513,7 @@
   *
   * @param  values  The set of pending values for this configuration attribute.
   */
  protected void setPendingValues(LinkedHashSet<AttributeValue> values)
  protected void setPendingValues(LinkedHashSet<ByteString> values)
  {
    pendingValues    = values;
    hasPendingValues = true;
@@ -533,8 +533,7 @@
   *                           provided set of values to this configuration
   *                           attribute.
   */
  protected void addValues(List<AttributeValue> values)
         throws ConfigException
  protected void addValues(List<ByteString> values) throws ConfigException
  {
    // If there are no values provided, then do nothing.
    if (values == null)
@@ -564,17 +563,17 @@
    // Create a temporary set of values that we will use for this change.  It
    // may not actually be applied if an error occurs for some reason.
    LinkedHashSet<AttributeValue> tempValues;
    LinkedHashSet<ByteString> tempValues;
    if (requiresAdminAction && hasPendingValues)
    {
      tempValues =
           new LinkedHashSet<AttributeValue>(pendingValues.size() + numValues);
           new LinkedHashSet<ByteString>(pendingValues.size() + numValues);
      tempValues.addAll(pendingValues);
    }
    else
    {
      tempValues =
           new LinkedHashSet<AttributeValue>(activeValues.size() + numValues);
           new LinkedHashSet<ByteString>(activeValues.size() + numValues);
      tempValues.addAll(activeValues);
    }
@@ -582,18 +581,18 @@
    // Iterate through all of the provided values.  Make sure that each is
    // acceptable for use and that it is not already contained in the value set.
    StringBuilder rejectReason = new StringBuilder();
    for (AttributeValue value : values)
    for (ByteString value : values)
    {
      if (tempValues.contains(value))
      {
        throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(
            name, value.getValue()));
            name, value));
      }
      if (! valueIsAcceptable(value, rejectReason))
      {
        throw new ConfigException(ERR_CONFIG_ATTR_REJECTED_VALUE.get(
            value.getValue(), name, rejectReason));
            value, name, rejectReason));
      }
    }
@@ -625,22 +624,20 @@
   *                           value set, or if this is a required attribute and
   *                           the resulting value list would be empty.
   */
  protected void removeValues(List<AttributeValue> values)
  protected void removeValues(List<ByteString> values)
         throws ConfigException
  {
    // Create a temporary set of values that we will use for this change.  It
    // may not actually be applied if an error occurs for some reason.
    LinkedHashSet<AttributeValue> tempValues;
    LinkedHashSet<ByteString> tempValues;
    if (requiresAdminAction && hasPendingValues)
    {
      tempValues =
           new LinkedHashSet<AttributeValue>(pendingValues.size());
      tempValues = new LinkedHashSet<ByteString>(pendingValues.size());
      tempValues.addAll(pendingValues);
    }
    else
    {
      tempValues =
           new LinkedHashSet<AttributeValue>(activeValues.size());
      tempValues = new LinkedHashSet<ByteString>(activeValues.size());
      tempValues.addAll(activeValues);
    }
@@ -648,12 +645,11 @@
    // Iterate through all the provided values and make sure that they are
    // contained in the list.  If not, then throw an exception.  If so, then
    // remove it.
    for (AttributeValue value : values)
    for (ByteString value : values)
    {
      if (! tempValues.remove(value))
      {
        throw new ConfigException(
            ERR_CONFIG_ATTR_NO_SUCH_VALUE.get(name, value.getValue()));
        throw new ConfigException(ERR_CONFIG_ATTR_NO_SUCH_VALUE.get(name, value));
      }
    }
@@ -704,7 +700,7 @@
    {
      if (pendingValues == null)
      {
        pendingValues = new LinkedHashSet<AttributeValue>();
        pendingValues = new LinkedHashSet<ByteString>();
      }
      else
      {
@@ -733,11 +729,11 @@
   * @param  values  The initial set of values to assign to this configuration
   *                 attribute.
   */
  public void setInitialValues(LinkedHashSet<AttributeValue> values)
  public void setInitialValues(LinkedHashSet<ByteString> values)
  {
    if (values == null)
    {
      values = new LinkedHashSet<AttributeValue>();
      values = new LinkedHashSet<ByteString>();
    }
    activeValues     = values;
@@ -782,10 +778,8 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public abstract LinkedHashSet<AttributeValue>
                       stringsToValues(List<String> valueStrings,
                                       boolean allowFailures)
         throws ConfigException;
  public abstract LinkedHashSet<ByteString> stringsToValues(
      List<String> valueStrings, boolean allowFailures) throws ConfigException;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/DNConfigAttribute.java
@@ -404,12 +404,12 @@
      {
        if (requiresAdminAction())
        {
          setPendingValues(new LinkedHashSet<AttributeValue>(0));
          setPendingValues(new LinkedHashSet<ByteString>(0));
          pendingValues = new ArrayList<DN>();
        }
        else
        {
          setActiveValues(new LinkedHashSet<AttributeValue>(0));
          setActiveValues(new LinkedHashSet<ByteString>(0));
          activeValues.clear();
        }
      }
@@ -428,8 +428,7 @@
    // Iterate through all the provided values, make sure that they are
    // acceptable, and build the value set.
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (DN value : values)
    {
      if (value == null)
@@ -438,10 +437,7 @@
        throw new ConfigException(message);
      }
      AttributeValue attrValue =
          AttributeValues.create(ByteString.valueOf(value.toString()),
              ByteString.valueOf(value.toNormalizedString()));
      ByteString attrValue = ByteString.valueOf(value.toString());
      if (valueSet.contains(attrValue))
      {
        LocalizableMessage message =
@@ -476,20 +472,18 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(DN value)
  private static LinkedHashSet<ByteString> getValueSet(DN value)
  {
    LinkedHashSet<AttributeValue> valueSet;
    LinkedHashSet<ByteString> valueSet;
    if (value == null)
    {
      valueSet = new LinkedHashSet<AttributeValue>(0);
      valueSet = new LinkedHashSet<ByteString>(0);
    }
    else
    {
      valueSet = new LinkedHashSet<AttributeValue>(1);
      valueSet.add(AttributeValues.create(ByteString.valueOf(value.toString()),
          ByteString.valueOf(value.toNormalizedString())));
      valueSet = new LinkedHashSet<ByteString>(1);
      valueSet.add(ByteString.valueOf(value.toString()));
    }
    return valueSet;
  }
@@ -502,22 +496,18 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(List<DN> values)
  private static LinkedHashSet<ByteString> getValueSet(List<DN> values)
  {
    if (values == null)
    {
      return null;
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(values.size());
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size());
    for (DN value : values)
    {
      valueSet.add(AttributeValues.create(ByteString.valueOf(value.toString()),
          ByteString.valueOf(value.toNormalizedString())));
      valueSet.add(ByteString.valueOf(value.toString()));
    }
    return valueSet;
  }
@@ -553,8 +543,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
                                   StringBuilder rejectReason)
  public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason)
  {
    // Make sure that the value is not null.
    if (value == null)
@@ -567,18 +556,15 @@
    // Make sure that it can be parsed as a DN.
    try
    {
      DN.valueOf(value.getValue().toString());
      DN.valueOf(value.toString());
    }
    catch (Exception e)
    {
      logger.traceException(e);
      rejectReason.append(ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
              value.getValue(), getName(), e));
      rejectReason.append(ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(value, getName(), e));
      return false;
    }
    return true;
  }
@@ -603,7 +589,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
         throws ConfigException
@@ -617,7 +603,7 @@
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
        return new LinkedHashSet<ByteString>();
      }
    }
@@ -631,8 +617,7 @@
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String valueString : valueStrings)
    {
      if (valueString == null)
@@ -672,8 +657,7 @@
      }
      valueSet.add(AttributeValues.create(ByteString.valueOf(dn.toString()),
          ByteString.valueOf(dn.toNormalizedString())));
      valueSet.add(ByteString.valueOf(dn.toString()));
    }
@@ -816,19 +800,19 @@
            }
            pendingValues = new ArrayList<DN>(numValues);
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              DN dn;
              try
              {
                dn = DN.valueOf(v.getValue().toString());
                dn = DN.valueOf(v.toString());
              }
              catch (Exception e)
              {
                logger.traceException(e);
                LocalizableMessage message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                    v.getValue(), getName(), e);
                    v, getName(), e);
                throw new ConfigException(message, e);
              }
@@ -881,19 +865,19 @@
          }
          activeValues = new ArrayList<DN>(numValues);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            DN dn;
            try
            {
              dn = DN.valueOf(v.getValue().toString());
              dn = DN.valueOf(v.toString());
            }
            catch (Exception e)
            {
              logger.traceException(e);
              LocalizableMessage message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                  v.getValue(), getName(), e);
                  v, getName(), e);
              throw new ConfigException(message, e);
            }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/IntegerConfigAttribute.java
@@ -631,12 +631,12 @@
      {
        if (requiresAdminAction())
        {
          setPendingValues(new LinkedHashSet<AttributeValue>(0));
          setPendingValues(new LinkedHashSet<ByteString>(0));
          pendingValues = new ArrayList<Long>();
        }
        else
        {
          setActiveValues(new LinkedHashSet<AttributeValue>(0));
          setActiveValues(new LinkedHashSet<ByteString>(0));
          activeValues.clear();
        }
      }
@@ -655,8 +655,7 @@
    // Iterate through all the provided values, make sure that they are
    // acceptable, and build the value set.
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (long value : values)
    {
      if (hasLowerBound && (value < lowerBound))
@@ -674,10 +673,7 @@
      }
      String valueString = String.valueOf(value);
      AttributeValue attrValue =
          AttributeValues.create(ByteString.valueOf(valueString),
              ByteString.valueOf(valueString));
      ByteString attrValue = ByteString.valueOf(valueString);
      if (valueSet.contains(attrValue))
      {
        LocalizableMessage message = ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(
@@ -712,15 +708,10 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(long value)
  private static LinkedHashSet<ByteString> getValueSet(long value)
  {
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    String valueString = String.valueOf(value);
    valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
        ByteString.valueOf(valueString)));
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(String.valueOf(value)));
    return valueSet;
  }
@@ -733,23 +724,18 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(List<Long> values)
  private static LinkedHashSet<ByteString> getValueSet(List<Long> values)
  {
    if (values == null)
    {
      return null;
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(values.size());
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size());
    for (long value : values)
    {
      String valueString = String.valueOf(value);
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(String.valueOf(value)));
    }
    return valueSet;
  }
@@ -785,11 +771,10 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
                                   StringBuilder rejectReason)
  public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason)
  {
    // First, make sure we can represent it as a long.
    String stringValue = value.getValue().toString();
    String stringValue = value.toString();
    long longValue;
    try
    {
@@ -846,9 +831,8 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
  {
    if ((valueStrings == null) || valueStrings.isEmpty())
@@ -860,7 +844,7 @@
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
        return new LinkedHashSet<ByteString>();
      }
    }
@@ -874,8 +858,7 @@
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String valueString : valueStrings)
    {
      long longValue;
@@ -933,9 +916,7 @@
        }
      }
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(valueString));
    }
@@ -1079,17 +1060,17 @@
            }
            pendingValues = new ArrayList<Long>(numValues);
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              long longValue;
              try
              {
                longValue = Long.parseLong(v.getValue().toString());
                longValue = Long.parseLong(v.toString());
              }
              catch (Exception e)
              {
                LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get(
                    v.getValue(), a.getName(), e);
                    v, a.getName(), e);
                throw new ConfigException(message, e);
              }
@@ -1161,17 +1142,17 @@
          }
          activeValues = new ArrayList<Long>(numValues);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            long longValue;
            try
            {
              longValue = Long.parseLong(v.getValue().toString());
              longValue = Long.parseLong(v.toString());
            }
            catch (Exception e)
            {
              LocalizableMessage message = ERR_CONFIG_ATTR_INT_COULD_NOT_PARSE.get(
                  v.getValue(), a.getName(), e);
                  v, a.getName(), e);
              throw new ConfigException(message, e);
            }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/IntegerWithUnitConfigAttribute.java
@@ -586,7 +586,7 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(long intValue,
  private static LinkedHashSet<ByteString> getValueSet(long intValue,
                                                           String unit)
  {
    if (unit == null)
@@ -594,13 +594,8 @@
      return null;
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    String valueString = intValue + " " + unit;
    valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
        ByteString.valueOf(valueString)));
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(intValue + " " + unit));
    return valueSet;
  }
@@ -638,12 +633,11 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
    // Get a string representation of the value and convert it to lowercase.
    String lowerValue = value.getValue().toString().toLowerCase();
    String lowerValue = value.toString().toLowerCase();
    return valueIsAcceptable(lowerValue, rejectReason);
  }
@@ -749,7 +743,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
  {
@@ -762,7 +756,7 @@
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
        return new LinkedHashSet<ByteString>();
      }
    }
@@ -776,8 +770,7 @@
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String valueString : valueStrings)
    {
      if ((valueString == null) || (valueString.length() == 0))
@@ -811,9 +804,7 @@
        }
      }
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(valueString));
    }
@@ -933,10 +924,8 @@
          }
          else
          {
            Iterator<AttributeValue> iterator = a.iterator();
            String valueString = iterator.next().getValue().toString();
            Iterator<ByteString> iterator = a.iterator();
            String valueString = iterator.next().toString();
            if (iterator.hasNext())
            {
              // This is illegal -- the attribute is single-valued.
@@ -1017,10 +1006,8 @@
        }
        else
        {
          Iterator<AttributeValue> iterator = a.iterator();
          String valueString = iterator.next().getValue().toString();
          Iterator<ByteString> iterator = a.iterator();
          String valueString = iterator.next().toString();
          if (iterator.hasNext())
          {
            // This is illegal -- the attribute is single-valued.
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/JMXMBean.java
@@ -414,18 +414,18 @@
            continue;
          }
          Iterator<AttributeValue> iterator = a.iterator();
          AttributeValue value = iterator.next();
          Iterator<ByteString> iterator = a.iterator();
          ByteString value = iterator.next();
          if (iterator.hasNext())
          {
            List<String> stringValues = new ArrayList<String>();
            stringValues.add(value.getValue().toString());
            stringValues.add(value.toString());
            while (iterator.hasNext())
            {
              value = iterator.next();
              stringValues.add(value.getValue().toString());
              stringValues.add(value.toString());
            }
            String[] valueArray = new String[stringValues.size()];
@@ -434,7 +434,7 @@
          }
          else
          {
            return new Attribute(name, value.getValue().toString());
            return new Attribute(name, value.toString());
          }
        }
      }
@@ -638,18 +638,18 @@
              continue;
            }
            Iterator<AttributeValue> iterator = a.iterator();
            AttributeValue value = iterator.next();
            Iterator<ByteString> iterator = a.iterator();
            ByteString value = iterator.next();
            if (iterator.hasNext())
            {
              List<String> stringValues = new ArrayList<String>();
              stringValues.add(value.getValue().toString());
              stringValues.add(value.toString());
              while (iterator.hasNext())
              {
                value = iterator.next();
                stringValues.add(value.getValue().toString());
                stringValues.add(value.toString());
              }
              String[] valueArray = new String[stringValues.size()];
@@ -659,7 +659,7 @@
            }
            else
            {
              attrList.add(new Attribute(name, value.getValue().toString()));
              attrList.add(new Attribute(name, value.toString()));
              break monitorLoop;
            }
          }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -461,12 +461,12 @@
      {
        if (requiresAdminAction())
        {
          setPendingValues(new LinkedHashSet<AttributeValue>(0));
          setPendingValues(new LinkedHashSet<ByteString>(0));
          pendingValues = new ArrayList<String>();
        }
        else
        {
          setActiveValues(new LinkedHashSet<AttributeValue>(0));
          setActiveValues(new LinkedHashSet<ByteString>(0));
          activeValues.clear();
        }
      }
@@ -485,8 +485,7 @@
    // Iterate through all the provided values, make sure that they are
    // acceptable, and build the value set.
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String value : values)
    {
      if ((value == null) || (value.length() == 0))
@@ -503,10 +502,7 @@
        throw new ConfigException(message);
      }
      AttributeValue attrValue =
          AttributeValues.create(ByteString.valueOf(value),
              ByteString.valueOf(value));
      ByteString attrValue = ByteString.valueOf(value);
      if (valueSet.contains(attrValue))
      {
        LocalizableMessage message =
@@ -541,14 +537,10 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(String value)
  private static LinkedHashSet<ByteString> getValueSet(String value)
  {
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    valueSet.add(AttributeValues.create(ByteString.valueOf(value),
        ByteString.valueOf(value)));
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(value));
    return valueSet;
  }
@@ -561,22 +553,18 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(List<String> values)
  private static LinkedHashSet<ByteString> getValueSet(List<String> values)
  {
    if (values == null)
    {
      return null;
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(values.size());
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size());
    for (String value : values)
    {
      valueSet.add(AttributeValues.create(ByteString.valueOf(value),
          ByteString.valueOf(value)));
      valueSet.add(ByteString.valueOf(value));
    }
    return valueSet;
  }
@@ -612,13 +600,12 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
    // Make sure that the value is non-empty.
    String stringValue;
    if ((value == null) ||
        ((stringValue = value.getValue().toString()).length() == 0))
    if (value == null || ((stringValue = value.toString()).length() == 0))
    {
      rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName()));
      return false;
@@ -658,9 +645,8 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
  {
    if ((valueStrings == null) || valueStrings.isEmpty())
@@ -670,10 +656,7 @@
        LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
        throw new ConfigException(message);
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
      }
      return new LinkedHashSet<ByteString>();
    }
@@ -686,8 +669,7 @@
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String valueString : valueStrings)
    {
      if ((valueString == null) || (valueString.length() == 0))
@@ -719,8 +701,7 @@
        }
      }
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(valueString));
    }
@@ -773,10 +754,7 @@
    {
      return pendingValues;
    }
    else
    {
      return null;
    }
    return null;
  }
@@ -829,14 +807,10 @@
            if (isRequired())
            {
              // This is illegal -- it must have a value.
              LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
              throw new ConfigException(message);
              throw new ConfigException(ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName()));
            }
            else
            {
              // This is fine.  The pending value set can be empty.
              pendingValues = new ArrayList<String>(0);
            }
            // This is fine. The pending value set can be empty.
            pendingValues = new ArrayList<String>(0);
          }
          else
          {
@@ -850,17 +824,17 @@
            }
            pendingValues = new ArrayList<String>(numValues);
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              String lowerValue = v.getValue().toString().toLowerCase();
              String lowerValue = v.toString().toLowerCase();
              if (! allowedValues.contains(lowerValue))
              {
                // This is illegal -- the value is not allowed.
                throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(
                    v.getValue(), a.getName()));
                    v, a.getName()));
              }
              pendingValues.add(v.getValue().toString());
              pendingValues.add(v.toString());
            }
          }
        }
@@ -893,11 +867,8 @@
            LocalizableMessage message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
            throw new ConfigException(message);
          }
          else
          {
            // This is fine.  The active value set can be empty.
            activeValues = new ArrayList<String>(0);
          }
          // This is fine. The active value set can be empty.
          activeValues = new ArrayList<String>(0);
        }
        else
        {
@@ -911,17 +882,17 @@
          }
          activeValues = new ArrayList<String>(numValues);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            String lowerValue = v.getValue().toString().toLowerCase();
            String lowerValue = v.toString().toLowerCase();
            if (! allowedValues.contains(lowerValue))
            {
              // This is illegal -- the value is not allowed.
              throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(
                  v.getValue(), a.getName()));
                  v, a.getName()));
            }
            activeValues.add(v.getValue().toString());
            activeValues.add(v.toString());
          }
        }
      }
@@ -980,17 +951,11 @@
      return new javax.management.Attribute(name, values);
    }
    else
    else if (!requestedValues.isEmpty())
    {
      if (requestedValues.isEmpty())
      {
        return null;
      }
      else
      {
        return new javax.management.Attribute(name, requestedValues.get(0));
      }
      return new javax.management.Attribute(name, requestedValues.get(0));
    }
    return null;
  }
  /**
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/ReadOnlyConfigAttribute.java
@@ -25,10 +25,9 @@
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.config;
import org.forgerock.i18n.LocalizableMessage;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
@@ -39,9 +38,7 @@
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.AttributeValues;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
@@ -276,14 +273,10 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(String value)
  private static LinkedHashSet<ByteString> getValueSet(String value)
  {
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    valueSet.add(AttributeValues.create(ByteString.valueOf(value),
        ByteString.valueOf(value)));
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(value));
    return valueSet;
  }
@@ -296,23 +289,13 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(List<String> values)
  private static LinkedHashSet<ByteString> getValueSet(List<String> values)
  {
    if (values == null)
    if (values != null)
    {
      return null;
      return toByteStrings(values);
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(values.size());
    for (String value : values)
    {
      valueSet.add(AttributeValues.create(ByteString.valueOf(value),
          ByteString.valueOf(value)));
    }
    return valueSet;
    return null;
  }
@@ -340,8 +323,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
                                   StringBuilder rejectReason)
  public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason)
  {
    rejectReason.append(ERR_CONFIG_ATTR_READ_ONLY.get(getName()));
    return false;
@@ -368,27 +350,24 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
  {
    if ((valueStrings == null) || valueStrings.isEmpty())
    {
      return new LinkedHashSet<AttributeValue>();
      return new LinkedHashSet<ByteString>();
    }
    return toByteStrings(valueStrings);
  }
    int numValues = valueStrings.size();
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    for (String valueString : valueStrings)
  private static LinkedHashSet<ByteString> toByteStrings(List<String> strings)
  {
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(strings.size());
    for (String valueString : strings)
    {
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(valueString));
    }
    return valueSet;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/config/StringConfigAttribute.java
@@ -406,12 +406,12 @@
      {
        if (requiresAdminAction())
        {
          setPendingValues(new LinkedHashSet<AttributeValue>(0));
          setPendingValues(new LinkedHashSet<ByteString>(0));
          pendingValues = new ArrayList<String>();
        }
        else
        {
          setActiveValues(new LinkedHashSet<AttributeValue>(0));
          setActiveValues(new LinkedHashSet<ByteString>(0));
          activeValues.clear();
        }
      }
@@ -430,8 +430,7 @@
    // Iterate through all the provided values, make sure that they are
    // acceptable, and build the value set.
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String value : values)
    {
      if ((value == null) || (value.length() == 0))
@@ -440,10 +439,7 @@
        throw new ConfigException(message);
      }
      AttributeValue attrValue =
          AttributeValues.create(ByteString.valueOf(value),
              ByteString.valueOf(value));
      ByteString attrValue = ByteString.valueOf(value);
      if (valueSet.contains(attrValue))
      {
        LocalizableMessage message =
@@ -478,14 +474,10 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(String value)
  private static LinkedHashSet<ByteString> getValueSet(String value)
  {
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(1);
    valueSet.add(AttributeValues.create(ByteString.valueOf(value),
        ByteString.valueOf(value)));
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(1);
    valueSet.add(ByteString.valueOf(value));
    return valueSet;
  }
@@ -498,22 +490,18 @@
   *
   * @return  The constructed value set.
   */
  private static LinkedHashSet<AttributeValue> getValueSet(List<String> values)
  private static LinkedHashSet<ByteString> getValueSet(List<String> values)
  {
    if (values == null)
    {
      return null;
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(values.size());
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(values.size());
    for (String value : values)
    {
      valueSet.add(AttributeValues.create(ByteString.valueOf(value),
          ByteString.valueOf(value)));
      valueSet.add(ByteString.valueOf(value));
    }
    return valueSet;
  }
@@ -549,17 +537,15 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  public boolean valueIsAcceptable(AttributeValue value,
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
    // The only requirement is that the value is not null or empty.
    if ((value == null) || (value.getValue().toString().length() == 0))
    if (value == null || value.toString().length() == 0)
    {
      rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName()));
      return false;
    }
    return true;
  }
@@ -584,7 +570,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  public LinkedHashSet<AttributeValue>
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings,
                              boolean allowFailures)
         throws ConfigException
@@ -598,7 +584,7 @@
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
        return new LinkedHashSet<ByteString>();
      }
    }
@@ -612,8 +598,7 @@
    }
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    LinkedHashSet<ByteString> valueSet = new LinkedHashSet<ByteString>(numValues);
    for (String valueString : valueStrings)
    {
      if ((valueString == null) || (valueString.length() == 0))
@@ -631,11 +616,9 @@
        }
      }
      valueSet.add(AttributeValues.create(ByteString.valueOf(valueString),
          ByteString.valueOf(valueString)));
      valueSet.add(ByteString.valueOf(valueString));
    }
    // If this method was configured to continue on error, then it is possible
    // that we ended up with an empty list.  Check to see if this is a required
    // attribute and if so deal with it accordingly.
@@ -645,7 +628,6 @@
      throw new ConfigException(message);
    }
    return valueSet;
  }
@@ -762,9 +744,9 @@
            }
            pendingValues = new ArrayList<String>(numValues);
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              pendingValues.add(v.getValue().toString());
              pendingValues.add(v.toString());
            }
          }
        }
@@ -815,9 +797,9 @@
          }
          activeValues = new ArrayList<String>(numValues);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            activeValues.add(v.getValue().toString());
            activeValues.add(v.toString());
          }
        }
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesControl.java
@@ -192,7 +192,7 @@
   *          this matched values control does match the provided attribute
   *          value, or <CODE>false</CODE> if none of the filters match.
   */
  public boolean valueMatches(AttributeType type, AttributeValue value)
  public boolean valueMatches(AttributeType type, ByteString value)
  {
    for (MatchedValuesFilter f : filters)
    {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java
@@ -138,7 +138,7 @@
  private AttributeType attributeType;
  // The processed assertion value for this matched values filter.
  private AttributeValue assertionValue;
  private ByteString assertionValue;
  // Indicates whether the elements of this matched values filter have been
  // fully decoded.
@@ -242,15 +242,14 @@
   */
  public static MatchedValuesFilter createEqualityFilter(
                                         AttributeType attributeType,
                                         AttributeValue assertionValue)
                                         ByteString assertionValue)
  {
    Reject.ifNull(attributeType, assertionValue);
    String rawAttributeType = attributeType.getNameOrOID();
    ByteString rawAssertionValue = assertionValue.getValue();
    MatchedValuesFilter filter =
         new MatchedValuesFilter(EQUALITY_MATCH_TYPE, rawAttributeType,
                                 rawAssertionValue, null, null, null, null);
                                 assertionValue, null, null, null, null);
    filter.attributeType  = attributeType;
    filter.assertionValue = assertionValue;
@@ -341,16 +340,15 @@
   */
  public static MatchedValuesFilter createGreaterOrEqualFilter(
                                         AttributeType attributeType,
                                         AttributeValue assertionValue)
                                         ByteString assertionValue)
  {
    Reject.ifNull(attributeType, assertionValue);
    String          rawAttributeType  = attributeType.getNameOrOID();
    ByteString rawAssertionValue = assertionValue.getValue();
    MatchedValuesFilter filter =
         new MatchedValuesFilter(GREATER_OR_EQUAL_TYPE, rawAttributeType,
                                 rawAssertionValue, null, null, null, null);
                                 assertionValue, null, null, null, null);
    filter.attributeType  = attributeType;
    filter.assertionValue = assertionValue;
@@ -388,16 +386,15 @@
   */
  public static MatchedValuesFilter createLessOrEqualFilter(
                                         AttributeType attributeType,
                                         AttributeValue assertionValue)
                                         ByteString assertionValue)
  {
    Reject.ifNull(attributeType, assertionValue);
    String          rawAttributeType = attributeType.getNameOrOID();
    ByteString rawAssertionValue = assertionValue.getValue();
    MatchedValuesFilter filter =
         new MatchedValuesFilter(LESS_OR_EQUAL_TYPE, rawAttributeType,
                                 rawAssertionValue, null, null, null, null);
                                 assertionValue, null, null, null, null);
    filter.attributeType  = attributeType;
    filter.assertionValue = assertionValue;
@@ -475,15 +472,14 @@
   */
  public static MatchedValuesFilter createApproximateFilter(
                                         AttributeType attributeType,
                                         AttributeValue assertionValue)
                                         ByteString assertionValue)
  {
    Reject.ifNull(attributeType,assertionValue);
    String          rawAttributeType  = attributeType.getNameOrOID();
    ByteString rawAssertionValue = assertionValue.getValue();
    MatchedValuesFilter filter =
         new MatchedValuesFilter(APPROXIMATE_MATCH_TYPE, rawAttributeType,
                                 rawAssertionValue, null, null, null, null);
                                 assertionValue, null, null, null, null);
    filter.attributeType  = attributeType;
    filter.assertionValue = assertionValue;
@@ -526,16 +522,15 @@
  public static MatchedValuesFilter createExtensibleMatchFilter(
                                         AttributeType attributeType,
                                         MatchingRule matchingRule,
                                         AttributeValue assertionValue)
                                         ByteString assertionValue)
  {
    Reject.ifNull(attributeType, matchingRule, assertionValue);
    String rawAttributeType = attributeType.getNameOrOID();
    String matchingRuleID = matchingRule.getOID();
    ByteString rawAssertionValue = assertionValue.getValue();
    MatchedValuesFilter filter =
         new MatchedValuesFilter(EXTENSIBLE_MATCH_TYPE, rawAttributeType,
                                 rawAssertionValue, null, null, null,
                                 assertionValue, null, null, null,
                                 matchingRuleID);
    filter.attributeType  = attributeType;
    filter.assertionValue = assertionValue;
@@ -849,7 +844,6 @@
          String     rawAttributeType  = null;
          String     matchingRuleID    = null;
          ByteString rawAssertionValue;
          if(reader.peekType() == TYPE_MATCHING_RULE_ID)
          {
@@ -860,7 +854,7 @@
          {
             rawAttributeType = reader.readOctetStringAsString();
          }
          rawAssertionValue = reader.readOctetString();
          ByteString rawAssertionValue = reader.readOctetString();
          reader.readEndSequence();
          return new MatchedValuesFilter(type, rawAttributeType,
@@ -958,17 +952,12 @@
   * @return  The assertion value for this matched values filter, or
   *          <CODE>null</CODE> if there is none.
   */
  public AttributeValue getAssertionValue()
  public ByteString getAssertionValue()
  {
    if (assertionValue == null)
    if (assertionValue == null && rawAssertionValue != null)
    {
      if (rawAssertionValue != null)
      {
        assertionValue = AttributeValues.create(
            getAttributeType(), rawAssertionValue);
      }
      assertionValue = rawAssertionValue;
    }
    return assertionValue;
  }
@@ -1286,7 +1275,7 @@
   *          criteria defined in this matched values filter, or
   *          <CODE>false</CODE> if not.
   */
  public boolean valueMatches(AttributeType type, AttributeValue value)
  public boolean valueMatches(AttributeType type, ByteString value)
  {
    fullyDecode();
@@ -1301,7 +1290,7 @@
        {
          try
          {
            final ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value.getValue());
            final ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value);
            final Assertion assertion = equalityMatchingRule.getAssertion(rawAssertionValue);
            return assertion.matches(normValue).toBoolean();
          }
@@ -1322,11 +1311,9 @@
          {
            ArrayList<ByteSequence> normalizedSubAnyBS =
                 new ArrayList<ByteSequence>(normalizedSubAny);
            return substringMatchingRule.valueMatchesSubstring(
                 substringMatchingRule.normalizeAttributeValue(value.getValue()),
                 normalizedSubInitial,
                 normalizedSubAnyBS, normalizedSubFinal);
                 substringMatchingRule.normalizeAttributeValue(value),
                 normalizedSubInitial, normalizedSubAnyBS, normalizedSubFinal);
          }
          catch (Exception e)
          {
@@ -1345,11 +1332,9 @@
        {
          try
          {
            ByteString nv = orderingMatchingRule.normalizeAssertionValue(value.getValue());
            ByteString nv = orderingMatchingRule.normalizeAssertionValue(value);
            return orderingMatchingRule.compareValues(
                         nv,
                         orderingMatchingRule.normalizeAttributeValue(
                         value.getValue())) >= 0;
                nv, orderingMatchingRule.normalizeAttributeValue(value)) >= 0;
          }
          catch (Exception e)
          {
@@ -1368,11 +1353,9 @@
        {
          try
          {
            ByteString nv = orderingMatchingRule.normalizeAssertionValue(value.getValue());
            ByteString nv = orderingMatchingRule.normalizeAssertionValue(value);
            return orderingMatchingRule.compareValues(
                         nv,
                         orderingMatchingRule.normalizeAttributeValue(
                         value.getValue())) <= 0;
                nv, orderingMatchingRule.normalizeAttributeValue(value)) <= 0;
          }
          catch (Exception e)
          {
@@ -1395,8 +1378,8 @@
        {
          try
          {
            Assertion assertion = approximateMatchingRule.getAssertion(assertionValue.getValue());
            ByteString nv = approximateMatchingRule.normalizeAttributeValue(value.getValue());
            Assertion assertion = approximateMatchingRule.getAssertion(assertionValue);
            ByteString nv = approximateMatchingRule.normalizeAttributeValue(value);
            return assertion.matches(nv).toBoolean();
          }
          catch (Exception e)
@@ -1422,9 +1405,8 @@
          try
          {
            ByteString nv1 =
                 matchingRule.normalizeAttributeValue(value.getValue());
            Assertion assertion = matchingRule.getAssertion(assertionValue.getValue());
            ByteString nv1 = matchingRule.normalizeAttributeValue(value);
            Assertion assertion = matchingRule.getAssertion(assertionValue);
            return assertion.matches(nv1) == ConditionResult.TRUE;
          }
          catch (Exception e)
@@ -1442,7 +1424,7 @@
          try
          {
            ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value.getValue());
            ByteString normValue = equalityMatchingRule.normalizeAttributeValue(value);
            return equalityMatchingRule.getAssertion(rawAssertionValue).matches(normValue).toBoolean();
          }
          catch (Exception e)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/ModifyOperationBasis.java
@@ -551,7 +551,7 @@
   * This method always returns null.
   */
  @Override
  public List<AttributeValue> getCurrentPasswords()
  public List<ByteString> getCurrentPasswords()
  {
    return null;
  }
@@ -573,7 +573,7 @@
   * This method always returns null.
   */
  @Override
  public List<AttributeValue> getNewPasswords()
  public List<ByteString> getNewPasswords()
  {
    return null;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/PasswordPolicyState.java
@@ -173,7 +173,7 @@
      {
        if (a.isEmpty()) continue;
        stringValue = a.iterator().next().getValue().toString();
        stringValue = a.iterator().next().toString();
        break ;
      }
    }
@@ -225,22 +225,21 @@
      final MatchingRule rule = attributeType.getEqualityMatchingRule();
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            ByteString normValue = rule.normalizeAttributeValue(v.getValue());
            ByteString normValue = rule.normalizeAttributeValue(v);
            timeValues.add(GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue));
          }
          catch (Exception e)
          {
            logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s",
                v.getValue(), attributeType.getNameOrOID(), userDNString);
                v, attributeType.getNameOrOID(), userDNString);
            LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.
                get(v.getValue(), attributeType.getNameOrOID(), userDNString, e);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                         message, e);
                get(v, attributeType.getNameOrOID(), userDNString, e);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e);
          }
        }
      }
@@ -355,7 +354,7 @@
   * @return The unmodifiable set of values for the password attribute
   *         from the user entry.
   */
  public Set<AttributeValue> getPasswordValues()
  public Set<ByteString> getPasswordValues()
  {
    List<Attribute> attrList = userEntry.getAttribute(passwordPolicy
        .getPasswordAttribute());
@@ -365,9 +364,8 @@
      {
        if (a.isEmpty()) continue;
        Set<AttributeValue> values =
          new LinkedHashSet<AttributeValue>(a.size());
        for (AttributeValue value : a)
        Set<ByteString> values = new LinkedHashSet<ByteString>(a.size());
        for (ByteString value : a)
        {
          values.add(value);
        }
@@ -710,7 +708,7 @@
    // Remove any expired failures from the list.
    if (passwordPolicy.getLockoutFailureExpirationInterval() > 0)
    {
      LinkedHashSet<AttributeValue> valuesToRemove = null;
      LinkedHashSet<ByteString> valuesToRemove = null;
      long expirationTime = currentTime -
           (passwordPolicy.getLockoutFailureExpirationInterval() * 1000L);
@@ -730,11 +728,10 @@
          if (valuesToRemove == null)
          {
            valuesToRemove = new LinkedHashSet<AttributeValue>();
            valuesToRemove = new LinkedHashSet<ByteString>();
          }
          valuesToRemove.add(AttributeValues.create(type,
                                              GeneralizedTimeSyntax.format(l)));
          valuesToRemove.add(ByteString.valueOf(GeneralizedTimeSyntax.format(l)));
        }
      }
@@ -806,9 +803,7 @@
                                  OP_ATTR_PWPOLICY_FAILURE_TIME);
    }
    Attribute addAttr = Attributes.create(type, AttributeValues.create(type,
        GeneralizedTimeSyntax.format(highestFailureTime)));
    Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestFailureTime));
    modifications.add(new Modification(ModificationType.ADD, addAttr, true));
    // Now check to see if there have been sufficient failures to lock the
@@ -856,8 +851,7 @@
    for (Long l : authFailureTimes)
    {
      highestFailureTime = Math.max(l, highestFailureTime);
      builder
          .add(AttributeValues.create(type, GeneralizedTimeSyntax.format(l)));
      builder.add(GeneralizedTimeSyntax.format(l));
    }
    Attribute a = builder.toAttribute();
@@ -974,9 +968,7 @@
                                  OP_ATTR_PWPOLICY_LOCKED_TIME);
    }
    Attribute a = Attributes.create(type, AttributeValues.create(type,
        GeneralizedTimeSyntax.format(failureLockedTime)));
    Attribute a = Attributes.create(type, GeneralizedTimeSyntax.format(failureLockedTime));
    modifications.add(new Modification(ModificationType.REPLACE, a, true));
  }
@@ -1213,8 +1205,7 @@
      {
        if (a.isEmpty()) continue;
        String valueString = a.iterator().next().getValue().toString();
        String valueString = a.iterator().next().toString();
        try
        {
          SimpleDateFormat dateFormat = new SimpleDateFormat(format);
@@ -2306,9 +2297,7 @@
                                  OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME);
    }
    Attribute addAttr = Attributes.create(type, AttributeValues.create(
        type, GeneralizedTimeSyntax.format(highestGraceTime)));
    Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestGraceTime));
    modifications.add(new Modification(ModificationType.ADD, addAttr, true));
  }
@@ -2342,8 +2331,7 @@
    AttributeBuilder builder = new AttributeBuilder(type);
    for (Long l : graceLoginTimes)
    {
      builder
          .add(AttributeValues.create(type, GeneralizedTimeSyntax.format(l)));
      builder.add(GeneralizedTimeSyntax.format(l));
    }
    Attribute a = builder.toAttribute();
@@ -2406,26 +2394,12 @@
    {
      boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax();
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        try
        {
          StringBuilder[] pwComponents;
          if (usesAuthPasswordSyntax)
          {
            pwComponents =
                 AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString());
          }
          else
          {
            String[] userPwComponents =
                 UserPasswordSyntax.decodeUserPassword(v.getValue().toString());
            pwComponents = new StringBuilder[userPwComponents.length];
            for (int i = 0; i < userPwComponents.length; ++i)
            {
              pwComponents[i] = new StringBuilder(userPwComponents[i]);
            }
          }
          StringBuilder[] pwComponents =
              getPwComponents(usesAuthPasswordSyntax, v);
          String schemeName = pwComponents[0].toString();
          PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax)
@@ -2496,26 +2470,12 @@
    {
      boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax();
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        try
        {
          StringBuilder[] pwComponents;
          if (usesAuthPasswordSyntax)
          {
            pwComponents =
                 AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString());
          }
          else
          {
            String[] userPwComponents =
                 UserPasswordSyntax.decodeUserPassword(v.getValue().toString());
            pwComponents = new StringBuilder[userPwComponents.length];
            for (int i = 0; i < userPwComponents.length; ++i)
            {
              pwComponents[i] = new StringBuilder(userPwComponents[i]);
            }
          }
          StringBuilder[] pwComponents =
              getPwComponents(usesAuthPasswordSyntax, v);
          String schemeName = pwComponents[0].toString();
          PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax)
@@ -2569,6 +2529,25 @@
  private StringBuilder[] getPwComponents(boolean usesAuthPasswordSyntax,
      ByteString v) throws DirectoryException
  {
    if (usesAuthPasswordSyntax)
    {
      return AuthPasswordSyntax.decodeAuthPassword(v.toString());
    }
    String[] userPwComponents = UserPasswordSyntax.decodeUserPassword(v.toString());
    StringBuilder[] pwComponents = new StringBuilder[userPwComponents.length];
    for (int i = 0; i < userPwComponents.length; ++i)
    {
      pwComponents[i] = new StringBuilder(userPwComponents[i]);
    }
    return pwComponents;
  }
  /**
   * Indicates whether the provided password value is pre-encoded.
   *
@@ -2706,38 +2685,22 @@
    HashSet<String> existingDefaultSchemes = new HashSet<String>();
    LinkedHashSet<AttributeValue> removedValues =
         new LinkedHashSet<AttributeValue>();
    LinkedHashSet<AttributeValue> updatedValues =
         new LinkedHashSet<AttributeValue>();
    LinkedHashSet<ByteString> removedValues = new LinkedHashSet<ByteString>();
    LinkedHashSet<ByteString> updatedValues = new LinkedHashSet<ByteString>();
    boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax();
    for (Attribute a : attrList)
    {
      Iterator<AttributeValue> iterator = a.iterator();
      Iterator<ByteString> iterator = a.iterator();
      while (iterator.hasNext())
      {
        AttributeValue v = iterator.next();
        ByteString v = iterator.next();
        try
        {
          StringBuilder[] pwComponents;
          if (usesAuthPasswordSyntax)
          {
            pwComponents =
                 AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString());
          }
          else
          {
            String[] userPwComponents =
                 UserPasswordSyntax.decodeUserPassword(v.getValue().toString());
            pwComponents = new StringBuilder[userPwComponents.length];
            for (int i = 0; i < userPwComponents.length; ++i)
            {
              pwComponents[i] = new StringBuilder(userPwComponents[i]);
            }
          }
          StringBuilder[] pwComponents =
              getPwComponents(usesAuthPasswordSyntax, v);
          String schemeName = pwComponents[0].toString();
          PasswordStorageScheme<?> scheme = (usesAuthPasswordSyntax)
@@ -2801,8 +2764,7 @@
      return;
    }
    LinkedHashSet<AttributeValue> addedValues = new
         LinkedHashSet<AttributeValue>();
    LinkedHashSet<ByteString> addedValues = new LinkedHashSet<ByteString>();
    for (PasswordStorageScheme<?> s :
         passwordPolicy.getDefaultPasswordStorageSchemes())
    {
@@ -2814,10 +2776,8 @@
          ByteString encodedPassword = (usesAuthPasswordSyntax)
                                       ? s.encodeAuthPassword(password)
                                       : s.encodePasswordWithScheme(password);
          AttributeValue v =
              AttributeValues.create(type, encodedPassword);
          addedValues.add(v);
          updatedValues.add(v);
          addedValues.add(encodedPassword);
          updatedValues.add(encodedPassword);
        }
        catch (Exception e)
        {
@@ -2921,7 +2881,7 @@
    // Get the attribute containing the history and check to see if any of the
    // values is equal to the provided password.  However, first prune the list
    // by size and duration if necessary.
    TreeMap<Long,AttributeValue> historyMap = getSortedHistoryValues(null);
    TreeMap<Long, ByteString> historyMap = getSortedHistoryValues(null);
    int historyCount = passwordPolicy.getPasswordHistoryCount();
    if ((historyCount > 0) && (historyMap.size() > historyCount))
@@ -2955,7 +2915,7 @@
      }
    }
    for (AttributeValue v : historyMap.values())
    for (ByteString v : historyMap.values())
    {
      if (historyValueMatches(password, v))
      {
@@ -2990,11 +2950,10 @@
   *                      not be properly decoded.  It may be {@code null} if
   *                      this is not needed.
   */
  private TreeMap<Long,AttributeValue> getSortedHistoryValues(List<Attribute>
  private TreeMap<Long,ByteString> getSortedHistoryValues(List<Attribute>
                                                                   removeAttrs)
  {
    TreeMap<Long,AttributeValue> historyMap =
         new TreeMap<Long,AttributeValue>();
    TreeMap<Long, ByteString> historyMap = new TreeMap<Long, ByteString>();
    AttributeType historyType =
         DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true);
    List<Attribute> attrList = userEntry.getAttribute(historyType);
@@ -3002,9 +2961,9 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          String histStr = v.getValue().toString();
          String histStr = v.toString();
          int    hashPos = histStr.indexOf('#');
          if (hashPos <= 0)
          {
@@ -3068,14 +3027,14 @@
   *          or {@code false} if not.
   */
  private boolean historyValueMatches(ByteString password,
                                      AttributeValue historyValue)
                                      ByteString historyValue)
  {
    // According to draft-behera-ldap-password-policy, password history values
    // should be in the format time#syntaxoid#encodedvalue.  In this method,
    // we only care about the syntax OID and encoded password.
    try
    {
      String histStr  = historyValue.getValue().toString();
      String histStr  = historyValue.toString();
      int    hashPos1 = histStr.indexOf('#');
      if (hashPos1 <= 0)
      {
@@ -3203,9 +3162,9 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          addPasswordToHistory(v.getValue().toString());
          addPasswordToHistory(v.toString());
        }
      }
    }
@@ -3239,8 +3198,7 @@
    // Get a sorted list of the existing values to see if there are any that
    // should be removed.
    LinkedList<Attribute> removeAttrs = new LinkedList<Attribute>();
    TreeMap<Long,AttributeValue> historyMap =
         getSortedHistoryValues(removeAttrs);
    TreeMap<Long, ByteString> historyMap = getSortedHistoryValues(removeAttrs);
    // If there is a maximum number of values to retain and we would be over the
@@ -3252,19 +3210,19 @@
    if  ((historyCount > 0) && (historyMap.size() >= historyCount))
    {
      int numToDelete = (historyMap.size() - historyCount) + 1;
      LinkedHashSet<AttributeValue> removeValues =
           new LinkedHashSet<AttributeValue>(numToDelete);
      Iterator<AttributeValue> iterator = historyMap.values().iterator();
      LinkedHashSet<ByteString> removeValues =
           new LinkedHashSet<ByteString>(numToDelete);
      Iterator<ByteString> iterator = historyMap.values().iterator();
      while (iterator.hasNext() && (numToDelete > 0))
      {
        AttributeValue v = iterator.next();
        ByteString v = iterator.next();
        removeValues.add(v);
        iterator.remove();
        numToDelete--;
        if (logger.isTraceEnabled())
        {
          logger.trace("Removing history value %s to preserve the history count.", v.getValue());
          logger.trace("Removing history value %s to preserve the history count.", v);
        }
      }
@@ -3284,20 +3242,19 @@
    {
      long minAgeToKeep = currentTime - (1000L * historyDuration);
      Iterator<Long> iterator = historyMap.keySet().iterator();
      LinkedHashSet<AttributeValue> removeValues =
           new LinkedHashSet<AttributeValue>();
      LinkedHashSet<ByteString> removeValues = new LinkedHashSet<ByteString>();
      while (iterator.hasNext())
      {
        long timestamp = iterator.next();
        if (timestamp < minAgeToKeep)
        {
          AttributeValue v = historyMap.get(timestamp);
          ByteString v = historyMap.get(timestamp);
          removeValues.add(v);
          iterator.remove();
          if (logger.isTraceEnabled())
          {
            logger.trace("Removing history value %s to preserve the history duration.", v.getValue());
            logger.trace("Removing history value %s to preserve the history duration.", v);
          }
        }
        else
@@ -3364,9 +3321,9 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          historyValues.add(v.getValue().toString());
          historyValues.add(v.toString());
        }
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/PluginConfigManager.java
@@ -1011,8 +1011,7 @@
      for (DirectoryServerPlugin p : pluginArray)
      {
        DN dn = p.getPluginEntryDN();
        String lowerName =
            toLowerCase(dn.rdn().getAttributeValue(0).getValue().toString());
        String lowerName = toLowerCase(dn.rdn().getAttributeValue(0).toString());
        if (initialPluginNames.contains(lowerName))
        {
          initialPlugins.put(lowerName, p);
@@ -1031,8 +1030,7 @@
      // Get the name of the provided plugin from its RDN value and put it in
      // the correct category.
      DN dn = plugin.getPluginEntryDN();
      String lowerName =
           toLowerCase(dn.rdn().getAttributeValue(0).getValue().toString());
      String lowerName = toLowerCase(dn.rdn().getAttributeValue(0).toString());
      if (initialPluginNames.contains(lowerName))
      {
        initialPlugins.put(lowerName, plugin);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SchemaConfigManager.java
@@ -35,9 +35,10 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.schema.*;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
@@ -710,13 +711,12 @@
    {
      for (Attribute a : ldapSyntaxList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          LDAPSyntaxDescription syntaxDescription;
          try
          {
            syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(
                    v.getValue(),schema,false);
            syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, schema, false);
            setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null);
            setSchemaFile(syntaxDescription, schemaFile);
          }
@@ -735,8 +735,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get(
                    schemaFile,
                    v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -779,14 +778,13 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the attribute type.
          AttributeType attrType;
          try
          {
            attrType = AttributeTypeSyntax.decodeAttributeType(v.getValue(),
                                                          schema, false);
            attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
            setExtraProperty(attrType, SCHEMA_PROPERTY_FILENAME, null);
            setSchemaFile(attrType, schemaFile);
          }
@@ -804,7 +802,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get(
                    schemaFile, v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -846,14 +844,13 @@
    {
      for (Attribute a : ocList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the objectclass.
          ObjectClass oc;
          try
          {
            oc =
              ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, false);
            oc = ObjectClassSyntax.decodeObjectClass(v, schema, false);
            setExtraProperty(oc, SCHEMA_PROPERTY_FILENAME, null);
            setSchemaFile(oc, schemaFile);
          }
@@ -872,8 +869,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_OC.get(
                    schemaFile,
                    v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -915,13 +911,13 @@
    {
      for (Attribute a : nfList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the name form.
          NameForm nf;
          try
          {
            nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, false);
            nf = NameFormSyntax.decodeNameForm(v, schema, false);
            nf.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME);
            setSchemaFile(nf, schemaFile);
          }
@@ -939,7 +935,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_NAME_FORM.get(
                    schemaFile,  v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile,  v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -981,14 +977,13 @@
    {
      for (Attribute a : dcrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the DIT content rule.
          DITContentRule dcr;
          try
          {
            dcr = DITContentRuleSyntax.decodeDITContentRule(
                v.getValue(), schema, false);
            dcr = DITContentRuleSyntax.decodeDITContentRule(v, schema, false);
            dcr.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME);
            setSchemaFile(dcr, schemaFile);
          }
@@ -1006,7 +1001,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_DCR.get(
                    schemaFile,v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -1058,14 +1053,13 @@
    {
      for (Attribute a : dsrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the DIT content rule.
          DITStructureRule dsr;
          try
          {
            dsr = DITStructureRuleSyntax.decodeDITStructureRule(
                v.getValue(), schema, false);
            dsr = DITStructureRuleSyntax.decodeDITStructureRule(v, schema, false);
            dsr.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME);
            setSchemaFile(dsr, schemaFile);
          }
@@ -1083,7 +1077,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_DSR.get(
                    schemaFile, v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
@@ -1125,14 +1119,13 @@
    {
      for (Attribute a : mruList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          // Parse the matching rule use definition.
          MatchingRuleUse mru;
          try
          {
            mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(
                            v.getValue(), schema, false);
            mru = MatchingRuleUseSyntax.decodeMatchingRuleUse(v, schema, false);
            mru.getExtraProperties().remove(SCHEMA_PROPERTY_FILENAME);
            setSchemaFile(mru, schemaFile);
          }
@@ -1150,8 +1143,7 @@
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_MRU.get(
                    schemaFile,
                    v.getValue() + ":  " + getExceptionMessage(e));
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -717,10 +717,8 @@
           filteredEntry.getObjectClasses().values().iterator();
      while (ocIterator.hasNext())
      {
        String ocName = ocIterator.next();
        AttributeValue v =
            AttributeValues.create(attrType,ocName);
        if (! matchedValuesControl.valueMatches(attrType, v))
        ByteString ocName = ByteString.valueOf(ocIterator.next());
        if (! matchedValuesControl.valueMatches(attrType, ocName))
        {
          ocIterator.remove();
        }
@@ -741,7 +739,7 @@
          // Assume that the attribute will be either empty or contain
          // very few values.
          AttributeBuilder builder = new AttributeBuilder(a, true);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (matchedValuesControl.valueMatches(t, v))
            {
@@ -768,7 +766,7 @@
          // Assume that the attribute will be either empty or contain
          // very few values.
          AttributeBuilder builder = new AttributeBuilder(a, true);
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (matchedValuesControl.valueMatches(t, v))
            {
@@ -1392,10 +1390,10 @@
    case EQUALITY:
      if (filter.getAttributeType().isObjectClass())
      {
        AttributeValue v = filter.getAssertionValue();
        ByteString v = filter.getAssertionValue();
        // FIXME : technically this is not correct since the presence
        // of draft oc would trigger rfc oc visibility and visa versa.
        String stringValueLC = toLowerCase(v.getValue().toString());
        String stringValueLC = toLowerCase(v.toString());
        if (stringValueLC.equals(OC_LDAP_SUBENTRY_LC) ||
            stringValueLC.equals(OC_SUBENTRY))
        {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SubentryPasswordPolicy.java
@@ -256,9 +256,9 @@
      {
        for (Attribute attr : pwdAttrList)
        {
          for (AttributeValue val : attr)
          for (ByteString val : attr)
          {
            DN validatorDN = DN.decode(val.getValue());
            DN validatorDN = DN.decode(val);
            if (DirectoryServer.getPasswordValidator(validatorDN) == null)
            {
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
@@ -386,7 +386,7 @@
    {
      for (Attribute attr : pwdAttrList)
      {
        for (AttributeValue value : attr)
        for (ByteString value : attr)
        {
          return value.toString();
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/crypto/CryptoManagerImpl.java
@@ -503,8 +503,7 @@
  static byte[] getInstanceKeyCertificateFromLocalTruststore()
          throws CryptoManagerException {
    // Construct the key entry DN.
    final AttributeValue distinguishedValue = AttributeValues.create(
            attrKeyID, ConfigConstants.ADS_CERTIFICATE_ALIAS);
    final ByteString distinguishedValue = ByteString.valueOf(ConfigConstants.ADS_CERTIFICATE_ALIAS);
    final DN entryDN = localTruststoreDN.child(
            RDN.create(attrKeyID, distinguishedValue));
    // Construct the search filter.
@@ -644,8 +643,7 @@
    final String instanceKeyID
            = getInstanceKeyID(instanceKeyCertificate);
    // Construct the key entry DN.
    final AttributeValue distinguishedValue =
        AttributeValues.create(attrKeyID, instanceKeyID);
    final ByteString distinguishedValue = ByteString.valueOf(instanceKeyID);
    final DN entryDN = instanceKeysDN.child(
         RDN.create(attrKeyID, distinguishedValue));
    // Construct the search filter.
@@ -675,18 +673,15 @@
        // Add the key ID attribute.
        final Attribute keyIDAttr = Attributes.create(attrKeyID,
            distinguishedValue);
        entry.addAttribute(keyIDAttr, new ArrayList<AttributeValue>(0));
        entry.addAttribute(keyIDAttr, new ArrayList<ByteString>(0));
        // Add the public key certificate attribute.
        AttributeBuilder builder = new AttributeBuilder(
            attrPublicKeyCertificate);
        builder.setOption("binary");
        builder.add(AttributeValues.create(
            attrPublicKeyCertificate,
            ByteString.wrap(instanceKeyCertificate)));
        builder.add(ByteString.wrap(instanceKeyCertificate));
        final Attribute certificateAttr = builder.toAttribute();
        entry.addAttribute(certificateAttr,
                new ArrayList<AttributeValue>(0));
        entry.addAttribute(certificateAttr, new ArrayList<ByteString>(0));
        AddOperation addOperation = icc.processAdd(entry.getName(),
                entry.getObjectClasses(),
@@ -1596,7 +1591,7 @@
      String value)
  {
    ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
    attrList.add(Attributes.create(type, AttributeValues.create(type, value)));
    attrList.add(Attributes.create(type, value));
    attrs.put(type, attrList);
  }
@@ -1678,9 +1673,8 @@
         throws CryptoManagerException
    {
      // Construct the key entry DN.
      AttributeValue distinguishedValue =
           AttributeValues.create(attrKeyID,
               keyEntry.getKeyID().getStringValue());
      ByteString distinguishedValue =
           ByteString.valueOf(keyEntry.getKeyID().getStringValue());
      DN entryDN = secretKeysDN.child(
           RDN.create(attrKeyID, distinguishedValue));
@@ -1730,7 +1724,7 @@
        String symmetricKey = cryptoManager.encodeSymmetricKeyAttribute(
            mapEntry.getKey(), mapEntry.getValue(), keyEntry.getSecretKey());
        builder.add(AttributeValues.create(attrSymmetricKey, symmetricKey));
        builder.add(symmetricKey);
      }
      attrList = new ArrayList<Attribute>(1);
      attrList.add(builder.toAttribute());
@@ -2209,9 +2203,8 @@
         throws CryptoManagerException
    {
      // Construct the key entry DN.
      AttributeValue distinguishedValue =
           AttributeValues.create(attrKeyID,
                              keyEntry.getKeyID().getStringValue());
      ByteString distinguishedValue =
           ByteString.valueOf(keyEntry.getKeyID().getStringValue());
      DN entryDN = secretKeysDN.child(
           RDN.create(attrKeyID, distinguishedValue));
@@ -2258,9 +2251,7 @@
                  mapEntry.getKey(),
                  mapEntry.getValue(),
                  keyEntry.getSecretKey());
        builder.add(
            AttributeValues.create(attrSymmetricKey, symmetricKey));
        builder.add(symmetricKey);
      }
      attrList = new ArrayList<Attribute>(1);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/AttributeValuePasswordValidator.java
@@ -117,10 +117,12 @@
      {
        Attribute substring = Attributes.create(a.getAttributeType(),
            password.substring(i, j));
        for (AttributeValue val : a)
        for (ByteString val : a)
        {
          if (substring.contains(val))
          {
            return true;
          }
        }
      }
    }
@@ -175,8 +177,8 @@
        continue;
      }
      AttributeValue vf = AttributeValues.create(t, password);
      AttributeValue vr = AttributeValues.create(t, reversed);
      ByteString vf = ByteString.valueOf(password);
      ByteString vr = ByteString.valueOf(reversed);
      for (Attribute a : attrList)
      {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/CollectiveAttributeSubentriesVirtualAttributeProvider.java
@@ -26,19 +26,17 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.
        CollectiveAttributeSubentriesVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
/**
@@ -71,51 +69,25 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    Set<AttributeValue> values = null;
    AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType());
    if (!entry.isSubentry() && !entry.isLDAPSubentry())
    {
      List<SubEntry> subentries = DirectoryServer.getSubentryManager()
          .getCollectiveSubentries(entry);
      AttributeType dnAttrType =
              DirectoryServer.getAttributeType("2.5.4.49");
      for (SubEntry subentry : subentries)
      {
        if (subentry.isCollective() ||
            subentry.isInheritedCollective())
        {
          DN subentryDN = subentry.getDN();
          AttributeValue value = AttributeValues.create(
                  dnAttrType, subentryDN.toString());
          if (values == null)
          {
            values = Collections.singleton(value);
          }
          else if (values.size() == 1)
          {
            Set<AttributeValue> tmp = new HashSet<AttributeValue>(2);
            tmp.addAll(values);
            tmp.add(value);
            values = tmp;
          }
          else
          {
            values.add(value);
          }
          builder.add(subentry.getDN().toString());
        }
      }
    }
    if (values != null)
    {
      return Collections.unmodifiableSet(values);
    }
    return Collections.emptySet();
    return builder.toAttribute();
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/DynamicGroup.java
@@ -41,7 +41,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
@@ -148,16 +148,16 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            memberURLs.add(LDAPURL.decode(v.getValue().toString(), true));
            memberURLs.add(LDAPURL.decode(v.toString(), true));
          }
          catch (DirectoryException de)
          {
            logger.traceException(de);
            logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v.getValue(),
            logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v,
                    groupEntry.getName(), de.getMessageObject());
          }
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/EntityTagVirtualAttributeProvider.java
@@ -25,29 +25,28 @@
 */
package org.opends.server.extensions;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.EntityTagVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.ExtensionMessages.*;
/**
 * This class implements a virtual attribute provider which ensures that all
 * entries contain an "entity tag" or "Etag" as defined in section 3.11 of RFC
@@ -107,7 +106,7 @@
   */
  @Override()
  public ConditionResult approximatelyEqualTo(final Entry entry,
      final VirtualAttributeRule rule, final AttributeValue value)
      final VirtualAttributeRule rule, final ByteString value)
  {
    // ETags cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
@@ -130,8 +129,7 @@
   * {@inheritDoc}
   */
  @Override()
  public Set<AttributeValue> getValues(final Entry entry,
      final VirtualAttributeRule rule)
  public Attribute getValues(final Entry entry, final VirtualAttributeRule rule)
  {
    // Save reference to current configuration in case it changes.
    final EntityTagVirtualAttributeCfg cfg = config;
@@ -149,8 +147,7 @@
    }
    final ByteString etag = checksumEntry(cfg, checksummer, entry);
    final AttributeValue value = AttributeValues.create(etag, etag);
    return Collections.singleton(value);
    return Attributes.create(rule.getAttributeType(), etag);
  }
@@ -160,7 +157,7 @@
   */
  @Override()
  public ConditionResult greaterThanOrEqualTo(final Entry entry,
      final VirtualAttributeRule rule, final AttributeValue value)
      final VirtualAttributeRule rule, final ByteString value)
  {
    // ETags cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -240,7 +237,7 @@
   */
  @Override()
  public ConditionResult lessThanOrEqualTo(final Entry entry,
      final VirtualAttributeRule rule, final AttributeValue value)
      final VirtualAttributeRule rule, final ByteString value)
  {
    // ETags cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -318,15 +315,15 @@
      break;
    case 1:
      // Avoid sorting single valued attributes.
      checksumValue(checksummer, attribute.iterator().next().getValue());
      checksumValue(checksummer, attribute.iterator().next());
      break;
    default:
      // Multi-valued attributes need sorting.
      final ByteString[] values = new ByteString[size];
      int i = 0;
      for (final AttributeValue av : attribute)
      for (final ByteString av : attribute)
      {
        values[i++] = av.getValue();
        values[i++] = av;
      }
      Arrays.sort(values);
      for (final ByteString value : values)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProvider.java
@@ -71,14 +71,10 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    String normDNString = entry.getName().toNormalizedString();
    AttributeValue value = AttributeValues.create(
                                  ByteString.valueOf(normDNString),
                                  ByteString.valueOf(normDNString));
    return Collections.singleton(value);
    return Attributes.create(rule.getAttributeType(), normDNString);
  }
  /** {@inheritDoc} */
@@ -91,15 +87,14 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    try
    {
      MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule();
      ByteString dn = ByteString.valueOf(entry.getName().toString());
      ByteString normalizedDN = eqRule.normalizeAttributeValue(dn);
      ByteString normalizedValue = eqRule.normalizeAttributeValue(value.getValue());
      ByteString normalizedValue = eqRule.normalizeAttributeValue(value);
      return normalizedDN.equals(normalizedValue);
    }
    catch (DecodeException e)
@@ -111,18 +106,6 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule,
                             Collection<AttributeValue> values)
  {
    String ndnString = entry.getName().toNormalizedString();
    AttributeValue v = AttributeValues.create(ByteString.valueOf(ndnString),
        ByteString.valueOf(ndnString));
    return values.contains(v);
  }
  /** {@inheritDoc} */
  @Override()
  public ConditionResult matchesSubstring(Entry entry,
                                          VirtualAttributeRule rule,
                                          ByteString subInitial,
@@ -137,7 +120,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -147,7 +130,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -157,7 +140,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
@@ -313,7 +296,7 @@
        {
          try
          {
            dnSet.add(DN.decode(filter.getAssertionValue().getValue()));
            dnSet.add(DN.decode(filter.getAssertionValue()));
          }
          catch (Exception e)
          {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProvider.java
@@ -26,9 +26,7 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.forgerock.i18n.LocalizableMessage;
@@ -40,8 +38,8 @@
import org.opends.server.api.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.Attribute;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.VirtualAttributeRule;
@@ -81,16 +79,12 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    String normDNString = entry.getName().toNormalizedString();
    String uuidString =
         UUID.nameUUIDFromBytes(getBytes(normDNString)).toString();
    AttributeValue value = AttributeValues.create(
         ByteString.valueOf(uuidString),
         ByteString.valueOf(uuidString));
    return Collections.singleton(value);
    return Attributes.create(rule.getAttributeType(), uuidString);
  }
  /** {@inheritDoc} */
@@ -103,8 +97,7 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    MatchingRule matchingRule =
        rule.getAttributeType().getEqualityMatchingRule();
@@ -114,7 +107,7 @@
      String uuidString =
           UUID.nameUUIDFromBytes(getBytes(normalizedDN)).toString();
      ByteString normValue = matchingRule.normalizeAttributeValue(value.getValue());
      ByteString normValue = matchingRule.normalizeAttributeValue(value);
      return uuidString.equals(normValue.toString());
    }
    catch (Exception e)
@@ -140,7 +133,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -150,7 +143,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -160,7 +153,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ExactMatchIdentityMapper.java
@@ -35,6 +35,7 @@
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -179,7 +180,7 @@
    SearchFilter filter;
    if (attributeTypes.length == 1)
    {
      AttributeValue value = AttributeValues.create(attributeTypes[0], id);
      ByteString value = ByteString.valueOf(id);
      filter = SearchFilter.createEqualityFilter(attributeTypes[0], value);
    }
    else
@@ -188,7 +189,7 @@
           new ArrayList<SearchFilter>(attributeTypes.length);
      for (AttributeType t : attributeTypes)
      {
        AttributeValue value = AttributeValues.create(t, id);
        ByteString value = ByteString.valueOf(id);
        filterComps.add(SearchFilter.createEqualityFilter(t, value));
      }
@@ -268,15 +269,7 @@
      }
    }
    if (matchingEntry == null)
    {
      return null;
    }
    else
    {
      return matchingEntry;
    }
    return matchingEntry;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -243,22 +243,8 @@
        {
          try
          {
            byte[] certBytes = clientCertChain[0].getEncoded();
            AttributeValue v =
                AttributeValues.create(
                    certificateAttributeType, ByteString.wrap(certBytes));
            boolean found = false;
            for (Attribute a : certAttrList)
            {
              if (a.contains(v))
              {
                found = true;
                break;
              }
            }
            if (! found)
            ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded());
            if (!find(certAttrList, certBytes))
            {
              bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS);
@@ -286,22 +272,8 @@
        {
          try
          {
            byte[] certBytes = clientCertChain[0].getEncoded();
            AttributeValue v =
                AttributeValues.create(
                    certificateAttributeType, ByteString.wrap(certBytes));
            boolean found = false;
            for (Attribute a : certAttrList)
            {
              if (a.contains(v))
              {
                found = true;
                break;
              }
            }
            if (! found)
            ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded());
            if (!find(certAttrList, certBytes))
            {
              bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS);
@@ -333,6 +305,20 @@
  private boolean find(List<Attribute> certAttrList, ByteString certBytes)
  {
    for (Attribute a : certAttrList)
    {
      if (a.contains(certBytes))
      {
        return true;
      }
    }
    return false;
  }
  /**
   * {@inheritDoc}
   */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/FingerprintCertificateMapper.java
@@ -35,6 +35,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -215,8 +216,7 @@
    // Create the search filter from the fingerprint.
    AttributeValue value =
        AttributeValues.create(fingerprintAttributeType, fingerprintString);
    ByteString value = ByteString.valueOf(fingerprintString);
    SearchFilter filter =
         SearchFilter.createEqualityFilter(fingerprintAttributeType, value);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProvider.java
@@ -26,19 +26,17 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.GoverningStructureRuleVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
@@ -70,19 +68,15 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    DITStructureRule ditRule = getDITStructureRule(entry);
    if(ditRule !=null)
    {
      return Collections.singleton(AttributeValues.create(
                  rule.getAttributeType(),
                  String.valueOf(ditRule.getRuleID())));
      return Attributes.create(
          rule.getAttributeType(), String.valueOf(ditRule.getRuleID()));
    }
    return Collections.<AttributeValue>emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
@@ -108,7 +102,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DITStructureRule cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -118,7 +112,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DITStructureRule cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -128,7 +122,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DITStructureRule cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java
@@ -26,9 +26,7 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -74,8 +72,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    Backend backend = DirectoryServer.getBackend(entry.getName());
@@ -84,10 +81,7 @@
      ConditionResult ret = backend.hasSubordinates(entry.getName());
      if(ret != null && ret != ConditionResult.UNDEFINED)
      {
        AttributeValue value =
            AttributeValues.create(ByteString.valueOf(ret.toString()),
                ByteString.valueOf(ret.toString()));
        return Collections.singleton(value);
        return Attributes.create(rule.getAttributeType(), ret.toString());
      }
    }
    catch(DirectoryException de)
@@ -95,7 +89,7 @@
      logger.traceException(de);
    }
    return Collections.emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
@@ -119,8 +113,7 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    Backend backend = DirectoryServer.getBackend(entry.getName());
    MatchingRule matchingRule =
@@ -128,8 +121,7 @@
    try
    {
      ByteString normValue =
          matchingRule.normalizeAttributeValue(value.getValue());
      ByteString normValue = matchingRule.normalizeAttributeValue(value);
      ConditionResult ret = backend.hasSubordinates(entry.getName());
      return ret != null
          && ret != ConditionResult.UNDEFINED
@@ -158,7 +150,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // This virtual attribute does not support ordering matching.
    return ConditionResult.UNDEFINED;
@@ -168,7 +160,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // This virtual attribute does not support ordering matching.
    return ConditionResult.UNDEFINED;
@@ -178,7 +170,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // This virtual attribute does not support approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProvider.java
@@ -26,7 +26,7 @@
 */
package org.opends.server.extensions;
import java.util.*;
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
@@ -71,34 +71,17 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    // FIXME -- This probably isn't the most efficient implementation.
    Set<AttributeValue> values = null;
    AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType());
    for (Group<?> g : DirectoryServer.getGroupManager().getGroupInstances())
    {
      try
      {
        if (g.isMember(entry))
        {
          AttributeValue value = AttributeValues.create(
              rule.getAttributeType(), g.getGroupDN().toString());
          if (values == null)
          {
            values = Collections.singleton(value);
          }
          else if (values.size() == 1)
          {
            Set<AttributeValue> tmp = new HashSet<AttributeValue>(2);
            tmp.addAll(values);
            tmp.add(value);
            values = tmp;
          }
          else
          {
            values.add(value);
          }
          builder.add(g.getGroupDN().toString());
        }
      }
      catch (Exception e)
@@ -106,12 +89,7 @@
        logger.traceException(e);
      }
    }
    if (values != null)
    {
      return Collections.unmodifiableSet(values);
    }
    return Collections.emptySet();
    return builder.toAttribute();
  }
  /** {@inheritDoc} */
@@ -140,11 +118,11 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
                          ByteString value)
  {
    try
    {
      DN groupDN = DN.decode(value.getValue());
      DN groupDN = DN.decode(value);
      Group<?> g = DirectoryServer.getGroupManager().getGroupInstance(groupDN);
      return g != null && g.isMember(entry);
    }
@@ -158,22 +136,6 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule,
                             Collection<AttributeValue> values)
  {
    for (AttributeValue value : values)
    {
      if (hasValue(entry, rule, value))
      {
        return true;
      }
    }
    return false;
  }
  /** {@inheritDoc} */
  @Override()
  public ConditionResult matchesSubstring(Entry entry,
                                          VirtualAttributeRule rule,
                                          ByteString subInitial,
@@ -188,7 +150,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -198,7 +160,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -208,7 +170,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
@@ -354,7 +316,7 @@
        {
          try
          {
            DN dn = DN.decode(filter.getAssertionValue().getValue());
            DN dn = DN.decode(filter.getAssertionValue());
            return DirectoryServer.getGroupManager().getGroupInstance(dn);
          }
          catch (Exception e)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -61,7 +61,6 @@
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ConfigChangeResult;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.DN;
@@ -1660,7 +1659,7 @@
                {
                  if (!attribute.isEmpty())
                  {
                    username = attribute.iterator().next().getValue();
                    username = attribute.iterator().next();
                    break mapBind;
                  }
                }
@@ -1696,7 +1695,7 @@
              {
                for (final Attribute attribute : attributes)
                {
                  for (final AttributeValue value : attribute)
                  for (final ByteString value : attribute)
                  {
                    filterComponents.add(SearchFilter.createEqualityFilter(at,
                        value));
@@ -1846,12 +1845,11 @@
              {
                MatchingRule rule =
                    attribute.getAttributeType().getEqualityMatchingRule();
                for (AttributeValue value : attribute)
                for (ByteString value : attribute)
                {
                  try
                  {
                    ByteString normValue =
                        rule.normalizeAttributeValue(value.getValue());
                    ByteString normValue = rule.normalizeAttributeValue(value);
                    long cachedPasswordTime = GeneralizedTimeSyntax
                            .decodeGeneralizedTimeValue(normValue);
                    long currentTime = provider.getCurrentTimeMS();
@@ -1898,9 +1896,9 @@
              // Ignore any attributes with options.
              if (!attribute.hasOptions())
              {
                for (AttributeValue value : attribute)
                for (ByteString value : attribute)
                {
                  cachedPassword = value.getValue();
                  cachedPassword = value;
                  break foundCachedPassword;
                }
              }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/MemberVirtualAttributeProvider.java
@@ -26,32 +26,29 @@
 */
package org.opends.server.extensions;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.MemberVirtualAttributeCfg;
import org.opends.server.api.Group;
import org.opends.server.api.VirtualAttributeProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Attributes;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.MemberList;
import org.opends.server.types.MembershipException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.VirtualAttributeRule;
/**
@@ -112,22 +109,21 @@
   * {@inheritDoc}
   */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    if (! currentConfig.isAllowRetrievingMembership())
    {
      return Collections.emptySet();
      return Attributes.empty(rule.getAttributeType());
    }
    Group<?> g =
      DirectoryServer.getGroupManager().getGroupInstance(entry.getName());
    if (g == null)
    {
      return Collections.emptySet();
      return Attributes.empty(rule.getAttributeType());
    }
    HashSet<AttributeValue> values = new HashSet<AttributeValue>();
    AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType());
    try
    {
      MemberList memberList = g.getMembers();
@@ -138,8 +134,7 @@
          DN memberDN = memberList.nextMemberDN();
          if (memberDN != null)
          {
            values.add(AttributeValues.create(rule.getAttributeType(),
                                          memberDN.toString()));
            builder.add(ByteString.valueOf(memberDN.toString()));
          }
        }
        catch (MembershipException me)
@@ -156,7 +151,7 @@
      logger.traceException(e);
    }
    return Collections.unmodifiableSet(values);
    return builder.toAttribute();
  }
@@ -211,8 +206,7 @@
   * {@inheritDoc}
   */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    Group<?> g =
      DirectoryServer.getGroupManager().getGroupInstance(entry.getName());
@@ -223,7 +217,7 @@
    try
    {
      return g.isMember(DN.decode(value.getValue()));
      return g.isMember(DN.decode(value));
    }
    catch (Exception e)
    {
@@ -239,26 +233,6 @@
   * {@inheritDoc}
   */
  @Override()
  public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule,
                             Collection<AttributeValue> values)
  {
    for (AttributeValue v : values)
    {
      if (hasValue(entry, rule, v))
      {
        return true;
      }
    }
    return false;
  }
  /**
   * {@inheritDoc}
   */
  @Override()
  public ConditionResult matchesSubstring(Entry entry,
                                          VirtualAttributeRule rule,
                                          ByteString subInitial,
@@ -277,7 +251,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -291,7 +265,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -305,7 +279,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java
@@ -26,9 +26,7 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -76,8 +74,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    Backend backend = DirectoryServer.getBackend(entry.getName());
@@ -86,10 +83,7 @@
      long count = backend.numSubordinates(entry.getName(), false);
      if(count >= 0)
      {
        AttributeValue value =
            AttributeValues.create(ByteString.valueOf(String.valueOf(count)),
                ByteString.valueOf(String.valueOf(count)));
        return Collections.singleton(value);
        return Attributes.create(rule.getAttributeType(), String.valueOf(count));
      }
    }
    catch(DirectoryException de)
@@ -97,7 +91,7 @@
      logger.traceException(de);
    }
    return Collections.emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
@@ -119,15 +113,14 @@
  /** {@inheritDoc} */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    Backend backend = DirectoryServer.getBackend(entry.getName());
    MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule();
    try
    {
      String nv = eqRule.normalizeAttributeValue(value.getValue()).toString();
      String nv = eqRule.normalizeAttributeValue(value).toString();
      long count = backend.numSubordinates(entry.getName(), false);
      return count >= 0 && Long.parseLong(nv) == count;
    }
@@ -159,7 +152,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // This virtual attribute does not support approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProvider.java
@@ -26,20 +26,17 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
import
  org.opends.server.admin.std.server.PasswordExpirationTimeVirtualAttributeCfg;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.PasswordPolicyState;
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
/**
@@ -71,27 +68,22 @@
  /** {@inheritDoc} */
  @Override
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    // Do not process LDAP operational entries.
    if (!entry.isSubentry() && !entry.isLDAPSubentry())
    {
      long expirationTime = getPasswordExpirationTime(entry);
      if (expirationTime == -1)
      {
        // It does not expire.
        return Collections.emptySet();
        return Attributes.empty(rule.getAttributeType());
      }
      AttributeValue value =
        GeneralizedTimeSyntax.createGeneralizedTimeValue(expirationTime);
      return Collections.singleton(value);
      return Attributes.create(rule.getAttributeType(),
          GeneralizedTimeSyntax.createGeneralizedTimeValue(expirationTime));
    }
    return Collections.emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -812,17 +812,17 @@
      if (oldPassword != null)
      {
        // Remove all existing encoded values that match the old password.
        Set<AttributeValue> existingValues = pwPolicyState.getPasswordValues();
        Set<AttributeValue> deleteValues =
             new LinkedHashSet<AttributeValue>(existingValues.size());
        Set<ByteString> existingValues = pwPolicyState.getPasswordValues();
        Set<ByteString> deleteValues =
             new LinkedHashSet<ByteString>(existingValues.size());
        if (pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax())
        {
          for (AttributeValue v : existingValues)
          for (ByteString v : existingValues)
          {
            try
            {
              StringBuilder[] components =
                 AuthPasswordSyntax.decodeAuthPassword(v.getValue().toString());
                 AuthPasswordSyntax.decodeAuthPassword(v.toString());
              PasswordStorageScheme<?> scheme =
                   DirectoryServer.getAuthPasswordStorageScheme(
                        components[0].toString());
@@ -854,12 +854,12 @@
        }
        else
        {
          for (AttributeValue v : existingValues)
          for (ByteString v : existingValues)
          {
            try
            {
              String[] components =
                 UserPasswordSyntax.decodeUserPassword(v.getValue().toString());
                 UserPasswordSyntax.decodeUserPassword(v.toString());
              PasswordStorageScheme<?> scheme =
                   DirectoryServer.getPasswordStorageScheme(
                        toLowerCase(components[0]));
@@ -896,14 +896,14 @@
        builder = new AttributeBuilder(attrType);
        builder.addAll(toAttributeValues(attrType, encodedPasswords));
        builder.addAll(toAttributeValues(encodedPasswords));
        Attribute addAttr = builder.toAttribute();
        modList.add(new Modification(ModificationType.ADD, addAttr));
      }
      else
      {
        AttributeBuilder builder = new AttributeBuilder(attrType);
        builder.addAll(toAttributeValues(attrType, encodedPasswords));
        builder.addAll(toAttributeValues(encodedPasswords));
        Attribute addAttr = builder.toAttribute();
        modList.add(new Modification(ModificationType.REPLACE, addAttr));
      }
@@ -1050,19 +1050,17 @@
      // Handle Account Status Notifications that may be needed.
      // They are not handled by the backend for internal operations.
      List<AttributeValue> currentPasswords = null;
      List<ByteString> currentPasswords = null;
      if (oldPassword != null)
      {
        currentPasswords = new ArrayList<AttributeValue>(1);
        currentPasswords.add(AttributeValues
                            .create(oldPassword, oldPassword));
        currentPasswords = new ArrayList<ByteString>(1);
        currentPasswords.add(oldPassword);
      }
      List<AttributeValue> newPasswords = null;
      List<ByteString> newPasswords = null;
      if (newPassword != null)
      {
        newPasswords = new ArrayList<AttributeValue>(1);
        newPasswords.add(AttributeValues
                         .create(newPassword, newPassword));
        newPasswords = new ArrayList<ByteString>(1);
        newPasswords.add(newPassword);
      }
      if (selfChange)
      {
@@ -1092,14 +1090,12 @@
    }
  }
  private Collection<AttributeValue> toAttributeValues(AttributeType attrType,
      Collection<ByteString> values)
  private Collection<ByteString> toAttributeValues(Collection<ByteString> values)
  {
    Set<AttributeValue> results =
        new LinkedHashSet<AttributeValue>(values.size());
    Set<ByteString> results = new LinkedHashSet<ByteString>(values.size());
    for (ByteString s : values)
    {
      results.add(AttributeValues.create(attrType, s));
      results.add(s);
    }
    return results;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/PasswordPolicySubentryVirtualAttributeProvider.java
@@ -26,19 +26,15 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.
        PasswordPolicySubentryVirtualAttributeCfg;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
/**
@@ -73,8 +69,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    if (!entry.isSubentry() && !entry.isLDAPSubentry())
    {
@@ -102,12 +97,8 @@
      }
      else if (policy.isPasswordPolicy())
      {
        AttributeType dnAttrType = DirectoryServer
            .getAttributeType("1.3.6.1.4.1.42.2.27.8.1.23");
        DN policyDN = policy.getDN();
        AttributeValue value = AttributeValues.create(dnAttrType,
            policyDN.toString());
        return Collections.singleton(value);
        return Attributes.create(rule.getAttributeType(),
            policy.getDN().toString());
      }
      else
      {
@@ -120,7 +111,7 @@
      }
    }
    return Collections.emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/RegularExpressionIdentityMapper.java
@@ -38,6 +38,7 @@
import java.util.regex.PatternSyntaxException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -200,8 +201,7 @@
    SearchFilter filter;
    if (attributeTypes.length == 1)
    {
      AttributeValue value =
          AttributeValues.create(attributeTypes[0], processedID);
      ByteString value = ByteString.valueOf(processedID);
      filter = SearchFilter.createEqualityFilter(attributeTypes[0], value);
    }
    else
@@ -210,7 +210,7 @@
           new ArrayList<SearchFilter>(attributeTypes.length);
      for (AttributeType t : attributeTypes)
      {
        AttributeValue value = AttributeValues.create(t, processedID);
        ByteString value = ByteString.valueOf(processedID);
        filterComps.add(SearchFilter.createEqualityFilter(t, value));
      }
@@ -290,15 +290,7 @@
      }
    }
    if (matchingEntry == null)
    {
      return null;
    }
    else
    {
      return matchingEntry;
    }
    return matchingEntry;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
@@ -53,7 +53,7 @@
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
@@ -541,15 +541,15 @@
        {
          for (Attribute a : attrList)
          {
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              if (logger.isTraceEnabled())
              {
                logger.trace("Adding end user recipient %s from attr %s",
                    v.getValue(), a.getNameWithOptions());
                    v, a.getNameWithOptions());
              }
              recipients.add(v.getValue().toString());
              recipients.add(v.toString());
            }
          }
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/StaticGroup.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -52,7 +50,6 @@
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.Attributes;
import org.opends.server.types.Control;
import org.opends.server.types.DirectoryConfig;
@@ -71,8 +68,6 @@
import static org.opends.server.util.ServerConstants.*;
import static org.forgerock.util.Reject.*;
/**
 * This class provides a static group implementation, in which the DNs
 * of all members are explicitly listed.  There are three variants of
@@ -237,25 +232,23 @@
    {
      for (Attribute a : memberAttrList)
      {
        MatchingRule eqRule =
            a.getAttributeType().getEqualityMatchingRule();
        for (AttributeValue v : a)
        MatchingRule eqRule = a.getAttributeType().getEqualityMatchingRule();
        for (ByteString v : a)
        {
          try
          {
            someMemberDNs.add(eqRule.normalizeAttributeValue(v.getValue()));
            someMemberDNs.add(eqRule.normalizeAttributeValue(v));
          }
          catch (DecodeException de)
          {
            logger.traceException(de);
            logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v.getValue(),
            logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v,
                someMemberAttributeType.getNameOrOID(), groupEntry.getName(), de.getMessageObject());
          }
        }
      }
    }
    return new StaticGroup(groupEntry.getName(),
            someMemberAttributeType, someMemberDNs);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProvider.java
@@ -26,18 +26,19 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.StructuralObjectClassVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.VirtualAttributeRule;
import static org.opends.messages.ExtensionMessages.*;
@@ -69,13 +70,10 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    AttributeValue value =
        AttributeValues.create(rule.getAttributeType(),
        entry.getStructuralObjectClass().getNameOrOID());
    return Collections.singleton(value);
    return Attributes.create(rule.getAttributeType(), entry
        .getStructuralObjectClass().getNameOrOID());
  }
  /** {@inheritDoc} */
@@ -102,7 +100,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // An object class can not be used for ordering.
    return ConditionResult.UNDEFINED;
@@ -112,7 +110,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // An object class can not be used for ordering.
    return ConditionResult.UNDEFINED;
@@ -122,7 +120,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // An object class can not be used in approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java
@@ -37,7 +37,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CertificateMapperCfg;
@@ -49,7 +51,6 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
@@ -182,10 +183,8 @@
    // filter.
    X500Principal peerPrincipal = peerCertificate.getSubjectX500Principal();
    String peerName = peerPrincipal.getName(X500Principal.RFC2253);
    AttributeValue value =
        AttributeValues.create(subjectAttributeType, peerName);
    SearchFilter filter =
         SearchFilter.createEqualityFilter(subjectAttributeType, value);
    SearchFilter filter = SearchFilter.createEqualityFilter(
        subjectAttributeType, ByteString.valueOf(peerName));
    // If we have an explicit set of base DNs, then use it.  Otherwise, use the
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProvider.java
@@ -26,19 +26,17 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.SubschemaSubentryVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ExtensionMessages.*;
@@ -70,18 +68,14 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    DN schemaDN = DirectoryServer.getSchemaDN();
    if (schemaDN == null)
    {
      return Collections.emptySet();
      return Attributes.empty(rule.getAttributeType());
    }
    AttributeValue value =
        AttributeValues.create(rule.getAttributeType(),
        schemaDN.toString());
    return Collections.singleton(value);
    return Attributes.create(rule.getAttributeType(), schemaDN.toString());
  }
  /** {@inheritDoc} */
@@ -100,7 +94,7 @@
  @Override()
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -110,7 +104,7 @@
  @Override()
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in ordering matching.
    return ConditionResult.UNDEFINED;
@@ -120,7 +114,7 @@
  @Override()
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              AttributeValue value)
                              ByteString value)
  {
    // DNs cannot be used in approximate matching.
    return ConditionResult.UNDEFINED;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java
@@ -34,7 +34,7 @@
import org.opends.server.types.AccountStatusNotification;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
@@ -78,9 +78,9 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          buffer.append(v.getValue().toString());
          buffer.append(v.toString());
          return;
        }
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/UserDefinedVirtualAttributeProvider.java
@@ -25,23 +25,18 @@
 *      Portions Copyright 2012-2014 ForgeRock AS
 */
package org.opends.server.extensions;
import org.forgerock.i18n.LocalizableMessage;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
/**
 * This class implements a virtual attribute provider that allows administrators
@@ -103,14 +98,11 @@
  @Override()
  public boolean isMultiValued()
  {
    if (currentConfig == null)
    if (currentConfig != null)
    {
      return true;
      return currentConfig.getValue().size() > 1;
    }
    else
    {
      return (currentConfig.getValue().size() > 1);
    }
    return true;
  }
@@ -119,28 +111,23 @@
   * {@inheritDoc}
   */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    AttributeType attributeType = rule.getAttributeType();
    Set<String> userDefinedValues = currentConfig.getValue();
    switch (userDefinedValues.size()) {
    case 0:
      return Collections.emptySet();
      return Attributes.empty(rule.getAttributeType());
    case 1:
      String valueString = userDefinedValues.iterator().next();
      AttributeValue value =
          AttributeValues.create(attributeType, valueString);
      return Collections.singleton(value);
      return Attributes.create(rule.getAttributeType(), valueString);
    default:
      HashSet<AttributeValue> values =
          new HashSet<AttributeValue>(userDefinedValues.size());
      for (String valueString2 : userDefinedValues)
      AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType());
      for (String valueStr : userDefinedValues)
      {
        values.add(AttributeValues.create(attributeType, valueString2));
        builder.add(valueStr);
      }
      return Collections.unmodifiableSet(values);
      return builder.toAttribute();
    }
  }
@@ -176,6 +163,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      UserDefinedVirtualAttributeCfg configuration,
                      List<LocalizableMessage> unacceptableReasons)
@@ -189,6 +177,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
                                 UserDefinedVirtualAttributeCfg configuration)
  {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/extensions/VirtualStaticGroup.java
@@ -40,7 +40,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -142,7 +142,7 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          if (targetDN != null)
          {
@@ -152,14 +152,14 @@
          try
          {
            targetDN = DN.decode(v.getValue());
            targetDN = DN.decode(v);
          }
          catch (DirectoryException de)
          {
            logger.traceException(de);
            LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET.
                get(v.getValue(), groupEntry.getName(), de.getMessageObject());
                get(v, groupEntry.getName(), de.getMessageObject());
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                         message, de);
          }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.loggers;
import static org.opends.messages.ConfigMessages.*;
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.opends.server.util.ServerConstants.*;
@@ -44,14 +42,13 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.*;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.Base64;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.TimeThread;
/**
 * This class provides the implementation of the audit logger used by
 * the directory server.
@@ -323,13 +320,7 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        {
          buffer.append(a.getName());
          buffer.append(":");
          encodeValue(v.getValue(), buffer);
          buffer.append(EOL);
        }
        append(buffer, a);
      }
    }
@@ -338,13 +329,7 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        {
          buffer.append(a.getName());
          buffer.append(":");
          encodeValue(v.getValue(), buffer);
          buffer.append(EOL);
        }
        append(buffer, a);
      }
    }
@@ -484,13 +469,7 @@
      buffer.append(a.getName());
      buffer.append(EOL);
      for (AttributeValue v : a)
      {
        buffer.append(a.getName());
        buffer.append(":");
        encodeValue(v.getValue(), buffer);
        buffer.append(EOL);
      }
      append(buffer, a);
    }
    writer.writeRecord(buffer.toString());
@@ -498,6 +477,19 @@
  private void append(StringBuilder buffer, Attribute a)
  {
    for (ByteString v : a)
    {
      buffer.append(a.getName());
      buffer.append(":");
      encodeValue(v, buffer);
      buffer.append(EOL);
    }
  }
  // Appends the common log header information to the provided buffer.
  private void appendHeader(Operation operation, StringBuilder buffer)
  {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/BackendMonitor.java
@@ -157,7 +157,7 @@
    DN[] baseDNs = backend.getBaseDNs();
    for (DN dn : baseDNs)
    {
      builder.add(AttributeValues.create(baseDNType, dn.toString()));
      builder.add(dn.toString());
    }
    attrs.add(builder.toAttribute());
@@ -182,8 +182,7 @@
        {
          logger.traceException(ex);
        }
        String s = entryCount + " " + dn.toString();
        builder.add(AttributeValues.create(baseDNEntryCountType, s));
        builder.add(entryCount + " " + dn.toString());
      }
    }
    else
@@ -191,8 +190,7 @@
      // This is done to avoid recalculating the number of entries
      // using the numSubordinates method in the case where the
      // backend has a single base DN.
      String s = backendCount + " " + baseDNs[0].toString();
      builder.add(AttributeValues.create(baseDNEntryCountType, s));
      builder.add(backendCount + " " + baseDNs[0].toString());
    }
    attrs.add(builder.toAttribute());
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/ClientConnectionMonitorProvider.java
@@ -41,7 +41,6 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.InitializationException;
@@ -169,8 +168,7 @@
    AttributeBuilder builder = new AttributeBuilder(attrType);
    for (ClientConnection conn : connMap.values())
    {
      builder.add(AttributeValues.create(attrType, conn
          .getMonitorSummary()));
      builder.add(conn.getMonitorSummary());
    }
    ArrayList<Attribute> attrs = new ArrayList<Attribute>(1);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/ConnectionHandlerMonitor.java
@@ -22,11 +22,10 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.monitors;
import static org.opends.server.util.ServerConstants.*;
import java.util.LinkedList;
@@ -39,7 +38,6 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.types.*;
/**
 * This class implements a monitor provider that will report generic information
 * for an enabled Directory Server connection handler, including its protocol,
@@ -167,7 +165,7 @@
      AttributeBuilder builder = new AttributeBuilder(listenerType);
      for (HostPort hp : listeners)
      {
        builder.add(AttributeValues.create(listenerType, hp.toString()));
        builder.add(hp.toString());
      }
      attrs.add(builder.toAttribute());
    }
@@ -178,8 +176,7 @@
      for (ClientConnection c : conns)
      {
        numConnections++;
        builder.add(AttributeValues.create(connectionsType, c
            .getMonitorSummary()));
        builder.add(c.getMonitorSummary());
      }
      attrs.add(builder.toAttribute());
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/MemoryUsageMonitorProvider.java
@@ -223,11 +223,7 @@
  private Attribute createAttribute(String name, String value)
  {
    AttributeType attrType = DirectoryServer.getDefaultAttributeType(name);
    AttributeBuilder builder = new AttributeBuilder(attrType);
    builder.add(AttributeValues.create(attrType, value));
    return builder.toAttribute();
    return Attributes.create(attrType, value);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/StackTraceMonitorProvider.java
@@ -111,7 +111,7 @@
      buffer.append(" ---------- ");
      buffer.append(t.getName());
      buffer.append(" ----------");
      builder.add(AttributeValues.create(attrType, buffer.toString()));
      builder.add(buffer.toString());
      // Create an attribute for the stack trace.
      if (stackElements != null)
@@ -141,7 +141,7 @@
          }
          buffer.append(")");
          builder.add(AttributeValues.create(attrType, buffer.toString()));
          builder.add(buffer.toString());
        }
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/SystemInfoMonitorProvider.java
@@ -240,12 +240,7 @@
  private Attribute createAttribute(String name, String value)
  {
    AttributeType attrType = DirectoryServer.getDefaultAttributeType(name);
    AttributeBuilder builder = new AttributeBuilder(attrType);
    builder.add(AttributeValues.create(attrType, value));
    return builder.toAttribute();
    return Attributes.create(attrType, value);
  }
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/monitors/VersionMonitorProvider.java
@@ -223,12 +223,7 @@
  private Attribute createAttribute(String name, String value)
  {
    AttributeType attrType = DirectoryServer.getDefaultAttributeType(name);
    AttributeBuilder builder = new AttributeBuilder(attrType);
    builder.add(AttributeValues.create(attrType, value));
    return builder.toAttribute();
    return Attributes.create(attrType, value);
  }
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -34,7 +34,6 @@
import java.util.UUID;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
@@ -175,9 +174,7 @@
    byte[] dnBytes = getBytes(entry.getName().toNormalizedString());
    UUID uuid = UUID.nameUUIDFromBytes(dnBytes);
    Attribute uuidAttr = Attributes.create(entryUUIDType,
        AttributeValues.create(entryUUIDType,
            ByteString.valueOf(uuid.toString())));
    Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString());
    uuidList = new ArrayList<Attribute>(1);
    uuidList.add(uuidAttr);
    entry.putAttribute(entryUUIDType, uuidList);
@@ -210,8 +207,7 @@
    // Construct a new random UUID.
    UUID uuid = UUID.randomUUID();
    Attribute uuidAttr = Attributes.create(entryUUIDType,
        AttributeValues.create(entryUUIDType,uuid.toString()));
    Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString());
    uuidList = new ArrayList<Attribute>(1);
    uuidList.add(uuidAttr);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/LastModPlugin.java
@@ -166,13 +166,11 @@
    {
      // This must mean that the operation was performed anonymously.
      // Even so, we still need to update the creatorsName attribute.
      builder.add(AttributeValues.create(creatorsNameType,
          ByteString.empty()));
      builder.add(ByteString.empty());
    }
    else
    {
      builder.add(AttributeValues.create(creatorsNameType,
          ByteString.valueOf(creatorDN.toString())));
      builder.add(creatorDN.toString());
    }
    Attribute nameAttr = builder.toAttribute();
    ArrayList<Attribute> nameList = new ArrayList<Attribute>(1);
@@ -182,9 +180,7 @@
    //  Create the attribute list for the createTimestamp attribute.
    Attribute timeAttr = Attributes.create(createTimestampType,
        OP_ATTR_CREATE_TIMESTAMP,
        AttributeValues.create(createTimestampType,
            ByteString.valueOf(getGMTTime())));
        OP_ATTR_CREATE_TIMESTAMP, getGMTTime());
    ArrayList<Attribute> timeList = new ArrayList<Attribute>(1);
    timeList.add(timeAttr);
    addOperation.setAttribute(createTimestampType, timeList);
@@ -211,13 +207,11 @@
    {
      // This must mean that the operation was performed anonymously.
      // Even so, we still need to update the modifiersName attribute.
      builder.add(AttributeValues.create(modifiersNameType,
          ByteString.empty()));
      builder.add(ByteString.empty());
    }
    else
    {
      builder.add(AttributeValues.create(modifiersNameType,
          ByteString.valueOf(modifierDN.toString())));
      builder.add(modifierDN.toString());
    }
    Attribute nameAttr = builder.toAttribute();
    try
@@ -237,9 +231,7 @@
    //  Create the modifyTimestamp attribute.
    Attribute timeAttr = Attributes.create(modifyTimestampType,
        OP_ATTR_MODIFY_TIMESTAMP,
        AttributeValues.create(modifyTimestampType,
            ByteString.valueOf(getGMTTime())));
        OP_ATTR_MODIFY_TIMESTAMP, getGMTTime());
    try
    {
      modifyOperation.addModification(new Modification(ModificationType.REPLACE,
@@ -276,13 +268,11 @@
    {
      // This must mean that the operation was performed anonymously.
      // Even so, we still need to update the modifiersName attribute.
      builder.add(AttributeValues.create(modifiersNameType,
          ByteString.empty()));
      builder.add(ByteString.empty());
    }
    else
    {
      builder.add(AttributeValues.create(modifiersNameType,
          ByteString.valueOf(modifierDN.toString())));
      builder.add(modifierDN.toString());
    }
    Attribute nameAttr = builder.toAttribute();
    modifyDNOperation.addModification(new Modification(
@@ -291,9 +281,7 @@
    // Create the modifyTimestamp attribute.
    Attribute timeAttr = Attributes.create(modifyTimestampType,
        OP_ATTR_MODIFY_TIMESTAMP,
        AttributeValues.create(modifyTimestampType,
            ByteString.valueOf(getGMTTime())));
        OP_ATTR_MODIFY_TIMESTAMP, getGMTTime());
    modifyDNOperation.addModification(new Modification(
        ModificationType.REPLACE, timeAttr, true));
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -344,11 +344,11 @@
policyLoop:
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            policyDN = DN.decode(v.getValue());
            policyDN = DN.decode(v);
            AuthenticationPolicy authPolicy = DirectoryServer
                .getAuthenticationPolicy(policyDN);
            if (authPolicy == null)
@@ -386,10 +386,8 @@
            AttributeBuilder builder = new AttributeBuilder(a, true);
            boolean gotError = false;
            for (AttributeValue v : a)
            for (ByteString value : a)
            {
              ByteString value = v.getValue();
              if (policy.isAuthPasswordSyntax())
              {
                if (!AuthPasswordSyntax.isEncoded(value))
@@ -398,9 +396,7 @@
                  {
                    for (PasswordStorageScheme<?> s : schemes)
                    {
                      ByteString nv = s.encodeAuthPassword(value);
                      builder.add(AttributeValues.create(policy
                          .getPasswordAttribute(), nv));
                      builder.add(s.encodeAuthPassword(value));
                    }
                  }
                  catch (Exception e)
@@ -416,7 +412,7 @@
                }
                else
                {
                  builder.add(v);
                  builder.add(value);
                }
              }
              else
@@ -427,9 +423,7 @@
                  {
                    for (PasswordStorageScheme<?> s : schemes)
                    {
                      ByteString nv = s.encodePasswordWithScheme(value);
                      builder.add(AttributeValues.create(policy
                          .getPasswordAttribute(), nv));
                      builder.add(s.encodePasswordWithScheme(value));
                    }
                  }
                  catch (Exception e)
@@ -445,7 +439,7 @@
                }
                else
                {
                  builder.add(v);
                  builder.add(value);
                }
              }
            }
@@ -478,17 +472,15 @@
        AttributeBuilder builder = new AttributeBuilder(a, true);
        boolean gotError = false;
        for (AttributeValue v : a)
        for (ByteString value : a)
        {
          ByteString value = v.getValue();
          if (!AuthPasswordSyntax.isEncoded(value))
          {
            try
            {
              for (PasswordStorageScheme<?> s : defaultAuthPasswordSchemes)
              {
                ByteString nv = s.encodeAuthPassword(value);
                builder.add(AttributeValues.create(t, nv));
                builder.add(s.encodeAuthPassword(value));
              }
            }
            catch (Exception e)
@@ -502,7 +494,7 @@
          }
          else
          {
            builder.add(v);
            builder.add(value);
          }
        }
@@ -530,17 +522,15 @@
        AttributeBuilder builder = new AttributeBuilder(a, true);
        boolean gotError = false;
        for (AttributeValue v : a)
        for (ByteString value : a)
        {
          ByteString value = v.getValue();
          if (!UserPasswordSyntax.isEncoded(value))
          {
            try
            {
              for (PasswordStorageScheme<?> s : defaultUserPasswordSchemes)
              {
                ByteString nv = s.encodePasswordWithScheme(value);
                builder.add(AttributeValues.create(t, nv));
                builder.add(s.encodePasswordWithScheme(value));
              }
            }
            catch (Exception e)
@@ -554,7 +544,7 @@
          }
          else
          {
            builder.add(v);
            builder.add(value);
          }
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -45,6 +45,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
@@ -695,7 +696,7 @@
    for(AttributeType attributeType : attributeTypes)
    {
      componentFilters.add(SearchFilter.createEqualityFilter(attributeType,
          AttributeValues.create(attributeType, oldEntryDN.toString())));
          ByteString.valueOf(oldEntryDN.toString())));
    }
    InternalClientConnection conn =
@@ -784,15 +785,13 @@
    {
      if(e.hasAttribute(type))
      {
        AttributeValue value = AttributeValues
            .create(type, oldEntryDN.toString());
        ByteString value = ByteString.valueOf(oldEntryDN.toString());
        if (e.hasValue(type, null, value))
        {
          mods.add(new Modification(ModificationType.DELETE, Attributes
              .create(type, value)));
          // If the new entry DN exists, create an ADD modification for
          // it.
          // If the new entry DN exists, create an ADD modification for it.
          if(newEntryDN != null)
          {
            mods.add(new Modification(ModificationType.ADD, Attributes
@@ -1240,10 +1239,9 @@
    final MatchingRule rule = attr.getAttributeType().getEqualityMatchingRule();
    try
    {
      for (AttributeValue attrVal : attr)
      for (ByteString attrVal : attr)
      {
        DN valueEntryDN =
            DN.decode(rule.normalizeAttributeValue(attrVal.getValue()));
        DN valueEntryDN = DN.decode(rule.normalizeAttributeValue(attrVal));
        final Entry valueEntry;
        if (currentConfiguration.getCheckReferencesScopeCriteria()
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/SambaPasswordPlugin.java
@@ -808,7 +808,7 @@
     * the getNewPasswords() method. If they are encoded the method would return
     * null. The list of passwords should not be modified.
     */
    final List<AttributeValue> passwords = modifyOperation.getNewPasswords();
    final List<ByteString> passwords = modifyOperation.getNewPasswords();
    /*
     * If the password list is not empty, we can be sure the current operation
@@ -1039,7 +1039,7 @@
   */
  private void processModification(
      final PreOperationModifyOperation modifyOperation,
      final List<AttributeValue> passwords)
      final List<ByteString> passwords)
  {
    // Get the last password (in case there is more then one).
    final String password = passwords.get(passwords.size() - 1).toString();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.plugins;
import java.util.List;
import java.util.Set;
@@ -36,7 +34,9 @@
import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.SevenBitCleanPluginCfg;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.*;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
@@ -49,8 +49,6 @@
import static org.opends.messages.PluginMessages.*;
/**
 * This class implements a Directory Server plugin that can be used to ensure
 * that the values for a specified set of attributes (optionally, below a
@@ -172,9 +170,9 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (! is7BitClean(v.getValue()))
            if (!is7BitClean(v))
            {
              LocalizableMessage rejectMessage =
                   ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(
@@ -239,9 +237,9 @@
          continue;
        }
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          if (! is7BitClean(v.getValue()))
          if (!is7BitClean(v))
          {
            return PluginResult.PreParse.stopProcessing(
                ResultCode.CONSTRAINT_VIOLATION,
@@ -317,9 +315,9 @@
          continue;
        }
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          if (! is7BitClean(v.getValue()))
          if (!is7BitClean(v))
          {
            return PluginResult.PreParse.stopProcessing(
                ResultCode.CONSTRAINT_VIOLATION,
@@ -384,7 +382,7 @@
          continue;
        }
        if (! is7BitClean(newRDN.getAttributeValue(i).getValue()))
        if (!is7BitClean(newRDN.getAttributeValue(i)))
        {
          return PluginResult.PreParse.stopProcessing(
              ResultCode.CONSTRAINT_VIOLATION,
@@ -474,6 +472,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      SevenBitCleanPluginCfg configuration,
                      List<LocalizableMessage> unacceptableReasons)
@@ -507,6 +506,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
                                 SevenBitCleanPluginCfg configuration)
  {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/plugins/UniqueAttributePlugin.java
@@ -31,7 +31,10 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
@@ -42,13 +45,11 @@
import org.opends.server.api.plugin.*;
import org.opends.server.api.plugin.PluginResult.PostOperation;
import org.opends.server.api.plugin.PluginResult.PreOperation;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.operation.*;
import static org.opends.messages.PluginMessages.*;
@@ -97,7 +98,7 @@
   * The data structure to store the mapping between the attribute value and the
   * corresponding dn.
   */
  private ConcurrentHashMap<AttributeValue,DN> uniqueAttrValue2Dn;
  private ConcurrentHashMap<ByteString,DN> uniqueAttrValue2Dn;
@@ -152,7 +153,7 @@
      }
    }
    uniqueAttrValue2Dn  = new ConcurrentHashMap<AttributeValue,DN>();
    uniqueAttrValue2Dn  = new ConcurrentHashMap<ByteString,DN>();
    DirectoryServer.registerAlertGenerator(this);
  }
@@ -188,7 +189,7 @@
    }
    DN entryDN = entry.getName();
    List<AttributeValue> recordedValues = new LinkedList<AttributeValue>();
    List<ByteString> recordedValues = new LinkedList<ByteString>();
    for (AttributeType t : config.getType())
    {
      List<Attribute> attrList = entry.getAttribute(t);
@@ -196,7 +197,7 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            PreOperation stop =
                checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
@@ -231,7 +232,7 @@
      return PluginResult.PreOperation.continueOperationProcessing();
    }
    List<AttributeValue> recordedValues = new LinkedList<AttributeValue>();
    List<ByteString> recordedValues = new LinkedList<ByteString>();
    for (Modification m : modifyOperation.getModifications())
    {
      Attribute a = m.getAttribute();
@@ -246,7 +247,7 @@
      {
        case ADD:
        case REPLACE:
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            PreOperation stop =
              checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
@@ -272,7 +273,7 @@
                continue;
              }
              for (AttributeValue v : updatedAttr)
              for (ByteString v : updatedAttr)
              {
                PreOperation stop = checkUniqueness(
                    entryDN, t, v, baseDNs, recordedValues, config);
@@ -298,7 +299,7 @@
  private PreOperation checkUniqueness(DN entryDN, AttributeType t,
      AttributeValue v, Set<DN> baseDNs, List<AttributeValue> recordedValues,
      ByteString v, Set<DN> baseDNs, List<ByteString> recordedValues,
      UniqueAttributePluginCfg config)
  {
    try
@@ -318,12 +319,12 @@
        // Before returning, we need to remove all values added
        // in the uniqueAttrValue2Dn map, because PostOperation
        // plugin does not get called.
        for (AttributeValue v2 : recordedValues)
        for (ByteString v2 : recordedValues)
        {
          uniqueAttrValue2Dn.remove(v2);
        }
        LocalizableMessage msg = ERR_PLUGIN_UNIQUEATTR_ATTR_NOT_UNIQUE.get(
            t.getNameOrOID(), v.getValue(), conflictDN);
            t.getNameOrOID(), v, conflictDN);
        return PluginResult.PreOperation.stopProcessing(
            ResultCode.CONSTRAINT_VIOLATION, msg);
      }
@@ -336,7 +337,7 @@
          de.getResultCode(), de.getMessageObject());
      // Try some cleanup before returning, to avoid memory leaks
      for (AttributeValue v2 : recordedValues)
      for (ByteString v2 : recordedValues)
      {
        uniqueAttrValue2Dn.remove(v2);
      }
@@ -364,7 +365,7 @@
      return PluginResult.PreOperation.continueOperationProcessing();
    }
    List<AttributeValue> recordedValues = new LinkedList<AttributeValue>();
    List<ByteString> recordedValues = new LinkedList<ByteString>();
    RDN newRDN = modifyDNOperation.getNewRDN();
    for (int i=0; i < newRDN.getNumValues(); i++)
    {
@@ -375,7 +376,7 @@
        continue;
      }
      AttributeValue v = newRDN.getAttributeValue(i);
      ByteString v = newRDN.getAttributeValue(i);
      DN entryDN = modifyDNOperation.getEntryDN();
      PreOperation stop =
          checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config);
@@ -415,7 +416,7 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t,
                v, baseDNs, config);
@@ -458,7 +459,7 @@
      {
        case ADD:
        case REPLACE:
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            sendAlertForUnresolvedConflict(modifyOperation, entryDN, entryDN, t,
                v, baseDNs, config);
@@ -480,7 +481,7 @@
                continue;
              }
              for (AttributeValue v : updatedAttr)
              for (ByteString v : updatedAttr)
              {
                sendAlertForUnresolvedConflict(modifyOperation, entryDN,
                    entryDN, t, v, baseDNs, config);
@@ -528,7 +529,7 @@
        continue;
      }
      AttributeValue v = newRDN.getAttributeValue(i);
      ByteString v = newRDN.getAttributeValue(i);
      sendAlertForUnresolvedConflict(modifyDNOperation, entryDN,
          updatedEntryDN, t, v, baseDNs, config);
    }
@@ -537,7 +538,7 @@
  private void sendAlertForUnresolvedConflict(PluginOperation operation,
      DN entryDN, DN updatedEntryDN, AttributeType t, AttributeValue v,
      DN entryDN, DN updatedEntryDN, AttributeType t, ByteString v,
      Set<DN> baseDNs, UniqueAttributePluginCfg config)
  {
    try
@@ -553,7 +554,7 @@
                               t.getNameOrOID(),
                               operation.getConnectionID(),
                               operation.getOperationID(),
                               v.getValue(),
                               v,
                               updatedEntryDN,
                               conflictDN);
        DirectoryServer.sendAlertNotification(this,
@@ -629,7 +630,7 @@
   */
  private DN getConflictingEntryDN(Set<DN> baseDNs, DN targetDN,
                                   UniqueAttributePluginCfg config,
                                   AttributeValue value)
                                   ByteString value)
          throws DirectoryException
  {
    SearchFilter filter;
@@ -837,7 +838,7 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            uniqueAttrValue2Dn.remove(v);
          }
@@ -882,7 +883,7 @@
      {
        case ADD:
        case REPLACE:
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            uniqueAttrValue2Dn.remove(v);
          }
@@ -903,7 +904,7 @@
                continue;
              }
              for (AttributeValue v : updatedAttr)
              for (ByteString v : updatedAttr)
              {
                uniqueAttrValue2Dn.remove(v);
              }
@@ -948,8 +949,7 @@
        // We aren't interested in this attribute type.
        continue;
      }
      AttributeValue v = newRDN.getAttributeValue(i);
      uniqueAttrValue2Dn.remove(v);
      uniqueAttrValue2Dn.remove(newRDN.getAttributeValue(i));
    }
    return PostOperation.continueOperationProcessing();
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -169,7 +169,7 @@
      AttributeBuilder builder = new AttributeBuilder(privType);
      for (Privilege p : Privilege.getDefaultRootPrivileges())
      {
        builder.add(AttributeValues.create(privType, p.getName()));
        builder.add(p.getName());
      }
      attrList = new LinkedList<Attribute>();
      attrList.add(builder.toAttribute());
@@ -704,8 +704,7 @@
  public AddOperation processAdd(String rawEntryDN,
                                 List<RawAttribute> rawAttributes)
  {
    return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes,
                      null);
    return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes, null);
  }
@@ -880,21 +879,18 @@
    LinkedHashMap<AttributeType,List<Attribute>> opAttrs =
         new LinkedHashMap<AttributeType,List<Attribute>>();
    Entry e = new Entry(addRecord.getDN(), objectClasses, userAttrs,
                        opAttrs);
    Entry e = new Entry(addRecord.getDN(), objectClasses, userAttrs, opAttrs);
    ArrayList<AttributeValue> duplicateValues =
         new ArrayList<AttributeValue>();
    ArrayList<ByteString> duplicateValues = new ArrayList<ByteString>();
    for (Attribute a : addRecord.getAttributes())
    {
      if (a.getAttributeType().isObjectClass())
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          String ocName = v.getValue().toString();
          String ocName = v.toString();
          String lowerName = toLowerCase(ocName);
          ObjectClass oc = DirectoryServer.getObjectClass(lowerName,
                                                          true);
          ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true);
          objectClasses.put(oc, ocName);
        }
      }
@@ -904,8 +900,7 @@
      }
    }
    return processAdd(addRecord.getDN(), objectClasses, userAttrs,
                      opAttrs);
    return processAdd(addRecord.getDN(), objectClasses, userAttrs, opAttrs);
  }
@@ -926,8 +921,7 @@
                                         String password)
  {
    return processSimpleBind(ByteString.valueOf(rawBindDN),
        ByteString.valueOf(password),
                             null);
        ByteString.valueOf(password), null);
  }
@@ -1184,8 +1178,7 @@
                                         String attributeType,
                                         String assertionValue)
  {
    return processCompare(ByteString.valueOf(rawEntryDN),
                          attributeType,
    return processCompare(ByteString.valueOf(rawEntryDN), attributeType,
        ByteString.valueOf(assertionValue), null);
  }
@@ -1212,10 +1205,8 @@
                                         String assertionValue,
                                         List<Control> controls)
  {
    return processCompare(ByteString.valueOf(rawEntryDN),
                          attributeType,
        ByteString.valueOf(assertionValue),
                          controls);
    return processCompare(ByteString.valueOf(rawEntryDN), attributeType,
        ByteString.valueOf(assertionValue), controls);
  }
@@ -1791,8 +1782,7 @@
                                           String rawNewSuperior)
  {
    return processModifyDN(ByteString.valueOf(rawEntryDN),
        ByteString.valueOf(rawNewRDN),
                           deleteOldRDN,
        ByteString.valueOf(rawNewRDN), deleteOldRDN,
        ByteString.valueOf(rawNewSuperior), null);
  }
@@ -1823,10 +1813,8 @@
                                           List<Control> controls)
  {
    return processModifyDN(ByteString.valueOf(rawEntryDN),
        ByteString.valueOf(rawNewRDN),
                           deleteOldRDN,
        ByteString.valueOf(rawNewSuperior),
                           controls);
        ByteString.valueOf(rawNewRDN), deleteOldRDN,
        ByteString.valueOf(rawNewSuperior), controls);
  }
@@ -2039,8 +2027,7 @@
                     le.getErrorMessage(), le);
    }
    return processSearch(ByteString.valueOf(rawBaseDN), scope,
                         rawFilter);
    return processSearch(ByteString.valueOf(rawBaseDN), scope, rawFilter);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java
@@ -170,9 +170,9 @@
      values = new ArrayList<ByteString>(attribute.size());
    }
    for (AttributeValue v : attribute)
    for (ByteString v : attribute)
    {
      values.add(v.getValue());
      values.add(v);
    }
  }
@@ -261,11 +261,9 @@
      builder = new AttributeBuilder(attributeType);
    }
    AttributeType attrType = builder.getAttributeType();
    for (ByteString value : values)
    {
      if (!builder.add(
          AttributeValues.create(attrType, value)))
      if (!builder.add(value))
      {
        LocalizableMessage message =
            ERR_LDAP_ATTRIBUTE_DUPLICATE_VALUES.get(attributeType);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java
@@ -37,7 +37,6 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
@@ -176,7 +175,7 @@
      case LESS_OR_EQUAL:
      case APPROXIMATE_MATCH:
        attributeType  = filter.getAttributeType().getNameOrOID();
        assertionValue = filter.getAssertionValue().getValue();
        assertionValue = filter.getAssertionValue();
        filterComponents  = null;
        notComponent      = null;
@@ -251,16 +250,7 @@
          attributeType = attrType.getNameOrOID();
        }
        AttributeValue av = filter.getAssertionValue();
        if (av == null)
        {
          assertionValue = null;
        }
        else
        {
          assertionValue = av.getValue();
        }
        assertionValue    = filter.getAssertionValue();
        filterComponents  = null;
        notComponent      = null;
        subInitialElement = null;
@@ -1942,64 +1932,27 @@
    }
    AttributeValue value;
    if (assertionValue == null)
    {
      value = null;
    }
    else if (attrType == null)
    if (assertionValue != null && attrType == null)
    {
      if (matchingRuleID == null)
      {
        LocalizableMessage message = ERR_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR.get();
        throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
        throw new DirectoryException(ResultCode.PROTOCOL_ERROR,
            ERR_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR.get());
      }
      else
      MatchingRule mr = DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID));
      if (mr == null)
      {
        MatchingRule mr =
             DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID));
        if (mr == null)
        {
          LocalizableMessage message =
              ERR_LDAP_FILTER_UNKNOWN_MATCHING_RULE.get(matchingRuleID);
          throw new DirectoryException(ResultCode.INAPPROPRIATE_MATCHING,
                                       message);
        }
        else
        {
          try
          {
            ByteString normalizedValue =
                mr.normalizeAttributeValue(assertionValue);
            value = AttributeValues.create(assertionValue, normalizedValue);
          }
          catch (DecodeException e)
          {
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                e.getMessageObject(), e);
          }
        }
        throw new DirectoryException(ResultCode.INAPPROPRIATE_MATCHING,
            ERR_LDAP_FILTER_UNKNOWN_MATCHING_RULE.get(matchingRuleID));
      }
    }
    else
    {
      value = AttributeValues.create(attrType, assertionValue);
    }
    ArrayList<ByteString> subAnyComps;
    if (subAnyElements == null)
    {
      subAnyComps = null;
    }
    else
    {
      subAnyComps = new ArrayList<ByteString>(subAnyElements);
    }
    ArrayList<ByteString> subAnyComps =
        subAnyElements != null ? new ArrayList<ByteString>(subAnyElements) : null;
    return new SearchFilter(filterType, subComps, notComp, attrType,
                            options, value, subInitialElement, subAnyComps,
                            options, assertionValue, subInitialElement, subAnyComps,
                            subFinalElement, matchingRuleID, dnAttributes);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
@@ -664,11 +664,7 @@
  {
    AttributeType attrType =
      DirectoryServer.getAttributeType(name.toLowerCase());
    AttributeBuilder builder = new AttributeBuilder(attrType, name);
    builder.add(AttributeValues.create(attrType, value));
    return builder.toAttribute();
    return Attributes.create(attrType, value);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.protocols.ldap;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -45,7 +43,6 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -54,8 +51,6 @@
import org.opends.server.types.SearchResultEntry;
import org.opends.server.util.Base64;
/**
 * This class defines the structures and methods for an LDAP search result entry
 * protocol op, which is used to return entries that match the associated search
@@ -637,9 +632,9 @@
    stream.writeStartSequence();
    stream.writeOctetString(a.getNameWithOptions());
    stream.writeStartSet();
    for (AttributeValue value : a)
    for (ByteString value : a)
    {
      stream.writeOctetString(value.getValue());
      stream.writeOctetString(value);
    }
    stream.writeEndSequence();
    stream.writeEndSequence();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java
@@ -26,18 +26,15 @@
 */
package org.opends.server.replication.common;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.ExtensionMessages.*;
@@ -56,7 +53,7 @@
   * TODO: This shouldn't be a virtual attribute, but directly
   * registered in the RootDSE.
   */
  private final Set<AttributeValue> values;
  private Attribute values;
  /**
@@ -65,10 +62,6 @@
  public ChangelogBaseDNVirtualAttributeProvider()
  {
    super();
    ByteString dn =
        ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT);
    values = Collections.singleton(AttributeValues.create(dn, dn));
  }
  /** {@inheritDoc} */
@@ -80,8 +73,13 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    if (values == null)
    {
      values = Attributes.create(rule.getAttributeType(),
          ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT);
    }
    return values;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
@@ -26,21 +26,18 @@
 */
package org.opends.server.replication.common;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement;
import static org.opends.messages.ExtensionMessages.*;
@@ -83,7 +80,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
  public Attribute getValues(Entry entry,VirtualAttributeRule rule)
  {
    String value = "0";
    try
@@ -105,8 +102,7 @@
      value = "-1";
      logger.traceException(e);
    }
    ByteString valueBS = ByteString.valueOf(value);
    return Collections.singleton(AttributeValues.create(valueBS, valueBS));
    return Attributes.create(rule.getAttributeType(), value);
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
@@ -26,21 +26,18 @@
 */
package org.opends.server.replication.common;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement;
import static org.opends.messages.ExtensionMessages.*;
@@ -83,7 +80,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
  public Attribute getValues(Entry entry,VirtualAttributeRule rule)
  {
    String value = "0";
    try
@@ -105,8 +102,7 @@
      value = "-1";
      logger.traceException(e);
    }
    ByteString valueBS = ByteString.valueOf(value);
    return Collections.singleton(AttributeValues.create(valueBS, valueBS));
    return Attributes.create(rule.getAttributeType(), value);
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
@@ -26,22 +26,20 @@
 */
package org.opends.server.replication.common;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.replication.plugin.MultimasterReplication;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.ServerConstants;
import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement;
@@ -87,7 +85,7 @@
  /** {@inheritDoc} */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
  public Attribute getValues(Entry entry, VirtualAttributeRule rule)
  {
    try
    {
@@ -102,15 +100,14 @@
        final ReplicationServer rs = eclwe.getReplicationServer();
        String newestCookie = rs.getNewestECLCookie(excludedDomains).toString();
        final ByteString cookie = ByteString.valueOf(newestCookie);
        return Collections.singleton(AttributeValues.create(cookie, cookie));
        return Attributes.create(rule.getAttributeType(), newestCookie);
      }
    }
    catch (Exception e)
    {
      logger.traceException(e);
    }
    return Collections.emptySet();
    return Attributes.empty(rule.getAttributeType());
  }
  /** {@inheritDoc} */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/AttrHistorical.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock, AS.
 *      Portions Copyright 2013-2014 ForgeRock, AS.
 */
package org.opends.server.replication.plugin;
@@ -31,7 +31,7 @@
import org.opends.server.replication.common.CSN;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
@@ -111,7 +111,7 @@
   * @param csn     the associated CSN.
   */
  public abstract void assign(
      HistAttrModificationKey histKey, AttributeValue value, CSN csn);
      HistAttrModificationKey histKey, ByteString value, CSN csn);
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -30,6 +30,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.*;
@@ -54,7 +55,7 @@
   * LinkedHashMap here because we want:
   * <ol>
   * <li>Fast access for removing/adding a AttrValueHistorical keyed by the
   * AttributeValue => Use a Map</li>
   * attribute value => Use a Map</li>
   * <li>Ordering changes according to the CSN of each changes => Use a
   * LinkedHashMap</li>
   * </ol>
@@ -157,7 +158,7 @@
    * @param val value that was deleted
    * @param csn time when the delete was done
    */
   protected void delete(AttributeValue val, CSN csn)
   protected void delete(ByteString val, CSN csn)
   {
     AttrValueHistorical info = new AttrValueHistorical(val, null, csn);
     valuesHist.remove(info);
@@ -179,7 +180,7 @@
     */
  protected void delete(Attribute attr, CSN csn)
  {
    for (AttributeValue val : attr)
    for (ByteString val : attr)
    {
      AttrValueHistorical info = new AttrValueHistorical(val, null, csn);
      valuesHist.remove(info);
@@ -199,7 +200,7 @@
     * @param csn
     *          time when the value was added
     */
   protected void add(AttributeValue addedValue, CSN csn)
   protected void add(ByteString addedValue, CSN csn)
   {
     AttrValueHistorical info = new AttrValueHistorical(addedValue, csn, null);
     valuesHist.remove(info);
@@ -220,7 +221,7 @@
     */
  private void add(Attribute attr, CSN csn)
  {
    for (AttributeValue val : attr)
    for (ByteString val : attr)
    {
      AttrValueHistorical info = new AttrValueHistorical(val, csn, null);
      valuesHist.remove(info);
@@ -466,7 +467,7 @@
      // we are processing DELETE of some attribute values
      AttributeBuilder builder = new AttributeBuilder(modAttr);
      for (AttributeValue val : modAttr)
      for (ByteString val : modAttr)
      {
        boolean deleteIt = true;  // true if the delete must be done
        boolean addedInCurrentOp = false;
@@ -564,7 +565,7 @@
    }
    AttributeBuilder builder = new AttributeBuilder(m.getAttribute());
    for (AttributeValue addVal : m.getAttribute())
    for (ByteString addVal : m.getAttribute())
    {
      AttrValueHistorical valInfo =
        new AttrValueHistorical(addVal, csn, null);
@@ -641,8 +642,7 @@
   * {@inheritDoc}
   */
  @Override
  public void assign(HistAttrModificationKey histKey, AttributeValue value,
      CSN csn)
  public void assign(HistAttrModificationKey histKey, ByteString value, CSN csn)
  {
    switch (histKey)
    {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/AttrHistoricalSingle.java
@@ -30,9 +30,13 @@
import java.util.Iterator;
import java.util.Map;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
/**
 * This class is used to store historical information for single valued
@@ -45,17 +49,17 @@
public class AttrHistoricalSingle extends AttrHistorical
{
  /** Last time when the attribute was deleted. */
  private CSN deleteTime = null;
  private CSN deleteTime;
  /** Last time when a value was added. */
  private CSN addTime = null;
  private CSN addTime;
  /** Last added value. */
  private AttributeValue value = null;
  private ByteString value;
/**
 * last operation applied. This is only used for multiple mods on the same
 * single valued attribute in the same modification.
 */
  private HistAttrModificationKey lastMod = null;
  private HistAttrModificationKey lastMod;
  /**
   * {@inheritDoc}
@@ -89,7 +93,7 @@
  @Override
  public void processLocalOrNonConflictModification(CSN csn, Modification mod)
  {
    AttributeValue newValue = null;
    ByteString newValue = null;
    Attribute modAttr = mod.getAttribute();
    if (modAttr != null && !modAttr.isEmpty())
    {
@@ -143,7 +147,7 @@
  {
    boolean conflict = false;
    AttributeValue newValue = null;
    ByteString newValue = null;
    Attribute modAttr = mod.getAttribute();
    if (modAttr != null && !modAttr.isEmpty())
    {
@@ -287,8 +291,7 @@
   * {@inheritDoc}
   */
  @Override
  public void assign(HistAttrModificationKey histKey,
      AttributeValue value, CSN csn)
  public void assign(HistAttrModificationKey histKey, ByteString value, CSN csn)
  {
    switch (histKey)
    {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/AttrValueHistorical.java
@@ -22,32 +22,30 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS.
 *      Portions Copyright 2013-2014 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
/**
 * Store historical information for an attribute value.
 */
public class AttrValueHistorical
{
  private AttributeValue value;
  private ByteString value;
  private CSN valueDeleteTime;
  private CSN valueUpdateTime;
  /**
   * Build an AttrValueHistorical for a provided AttributeValue, providing
   * Build an AttrValueHistorical for a provided attribute value, providing
   * the last time the provided value is either updated or deleted.
   * @param value    the provided attributeValue
   * @param csnUpdate last time when this value was updated
   * @param csnDelete last time when this value for deleted
   */
  public AttrValueHistorical(AttributeValue value,
                   CSN csnUpdate,
                   CSN csnDelete)
  public AttrValueHistorical(ByteString value, CSN csnUpdate, CSN csnDelete)
  {
    this.value = value;
    this.valueUpdateTime = csnUpdate;
@@ -104,7 +102,7 @@
   * Get the attributeValue for which this object was generated.
   * @return the value for which this object was generated
   */
  public AttributeValue getAttributeValue()
  public ByteString getAttributeValue()
  {
    return value;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/EntryHistorical.java
@@ -29,6 +29,7 @@
import java.util.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.common.CSN;
@@ -320,7 +321,7 @@
    // Get the CSN from the attached synchronization context
    // Create the attribute (encoded)
    CSN addCSN = OperationContext.getCSN(addOperation);
    AttributeValue attrValue = encodeHistorical(addCSN, "add");
    String attrValue = encodeHistorical(addCSN, "add");
    Attribute attr = Attributes.create(historicalAttrType, attrValue);
    // Set the created attribute to the operation
@@ -341,13 +342,9 @@
   * @return The attribute value containing the historical information for the
   *         Operation type.
   */
  private static AttributeValue encodeHistorical(CSN csn, String operationType)
  private static String encodeHistorical(CSN csn, String operationType)
  {
    AttributeType historicalAttrType =
      DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME);
    String strValue = "dn:" + csn + ":" + operationType;
    return AttributeValues.create(historicalAttrType, strValue);
    return "dn:" + csn + ":" + operationType;
  }
  /**
@@ -465,7 +462,7 @@
        for (AttrValueHistorical attrValHist : attrHist.getValuesHistorical()
            .keySet())
        {
          final AttributeValue value = attrValHist.getAttributeValue();
          final ByteString value = attrValHist.getAttributeValue();
          // Encode an attribute value
          final String strValue;
@@ -478,7 +475,7 @@
            }
            strValue = encode("del", type, optionsString, attrValHist
                    .getValueDeleteTime(), value);
            builder.add(AttributeValues.create(historicalAttrType, strValue));
            builder.add(strValue);
          }
          else if (attrValHist.getValueUpdateTime() != null)
          {
@@ -507,7 +504,7 @@
              strValue = encode("add", type, optionsString, updateTime);
            }
            builder.add(AttributeValues.create(historicalAttrType, strValue));
            builder.add(strValue);
          }
        }
@@ -519,7 +516,7 @@
            continue;
          }
          String strValue = encode("attrDel", type, optionsString, deleteTime);
          builder.add(AttributeValues.create(historicalAttrType, strValue));
          builder.add(strValue);
        }
      }
    }
@@ -560,7 +557,7 @@
  }
  private String encode(String operation, AttributeType type,
      String optionsString, CSN changeTime, AttributeValue value)
      String optionsString, CSN changeTime, ByteString value)
  {
    return type.getNormalizedPrimaryName() + optionsString + ":" + changeTime
        + ":" + operation + ":" + value;
@@ -650,16 +647,16 @@
      for (Attribute histAttrFromEntry : histAttrWithOptionsFromEntry)
      {
        // For each Attribute (option), traverse the values
        for (AttributeValue histAttrValueFromEntry : histAttrFromEntry)
        for (ByteString histAttrValueFromEntry : histAttrFromEntry)
        {
          // From each value of the hist attr, create an object
          HistoricalAttributeValue histVal = new HistoricalAttributeValue(
              histAttrValueFromEntry.getValue().toString());
              histAttrValueFromEntry.toString());
          AttributeType attrType = histVal.getAttrType();
          Set<String> options = histVal.getOptions();
          CSN csn = histVal.getCSN();
          AttributeValue value = histVal.getAttributeValue();
          ByteString value = histVal.getAttributeValue();
          HistAttrModificationKey histKey = histVal.getHistKey();
          // update the oldest CSN stored in the new entry historical
@@ -753,10 +750,10 @@
    {
      for (Attribute attr : attrs)
      {
        for (AttributeValue val : attr)
        for (ByteString val : attr)
        {
          HistoricalAttributeValue histVal =
            new HistoricalAttributeValue(val.getValue().toString());
            new HistoricalAttributeValue(val.toString());
          if (histVal.isADDOperation())
          {
            // Found some historical information indicating that this
@@ -903,11 +900,10 @@
  {
    if (entryUUIDAttributes != null)
    {
      Attribute uuid = entryUUIDAttributes.get(0);
      if (!uuid.isEmpty())
      Attribute uuidAttr = entryUUIDAttributes.get(0);
      if (!uuidAttr.isEmpty())
      {
        AttributeValue uuidVal = uuid.iterator().next();
        return uuidVal.getValue().toString();
        return uuidAttr.iterator().next().toString();
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/ExternalChangelogDomain.java
@@ -117,7 +117,7 @@
      if (domain==null)
      {
        RDN rdn = configuration.dn().parent().rdn();
        DN rdns = DN.decode(rdn.getAttributeValue(0).getValue());
        DN rdns = DN.decode(rdn.getAttributeValue(0));
        domain = MultimasterReplication.findDomain(rdns, null);
      }
      return null;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -40,6 +40,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.plugin.LDAPReplicationDomain.*;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.replication.plugin.LDAPReplicationDomain.*;
@@ -459,7 +460,7 @@
      // Now flush attribute values into entry
      if (somethingToFlush)
      {
        List<AttributeValue> duplicateValues = new ArrayList<AttributeValue>();
        List<ByteString> duplicateValues = new ArrayList<ByteString>();
        entry.addAttribute(attrBuilder.toAttribute(), duplicateValues);
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalAttributeValue.java
@@ -29,6 +29,7 @@
import java.util.LinkedHashSet;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.common.CSN;
@@ -70,7 +71,7 @@
{
  private AttributeType attrType;
  private String attrString;
  private AttributeValue attributeValue;
  private ByteString attributeValue;
  private CSN csn;
  private Set<String> options;
  private HistAttrModificationKey histKey;
@@ -136,10 +137,12 @@
      if (token.length == 4)
      {
        stringValue = token[3];
        attributeValue = AttributeValues.create(attrType, stringValue);
        attributeValue = ByteString.valueOf(stringValue);
      }
      else
      {
        attributeValue = null;
      }
    }
    else
    {
@@ -200,7 +203,7 @@
   * Get the Attribute Value.
   * @return The Attribute Value.
   */
  public AttributeValue getAttributeValue()
  public ByteString getAttributeValue()
  {
    return attributeValue;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -818,14 +818,14 @@
   */
  public static class AttributeValueStringIterator implements Iterator<String>
  {
    private Iterator<AttributeValue> attrValIt;
    private Iterator<ByteString> attrValIt;
    /**
     * Creates a new AttributeValueStringIterator object.
     * @param attrValIt The underlying attribute iterator to use, assuming
     * internal values are strings.
     */
    public AttributeValueStringIterator(Iterator<AttributeValue> attrValIt)
    public AttributeValueStringIterator(Iterator<ByteString> attrValIt)
    {
      this.attrValIt = attrValIt;
    }
@@ -841,7 +841,7 @@
    @Override
    public String next()
    {
      return attrValIt.next().getValue().toString();
      return attrValIt.next().toString();
    }
    /** {@inheritDoc} */
@@ -1224,16 +1224,16 @@
        support remove so we have to create a new list, keeping only the
        attribute value which is the same as in the RDN
        */
        AttributeValue rdnAttributeValue =
        ByteString rdnAttributeValue =
          entryRdn.getAttributeValue(attributeType);
        List<Attribute> attrList = attributesMap.get(attributeType);
        AttributeValue sameAttrValue = null;
        ByteString sameAttrValue = null;
        // Locate the attribute value identical to the one in the RDN
        for (Attribute attr : attrList)
        {
          if (attr.contains(rdnAttributeValue))
          {
            for (AttributeValue attrValue : attr) {
            for (ByteString attrValue : attr) {
              if (rdnAttributeValue.equals(attrValue)) {
                // Keep the value we want
                sameAttrValue = attrValue;
@@ -3102,8 +3102,7 @@
    // create new internal modify operation and run it.
    AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT,
        true);
    Attribute attr = Attributes.create(attrType, AttributeValues.create(
        attrType, conflictDN.toNormalizedString()));
    Attribute attr = Attributes.create(attrType, conflictDN.toNormalizedString());
    List<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE, attr));
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/plugin/PersistentServerState.java
@@ -276,7 +276,7 @@
    if (attrs != null)
    {
      Attribute attr = attrs.get(0);
      for (AttributeValue value : attr)
      for (ByteString value : attr)
      {
        update(new CSN(value.toString()));
      }
@@ -413,8 +413,7 @@
        dbMaxCsn = serverStateMaxCsn;
        for (SearchResultEntry resEntry : op.getSearchEntries())
        {
          for (AttributeValue attrValue :
                    resEntry.getAttribute(histType).get(0))
          for (ByteString attrValue : resEntry.getAttribute(histType).get(0))
          {
            HistoricalAttributeValue histVal =
                new HistoricalAttributeValue(attrValue.toString());
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/protocol/AddMsg.java
@@ -48,7 +48,6 @@
import org.opends.server.types.operation.PostOperationAddOperation;
import static org.opends.server.replication.protocol.OperationContext.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class is used to exchange Add operation between LDAP servers
@@ -333,8 +332,7 @@
      builder.setInitialCapacity(objectClasses.size());
      for (String s : objectClasses.values())
      {
        builder.add(AttributeValues.create(ByteString.valueOf(s),
            ByteString.valueOf(toLowerCase(s))));
        builder.add(s);
      }
      Attribute attr = builder.toAttribute();
@@ -345,9 +343,10 @@
      {
        for (Attribute a : list)
        {
          if (!EntryHistorical.isHistoricalAttribute(a))
            if (!a.isVirtual())
              new LDAPAttribute(a).write(writer);
          if (!EntryHistorical.isHistoricalAttribute(a) && !a.isVirtual())
          {
            new LDAPAttribute(a).write(writer);
          }
        }
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -705,8 +705,7 @@
      {
        try
        {
          CSN startingCSN =
             new CSN(filter.getAssertionValue().getValue().toString());
          CSN startingCSN = new CSN(filter.getAssertionValue().toString());
          return new CSN(startingCSN.getTime(),
              startingCSN.getSeqnum() - 1, startingCSN.getServerId());
        }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/service/ReplicationMonitor.java
@@ -120,7 +120,7 @@
    AttributeBuilder builder = new AttributeBuilder(type, ATTR_SERVER_STATE);
    for (String str : domain.getServerState().toStringSet())
    {
      builder.add(AttributeValues.create(type,str));
      builder.add(str);
    }
    attributes.add(builder.toAttribute());
@@ -203,7 +203,7 @@
      {
        final Integer serverId = entry.getKey();
        final Integer nb = entry.getValue();
        builder.add(AttributeValues.create(type, serverId + ":" + nb));
        builder.add(serverId + ":" + nb);
      }
      attributes.add(builder.toAttribute());
    }
@@ -220,9 +220,7 @@
  public static void addMonitorData(List<Attribute> attributes, String name,
      int value)
  {
    AttributeType type = DirectoryServer.getDefaultAttributeType(name);
    attributes.add(Attributes.create(type, AttributeValues.create(type,
        String.valueOf(value))));
    addMonitorData(attributes, name, String.valueOf(value));
  }
  /**
@@ -236,9 +234,7 @@
  public static void addMonitorData(List<Attribute> attributes, String name,
      long value)
  {
    AttributeType type = DirectoryServer.getDefaultAttributeType(name);
    attributes.add(Attributes.create(type, AttributeValues.create(type,
        String.valueOf(value))));
    addMonitorData(attributes, name, String.valueOf(value));
  }
  /**
@@ -253,7 +249,6 @@
      String value)
  {
    AttributeType type = DirectoryServer.getDefaultAttributeType(name);
    attributes
        .add(Attributes.create(type, AttributeValues.create(type, value)));
    attributes.add(Attributes.create(type, value));
  }
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/BooleanSyntax.java
@@ -37,8 +37,6 @@
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.SchemaMessages.*;
@@ -243,12 +241,9 @@
   *
   * @return  The attribute value created from the provided boolean value.
   */
  public static AttributeValue createBooleanValue(boolean b)
  public static ByteString createBooleanValue(boolean b)
  {
    ByteString value = b
        ? ServerConstants.TRUE_VALUE
        : ServerConstants.FALSE_VALUE;
    return AttributeValues.create(value, value);
    return b ? ServerConstants.TRUE_VALUE : ServerConstants.FALSE_VALUE;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java
@@ -387,11 +387,9 @@
   *
   * @return  The attribute value created from the date.
   */
  public static AttributeValue createGeneralizedTimeValue(long time)
  public static ByteString createGeneralizedTimeValue(long time)
  {
    String valueString = format(time);
    return AttributeValues.create(ByteString.valueOf(valueString),
        ByteString.valueOf(valueString));
    return ByteString.valueOf(format(time));
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/schema/UTCTimeSyntax.java
@@ -831,17 +831,14 @@
   *
   * @return  The attribute value created from the date.
   */
  public static AttributeValue createUTCTimeValue(Date d)
  public static ByteString createUTCTimeValue(Date d)
  {
    String valueString;
    synchronized (dateFormatLock)
    {
      valueString = dateFormat.format(d);
    }
    return AttributeValues.create(ByteString.valueOf(valueString),
        ByteString.valueOf(valueString));
    return ByteString.valueOf(valueString);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/AddSchemaFileTask.java
@@ -43,6 +43,7 @@
import org.opends.server.core.SchemaConfigManager;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.TaskMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -59,7 +60,7 @@
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The list of files to be added to the server schema. */
  TreeSet<String> filesToAdd;
  private TreeSet<String> filesToAdd;
  /**
   * {@inheritDoc}
@@ -111,9 +112,9 @@
    filesToAdd = new TreeSet<String>();
    for (Attribute a : attrList)
    {
      for (AttributeValue v  : a)
      for (ByteString v  : a)
      {
        String filename = v.getValue().toString();
        String filename = v.toString();
        filesToAdd.add(filename);
        try
@@ -207,9 +208,9 @@
            Attribute a = m.getAttribute();
            AttributeBuilder builder = new AttributeBuilder(a
                .getAttributeType(), a.getName());
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              String s = v.getValue().toString();
              String s = v.toString();
              if (!s.contains(SCHEMA_PROPERTY_FILENAME))
              {
                if (s.endsWith(" )"))
@@ -224,7 +225,7 @@
                }
              }
              builder.add(AttributeValues.create(a.getAttributeType(), s));
              builder.add(s);
            }
            mods.add(new Modification(m.getModificationType(), builder
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/DisconnectClientTask.java
@@ -39,7 +39,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DisconnectReason;
import org.opends.server.types.Entry;
@@ -113,17 +113,16 @@
connIDLoop:
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            connectionID = Long.parseLong(v.getValue().toString());
            connectionID = Long.parseLong(v.toString());
            break connIDLoop;
          }
          catch (Exception e)
          {
            LocalizableMessage message =
               ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v.getValue());
            LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                         message, e);
          }
@@ -151,9 +150,9 @@
notifyClientLoop:
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          String stringValue = toLowerCase(v.getValue().toString());
          String stringValue = toLowerCase(v.toString());
          if (stringValue.equals("true"))
          {
            notifyClient = true;
@@ -185,9 +184,9 @@
disconnectMessageLoop:
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          disconnectMessage = LocalizableMessage.raw(v.getValue().toString());
          disconnectMessage = LocalizableMessage.raw(v.toString());
          break disconnectMessageLoop;
        }
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ShutdownTask.java
@@ -102,7 +102,7 @@
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty())
      {
        String valueString = attr.iterator().next().getValue().toString();
        String valueString = attr.iterator().next().toString();
        shutdownMessage = INFO_TASK_SHUTDOWN_CUSTOM_MESSAGE.get(taskEntry.getName(), valueString);
      }
    }
@@ -115,9 +115,7 @@
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty())
      {
        String valueString = toLowerCase(attr.iterator().next()
            .getValue().toString());
        String valueString = toLowerCase(attr.iterator().next().toString());
        restart = (valueString.equals("true") || valueString.equals("yes")
            || valueString.equals("on") || valueString.equals("1"));
      }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/TaskUtils.java
@@ -33,23 +33,26 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.messages.TaskMessages;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.Backend;
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.config.StringConfigAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.RawModification;
import org.opends.server.util.ServerConstants;
import static org.opends.messages.ConfigMessages.*;
@@ -329,9 +332,9 @@
    for (Attribute a : attrList)
    {
      for (AttributeValue v  : a)
      for (ByteString v  : a)
      {
        String valueString = toLowerCase(v.getValue().toString());
        String valueString = toLowerCase(v.toString());
        if (valueString.equals("true") || valueString.equals("yes") ||
            valueString.equals("on") || valueString.equals("1"))
        {
@@ -367,9 +370,9 @@
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty())
      {
        for (AttributeValue value : attr)
        for (ByteString value : attr)
        {
          valueStrings.add(value.getValue().toString());
          valueStrings.add(value.toString());
        }
      }
    }
@@ -388,17 +391,15 @@
   */
  public static String getSingleValueString(List<Attribute> attrList)
  {
    if (attrList == null || attrList.isEmpty())
    if (attrList != null && !attrList.isEmpty())
    {
      return null;
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty())
      {
        return attr.iterator().next().toString();
      }
    }
    String valueString = null;
    Attribute attr = attrList.get(0);
    if (!attr.isEmpty())
    {
      valueString = attr.iterator().next().getValue().toString();
    }
    return valueString;
    return null;
  }
@@ -421,11 +422,9 @@
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty())
      {
        String valueString = attr.iterator().next()
            .getValue().toString();
        try
        {
          return Integer.parseInt(valueString);
          return Integer.parseInt(attr.iterator().next().toString());
        }
        catch (NumberFormatException e)
        {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java
@@ -46,8 +46,7 @@
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -789,7 +788,7 @@
      AttributeBuilder builder = new AttributeBuilder(attrType);
      for (ObjectClass oc : sourceClasses)
      {
        builder.add(AttributeValues.create(attrType, oc.getNameOrOID()));
        builder.add(oc.getNameOrOID());
      }
      modifications.add(new Modification(ModificationType.DELETE, builder
@@ -803,7 +802,7 @@
      AttributeBuilder builder = new AttributeBuilder(attrType);
      for (ObjectClass oc : targetClasses)
      {
        builder.add(AttributeValues.create(attrType, oc.getNameOrOID()));
        builder.add(oc.getNameOrOID());
      }
      modifications.add(new Modification(ModificationType.ADD, builder
@@ -940,7 +939,7 @@
          else
          {
            LinkedList<Modification> attrMods = new LinkedList<Modification>();
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              AttributeBuilder builder = new AttributeBuilder(a, true);
              builder.add(v);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java
@@ -38,13 +38,13 @@
import java.util.TreeMap;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -324,9 +324,9 @@
        AttributeType t = a.getAttributeType();
        if (t.isObjectClass())
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            String stringValue = v.getValue().toString();
            String stringValue = v.toString();
            String lowerValue  = toLowerCase(stringValue);
            ObjectClass oc = DirectoryServer.getObjectClass(lowerValue, true);
            objectClasses.put(oc, stringValue);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/Branch.java
@@ -37,7 +37,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -146,15 +146,13 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            String[] valueStrings = new String[] { v.getValue().toString()};
            Tag[] tags = new Tag[1];
            tags[0] = new StaticTextTag();
            tags[0].initializeForBranch(templateFile, this, valueStrings, 0,
                                        warnings);
            String[] valueStrings = new String[] { v.toString() };
            Tag[] tags = new Tag[] { new StaticTextTag() };
            tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
            lineList.add(new TemplateLine(a.getAttributeType(), 0, tags));
          }
          catch (Exception e)
@@ -170,15 +168,13 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          try
          {
            String[] valueStrings = new String[] { v.getValue().toString()};
            Tag[] tags = new Tag[1];
            tags[0] = new StaticTextTag();
            tags[0].initializeForBranch(templateFile, this, valueStrings, 0,
                                        warnings);
            String[] valueStrings = new String[] { v.toString() };
            Tag[] tags = new Tag[] { new StaticTextTag() };
            tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings);
            lineList.add(new TemplateLine(a.getAttributeType(), 0, tags));
          }
          catch (Exception e)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -26,25 +26,20 @@
 */
package org.opends.server.tools.makeldif;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.LDIFException;
import static org.opends.server.util.LDIFWriter.appendLDIFSeparatorAndValue;
import static org.opends.server.util.LDIFWriter.writeLDIFLine;
import static org.opends.server.util.LDIFWriter.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines an entry that is generated using a MakeLDIF branch or
 * template.
@@ -167,14 +162,12 @@
          return null;
        }
        AttributeValue value =
            AttributeValues.create(t, v.getValue().toString());
        rdn = new RDN(t, value);
        rdn = new RDN(t, ByteString.valueOf(v.getValue().toString()));
      }
      else
      {
        String[]         names  = new String[rdnAttrs.length];
        AttributeValue[] values = new AttributeValue[rdnAttrs.length];
        ByteString[] values = new ByteString[rdnAttrs.length];
        for (int i=0; i < rdnAttrs.length; i++)
        {
          AttributeType t = rdnAttrs[i];
@@ -185,7 +178,7 @@
          }
          names[i]  = t.getPrimaryName();
          values[i] = AttributeValues.create(t, v.getValue().toString());
          values[i] = ByteString.valueOf(v.getValue().toString());
        }
        rdn = new RDN(rdnAttrs, names, values);
@@ -228,14 +221,11 @@
  public TemplateValue getValue(AttributeType attributeType)
  {
    ArrayList<TemplateValue> valueList = attributes.get(attributeType);
    if ((valueList == null) || valueList.isEmpty())
    {
      return null;
    }
    else
    if (valueList != null && !valueList.isEmpty())
    {
      return valueList.get(0);
    }
    return null;
  }
@@ -251,8 +241,7 @@
   */
  public List<TemplateValue> getValues(AttributeType attributeType)
  {
    ArrayList<TemplateValue> valueList = attributes.get(attributeType);
    return valueList;
    return attributes.get(attributeType);
  }
@@ -269,13 +258,9 @@
    if (valueList == null)
    {
      valueList = new ArrayList<TemplateValue>();
      valueList.add(value);
      attributes.put(value.getAttributeType(), valueList);
    }
    else
    {
      valueList.add(value);
    }
    valueList.add(value);
  }
@@ -327,7 +312,7 @@
        AttributeBuilder builder = new AttributeBuilder(t, t.getNameOrOID());
        for (TemplateValue v : valueList)
        {
          builder.add(AttributeValues.create(t, v.getValue().toString()));
          builder.add(v.getValue().toString());
        }
        ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
@@ -341,8 +326,7 @@
        AttributeBuilder base64Builder = null;
        for (TemplateValue v : valueList)
        {
          AttributeValue value =
            AttributeValues.create(t, v.getValue().toString());
          ByteString value = ByteString.valueOf(v.getValue().toString());
          builder.add(value);
          if (v.getTemplateLine().isURL())
          {
@@ -456,7 +440,7 @@
            List<Attribute> urlAttrList = urlAttributes.get(attrType);
            List<Attribute> base64AttrList = base64Attributes.get(attrType);
            for (AttributeValue v : a)
            for (ByteString v : a)
            {
              StringBuilder attrLine = new StringBuilder();
              attrLine.append(attrName);
@@ -465,7 +449,7 @@
              {
                for (Attribute urlAttr : urlAttrList)
                {
                  for (AttributeValue urlValue : urlAttr)
                  for (ByteString urlValue : urlAttr)
                  {
                    if (urlValue.equals(v))
                    {
@@ -484,7 +468,7 @@
              {
                for (Attribute base64Attr : base64AttrList)
                {
                  for (AttributeValue base64Value : base64Attr)
                  for (ByteString base64Value : base64Attr)
                  {
                    if (base64Value.equals(v))
                    {
@@ -499,7 +483,7 @@
                }
              }
              appendLDIFSeparatorAndValue(attrLine,
                                          v.getValue(),
                                          v,
                                          isURLValue,
                                          isBase64Value);
              writeLDIFLine(attrLine, writer, wrapLines, wrapColumn);
@@ -548,14 +532,12 @@
                attrName.append(o);
              }
              for (AttributeValue v : a)
              for (ByteString v : a)
              {
                StringBuilder attrLine = new StringBuilder();
                attrLine.append(attrName);
                appendLDIFSeparatorAndValue(attrLine,
                                            v.getValue());
                writeLDIFLine(attrLine, writer, wrapLines,
                              wrapColumn);
                appendLDIFSeparatorAndValue(attrLine, v);
                writeLDIFLine(attrLine, writer, wrapLines, wrapColumn);
              }
            }
          }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskEntry.java
@@ -33,7 +33,7 @@
import org.opends.server.types.Entry;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import java.util.Map;
@@ -143,13 +143,13 @@
                type.getNormalizedPrimaryName());
        List<Attribute> attrList = entry.getUserAttribute(type);
        for (Attribute attr : attrList) {
          for (AttributeValue av : attr) {
          for (ByteString av : attr) {
            List<String> valueList = taskSpecificAttrValues.get(attrTypeName);
            if (valueList == null) {
              valueList = new ArrayList<String>();
              taskSpecificAttrValues.put(attrTypeName, valueList);
            }
            valueList.add(av.getValue().toString());
            valueList.add(av.toString());
          }
        }
      }
@@ -441,7 +441,7 @@
    if (attrList != null && attrList.size() == 1) {
      Attribute attr = attrList.get(0);
      if (!attr.isEmpty()) {
        return attr.iterator().next().getValue().toString();
        return attr.iterator().next().toString();
      }
    }
    return "";
@@ -452,8 +452,8 @@
    List<Attribute> attrList = entry.getAttribute(attrName);
    if (attrList != null) {
      for (Attribute attr : attrList) {
        for (AttributeValue value : attr) {
          valuesList.add(value.getValue().toString());
        for (ByteString value : attr) {
          valuesList.add(value.toString());
        }
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AbstractAttribute.java
@@ -26,12 +26,12 @@
 */
package org.opends.server.types;
import static org.opends.server.util.StaticUtils.*;
import java.util.Collection;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.server.util.StaticUtils.*;
/**
 * An abstract base class for implementing new types of
@@ -60,18 +60,18 @@
   * <p>
   * This implementation iterates through each attribute value in the
   * provided collection, checking to see if this attribute contains
   * the value using {@link #contains(AttributeValue)}.
   * the value using {@link #contains(ByteString)}.
   */
  public boolean containsAll(Collection<AttributeValue> values)
  @Override
  public boolean containsAll(Collection<ByteString> values)
  {
    for (AttributeValue value : values)
    for (ByteString value : values)
    {
      if (!contains(value))
      {
        return false;
      }
    }
    return true;
  }
@@ -101,7 +101,7 @@
        return false;
      }
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        if (!contains(v))
        {
@@ -126,6 +126,7 @@
   * attribute's attribute type or, if there is no primary name, the
   * attribute type's OID.
   */
  @Override
  public String getName()
  {
    return getAttributeType().getNameOrOID();
@@ -141,6 +142,7 @@
   * this attribute's name followed by a semi-colon and a semi-colon
   * separated list of its attribute options.
   */
  @Override
  public String getNameWithOptions()
  {
    if (!hasOptions())
@@ -173,6 +175,7 @@
   * {@link #hasOption(String)} and <code>true</code> is
   * returned if all the provided options are present.
   */
  @Override
  public boolean hasAllOptions(Collection<String> options)
  {
    if (options == null || options.isEmpty())
@@ -202,15 +205,13 @@
   * {@inheritDoc}
   */
  @Override
  public final int hashCode()
  public int hashCode()
  {
    int hashCode = getAttributeType().hashCode();
    for (AttributeValue value : this)
    for (ByteString value : this)
    {
      hashCode += value.hashCode();
    }
    return hashCode;
  }
@@ -225,6 +226,7 @@
   * case insensitive (this is why we iterate through the set of
   * options, rather than doing a simpler set membership test).
   */
  @Override
  public boolean hasOption(String option)
  {
    String noption = toLowerCase(option);
@@ -250,6 +252,7 @@
   * This implementation retrieves the set of options associated with
   * this attribute and tests to see if it is empty.
   */
  @Override
  public boolean hasOptions()
  {
    return !getOptions().isEmpty();
@@ -263,6 +266,7 @@
   * This implementation returns <code>true</code> if the
   * {@link #size()} of this attribute is zero.
   */
  @Override
  public boolean isEmpty()
  {
    return size() == 0;
@@ -282,6 +286,7 @@
   * {@link #hasOption(String)} and <code>true</code> is
   * returned if all the provided options are present.
   */
  @Override
  public boolean optionsEqual(Set<String> options)
  {
    if (options == null)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AccountStatusNotification.java
@@ -33,6 +33,7 @@
import java.util.Map;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.PasswordPolicyState;
@@ -40,8 +41,6 @@
                   AccountStatusNotificationProperty.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines a data type for storing information associated
 * with an account status notification.
@@ -227,8 +226,8 @@
                     createProperties(
                          PasswordPolicyState pwPolicyState,
                          boolean tempLocked, int timeToExpiration,
                          List<AttributeValue> oldPasswords,
                          List<AttributeValue> newPasswords)
                          List<ByteString> oldPasswords,
                          List<ByteString> newPasswords)
  {
    HashMap<AccountStatusNotificationProperty,List<String>> props =
         new HashMap<AccountStatusNotificationProperty,
@@ -282,29 +281,27 @@
    if ((oldPasswords != null) && (! oldPasswords.isEmpty()))
    {
      propList = new ArrayList<String>(oldPasswords.size());
      for (AttributeValue v : oldPasswords)
      {
        propList.add(v.getValue().toString());
      }
      props.put(OLD_PASSWORD, propList);
      props.put(OLD_PASSWORD, toStrings(oldPasswords));
    }
    if ((newPasswords != null) && (! newPasswords.isEmpty()))
    {
      propList = new ArrayList<String>(newPasswords.size());
      for (AttributeValue v : newPasswords)
      {
        propList.add(v.getValue().toString());
      }
      props.put(NEW_PASSWORD, propList);
      props.put(NEW_PASSWORD, toStrings(newPasswords));
    }
    return props;
  }
  private static ArrayList<String> toStrings(List<ByteString> byteStrings)
  {
    ArrayList<String> results = new ArrayList<String>(byteStrings.size());
    for (ByteString v : byteStrings)
    {
      results.add(v.toString());
    }
    return results;
  }
  /**
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Attribute.java
@@ -55,7 +55,7 @@
    mayInstantiate = false,
    mayExtend = false,
    mayInvoke = true)
public interface Attribute extends Iterable<AttributeValue>
public interface Attribute extends Iterable<ByteString>
{
  /**
@@ -69,7 +69,7 @@
   *         least one value is approximately equal to the provided
   *         value, or <CODE>false</CODE> otherwise.
   */
  ConditionResult approximatelyEqualTo(AttributeValue value);
  ConditionResult approximatelyEqualTo(ByteString value);
@@ -81,7 +81,7 @@
   * @return <CODE>true</CODE> if this attribute has the specified
   *         value, or <CODE>false</CODE> if not.
   */
  boolean contains(AttributeValue value);
  boolean contains(ByteString value);
@@ -95,7 +95,7 @@
   *         values in the provided collection, or <CODE>false</CODE>
   *         if it does not contain at least one of them.
   */
  boolean containsAll(Collection<AttributeValue> values);
  boolean containsAll(Collection<ByteString> values);
@@ -166,7 +166,7 @@
   *         least one value is greater than or equal to the provided
   *         value, or <CODE>false</CODE> otherwise.
   */
  ConditionResult greaterThanOrEqualTo(AttributeValue value);
  ConditionResult greaterThanOrEqualTo(ByteString value);
@@ -249,7 +249,7 @@
   * @return An iterator over the attribute values in this attribute.
   */
  @Override
  Iterator<AttributeValue> iterator();
  Iterator<ByteString> iterator();
@@ -264,7 +264,7 @@
   *         least one value is less than or equal to the provided
   *         value, or <CODE>false</CODE> otherwise.
   */
  ConditionResult lessThanOrEqualTo(AttributeValue value);
  ConditionResult lessThanOrEqualTo(ByteString value);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AttributeBuilder.java
@@ -32,7 +32,10 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
@@ -43,7 +46,9 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.api.SubstringMatchingRule;
@@ -59,7 +64,7 @@
 * {@link #AttributeBuilder(AttributeType)} or
 * {@link #AttributeBuilder(AttributeType, String)}. The caller is
 * then free to add new options using {@link #setOption(String)} and
 * new values using {@link #add(AttributeValue)} or
 * new values using {@link #add(ByteString)} or
 * {@link #addAll(Collection)}. Once all the options and values have
 * been added, the attribute can be retrieved using the
 * {@link #toAttribute()} method.
@@ -107,7 +112,7 @@
    mayExtend = false,
    mayInvoke = true)
public final class AttributeBuilder
  implements Iterable<AttributeValue>
  implements Iterable<ByteString>
{
  /**
@@ -125,7 +130,7 @@
    private final String name;
    // The unmodifiable set of values for this attribute.
    private final Set<AttributeValue> values;
    private final Map<ByteString, ByteString> values;
@@ -142,7 +147,7 @@
    private RealAttribute(
        AttributeType attributeType,
        String name,
        Set<AttributeValue> values)
        Map<ByteString, ByteString> values)
    {
      this.attributeType = attributeType;
      this.name = name;
@@ -154,7 +159,7 @@
     * {@inheritDoc}
     */
    @Override
    public final ConditionResult approximatelyEqualTo(AttributeValue value)
    public final ConditionResult approximatelyEqualTo(ByteString value)
    {
      MatchingRule matchingRule = attributeType.getApproximateMatchingRule();
      if (matchingRule == null)
@@ -165,7 +170,7 @@
      Assertion assertion = null;
      try
      {
        assertion = matchingRule.getAssertion(value.getValue());
        assertion = matchingRule.getAssertion(value);
      }
      catch (Exception e)
      {
@@ -174,11 +179,11 @@
      }
      ConditionResult result = ConditionResult.FALSE;
      for (AttributeValue v : values)
      for (ByteString v : values.values())
      {
        try
        {
          result = assertion.matches(matchingRule.normalizeAttributeValue(v.getValue()));
          result = assertion.matches(matchingRule.normalizeAttributeValue(v));
        }
        catch (Exception e)
        {
@@ -199,25 +204,12 @@
     * {@inheritDoc}
     */
    @Override
    public final boolean contains(AttributeValue value)
    public final boolean contains(ByteString value)
    {
      return values.contains(value);
      return values.containsKey(normalize(attributeType, value));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public final boolean containsAll(
        Collection<AttributeValue> values)
    {
      return this.values.containsAll(values);
    }
    /**
     * {@inheritDoc}
     */
@@ -244,8 +236,7 @@
     * {@inheritDoc}
     */
    @Override
    public final ConditionResult greaterThanOrEqualTo(
        AttributeValue value)
    public final ConditionResult greaterThanOrEqualTo(ByteString value)
    {
      OrderingMatchingRule matchingRule = attributeType
          .getOrderingMatchingRule();
@@ -257,7 +248,7 @@
      ByteString normalizedValue;
      try
      {
        normalizedValue = matchingRule.normalizeAttributeValue(value.getValue());
        normalizedValue = matchingRule.normalizeAttributeValue(value);
      }
      catch (Exception e)
      {
@@ -269,14 +260,12 @@
      }
      ConditionResult result = ConditionResult.FALSE;
      for (AttributeValue v : values)
      for (ByteString v : values.values())
      {
        try
        {
          ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
          int comparisonResult = matchingRule
              .compareValues(nv, normalizedValue);
          if (comparisonResult >= 0)
          ByteString nv = matchingRule.normalizeAttributeValue(v);
          if (matchingRule.compareValues(nv, normalizedValue) >= 0)
          {
            return ConditionResult.TRUE;
          }
@@ -312,9 +301,9 @@
     * {@inheritDoc}
     */
    @Override
    public final Iterator<AttributeValue> iterator()
    public final Iterator<ByteString> iterator()
    {
      return values.iterator();
      return values.values().iterator();
    }
@@ -323,8 +312,7 @@
     * {@inheritDoc}
     */
    @Override
    public final ConditionResult lessThanOrEqualTo(
        AttributeValue value)
    public final ConditionResult lessThanOrEqualTo(ByteString value)
    {
      OrderingMatchingRule matchingRule = attributeType
          .getOrderingMatchingRule();
@@ -336,7 +324,7 @@
      ByteString normalizedValue;
      try
      {
        normalizedValue = matchingRule.normalizeAttributeValue(value.getValue());
        normalizedValue = matchingRule.normalizeAttributeValue(value);
      }
      catch (Exception e)
      {
@@ -348,14 +336,12 @@
      }
      ConditionResult result = ConditionResult.FALSE;
      for (AttributeValue v : values)
      for (ByteString v : values.values())
      {
        try
        {
          ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
          int comparisonResult = matchingRule
              .compareValues(nv, normalizedValue);
          if (comparisonResult <= 0)
          ByteString nv = matchingRule.normalizeAttributeValue(v);
          if (matchingRule.compareValues(nv, normalizedValue) <= 0)
          {
            return ConditionResult.TRUE;
          }
@@ -462,13 +448,12 @@
      }
      ConditionResult result = ConditionResult.FALSE;
      for (AttributeValue value : values)
      for (ByteString value : values.values())
      {
        try
        {
          if (matchingRule.valueMatchesSubstring(
              attributeType.getSubstringMatchingRule().
                    normalizeAttributeValue(value.getValue()),
              matchingRule.normalizeAttributeValue(value),
              normalizedSubInitial,
              normalizedSubAny,
              normalizedSubFinal))
@@ -500,7 +485,17 @@
      return values.size();
    }
    /** {@inheritDoc} */
    @Override
    public int hashCode()
    {
      int hashCode = getAttributeType().hashCode();
      for (ByteString value : values.keySet())
      {
        hashCode += value.hashCode();
      }
      return hashCode;
    }
    /**
     * {@inheritDoc}
@@ -511,19 +506,7 @@
      buffer.append("Attribute(");
      buffer.append(getNameWithOptions());
      buffer.append(", {");
      boolean firstValue = true;
      for (AttributeValue value : values)
      {
        if (!firstValue)
        {
          buffer.append(", ");
        }
        value.toString(buffer);
        firstValue = false;
      }
      buffer.append(Utils.joinAsString(", ", values.keySet()));
      buffer.append("})");
    }
@@ -563,7 +546,7 @@
    private RealAttributeManyOptions(
        AttributeType attributeType,
        String name,
        Set<AttributeValue> values,
        Map<ByteString, ByteString> values,
        Set<String> options,
        SortedSet<String> normalizedOptions)
    {
@@ -630,7 +613,7 @@
    private RealAttributeNoOptions(
        AttributeType attributeType,
        String name,
        Set<AttributeValue> values)
        Map<ByteString, ByteString> values)
    {
      super(attributeType, name, values);
    }
@@ -735,7 +718,7 @@
    private RealAttributeSingleOption(
        AttributeType attributeType,
        String name,
        Set<AttributeValue> values,
        Map<ByteString, ByteString> values,
        String option)
    {
      super(attributeType, name, values);
@@ -794,7 +777,6 @@
   */
  private static final class SmallSet<T>
    extends AbstractSet<T>
    implements Set<T>
  {
    // The set of elements if there are more than one.
@@ -1065,9 +1047,11 @@
   * @return The new attribute.
   */
  static Attribute create(AttributeType attributeType, String name,
      Set<AttributeValue> values)
      Set<ByteString> values)
  {
    return new RealAttributeNoOptions(attributeType, name, values);
    final AttributeBuilder builder = new AttributeBuilder(attributeType, name);
    builder.addAll(values);
    return builder.toAttribute();
  }
@@ -1104,9 +1088,9 @@
  // The set of options.
  private final SmallSet<String> options = new SmallSet<String>();
  // The set of values for this attribute.
  private final SmallSet<AttributeValue> values =
    new SmallSet<AttributeValue>();
  /** The map of normalized values => values for this attribute. */
  private LinkedHashMap<ByteString, ByteString> values =
      new LinkedHashMap<ByteString, ByteString>();
@@ -1225,23 +1209,6 @@
   * Adds the specified attribute value to this attribute builder if
   * it is not already present.
   *
   * @param value
   *          The attribute value to be added to this attribute
   *          builder.
   * @return <code>true</code> if this attribute builder did not
   *         already contain the specified attribute value.
   */
  public boolean add(AttributeValue value)
  {
    return values.add(value);
  }
  /**
   * Adds the specified attribute value to this attribute builder if
   * it is not already present.
   *
   * @param valueString
   *          The string representation of the attribute value to be
   *          added to this attribute builder.
@@ -1250,7 +1217,7 @@
   */
  public boolean add(String valueString)
  {
    return add(AttributeValues.create(attributeType, valueString));
    return add(ByteString.valueOf(valueString));
  }
@@ -1267,7 +1234,29 @@
   */
  public boolean add(ByteString value)
  {
    return add(AttributeValues.create(attributeType, value));
    return values.put(normalize(value), value) == null;
  }
  private ByteString normalize(ByteString value)
  {
    return normalize(attributeType, value);
  }
  private static ByteString normalize(AttributeType attributeType, ByteString value)
  {
    try
    {
      if (attributeType != null)
      {
        final MatchingRule eqRule = attributeType.getEqualityMatchingRule();
        return eqRule.normalizeAttributeValue(value);
      }
    }
    catch (DecodeException e)
    {
      // nothing to do here
    }
    return value;
  }
  /**
@@ -1283,7 +1272,7 @@
  public boolean addAll(Attribute attribute)
  {
    boolean wasModified = false;
    for (AttributeValue v : attribute)
    for (ByteString v : attribute)
    {
      wasModified |= add(v);
    }
@@ -1302,9 +1291,14 @@
   * @return <code>true</code> if this attribute builder was
   *         modified.
   */
  public boolean addAll(Collection<AttributeValue> values)
  public boolean addAll(Collection<ByteString> values)
  {
    return this.values.addAll(values);
    boolean wasModified = false;
    for (ByteString v : values)
    {
      wasModified |= add(v);
    }
    return wasModified;
  }
@@ -1328,9 +1322,9 @@
   * @return <CODE>true</CODE> if this attribute builder has the
   *         specified value, or <CODE>false</CODE> if not.
   */
  public boolean contains(AttributeValue value)
  public boolean contains(ByteString value)
  {
    return values.contains(value);
    return values.containsKey(normalize(value));
  }
@@ -1346,9 +1340,16 @@
   *         <CODE>false</CODE> if it does not contain at least one
   *         of them.
   */
  public boolean containsAll(Collection<AttributeValue> values)
  public boolean containsAll(Collection<ByteString> values)
  {
    return this.values.containsAll(values);
    for (ByteString v : values)
    {
      if (!contains(v))
      {
        return false;
      }
    }
    return true;
  }
@@ -1391,9 +1392,9 @@
   *         builder.
   */
  @Override
  public Iterator<AttributeValue> iterator()
  public Iterator<ByteString> iterator()
  {
    return values.iterator();
    return values.values().iterator();
  }
@@ -1408,9 +1409,9 @@
   * @return <code>true</code> if this attribute builder contained
   *         the specified attribute value.
   */
  public boolean remove(AttributeValue value)
  public boolean remove(ByteString value)
  {
    return values.remove(value);
    return values.remove(normalize(value)) != null;
  }
@@ -1427,9 +1428,7 @@
   */
  public boolean remove(String valueString)
  {
    AttributeValue value =
        AttributeValues.create(attributeType, valueString);
    return remove(value);
    return remove(ByteString.valueOf(valueString));
  }
@@ -1447,7 +1446,7 @@
  public boolean removeAll(Attribute attribute)
  {
    boolean wasModified = false;
    for (AttributeValue v : attribute)
    for (ByteString v : attribute)
    {
      wasModified |= remove(v);
    }
@@ -1466,9 +1465,14 @@
   * @return <code>true</code> if this attribute builder was
   *         modified.
   */
  public boolean removeAll(Collection<AttributeValue> values)
  public boolean removeAll(Collection<ByteString> values)
  {
    return this.values.removeAll(values);
    boolean wasModified = false;
    for (ByteString v : values)
    {
      wasModified |= remove(v);
    }
    return wasModified;
  }
@@ -1480,7 +1484,7 @@
   * @param value
   *          The attribute value to replace all existing values.
   */
  public void replace(AttributeValue value)
  public void replace(ByteString value)
  {
    clear();
    add(value);
@@ -1498,9 +1502,7 @@
   */
  public void replace(String valueString)
  {
    AttributeValue value =
        AttributeValues.create(attributeType, valueString);
    replace(value);
    replace(ByteString.valueOf(valueString));
  }
@@ -1528,7 +1530,7 @@
   * @param values
   *          The attribute values to replace all existing values.
   */
  public void replaceAll(Collection<AttributeValue> values)
  public void replaceAll(Collection<ByteString> values)
  {
    clear();
    addAll(values);
@@ -1609,7 +1611,7 @@
  public AttributeBuilder setInitialCapacity(int initialCapacity)
      throws IllegalStateException
  {
    values.setInitialCapacity(initialCapacity);
    // This is now a no op.
    return this;
  }
@@ -1761,18 +1763,22 @@
    // First determine the minimum representation required for the set
    // of values.
    Set<AttributeValue> newValues;
    if (values.elements != null)
    final int size = values.size();
    Map<ByteString, ByteString> newValues;
    if (size == 0)
    {
      newValues = Collections.unmodifiableSet(values.elements);
      newValues = Collections.emptyMap();
    }
    else if (values.firstElement != null)
    else if (size == 1)
    {
      newValues = Collections.singleton(values.firstElement);
      Entry<ByteString, ByteString> entry = values.entrySet().iterator().next();
      newValues = Collections.singletonMap(entry.getKey(), entry.getValue());
      values.clear();
    }
    else
    {
      newValues = Collections.emptySet();
      newValues = Collections.unmodifiableMap(values);
      values = new LinkedHashMap<ByteString, ByteString>();
    }
    // Now create the appropriate attribute based on the options.
@@ -1780,8 +1786,7 @@
    switch (options.size())
    {
    case 0:
      attribute =
        new RealAttributeNoOptions(attributeType, name, newValues);
      attribute = new RealAttributeNoOptions(attributeType, name, newValues);
      break;
    case 1:
      attribute =
@@ -1801,7 +1806,6 @@
    name = null;
    normalizedOptions = null;
    options.clear();
    values.clear();
    return attribute;
  }
@@ -1817,7 +1821,7 @@
    StringBuilder builder = new StringBuilder();
    builder.append("AttributeBuilder(");
    builder.append(String.valueOf(name));
    builder.append(name);
    for (String option : options)
    {
@@ -1826,19 +1830,7 @@
    }
    builder.append(", {");
    boolean firstValue = true;
    for (AttributeValue value : values)
    {
      if (!firstValue)
      {
        builder.append(", ");
      }
      value.toString(builder);
      firstValue = false;
    }
    builder.append(Utils.joinAsString(", ", values.keySet()));
    builder.append("})");
    return builder.toString();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AttributeParser.java
@@ -120,7 +120,7 @@
     */
    public <T> T as(final Function<ByteString, ? extends T, Void> f, final T defaultValue) {
        if (!isEmpty(attribute)) {
            return f.apply(attribute.iterator().next().getValue(), null);
            return f.apply(attribute.iterator().next(), null);
        } else {
            return defaultValue;
        }
@@ -255,8 +255,8 @@
            final Collection<? extends T> defaultValues) {
        if (!isEmpty(attribute)) {
            final LinkedHashSet<T> result = new LinkedHashSet<T>(attribute.size());
            for (final AttributeValue v : attribute) {
                result.add(f.apply(v.getValue(), null));
            for (final ByteString v : attribute) {
                result.add(f.apply(v, null));
            }
            return result;
        } else if (defaultValues != null) {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AttributeValue.java
File was deleted
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AttributeValueIterable.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.types;
@@ -29,7 +30,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.forgerock.opendj.ldap.ByteString;
/**
 * An iterable read-only view of of a set of attribute values returned
@@ -45,8 +46,7 @@
     mayInstantiate=false,
     mayExtend=false,
     mayInvoke=true)
public final class AttributeValueIterable implements
    Iterable<AttributeValue> {
public final class AttributeValueIterable implements Iterable<ByteString> {
  // The set of attributes having the same type and options.
  private Iterable<Attribute> attributes;
@@ -90,16 +90,14 @@
   * @return  An iterator that can be used to cursor through the set
   *          of attribute values.
   */
  public Iterator<AttributeValue> iterator() {
  public Iterator<ByteString> iterator() {
    return new AttributeValueIterator();
  }
  /**
   * Private iterator implementation.
   */
  private class AttributeValueIterator
          implements Iterator<AttributeValue> {
  private class AttributeValueIterator implements Iterator<ByteString> {
    // Flag indicating whether iteration can proceed.
    private boolean hasNext;
@@ -107,7 +105,7 @@
    private Iterator<Attribute> attributeIterator;
    // The current value iterator.
    private Iterator<AttributeValue> valueIterator;
    private Iterator<ByteString> valueIterator;
    /**
     * Create a new attribute value iterator over the attribute set.
@@ -132,7 +130,6 @@
     *          return, or {@code false} if not.
     */
    public boolean hasNext() {
      return hasNext;
    }
@@ -144,14 +141,13 @@
     * @throws  NoSuchElementException  If there are no more values to
     *                                  return.
     */
    public AttributeValue next()
           throws NoSuchElementException
    public ByteString next() throws NoSuchElementException
    {
      if (hasNext == false) {
        throw new NoSuchElementException();
      }
      AttributeValue value = valueIterator.next();
      ByteString value = valueIterator.next();
      // We've reached the end of this array list, so skip to the next
      // non-empty one.
@@ -170,8 +166,7 @@
     * @throws  UnsupportedOperationException  If the last value
     *                                         cannot be removed.
     */
    public void remove()
           throws UnsupportedOperationException
    public void remove() throws UnsupportedOperationException
    {
      throw new UnsupportedOperationException();
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/AttributeValues.java
File was deleted
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Attributes.java
@@ -26,14 +26,13 @@
 */
package org.opends.server.types;
import static org.opends.server.util.StaticUtils.*;
import java.util.Collection;
import java.util.Collections;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class contains various methods for manipulating
@@ -70,8 +69,7 @@
   *          The attribute value.
   * @return A new attribute with the attribute type and value.
   */
  public static Attribute create(AttributeType attributeType,
      AttributeValue value)
  public static Attribute create(AttributeType attributeType, ByteString value)
  {
    return create(attributeType, attributeType.getNameOrOID(), value);
  }
@@ -110,7 +108,7 @@
   * @return A new attribute with the attribute type and value.
   */
  public static Attribute create(AttributeType attributeType,
      String name, AttributeValue value)
      String name, ByteString value)
  {
    return AttributeBuilder.create(attributeType, name, Collections
        .singleton(value));
@@ -133,8 +131,7 @@
  public static Attribute create(AttributeType attributeType,
      String name, String valueString)
  {
    AttributeValue value = AttributeValues.create(attributeType,
        valueString);
    ByteString value = ByteString.valueOf(valueString);
    return create(attributeType, name, value);
  }
@@ -253,7 +250,7 @@
      String name)
  {
    return AttributeBuilder.create(attributeType, name, Collections
        .<AttributeValue> emptySet());
        .<ByteString> emptySet());
  }
@@ -320,10 +317,10 @@
   *         provided attributes.
   */
  public static Attribute merge(Attribute a1, Attribute a2,
      Collection<AttributeValue> duplicateValues)
      Collection<ByteString> duplicateValues)
  {
    AttributeBuilder builder = new AttributeBuilder(a1);
    for (AttributeValue av : a2)
    for (ByteString av : a2)
    {
      if (!builder.add(av) && duplicateValues != null)
      {
@@ -381,10 +378,10 @@
   *         attribute which are not in the second attribute.
   */
  public static Attribute subtract(Attribute a1, Attribute a2,
      Collection<AttributeValue> missingValues)
      Collection<ByteString> missingValues)
  {
    AttributeBuilder builder = new AttributeBuilder(a1);
    for (AttributeValue av : a2)
    for (ByteString av : a2)
    {
      if (!builder.remove(av) && missingValues != null)
      {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/CollectiveVirtualAttribute.java
@@ -58,7 +58,7 @@
   * {@inheritDoc}
   */
  @Override
  public ConditionResult approximatelyEqualTo(AttributeValue value) {
  public ConditionResult approximatelyEqualTo(ByteString value) {
    return attribute.approximatelyEqualTo(value);
  }
@@ -66,7 +66,7 @@
   * {@inheritDoc}
   */
  @Override
  public boolean contains(AttributeValue value) {
  public boolean contains(ByteString value) {
    return attribute.contains(value);
  }
@@ -90,7 +90,7 @@
   * {@inheritDoc}
   */
  @Override
  public ConditionResult greaterThanOrEqualTo(AttributeValue value) {
  public ConditionResult greaterThanOrEqualTo(ByteString value) {
    return attribute.greaterThanOrEqualTo(value);
  }
@@ -106,7 +106,7 @@
   * {@inheritDoc}
   */
  @Override
  public Iterator<AttributeValue> iterator() {
  public Iterator<ByteString> iterator() {
    return attribute.iterator();
  }
@@ -114,7 +114,7 @@
   * {@inheritDoc}
   */
  @Override
  public ConditionResult lessThanOrEqualTo(AttributeValue value) {
  public ConditionResult lessThanOrEqualTo(ByteString value) {
    return attribute.lessThanOrEqualTo(value);
  }
@@ -135,6 +135,13 @@
    return attribute.size();
  }
  /** {@inheritDoc} */
  @Override
  public int hashCode()
  {
    return attribute.hashCode();
  }
  /**
   * {@inheritDoc}
   */
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/DN.java
@@ -635,11 +635,8 @@
              attributeNameString);
        }
        AttributeValue value =
            AttributeValues.create(ByteString.empty(),
                               ByteString.empty());
        rdnComponents.add(
            new RDN(attrType, attributeNameString, value));
            new RDN(attrType, attributeNameString, ByteString.empty()));
        return new DN(rdnComponents);
      }
@@ -666,9 +663,7 @@
            attributeNameString);
      }
      AttributeValue value =
           AttributeValues.create(attrType, parsedValue);
      RDN rdn = new RDN(attrType, attributeNameString, value);
      RDN rdn = new RDN(attrType, attributeNameString, parsedValue);
      // Skip over any spaces that might be after the attribute value.
@@ -788,9 +783,7 @@
                attributeNameString);
          }
          value = AttributeValues.create(ByteString.empty(),
                                     ByteString.empty());
          rdn.addValue(attrType, attributeNameString, value);
          rdn.addValue(attrType, attributeNameString, ByteString.empty());
          rdnComponents.add(rdn);
          return new DN(rdnComponents);
        }
@@ -817,8 +810,7 @@
              attributeNameString);
        }
        value = AttributeValues.create(attrType, parsedValue);
        rdn.addValue(attrType, attributeNameString, value);
        rdn.addValue(attrType, attributeNameString, parsedValue);
        // Skip over any spaces that might be after the attribute
@@ -995,10 +987,7 @@
          attrType = DirectoryServer.getDefaultAttributeType(name);
        }
        AttributeValue value =
            AttributeValues.create(ByteString.empty(),
                                ByteString.empty());
        rdnComponents.add(new RDN(attrType, name, value));
        rdnComponents.add(new RDN(attrType, name, ByteString.empty()));
        return new DN(rdnComponents);
      }
@@ -1023,10 +1012,7 @@
        attrType = DirectoryServer.getDefaultAttributeType(name);
      }
      AttributeValue value =
          AttributeValues.create(attrType,
              parsedValue.toByteString());
      RDN rdn = new RDN(attrType, name, value);
      RDN rdn = new RDN(attrType, name, parsedValue.toByteString());
      // Skip over any spaces that might be after the attribute value.
@@ -1157,9 +1143,7 @@
            attrType = DirectoryServer.getDefaultAttributeType(name);
          }
          value = AttributeValues.create(ByteString.empty(),
                                     ByteString.empty());
          rdn.addValue(attrType, name, value);
          rdn.addValue(attrType, name, ByteString.empty());
          rdnComponents.add(rdn);
          return new DN(rdnComponents);
        }
@@ -1184,9 +1168,7 @@
          attrType = DirectoryServer.getDefaultAttributeType(name);
        }
        value = AttributeValues.create(attrType,
            parsedValue.toByteString());
        rdn.addValue(attrType, name, value);
        rdn.addValue(attrType, name, parsedValue.toByteString());
        // Skip over any spaces that might be after the attribute
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Entry.java
@@ -370,18 +370,11 @@
    if(objectClassAttribute == null)
    {
      AttributeType ocType =
          DirectoryServer.getObjectClassAttributeType();
      AttributeBuilder builder =
          new AttributeBuilder(ocType, ATTR_OBJECTCLASS);
      for (Map.Entry<ObjectClass, String> e :
          objectClasses.entrySet())
      AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
      AttributeBuilder builder = new AttributeBuilder(ocType, ATTR_OBJECTCLASS);
      for (Map.Entry<ObjectClass, String> e : objectClasses.entrySet())
      {
        builder.add(AttributeValues.create(
            ByteString.valueOf(e.getValue()),
            ByteString.valueOf(e.getKey()
                .getNormalizedPrimaryName())));
        builder.add(e.getValue());
      }
      objectClassAttribute = builder.toAttribute();
@@ -1175,8 +1168,7 @@
   * @param duplicateValues
   *          A list to which any duplicate values will be added.
   */
  public void addAttribute(Attribute attribute,
      List<AttributeValue> duplicateValues)
  public void addAttribute(Attribute attribute, List<ByteString> duplicateValues)
  {
    setAttribute(attribute, duplicateValues, false /* merge */);
  }
@@ -1235,7 +1227,7 @@
    }
    // Decode the increment.
    Iterator<AttributeValue> i = attribute.iterator();
    Iterator<ByteString> i = attribute.iterator();
    if (!i.hasNext())
    {
      LocalizableMessage message = ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT.get(
@@ -1243,7 +1235,7 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    String incrementValue = i.next().getValue().toString();
    String incrementValue = i.next().toString();
    long increment;
    try
    {
@@ -1266,13 +1258,12 @@
    // Increment each attribute value by the specified amount.
    AttributeBuilder builder = new AttributeBuilder(a, true);
    for (AttributeValue v : a)
    for (ByteString v : a)
    {
      String s = v.getValue().toString();
      long currentValue;
      try
      {
        currentValue = Long.parseLong(s);
        currentValue = Long.parseLong(v.toString());
      }
      catch (NumberFormatException e)
      {
@@ -1283,8 +1274,7 @@
      }
      long newValue = currentValue + increment;
      builder.add(AttributeValues.create(attributeType, String
          .valueOf(newValue)));
      builder.add(String.valueOf(newValue));
    }
    replaceAttribute(builder.toAttribute());
@@ -1347,7 +1337,7 @@
   *         but will add those values to the provided list.
   */
  public boolean removeAttribute(Attribute attribute,
      List<AttributeValue> missingValues)
      List<ByteString> missingValues)
  {
    attachment = null;
@@ -1363,9 +1353,9 @@
      MatchingRule rule =
          attribute.getAttributeType().getEqualityMatchingRule();
      for (AttributeValue v : attribute)
      for (ByteString v : attribute)
      {
        String ocName = toLowerName(rule, v.getValue());
        String ocName = toLowerName(rule, v);
        boolean matchFound = false;
        for (ObjectClass oc : objectClasses.keySet())
@@ -1393,7 +1383,7 @@
    if (attributes == null)
    {
      // There are no attributes with the same attribute type.
      for (AttributeValue v : attribute)
      for (ByteString v : attribute)
      {
        missingValues.add(v);
      }
@@ -1416,7 +1406,7 @@
        {
          // Remove Specified values.
          AttributeBuilder builder = new AttributeBuilder(a);
          for (AttributeValue v : attribute)
          for (ByteString v : attribute)
          {
            if (!builder.remove(v))
            {
@@ -1475,7 +1465,7 @@
   *          attribute value, or <CODE>false</CODE> if it does not.
   */
  public boolean hasValue(AttributeType attributeType,
                          Set<String> options, AttributeValue value)
                          Set<String> options, ByteString value)
  {
    List<Attribute> attrList = getAttribute(attributeType, true);
    if (attrList == null || attrList.isEmpty())
@@ -1522,9 +1512,9 @@
    if (t.isObjectClass())
    {
      Map<ObjectClass, String> ocs = new LinkedHashMap<ObjectClass, String>();
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        String ocName    = v.getValue().toString();
        String ocName    = v.toString();
        String lowerName = toLowerCase(ocName);
        ObjectClass oc   =
             DirectoryServer.getObjectClass(lowerName, true);
@@ -1584,7 +1574,7 @@
    switch (mod.getModificationType().asEnum())
    {
      case ADD:
        List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
        List<ByteString> duplicateValues = new LinkedList<ByteString>();
        addAttribute(a, duplicateValues);
        if (!duplicateValues.isEmpty() && !relaxConstraints)
        {
@@ -1594,7 +1584,7 @@
        break;
      case DELETE:
        List<AttributeValue> missingValues = new LinkedList<AttributeValue>();
        List<ByteString> missingValues = new LinkedList<ByteString>();
        removeAttribute(a, missingValues);
        if (!missingValues.isEmpty() && !relaxConstraints)
        {
@@ -2792,9 +2782,9 @@
    Set<String> referralURLs = new LinkedHashSet<String>();
    for (Attribute a : refAttrs)
    {
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        referralURLs.add(v.getValue().toString());
        referralURLs.add(v.toString());
      }
    }
@@ -2867,7 +2857,7 @@
      Attribute aliasAttr = aliasAttrs.get(0);
      if (!aliasAttr.isEmpty())
      {
        return DN.valueOf(aliasAttr.iterator().next().getValue().toString());
        return DN.valueOf(aliasAttr.iterator().next().toString());
      }
    }
    return null;
@@ -3072,7 +3062,7 @@
    {
      for (Attribute attr : exclusionsAttrList)
      {
        for (AttributeValue attrValue : attr)
        for (ByteString attrValue : attr)
        {
          String exclusionsName = attrValue.toString().toLowerCase();
          if (VALUE_COLLECTIVE_EXCLUSIONS_EXCLUDE_ALL_LC.equals(exclusionsName)
@@ -3102,9 +3092,9 @@
              for (Attribute attr : getAttribute(
                   subEntry.getInheritFromDNType()))
              {
                for (AttributeValue value : attr)
                for (ByteString value : attr)
                {
                  inheritFromDN = DN.decode(value.getValue());
                  inheritFromDN = DN.decode(value);
                  // Respect subentry root scope.
                  if (!inheritFromDN.isDescendantOf(
                       subEntry.getDN().parent()))
@@ -3139,7 +3129,7 @@
                   subEntry.getInheritFromRDNAttrType()))
                {
                  inheritFromDN = subEntry.getInheritFromBaseDN();
                  for (AttributeValue value : attr)
                  for (ByteString value : attr)
                  {
                    inheritFromDN = inheritFromDN.child(
                        RDN.create(subEntry.getInheritFromRDNType(),
@@ -3533,10 +3523,10 @@
          buffer.append((byte)0x00);
          buffer.appendBERLength(a.size());
          for(AttributeValue v : a)
          for(ByteString v : a)
          {
            buffer.appendBERLength(v.getValue().length());
            buffer.append(v.getValue());
            buffer.appendBERLength(v.length());
            buffer.append(v);
          }
        }
      }
@@ -3866,7 +3856,7 @@
          ByteString valueBytes =
              entryBuffer.getByteSequence(valueLength).toByteString();
          builder.add(AttributeValues.create(attributeType, valueBytes));
          builder.add(valueBytes);
        }
@@ -3939,10 +3929,10 @@
          attrName.append(o);
        }
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          StringBuilder attrLine = new StringBuilder(attrName);
          appendLDIFSeparatorAndValue(attrLine, v.getValue());
          appendLDIFSeparatorAndValue(attrLine, v);
          ldifLines.add(attrLine);
        }
      }
@@ -4182,10 +4172,10 @@
    }
    else
    {
      for (AttributeValue v : attribute)
      for (ByteString v : attribute)
      {
        StringBuilder attrLine = new StringBuilder(attrName);
        appendLDIFSeparatorAndValue(attrLine, v.getValue());
        appendLDIFSeparatorAndValue(attrLine, v);
        LDIFWriter.writeLDIFLine(attrLine, writer, wrapLines, wrapColumn);
      }
    }
@@ -4461,15 +4451,15 @@
        }
        buffer.append("={");
        Iterator<AttributeValue> valueIterator = a.iterator();
        Iterator<ByteString> valueIterator = a.iterator();
        if (valueIterator.hasNext())
        {
          buffer.append(valueIterator.next().getValue().toString());
          buffer.append(valueIterator.next().toString());
          while (valueIterator.hasNext())
          {
            buffer.append(",");
            buffer.append(valueIterator.next().getValue().toString());
            buffer.append(valueIterator.next().toString());
          }
        }
@@ -4529,7 +4519,7 @@
   *          existing attribute.
   */
  private void setAttribute(Attribute attribute,
      List<AttributeValue> duplicateValues, boolean replace)
      List<ByteString> duplicateValues, boolean replace)
  {
    attachment = null;
@@ -4546,10 +4536,10 @@
      MatchingRule rule =
          attribute.getAttributeType().getEqualityMatchingRule();
      for (AttributeValue v : attribute)
      for (ByteString v : attribute)
      {
        String name = v.getValue().toString();
        String lowerName = toLowerName(rule, v.getValue());
        String name = v.toString();
        String lowerName = toLowerName(rule, v);
        // Create a default object class if necessary.
        ObjectClass oc =
@@ -4615,7 +4605,7 @@
        else
        {
          AttributeBuilder builder = new AttributeBuilder(a);
          for (AttributeValue v : attribute)
          for (ByteString v : attribute)
          {
            if (!builder.add(v))
            {
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/RDN.java
@@ -60,7 +60,7 @@
  private AttributeType[] attributeTypes;
  /** The set of values for the elements in this RDN. */
  private AttributeValue[] attributeValues;
  private ByteString[] attributeValues;
  /** The number of values for this RDN. */
  private int numValues;
@@ -85,11 +85,11 @@
   *                         {@code null}.
   */
  public RDN(AttributeType attributeType,
             AttributeValue attributeValue)
             ByteString attributeValue)
  {
    attributeTypes  = new AttributeType[] { attributeType };
    attributeNames  = new String[] { attributeType.getPrimaryName() };
    attributeValues = new AttributeValue[] { attributeValue };
    attributeValues = new ByteString[] { attributeValue };
    numValues     = 1;
    rdnString     = null;
@@ -109,11 +109,11 @@
   *                         {@code null}.
   */
  public RDN(AttributeType attributeType, String attributeName,
             AttributeValue attributeValue)
             ByteString attributeValue)
  {
    attributeTypes  = new AttributeType[] { attributeType };
    attributeNames  = new String[] { attributeName };
    attributeValues = new AttributeValue[] { attributeValue };
    attributeValues = new ByteString[] { attributeValue };
    numValues     = 1;
    rdnString     = null;
@@ -138,11 +138,11 @@
   */
  public RDN(List<AttributeType> attributeTypes,
             List<String> attributeNames,
             List<AttributeValue> attributeValues)
             List<ByteString> attributeValues)
  {
    this.attributeTypes  = new AttributeType[attributeTypes.size()];
    this.attributeNames  = new String[attributeNames.size()];
    this.attributeValues = new AttributeValue[attributeValues.size()];
    this.attributeValues = new ByteString[attributeValues.size()];
    attributeTypes.toArray(this.attributeTypes);
    attributeNames.toArray(this.attributeNames);
@@ -170,7 +170,7 @@
   *                          {@code attributeTypes} argument.
   */
  public RDN(AttributeType[] attributeTypes, String[] attributeNames,
             AttributeValue[] attributeValues)
             ByteString[] attributeValues)
  {
    this.numValues       = attributeTypes.length;
    this.attributeTypes  = attributeTypes;
@@ -193,8 +193,7 @@
   *
   * @return  The RDN created with the provided information.
   */
  public static RDN create(AttributeType attributeType,
                           AttributeValue attributeValue)
  public static RDN create(AttributeType attributeType, ByteString attributeValue)
  {
    return new RDN(attributeType, attributeValue);
  }
@@ -316,7 +315,7 @@
   *          <CODE>null</CODE> if the specified attribute type is not
   *          present in the RDN.
   */
  public AttributeValue getAttributeValue(AttributeType attributeType)
  public ByteString getAttributeValue(AttributeType attributeType)
  {
    for (int i=0; i < numValues; i++)
    {
@@ -341,7 +340,7 @@
   * @return  The value for the attribute type at the specified
   *          position in the set of attribute types for this RDN.
   */
  public AttributeValue getAttributeValue(int pos)
  public ByteString getAttributeValue(int pos)
  {
    return attributeValues[pos];
  }
@@ -372,7 +371,7 @@
   * @return  <CODE>true</CODE> if this RDN contains the specified
   *          attribute value, or <CODE>false</CODE> if not.
   */
  public boolean hasValue(AttributeType type, AttributeValue value)
  public boolean hasValue(AttributeType type, ByteString value)
  {
    for (int i=0; i < numValues; i++)
    {
@@ -400,7 +399,7 @@
   *          this RDN, or <CODE>false</CODE> if it was not (e.g., it
   *          was already present).
   */
  boolean addValue(AttributeType type, String name, AttributeValue value)
  boolean addValue(AttributeType type, String name, ByteString value)
  {
    for (int i=0; i < numValues; i++)
    {
@@ -423,7 +422,7 @@
    newNames[attributeNames.length] = name;
    attributeNames = newNames;
    AttributeValue[] newValues = new AttributeValue[numValues];
    ByteString[] newValues = new ByteString[numValues];
    System.arraycopy(attributeValues, 0, newValues, 0, attributeValues.length);
    newValues[attributeValues.length] = value;
    attributeValues = newValues;
@@ -679,9 +678,7 @@
      attrType = DirectoryServer.getDefaultAttributeType(name);
    }
    AttributeValue value = AttributeValues.create(attrType,
        parsedValue.toByteString());
    RDN rdn = new RDN(attrType, name, value);
    RDN rdn = new RDN(attrType, name, parsedValue.toByteString());
    // Skip over any spaces that might be after the attribute value.
@@ -801,8 +798,7 @@
          attrType = DirectoryServer.getDefaultAttributeType(name);
        }
        value = AttributeValues.create(ByteString.empty(), ByteString.empty());
        rdn.addValue(attrType, name, value);
        rdn.addValue(attrType, name, ByteString.empty());
        return rdn;
      }
@@ -826,8 +822,7 @@
        attrType = DirectoryServer.getDefaultAttributeType(name);
      }
      value = AttributeValues.create(attrType, parsedValue.toByteString());
      rdn.addValue(attrType, name, value);
      rdn.addValue(attrType, name, parsedValue.toByteString());
      // Skip over any spaces that might be after the attribute value.
@@ -879,7 +874,7 @@
    String[] newNames = new String[numValues];
    System.arraycopy(attributeNames, 0, newNames, 0, numValues);
    AttributeValue[] newValues = new AttributeValue[numValues];
    ByteString[] newValues = new ByteString[numValues];
    System.arraycopy(attributeValues, 0, newValues, 0, numValues);
    return new RDN(newTypes, newNames, newValues);
@@ -946,14 +941,14 @@
      buffer.append(attributeNames[0]);
      buffer.append("=");
      buffer.append(getDNValue(attributeValues[0].getValue()));
      buffer.append(getDNValue(attributeValues[0]));
      for (int i=1; i < numValues; i++)
      {
        buffer.append("+");
        buffer.append(attributeNames[i]);
        buffer.append("=");
        buffer.append(getDNValue(attributeValues[i].getValue()));
        buffer.append(getDNValue(attributeValues[i]));
      }
      rdnString = buffer.toString();
@@ -1056,17 +1051,17 @@
      buffer.append(type.getNormalizedPrimaryNameOrOID());
      buffer.append('=');
      AttributeValue value = attributeValues[pos];
      ByteString value = attributeValues[pos];
      try
      {
        MatchingRule rule = type.getEqualityMatchingRule();
        ByteString normValue = rule.normalizeAttributeValue(value.getValue());
        ByteString normValue = rule.normalizeAttributeValue(value);
        buffer.append(getDNValue(normValue));
      }
      catch (Exception e)
      {
        logger.traceException(e);
        buffer.append(getDNValue(value.getValue()));
        buffer.append(getDNValue(value));
      }
  }
@@ -1109,8 +1104,7 @@
    TreeMap<String,AttributeType> typeMap1 =
         new TreeMap<String,AttributeType>();
    TreeMap<String,AttributeValue> valueMap1 =
         new TreeMap<String,AttributeValue>();
    TreeMap<String, ByteString> valueMap1 = new TreeMap<String, ByteString>();
    for (int i=0; i < attributeTypes.length; i++)
    {
      String lowerName = attributeTypes[i].getNormalizedPrimaryNameOrOID();
@@ -1120,8 +1114,7 @@
    TreeMap<String,AttributeType> typeMap2 =
         new TreeMap<String,AttributeType>();
    TreeMap<String,AttributeValue> valueMap2 =
         new TreeMap<String,AttributeValue>();
    TreeMap<String, ByteString> valueMap2 = new TreeMap<String, ByteString>();
    for (int i=0; i < rdn.attributeTypes.length; i++)
    {
      String lowerName = rdn.attributeTypes[i].getNormalizedPrimaryNameOrOID();
@@ -1135,8 +1128,8 @@
    String           name2     = iterator2.next();
    AttributeType    type1     = typeMap1.get(name1);
    AttributeType    type2     = typeMap2.get(name2);
    AttributeValue   value1    = valueMap1.get(name1);
    AttributeValue   value2    = valueMap2.get(name2);
    ByteString       value1    = valueMap1.get(name1);
    ByteString       value2    = valueMap2.get(name2);
    while (true)
    {
@@ -1189,8 +1182,7 @@
   *         positive integer if value1 should come after value2, or zero if
   *         there is no difference with regard to ordering.
   */
  private int compare(AttributeValue value1, AttributeValue value2,
      AttributeType type)
  private int compare(ByteString value1, ByteString value2, AttributeType type)
  {
    final OrderingMatchingRule omr = type.getOrderingMatchingRule();
    final MatchingRule emr = type.getEqualityMatchingRule();
@@ -1200,14 +1192,14 @@
    try
    {
      final MatchingRule rule = omr != null ? omr : emr;
      val1 = rule.normalizeAttributeValue(value1.getValue());
      val2 = rule.normalizeAttributeValue(value2.getValue());
      val1 = rule.normalizeAttributeValue(value1);
      val2 = rule.normalizeAttributeValue(value2);
    }
    catch (DecodeException e)
    {
      logger.traceException(e);
      val1 = value1.getValue();
      val2 = value2.getValue();
      val1 = value1;
      val2 = value2;
    }
    if (omr != null)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
@@ -2517,7 +2517,7 @@
    {
      if (!newElements.contains(s))
      {
        builder.add(AttributeValues.create(attributeTypesType, s));
        builder.add(s);
      }
    }
@@ -2532,7 +2532,7 @@
    {
      if (!oldElements.contains(s))
      {
        builder.add(AttributeValues.create(attributeTypesType, s));
        builder.add(s);
      }
    }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
@@ -70,7 +70,8 @@
  private final AttributeType attributeType;
  // The assertion value for this filter.
  private final AttributeValue assertionValue;
  private final ByteString assertionValue;
  private ByteString normalizedAssertionValue;
  // Indicates whether to match on DN attributes for extensible match
  // filters.
@@ -133,7 +134,7 @@
                      SearchFilter notComponent,
                      AttributeType attributeType,
                      Set<String> attributeOptions,
                      AttributeValue assertionValue,
                      ByteString assertionValue,
                      ByteString subInitialElement,
                      List<ByteString> subAnyElements,
                      ByteString subFinalElement,
@@ -232,7 +233,7 @@
   */
  public static SearchFilter createEqualityFilter(
                                  AttributeType attributeType,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.EQUALITY, null, null,
                            attributeType, null, assertionValue, null,
@@ -257,7 +258,7 @@
  public static SearchFilter createEqualityFilter(
                                  AttributeType attributeType,
                                  Set<String> attributeOptions,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.EQUALITY, null, null,
                            attributeType, attributeOptions,
@@ -339,7 +340,7 @@
   */
  public static SearchFilter createGreaterOrEqualFilter(
                                  AttributeType attributeType,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.GREATER_OR_EQUAL, null, null,
                            attributeType, null, assertionValue, null,
@@ -364,7 +365,7 @@
  public static SearchFilter createGreaterOrEqualFilter(
                                  AttributeType attributeType,
                                  Set<String> attributeOptions,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.GREATER_OR_EQUAL, null, null,
                            attributeType, attributeOptions,
@@ -387,7 +388,7 @@
   */
  public static SearchFilter createLessOrEqualFilter(
                                  AttributeType attributeType,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.LESS_OR_EQUAL, null, null,
                            attributeType, null, assertionValue, null,
@@ -412,7 +413,7 @@
  public static SearchFilter createLessOrEqualFilter(
                                  AttributeType attributeType,
                                  Set<String> attributeOptions,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.LESS_OR_EQUAL, null, null,
                            attributeType, attributeOptions,
@@ -474,7 +475,7 @@
   */
  public static SearchFilter createApproximateFilter(
                                  AttributeType attributeType,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.APPROXIMATE_MATCH, null, null,
                            attributeType, null, assertionValue, null,
@@ -499,7 +500,7 @@
  public static SearchFilter createApproximateFilter(
                                  AttributeType attributeType,
                                  Set<String> attributeOptions,
                                  AttributeValue assertionValue)
                                  ByteString assertionValue)
  {
    return new SearchFilter(FilterType.APPROXIMATE_MATCH, null, null,
                            attributeType, attributeOptions,
@@ -530,7 +531,7 @@
   */
  public static SearchFilter createExtensibleMatchFilter(
                                  AttributeType attributeType,
                                  AttributeValue assertionValue,
                                  ByteString assertionValue,
                                  String matchingRuleID,
                                  boolean dnAttributes)
         throws DirectoryException
@@ -575,7 +576,7 @@
  public static SearchFilter createExtensibleMatchFilter(
                                  AttributeType attributeType,
                                  Set<String> attributeOptions,
                                  AttributeValue assertionValue,
                                  ByteString assertionValue,
                                  String matchingRuleID,
                                  boolean dnAttributes)
         throws DirectoryException
@@ -815,9 +816,7 @@
    if (valueStr.length() == 0)
    {
      return new SearchFilter(filterType, null, null, attributeType,
                    attributeOptions,
          AttributeValues.create(ByteString.empty(),
                                       ByteString.empty()),
                    attributeOptions, ByteString.empty(),
                    null, null, null, null, false);
    }
    else if (valueStr.equals("*"))
@@ -1007,10 +1006,8 @@
        userValue = ByteString.wrap(valueBytes);
      }
      AttributeValue value =
          AttributeValues.create(attributeType, userValue);
      return new SearchFilter(filterType, null, null, attributeType,
                              attributeOptions, value, null, null,
                              attributeOptions, userValue, null, null,
                              null, null, false);
    }
  }
@@ -2063,52 +2060,24 @@
    // Make sure that the filter contains at least one of an attribute
    // type or a matching rule ID.  Also, construct the appropriate
    // attribute  value.
    AttributeValue value;
    if (attributeType == null)
    {
      if (matchingRuleID == null)
      {
        LocalizableMessage message =
            ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR.
              get(filterString, startPos);
        throw new DirectoryException(ResultCode.PROTOCOL_ERROR,
                                     message);
            ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR.get(filterString, startPos));
      }
      else
      MatchingRule mr = DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID));
      if (mr == null)
      {
        MatchingRule mr = DirectoryServer.getMatchingRule(
                               toLowerCase(matchingRuleID));
        if (mr == null)
        {
          LocalizableMessage message =
              ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_SUCH_MR.
                get(filterString, startPos, matchingRuleID);
          throw new DirectoryException(ResultCode.PROTOCOL_ERROR,
                                       message);
        }
        else
        {
          try
          {
            value = AttributeValues.create(
                userValue, mr.normalizeAttributeValue(userValue));
          }
          catch (DecodeException e)
          {
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                e.getMessageObject(), e);
          }
        }
        throw new DirectoryException(ResultCode.PROTOCOL_ERROR,
            ERR_SEARCH_FILTER_EXTENSIBLE_MATCH_NO_SUCH_MR.get(filterString, startPos, matchingRuleID));
      }
    }
    else
    {
      value = AttributeValues.create(attributeType,
          userValue);
    }
    return new SearchFilter(FilterType.EXTENSIBLE_MATCH, null, null,
                            attributeType, attributeOptions, value,
                            attributeType, attributeOptions, userValue,
                            null, null, null, matchingRuleID,
                            dnAttributes);
  }
@@ -2172,11 +2141,45 @@
   * @return  The assertion value for this filter, or
   *          <CODE>null</CODE> if there is none.
   */
  public AttributeValue getAssertionValue()
  public ByteString getAssertionValue()
  {
    return assertionValue;
  }
  private ByteString getNormalizedAssertionValue() throws DecodeException
  {
    if (normalizedAssertionValue == null)
    {
      return normalizedAssertionValue = normalizeAssertionValue();
    }
    return normalizedAssertionValue;
  }
  private ByteString normalizeAssertionValue() throws DecodeException
  {
    switch (filterType)
    {
    case EQUALITY:
      return attributeType.getEqualityMatchingRule()
          .normalizeAssertionValue(assertionValue);
    case GREATER_OR_EQUAL:
    case LESS_OR_EQUAL:
      return attributeType.getOrderingMatchingRule()
          .normalizeAssertionValue(assertionValue);
    case APPROXIMATE_MATCH:
      return attributeType.getApproximateMatchingRule()
          .normalizeAssertionValue(assertionValue);
    case AND:
    case OR:
    case NOT:
    case PRESENT:
    case SUBSTRING:
    case EXTENSIBLE_MATCH:
    default:
      return null;
    }
  }
  /**
@@ -2720,12 +2723,10 @@
      return ConditionResult.UNDEFINED;
    }
    // Normalize the assertion value
    ByteString value = assertionValue.getValue();
    ByteString normalizedValue;
    ByteString normAssertionValue;
    try
    {
        normalizedValue = matchingRule.normalizeAssertionValue(value);
      normAssertionValue = matchingRule.normalizeAssertionValue(assertionValue);
    }
    catch (Exception e)
    {
@@ -2737,12 +2738,10 @@
    }
    // Iterate through all the attributes and see if we can find a match.
    AttributeValue dummyAttributeValue = AttributeValues.create(value,
                                           normalizedValue);
    for (Attribute a : attrs)
    {
      if (a.contains(dummyAttributeValue))
      // FIXME next if is incorrect
      if (a.contains(normAssertionValue))
      {
        if (logger.isTraceEnabled())
        {
@@ -2759,7 +2758,7 @@
      logger.trace(
          "Returning FALSE for equality component %s in filter " +
          "%s because entry %s didn't have attribute type %s with value %s",
          this, completeFilter, entry.getName(), attributeType.getNameOrOID(), assertionValue.getValue());
          this, completeFilter, entry.getName(), attributeType.getNameOrOID(), assertionValue);
    }
    return ConditionResult.FALSE;
  }
@@ -3327,7 +3326,7 @@
    Assertion assertion;
    try
    {
      assertion = matchingRule.getAssertion(assertionValue.getValue());
      assertion = matchingRule.getAssertion(assertionValue);
    }
    catch (Exception e)
    {
@@ -3350,12 +3349,11 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            try
            {
              ByteString nv =
                   matchingRule.normalizeAttributeValue(v.getValue());
              ByteString nv = matchingRule.normalizeAttributeValue(v);
              ConditionResult r = assertion.matches(nv);
              switch (r)
              {
@@ -3392,12 +3390,11 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            try
            {
              ByteString nv =
                   matchingRule.normalizeAttributeValue(v.getValue());
              ByteString nv = matchingRule.normalizeAttributeValue(v);
              ConditionResult r = assertion.matches(nv);
              switch (r)
              {
@@ -3430,11 +3427,11 @@
      }
      Attribute a = entry.getObjectClassAttribute();
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        try
        {
          ByteString nv = matchingRule.normalizeAttributeValue(v.getValue());
          ByteString nv = matchingRule.normalizeAttributeValue(v);
          ConditionResult r = assertion.matches(nv);
          switch (r)
          {
@@ -3470,12 +3467,11 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            try
            {
              ByteString nv =
                   matchingRule.normalizeAttributeValue(v.getValue());
              ByteString nv = matchingRule.normalizeAttributeValue(v);
              ConditionResult r = assertion.matches(nv);
              switch (r)
              {
@@ -3527,9 +3523,8 @@
            if ((attributeType == null) ||
                attributeType.equals(rdn.getAttributeType(i)))
            {
              AttributeValue v = rdn.getAttributeValue(i);
              ByteString nv =
                   matchingRule.normalizeAttributeValue(v.getValue());
              ByteString v = rdn.getAttributeValue(i);
              ByteString nv = matchingRule.normalizeAttributeValue(v);
              ConditionResult r = assertion.matches(nv);
              switch (r)
              {
@@ -3622,226 +3617,243 @@
              continue outerComponentLoop;
            }
          }
          return false;
        }
        return true;
      case NOT:
        return notComponent.equals(f.notComponent);
      case EQUALITY:
        return (attributeType.equals(f.attributeType) &&
                optionsEqual(attributeOptions, f.attributeOptions) &&
                assertionValue.equals(f.assertionValue));
        return typeAndOptionsAndAssertionEqual(f);
      case SUBSTRING:
        if (! attributeType.equals(f.attributeType))
        {
          return false;
        }
        SubstringMatchingRule smr =
             attributeType.getSubstringMatchingRule();
        if (smr == null)
        {
          return false;
        }
        if (! optionsEqual(attributeOptions, f.attributeOptions))
        {
          return false;
        }
        if (subInitialElement == null)
        {
          if (f.subInitialElement != null)
          {
            return false;
          }
        }
        else
        {
          if (f.subInitialElement == null)
          {
            return false;
          }
          try
          {
            ByteString nSI1 =
                 smr.normalizeSubstring(subInitialElement);
            ByteString nSI2 =
                 smr.normalizeSubstring(f.subInitialElement);
            if (! nSI1.equals(nSI2))
            {
              return false;
            }
          }
          catch (Exception e)
          {
            return false;
          }
        }
        if (subFinalElement == null)
        {
          if (f.subFinalElement != null)
          {
            return false;
          }
        }
        else
        {
          if (f.subFinalElement == null)
          {
            return false;
          }
          try
          {
            ByteString nSF1 =
                 smr.normalizeSubstring(subFinalElement);
            ByteString nSF2 =
                 smr.normalizeSubstring(f.subFinalElement);
            if (! nSF1.equals(nSF2))
            {
              return false;
            }
          }
          catch (Exception e)
          {
            return false;
          }
        }
        if (subAnyElements.size() != f.subAnyElements.size())
        {
          return false;
        }
        for (int i = 0; i < subAnyElements.size(); i++)
        {
          try
          {
            ByteString nSA1 =
                 smr.normalizeSubstring(subAnyElements.get(i));
            ByteString nSA2 =
                 smr.normalizeSubstring(f.subAnyElements.get(i));
            if (! nSA1.equals(nSA2))
            {
              return false;
            }
          }
          catch (Exception e)
          {
            return false;
          }
        }
        return true;
        return equalsSubstring(f);
      case GREATER_OR_EQUAL:
        return (attributeType.equals(f.attributeType) &&
                optionsEqual(attributeOptions, f.attributeOptions) &&
                assertionValue.equals(f.assertionValue));
        return typeAndOptionsAndAssertionEqual(f);
      case LESS_OR_EQUAL:
        return (attributeType.equals(f.attributeType) &&
                optionsEqual(attributeOptions, f.attributeOptions) &&
                assertionValue.equals(f.assertionValue));
        return typeAndOptionsAndAssertionEqual(f);
      case PRESENT:
        return (attributeType.equals(f.attributeType) &&
                optionsEqual(attributeOptions, f.attributeOptions));
      case APPROXIMATE_MATCH:
        return (attributeType.equals(f.attributeType) &&
                optionsEqual(attributeOptions, f.attributeOptions) &&
                assertionValue.equals(f.assertionValue));
        return typeAndOptionsAndAssertionEqual(f);
      case EXTENSIBLE_MATCH:
        if (attributeType == null)
        {
          if (f.attributeType != null)
          {
            return false;
          }
        }
        else
        {
          if (! attributeType.equals(f.attributeType))
          {
            return false;
          }
          if (! optionsEqual(attributeOptions, f.attributeOptions))
          {
            return false;
          }
        }
        if (dnAttributes != f.dnAttributes)
        {
          return false;
        }
        if (matchingRuleID == null)
        {
          if (f.matchingRuleID != null)
          {
            return false;
          }
        }
        else
        {
          if (! matchingRuleID.equals(f.matchingRuleID))
          {
            return false;
          }
        }
        if (assertionValue == null)
        {
          if (f.assertionValue != null)
          {
            return false;
          }
        }
        else
        {
          if (matchingRuleID == null)
          {
            if (! assertionValue.equals(f.assertionValue))
            {
              return false;
            }
          }
          else
          {
            MatchingRule mr =
                 DirectoryServer.getMatchingRule(
                      toLowerCase(matchingRuleID));
            if (mr == null)
            {
              return false;
            }
            else
            {
              try
              {
                Assertion assertion = mr.getAssertion(f.assertionValue.getValue());
                return assertion.matches(mr.normalizeAttributeValue(assertionValue.getValue())) == ConditionResult.TRUE;
              }
              catch (Exception e)
              {
                return false;
              }
            }
          }
        }
        return true;
        return equalsExtensible(f);
      default:
        return false;
    }
  }
  private boolean typeAndOptionsAndAssertionEqual(SearchFilter f)
  {
    final boolean tmp =
        attributeType.equals(f.attributeType)
            && optionsEqual(attributeOptions, f.attributeOptions);
    try
    {
      return tmp && getNormalizedAssertionValue().equals(f.getNormalizedAssertionValue());
    }
    catch (DecodeException e)
    {
      return tmp && assertionValue.equals(f.assertionValue);
    }
  }
  private boolean equalsSubstring(SearchFilter f)
  {
    if (! attributeType.equals(f.attributeType))
    {
      return false;
    }
    SubstringMatchingRule smr =
         attributeType.getSubstringMatchingRule();
    if (smr == null)
    {
      return false;
    }
    if (! optionsEqual(attributeOptions, f.attributeOptions))
    {
      return false;
    }
    if (subInitialElement == null)
    {
      if (f.subInitialElement != null)
      {
        return false;
      }
    }
    else
    {
      if (f.subInitialElement == null)
      {
        return false;
      }
      try
      {
        ByteString nSI1 =
             smr.normalizeSubstring(subInitialElement);
        ByteString nSI2 =
             smr.normalizeSubstring(f.subInitialElement);
        if (! nSI1.equals(nSI2))
        {
          return false;
        }
      }
      catch (Exception e)
      {
        return false;
      }
    }
    if (subFinalElement == null)
    {
      if (f.subFinalElement != null)
      {
        return false;
      }
    }
    else
    {
      if (f.subFinalElement == null)
      {
        return false;
      }
      try
      {
        ByteString nSF1 =
             smr.normalizeSubstring(subFinalElement);
        ByteString nSF2 =
             smr.normalizeSubstring(f.subFinalElement);
        if (! nSF1.equals(nSF2))
        {
          return false;
        }
      }
      catch (Exception e)
      {
        return false;
      }
    }
    if (subAnyElements.size() != f.subAnyElements.size())
    {
      return false;
    }
    for (int i = 0; i < subAnyElements.size(); i++)
    {
      try
      {
        ByteString nSA1 =
             smr.normalizeSubstring(subAnyElements.get(i));
        ByteString nSA2 =
             smr.normalizeSubstring(f.subAnyElements.get(i));
        if (! nSA1.equals(nSA2))
        {
          return false;
        }
      }
      catch (Exception e)
      {
        return false;
      }
    }
    return true;
  }
  private boolean equalsExtensible(SearchFilter f)
  {
    if (attributeType == null)
    {
      if (f.attributeType != null)
      {
        return false;
      }
    }
    else
    {
      if (! attributeType.equals(f.attributeType))
      {
        return false;
      }
      if (! optionsEqual(attributeOptions, f.attributeOptions))
      {
        return false;
      }
    }
    if (dnAttributes != f.dnAttributes)
    {
      return false;
    }
    if (matchingRuleID == null)
    {
      if (f.matchingRuleID != null)
      {
        return false;
      }
    }
    else
    {
      if (! matchingRuleID.equals(f.matchingRuleID))
      {
        return false;
      }
    }
    if (assertionValue == null)
    {
      if (f.assertionValue != null)
      {
        return false;
      }
    }
    else
    {
      if (matchingRuleID == null)
      {
        if (! assertionValue.equals(f.assertionValue))
        {
          return false;
        }
      }
      else
      {
        MatchingRule mr =
             DirectoryServer.getMatchingRule(
                  toLowerCase(matchingRuleID));
        if (mr == null)
        {
          return false;
        }
        else
        {
          try
          {
            Assertion assertion = mr.getAssertion(f.assertionValue);
            return assertion.matches(mr.normalizeAttributeValue(assertionValue)).toBoolean();
          }
          catch (Exception e)
          {
            return false;
          }
        }
      }
    }
    return true;
  }
  /**
   * Indicates whether the two provided sets of attribute options
@@ -3916,75 +3928,34 @@
      case NOT:
        return notComponent.hashCode();
      case EQUALITY:
        return (attributeType.hashCode() + assertionValue.hashCode());
        return typeAndAssertionHashCode();
      case SUBSTRING:
        hashCode = attributeType.hashCode();
        SubstringMatchingRule smr =
             attributeType.getSubstringMatchingRule();
        if (subInitialElement != null)
        {
          if (smr == null)
          {
            hashCode += subInitialElement.hashCode();
          }
          else
          {
            try
            {
              hashCode += smr.normalizeSubstring(
                               subInitialElement).hashCode();
            }
            catch (Exception e) {}
          }
        }
        hashCode = hashCode(hashCode, smr, subInitialElement);
        if (subAnyElements != null)
        {
          for (ByteString e : subAnyElements)
          {
            if (smr == null)
            {
              hashCode += e.hashCode();
            }
            else
            {
              try
              {
                hashCode += smr.normalizeSubstring(e).hashCode();
              }
              catch (Exception e2) {}
            }
              hashCode = hashCode(hashCode, smr, e);
          }
        }
        if (subFinalElement != null)
        {
          if (smr == null)
          {
            hashCode += subFinalElement.hashCode();
          }
          else
          {
            try
            {
              hashCode +=
                   smr.normalizeSubstring(subFinalElement).hashCode();
            }
            catch (Exception e) {}
          }
        }
        hashCode = hashCode(hashCode, smr, subFinalElement);
        return hashCode;
      case GREATER_OR_EQUAL:
        return (attributeType.hashCode() + assertionValue.hashCode());
        return typeAndAssertionHashCode();
      case LESS_OR_EQUAL:
        return (attributeType.hashCode() + assertionValue.hashCode());
        return typeAndAssertionHashCode();
      case PRESENT:
        return attributeType.hashCode();
      case APPROXIMATE_MATCH:
        return (attributeType.hashCode() + assertionValue.hashCode());
        return typeAndAssertionHashCode();
      case EXTENSIBLE_MATCH:
        hashCode = 0;
@@ -4015,6 +3986,42 @@
  }
  private int typeAndAssertionHashCode()
  {
    final int hashCode = attributeType.hashCode();
    try
    {
      return hashCode + getNormalizedAssertionValue().hashCode();
    }
    catch (DecodeException e)
    {
      return hashCode + assertionValue.hashCode();
    }
  }
  private int hashCode(int hashCode, SubstringMatchingRule smr,
      ByteString subElem)
  {
    if (subElem != null)
    {
      if (smr == null)
      {
        hashCode += subElem.hashCode();
      }
      else
      {
        try
        {
          hashCode += smr.normalizeSubstring(subElem).hashCode();
        }
        catch (Exception e) {}
      }
    }
    return hashCode;
  }
  /**
   * Retrieves a string representation of this search filter.
@@ -4066,35 +4073,15 @@
      case EQUALITY:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append("=");
        valueToFilterString(buffer, assertionValue.getValue());
        valueToFilterString(buffer, assertionValue);
        buffer.append(")");
        break;
      case SUBSTRING:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append("=");
        if (subInitialElement != null)
@@ -4123,71 +4110,31 @@
      case GREATER_OR_EQUAL:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append(">=");
        valueToFilterString(buffer, assertionValue.getValue());
        valueToFilterString(buffer, assertionValue);
        buffer.append(")");
        break;
      case LESS_OR_EQUAL:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append("<=");
        valueToFilterString(buffer, assertionValue.getValue());
        valueToFilterString(buffer, assertionValue);
        buffer.append(")");
        break;
      case PRESENT:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append("=*)");
        break;
      case APPROXIMATE_MATCH:
        buffer.append("(");
        buffer.append(attributeType.getNameOrOID());
        if ((attributeOptions != null) &&
            (! attributeOptions.isEmpty()))
        {
          for (String option : attributeOptions)
          {
            buffer.append(";");
            buffer.append(option);
          }
        }
        appendOptions(buffer);
        buffer.append("~=");
        valueToFilterString(buffer, assertionValue.getValue());
        valueToFilterString(buffer, assertionValue);
        buffer.append(")");
        break;
      case EXTENSIBLE_MATCH:
@@ -4196,16 +4143,7 @@
        if (attributeType != null)
        {
          buffer.append(attributeType.getNameOrOID());
          if ((attributeOptions != null) &&
              (! attributeOptions.isEmpty()))
          {
            for (String option : attributeOptions)
            {
              buffer.append(";");
              buffer.append(option);
            }
          }
          appendOptions(buffer);
        }
        if (dnAttributes)
@@ -4220,13 +4158,26 @@
        }
        buffer.append(":=");
        valueToFilterString(buffer, assertionValue.getValue());
        valueToFilterString(buffer, assertionValue);
        buffer.append(")");
        break;
    }
  }
  private void appendOptions(StringBuilder buffer)
  {
    if (attributeOptions != null && !attributeOptions.isEmpty())
    {
      for (String option : attributeOptions)
      {
        buffer.append(";");
        buffer.append(option);
      }
    }
  }
  /**
   * Appends a properly-cleaned version of the provided value to the
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/SortKey.java
@@ -147,8 +147,7 @@
   *          list, or zero if there is no relative difference between
   *          the values.
   */
  public int compareValues(AttributeValue value1,
                           AttributeValue value2)
  public int compareValues(ByteString value1, ByteString value2)
  {
    // A null value will always come after a non-null value.
    if (value1 == null)
@@ -182,13 +181,13 @@
    return 0;
  }
  private int compareValues(OrderingMatchingRule rule, AttributeValue value1,
      AttributeValue value2)
  private int compareValues(OrderingMatchingRule rule, ByteString value1,
      ByteString value2)
  {
    try
    {
      final ByteString val1 = rule.normalizeAttributeValue(value1.getValue());
      final ByteString val2 = rule.normalizeAttributeValue(value2.getValue());
      final ByteString val1 = rule.normalizeAttributeValue(value1);
      final ByteString val2 = rule.normalizeAttributeValue(value2);
      if (ascending)
      {
        return rule.compareValues(val1, val2);
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/SubEntry.java
@@ -32,6 +32,7 @@
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.core.DirectoryServer;
@@ -158,22 +159,22 @@
  private boolean isInheritedFromRDNCollective = false;
  // Inherited collective DN attribute type.
  private AttributeType inheritFromDNType = null;
  private AttributeType inheritFromDNType;
  // Inherited collective RDN attribute type.
  private AttributeType inheritFromRDNAttrType = null;
  private AttributeType inheritFromRDNAttrType;
  // Inherited collective RDN type attribute type.
  private AttributeType inheritFromRDNType = null;
  private AttributeType inheritFromRDNType;
  // Inherited collective RDN attribute value.
  private AttributeValue inheritFromRDNAttrValue = null;
  private ByteString inheritFromRDNAttrValue;
  // Inherited collective from DN value.
  private AttributeValue inheritFromDNAttrValue = null;
  private ByteString inheritFromDNAttrValue;
  // Inherited collective from base DN.
  private DN inheritFromBaseDN = null;
  private DN inheritFromBaseDN;
  // Collective attributes.
  private List<Attribute> collectiveAttributes;
@@ -205,7 +206,7 @@
    {
      for (Attribute attr : specAttrList)
      {
        for (AttributeValue value : attr)
        for (ByteString value : attr)
        {
          specString = value.toString();
          try
@@ -307,7 +308,7 @@
        {
          for (Attribute attr : attrList)
          {
            for (AttributeValue value : attr)
            for (ByteString value : attr)
            {
              this.inheritFromDNType =
                      DirectoryServer.getAttributeType(
@@ -328,7 +329,7 @@
        {
          for (Attribute attr : attrList)
          {
            for (AttributeValue value : attr)
            for (ByteString value : attr)
            {
              this.inheritFromRDNAttrType =
                      DirectoryServer.getAttributeType(
@@ -345,7 +346,7 @@
        {
          for (Attribute attr : attrList)
          {
            for (AttributeValue value : attr)
            for (ByteString value : attr)
            {
              this.inheritFromRDNType =
                      DirectoryServer.getAttributeType(
@@ -361,12 +362,11 @@
        {
          for (Attribute attr : attrList)
          {
            for (AttributeValue value : attr)
            for (ByteString value : attr)
            {
              // Has to have a parent since subentry itself
              // cannot be a suffix entry within the server.
              this.inheritFromBaseDN =
                  getDN().parent().child(DN.decode(value.getValue()));
              this.inheritFromBaseDN = getDN().parent().child(DN.decode(value));
              break;
            }
          }
@@ -379,7 +379,7 @@
      {
        for (Attribute attr : attrList)
        {
          for (AttributeValue value : attr)
          for (ByteString value : attr)
          {
            CollectiveVirtualAttribute collectiveAttr =
              new CollectiveVirtualAttribute(
@@ -399,7 +399,7 @@
      {
        for (Attribute attr : attrList)
        {
          for (AttributeValue value : attr)
          for (ByteString value : attr)
          {
            for (CollectiveConflictBehavior behavior :
              CollectiveConflictBehavior.values())
@@ -509,10 +509,10 @@
  /**
   * Getter to retrieve inheritFromRDNAttribute value
   * for inherited collective attribute subentry.
   * @return AttributeValue of inheritFromRDNAttribute
   * @return ByteString of inheritFromRDNAttribute
   *         or, <code>null</code> if there is none.
   */
  public AttributeValue getInheritFromRDNAttrValue()
  public ByteString getInheritFromRDNAttrValue()
  {
    return this.inheritFromRDNAttrValue;
  }
@@ -531,10 +531,10 @@
  /**
   * Getter to retrieve inheritFromDNAttribute value
   * for inherited collective attribute subentry.
   * @return AttributeValue of inheritFromDNAttribute
   * @return ByteString of inheritFromDNAttribute
   *         or, <code>null</code> if there is none.
   */
  public AttributeValue getInheritFromDNAttrValue()
  public ByteString getInheritFromDNAttrValue()
  {
    return this.inheritFromDNAttrValue;
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/VirtualAttribute.java
@@ -32,8 +32,12 @@
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.util.Utils;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
/**
@@ -48,19 +52,19 @@
    mayInvoke = true)
public final class VirtualAttribute
  extends AbstractAttribute
  implements Attribute
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  // The attribute type.
  /** The attribute type. */
  private final AttributeType attributeType;
  // The entry with which this virtual attribute is associated.
  /** The entry with which this virtual attribute is associated. */
  private final Entry entry;
  // The virtual attribute provider for this virtual attribute.
  /** The virtual attribute provider for this virtual attribute. */
  private final VirtualAttributeProvider<?> provider;
  // The virtual attribute rule for this virtual attribute.
  /** The virtual attribute rule for this virtual attribute. */
  private final VirtualAttributeRule rule;
@@ -87,42 +91,34 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public ConditionResult approximatelyEqualTo(AttributeValue value)
  public ConditionResult approximatelyEqualTo(ByteString value)
  {
    return provider.approximatelyEqualTo(entry, rule, value);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean contains(AttributeValue value)
  public boolean contains(ByteString value)
  {
    return provider.hasValue(entry, rule, value);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean containsAll(Collection<AttributeValue> values)
  public boolean containsAll(Collection<ByteString> values)
  {
    return provider.hasAllValues(entry, rule, values);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public AttributeType getAttributeType()
  {
@@ -131,9 +127,7 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getNameWithOptions()
  {
@@ -142,9 +136,7 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Set<String> getOptions()
  {
@@ -167,31 +159,25 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public ConditionResult greaterThanOrEqualTo(AttributeValue value)
  public ConditionResult greaterThanOrEqualTo(ByteString value)
  {
    return provider.greaterThanOrEqualTo(entry, rule, value);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean hasAllOptions(Collection<String> options)
  {
    return (options == null || options.isEmpty());
    return options == null || options.isEmpty();
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean hasOption(String option)
  {
@@ -200,9 +186,7 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean hasOptions()
  {
@@ -211,9 +195,7 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean isEmpty()
  {
@@ -222,9 +204,7 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean isVirtual()
  {
@@ -233,93 +213,83 @@
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Iterator<AttributeValue> iterator()
  public Iterator<ByteString> iterator()
  {
    Set<AttributeValue> values = provider.getValues(entry, rule);
    return values.iterator();
    return provider.getValues(entry, rule).iterator();
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public ConditionResult lessThanOrEqualTo(AttributeValue value)
  public ConditionResult lessThanOrEqualTo(ByteString value)
  {
    return provider.lessThanOrEqualTo(entry, rule, value);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public ConditionResult matchesSubstring(ByteString subInitial,
      List<ByteString> subAny, ByteString subFinal)
  {
    return provider.matchesSubstring(entry, rule, subInitial, subAny,
        subFinal);
    return provider.matchesSubstring(entry, rule, subInitial, subAny, subFinal);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public boolean optionsEqual(Set<String> options)
  {
    return (options == null || options.isEmpty());
    return options == null || options.isEmpty();
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public int size()
  {
    if (!provider.isMultiValued())
    {
      return provider.hasValue(entry, rule) ? 1 : 0;
    }
    else
    if (provider.isMultiValued())
    {
      return provider.getValues(entry, rule).size();
    }
    return provider.hasValue(entry, rule) ? 1 : 0;
  }
  /** {@inheritDoc} */
  @Override
  public int hashCode()
  {
    int hashCode = getAttributeType().hashCode();
    for (ByteString value : this)
    {
      try
      {
        final MatchingRule eqRule = attributeType.getEqualityMatchingRule();
        final ByteString nv = eqRule.normalizeAttributeValue(value);
        hashCode += nv.hashCode();
      }
      catch (DecodeException e)
      {
        logger.traceException(e);
      }
    }
    return hashCode;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public void toString(StringBuilder buffer)
  {
    buffer.append("VirtualAttribute(");
    buffer.append(getAttributeType().getNameOrOID());
    buffer.append(", {");
    boolean firstValue = true;
    for (AttributeValue value : this)
    {
      if (!firstValue)
      {
        buffer.append(", ");
      }
      value.toString(buffer);
      firstValue = false;
    }
    buffer.append(Utils.joinAsString(", ", this));
    buffer.append("})");
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/operation/PostOperationModifyOperation.java
@@ -26,19 +26,14 @@
 */
package org.opends.server.types.operation;
import java.util.List;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.opends.server.types.RawModification;
/**
 * This class defines a set of methods that are available for use by
 * post-operation plugins for modify operations.  Note that this
@@ -129,7 +124,7 @@
   *          provided in the modify request, or <CODE>null</CODE> if
   *          there were none.
   */
  public List<AttributeValue> getCurrentPasswords();
  List<ByteString> getCurrentPasswords();
@@ -143,6 +138,6 @@
   * @return  The set of clear-text new passwords as provided in the
   *          modify request, or <CODE>null</CODE> if there were none.
   */
  public List<AttributeValue> getNewPasswords();
  List<ByteString> getNewPasswords();
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/operation/PostResponseModifyOperation.java
@@ -124,7 +124,7 @@
   *          provided in the modify request, or <CODE>null</CODE> if
   *          there were none.
   */
  public List<AttributeValue> getCurrentPasswords();
  List<ByteString> getCurrentPasswords();
@@ -138,6 +138,6 @@
   * @return  The set of clear-text new passwords as provided in the
   *          modify request, or <CODE>null</CODE> if there were none.
   */
  public List<AttributeValue> getNewPasswords();
  List<ByteString> getNewPasswords();
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/operation/PostSynchronizationModifyOperation.java
@@ -26,19 +26,14 @@
 */
package org.opends.server.types.operation;
import java.util.List;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.opends.server.types.RawModification;
/**
 * This class defines a set of methods that are available for use by
 * post-synchronization plugins for modify operations.  Note that this
@@ -129,7 +124,7 @@
   *          provided in the modify request, or <CODE>null</CODE> if
   *          there were none.
   */
  public List<AttributeValue> getCurrentPasswords();
  List<ByteString> getCurrentPasswords();
@@ -143,6 +138,6 @@
   * @return  The set of clear-text new passwords as provided in the
   *          modify request, or <CODE>null</CODE> if there were none.
   */
  public List<AttributeValue> getNewPasswords();
  List<ByteString> getNewPasswords();
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/types/operation/PreOperationModifyOperation.java
@@ -26,11 +26,8 @@
 */
package org.opends.server.types.operation;
import java.util.List;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
@@ -38,8 +35,6 @@
import org.opends.server.types.Modification;
import org.opends.server.types.RawModification;
/**
 * This class defines a set of methods that are available for use by
 * pre-operation plugins for modify operations.  Note that this
@@ -150,7 +145,7 @@
   *          provided in the modify request, or <CODE>null</CODE> if
   *          there were none.
   */
  public List<AttributeValue> getCurrentPasswords();
  List<ByteString> getCurrentPasswords();
@@ -164,6 +159,6 @@
   * @return  The set of clear-text new passwords as provided in the
   *          modify request, or <CODE>null</CODE> if there were none.
   */
  public List<AttributeValue> getNewPasswords();
  List<ByteString> getNewPasswords();
}
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/util/LDIFReader.java
@@ -1114,7 +1114,7 @@
        }
      }
      AttributeValue attributeValue = AttributeValues.create(attrType, value);
      ByteString attributeValue = value;
      final Map<AttributeType, List<AttributeBuilder>> attrBuilders;
      if (attrType.isOperational())
      {
@@ -1214,9 +1214,7 @@
        colonPos, attrName);
    AttributeBuilder builder = new AttributeBuilder(attribute, true);
    AttributeType attrType = attribute.getAttributeType();
    builder.add(AttributeValues.create(attrType, value));
    builder.add(value);
    return builder.toAttribute();
  }
@@ -1551,7 +1549,7 @@
  {
    Attribute attr =
      readSingleValueAttribute(lines, line, entryDN, attributeName);
    return attr.iterator().next().getValue().toString();
    return attr.iterator().next().toString();
  }
@@ -1578,7 +1576,7 @@
      String name = attr.getName();
      // Get the attribute description
      String attrDescr = attr.iterator().next().getValue().toString();
      String attrDescr = attr.iterator().next().toString();
      ModificationType modType;
      String lowerName = toLowerCase(name);
@@ -1681,7 +1679,7 @@
    AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
    AttributeBuilder builder = new AttributeBuilder(ocType, "objectClass");
    for (String value : objectClasses.values()) {
      builder.add(AttributeValues.create(ocType, value));
      builder.add(value);
    }
    Map<AttributeType, List<Attribute>> attributes =
        toAttributesMap(attrBuilders);
@@ -1924,7 +1922,7 @@
    for (int i=0; i < numAVAs; i++)
    {
      AttributeType  t = rdn.getAttributeType(i);
      AttributeValue v = rdn.getAttributeValue(i);
      ByteString v = rdn.getAttributeValue(i);
      String         n = rdn.getAttributeName(i);
      if (t.isOperational())
      {
@@ -1940,7 +1938,7 @@
  private void addRDNAttributesIfNecessary(
      Map<AttributeType, List<Attribute>> attributes, AttributeType t,
      AttributeValue v, String n)
      ByteString v, String n)
  {
    List<Attribute> attrList = attributes.get(t);
    if (attrList == null)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/util/LDIFWriter.java
@@ -297,7 +297,7 @@
      AddChangeRecordEntry addRecord = (AddChangeRecordEntry) changeRecord;
      for (Attribute a : addRecord.getAttributes())
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          final String attrName = a.getNameWithOptions();
          writeAttribute(attrName, v, writer, wrapLines, wrapColumn);
@@ -440,7 +440,7 @@
          attrName.append(o);
        }
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          writeAttribute(attrName, v, writer, wrapLines, wrapColumn);
        }
@@ -512,7 +512,7 @@
            attrName.append(o);
          }
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            writeAttribute(attrName, v, writer, wrapLines, wrapColumn);
          }
@@ -584,7 +584,7 @@
      modTypeLine.append(name);
      writeLDIFLine(modTypeLine, writer, wrapLines, wrapColumn);
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        writeAttribute(name, v, writer, wrapLines, wrapColumn);
      }
@@ -680,12 +680,12 @@
    writeLDIFLine(newLine, writer, wrapLines, wrapColumn);
  }
  private void writeAttribute(CharSequence attrName, AttributeValue v,
  private void writeAttribute(CharSequence attrName, ByteString v,
      BufferedWriter writer, boolean wrapLines, int wrapColumn)
      throws IOException
  {
    StringBuilder newLine = new StringBuilder(attrName);
    appendLDIFSeparatorAndValue(newLine, v.getValue());
    appendLDIFSeparatorAndValue(newLine, v);
    writeLDIFLine(newLine, writer, wrapLines, wrapColumn);
  }
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
@@ -48,6 +48,7 @@
import org.forgerock.i18n.LocalizableMessageDescriptor;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.util.Reject;
import org.opends.messages.ToolMessages;
import org.opends.server.api.ClientConnection;
@@ -3635,7 +3636,7 @@
    for (int i=0; i < numAVAs; i++)
    {
      AttributeType attrType = rdn.getAttributeType(i);
      AttributeValue attrValue = rdn.getAttributeValue(i);
      ByteString attrValue = rdn.getAttributeValue(i);
      String attrName = rdn.getAttributeName(i);
      // First, see if this type is allowed by the untypedObject class.  If not,
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -760,10 +760,10 @@
          }
          String attrName = a.getNameWithOptions();
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            builder.append(attrName);
            appendLDIFSeparatorAndValue(builder, v.getValue());
            appendLDIFSeparatorAndValue(builder, v);
            builder.append('\n');
          }
        }
@@ -817,10 +817,10 @@
          builder.append(attrName);
          builder.append('\n');
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            builder.append(attrName);
            appendLDIFSeparatorAndValue(builder, v.getValue());
            appendLDIFSeparatorAndValue(builder, v);
            builder.append('\n');
          }
          builder.append("-\n");
@@ -1142,7 +1142,7 @@
        at = DirectoryServer.getDefaultAttributeType("changeNumber");
      }
      AttributeValue av = rdn.getAttributeValue(at);
      ByteString av = rdn.getAttributeValue(at);
      if (av != null)
      {
        sf = SearchFilter.createEqualityFilter(at, av);
@@ -1250,8 +1250,7 @@
    try
    {
      MatchingRule rule = sf.getAttributeType().getEqualityMatchingRule();
      ByteString normValue =
          rule.normalizeAssertionValue(sf.getAssertionValue().getValue());
      ByteString normValue = rule.normalizeAssertionValue(sf.getAssertionValue());
      return Integer.decode(normValue.toString());
    }
    catch (DecodeException e)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -669,7 +669,7 @@
    for (int i=0; i < numAVAs; i++)
    {
      AttributeType  t = rdn.getAttributeType(i);
      AttributeValue v = rdn.getAttributeValue(i);
      ByteString     v = rdn.getAttributeValue(i);
      String         n = rdn.getAttributeName(i);
      if (t.isOperational())
      {
@@ -686,7 +686,7 @@
  private void addRDNAttributesIfNecessary(
      Map<AttributeType, List<Attribute>> attributes, AttributeType t,
      AttributeValue v, String n) throws DirectoryException
      ByteString v, String n) throws DirectoryException
  {
    List<Attribute> attrList = attributes.get(t);
    if (attrList == null)
@@ -841,10 +841,8 @@
         passwordPolicy.getDefaultPasswordStorageSchemes();
    AttributeBuilder builder = new AttributeBuilder(passwordAttr, true);
    builder.setInitialCapacity(defaultStorageSchemes.size());
    for (AttributeValue v : passwordAttr)
    for (ByteString value : passwordAttr)
    {
      ByteString value = v.getValue();
      // See if the password is pre-encoded.
      if (passwordPolicy.isAuthPasswordSyntax())
      {
@@ -853,7 +851,7 @@
          if (isInternalOperation() ||
              passwordPolicy.isAllowPreEncodedPasswords())
          {
            builder.add(v);
            builder.add(value);
            continue;
          }
          else
@@ -875,7 +873,7 @@
          if (isInternalOperation() ||
              passwordPolicy.isAllowPreEncodedPasswords())
          {
            builder.add(v);
            builder.add(value);
            continue;
          }
          else
@@ -923,18 +921,14 @@
      {
        for (PasswordStorageScheme<?> s : defaultStorageSchemes)
        {
          ByteString encodedValue = s.encodeAuthPassword(value);
          builder.add(AttributeValues.create(
              passwordAttribute, encodedValue));
          builder.add(s.encodeAuthPassword(value));
        }
      }
      else
      {
        for (PasswordStorageScheme<?> s : defaultStorageSchemes)
        {
          ByteString encodedValue = s.encodePasswordWithScheme(value);
          builder.add(AttributeValues.create(
              passwordAttribute, encodedValue));
          builder.add(s.encodePasswordWithScheme(value));
        }
      }
    }
@@ -1050,9 +1044,9 @@
        AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
        if (syntax != null)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            if (!syntax.valueIsAcceptable(v.getValue(), invalidReason))
            if (!syntax.valueIsAcceptable(v, invalidReason))
            {
              LocalizableMessage message;
              if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired())
@@ -1064,7 +1058,7 @@
              else
              {
                message = WARN_ADD_OP_INVALID_SYNTAX.
                    get(entryDN, v.getValue(), a.getName(), invalidReason);
                    get(entryDN, v, a.getName(), invalidReason);
              }
              switch (DirectoryServer.getSyntaxEnforcementPolicy())
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -1102,7 +1102,7 @@
    }
    // See if the user's entry contains a custom idle time limit.
    // idleTimeLimit = 1000L * Long.parseLong(v.getValue().toString());
    // idleTimeLimit = 1000L * Long.parseLong(v.toString());
    Integer customIdleTimeLimitInSec =
        getIntegerUserAttribute(userEntry, OP_ATTR_USER_IDLE_TIME_LIMIT,
            WARN_BIND_MULTIPLE_USER_IDLE_TIME_LIMITS,
@@ -1136,15 +1136,15 @@
      Attribute a = attrList.get(0);
      if (a.size() == 1)
      {
        AttributeValue v = a.iterator().next();
        ByteString v = a.iterator().next();
        try
        {
          return Integer.valueOf(v.getValue().toString());
          return Integer.valueOf(v.toString());
        }
        catch (Exception e)
        {
          logger.traceException(e);
          logger.error(cannotProcessAttributeMessage.get(v.getValue(), userEntry.getName()));
          logger.error(cannotProcessAttributeMessage.get(v, userEntry.getName()));
        }
      }
      else if (a.size() > 1)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -40,6 +40,7 @@
import org.opends.server.core.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.operation.PostOperationCompareOperation;
import org.opends.server.types.operation.PostResponseCompareOperation;
@@ -291,8 +292,7 @@
      }
      else
      {
        AttributeValue value =
            AttributeValues.create(attrType, getAssertionValue());
        ByteString value = getAssertionValue();
        boolean matchFound = false;
        for (Attribute a : attrList)
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -33,6 +33,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.api.Backend;
import org.opends.server.api.ChangeNotificationListener;
@@ -747,7 +748,7 @@
          }
        }
        List<AttributeValue> missingValues = new LinkedList<AttributeValue>();
        List<ByteString> missingValues = new LinkedList<ByteString>();
        newEntry.removeAttribute(a, missingValues);
        if (missingValues.isEmpty())
@@ -767,7 +768,7 @@
          newRDN.getAttributeName(i),
          newRDN.getAttributeValue(i));
      List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
      List<ByteString> duplicateValues = new LinkedList<ByteString>();
      newEntry.addAttribute(a, duplicateValues);
      if (duplicateValues.isEmpty())
@@ -842,13 +843,12 @@
      switch (m.getModificationType().asEnum())
      {
        case ADD:
          List<AttributeValue> duplicateValues =
               new LinkedList<AttributeValue>();
          List<ByteString> duplicateValues = new LinkedList<ByteString>();
          newEntry.addAttribute(a, duplicateValues);
          break;
        case DELETE:
          List<AttributeValue> missingValues = new LinkedList<AttributeValue>();
          List<ByteString> missingValues = new LinkedList<ByteString>();
          newEntry.removeAttribute(a, missingValues);
          break;
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -145,10 +145,10 @@
  private LDAPPreReadRequestControl preReadRequest;
  /** The set of clear-text current passwords (if any were provided).*/
  private List<AttributeValue> currentPasswords = null;
  private List<ByteString> currentPasswords;
  /** The set of clear-text new passwords (if any were provided).*/
  private List<AttributeValue> newPasswords = null;
  private List<ByteString> newPasswords;
  /**
   * The set of modifications contained in this request.
@@ -208,7 +208,7 @@
   *          information is not yet available.
   */
  @Override
  public final List<AttributeValue> getCurrentPasswords()
  public final List<ByteString> getCurrentPasswords()
  {
    return currentPasswords;
  }
@@ -243,7 +243,7 @@
   *          information is not yet available.
   */
  @Override
  public final List<AttributeValue> getNewPasswords()
  public final List<ByteString> getNewPasswords()
  {
    return newPasswords;
  }
@@ -1143,9 +1143,9 @@
    // Otherwise, store the clear-text values for later validation and
    // update the attribute with the encoded values.
    AttributeBuilder builder = new AttributeBuilder(pwAttr, true);
    for (AttributeValue v : pwAttr)
    for (ByteString v : pwAttr)
    {
      if (pwPolicyState.passwordIsPreEncoded(v.getValue()))
      if (pwPolicyState.passwordIsPreEncoded(v))
      {
        if ((!isInternalOperation())
            && !pwPolicyState.getAuthenticationPolicy()
@@ -1165,7 +1165,7 @@
        if (m.getModificationType() == ModificationType.ADD)
        {
          // Make sure that the password value doesn't already exist.
          if (pwPolicyState.passwordMatches(v.getValue()))
          if (pwPolicyState.passwordMatches(v))
          {
            pwpErrorType = PasswordPolicyErrorType.PASSWORD_IN_HISTORY;
            throw new DirectoryException(ResultCode.ATTRIBUTE_OR_VALUE_EXISTS,
@@ -1175,16 +1175,12 @@
        if (newPasswords == null)
        {
          newPasswords = new LinkedList<AttributeValue>();
          newPasswords = new LinkedList<ByteString>();
        }
        newPasswords.add(v);
        for (ByteString s : pwPolicyState.encodePassword(v.getValue()))
        {
          builder.add(AttributeValues.create(
              pwAttr.getAttributeType(), s));
        }
        builder.addAll(pwPolicyState.encodePassword(v));
      }
    }
@@ -1218,9 +1214,9 @@
      numPasswords = 0;
    }
    for (AttributeValue v : pwAttr)
    for (ByteString v : pwAttr)
    {
      if (pwPolicyState.passwordIsPreEncoded(v.getValue()))
      if (pwPolicyState.passwordIsPreEncoded(v))
      {
        if ((!isInternalOperation()) && selfChange)
        {
@@ -1242,7 +1238,7 @@
          boolean found = false;
          for (Attribute attr : attrList)
          {
            for (AttributeValue av : attr)
            for (ByteString av : attr)
            {
              if (av.equals(v))
              {
@@ -1269,20 +1265,20 @@
        boolean found = false;
        for (Attribute attr : attrList)
        {
          for (AttributeValue av : attr)
          for (ByteString av : attr)
          {
            if (pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax())
            {
              if (AuthPasswordSyntax.isEncoded(av.getValue()))
              if (AuthPasswordSyntax.isEncoded(av))
              {
                StringBuilder[] components = AuthPasswordSyntax
                    .decodeAuthPassword(av.getValue().toString());
                    .decodeAuthPassword(av.toString());
                PasswordStorageScheme<?> scheme = DirectoryServer
                    .getAuthPasswordStorageScheme(components[0].toString());
                if (scheme != null)
                {
                  if (scheme.authPasswordMatches(v.getValue(), components[1]
                      .toString(), components[2].toString()))
                  if (scheme.authPasswordMatches(v,
                      components[1].toString(), components[2].toString()))
                  {
                    builder.add(av);
                    found = true;
@@ -1300,20 +1296,16 @@
            }
            else
            {
              if (UserPasswordSyntax.isEncoded(av.getValue()))
              if (UserPasswordSyntax.isEncoded(av))
              {
                String[] components = UserPasswordSyntax.decodeUserPassword(av
                    .getValue().toString());
                String[] components = UserPasswordSyntax.decodeUserPassword(av.toString());
                PasswordStorageScheme<?> scheme = DirectoryServer
                    .getPasswordStorageScheme(toLowerCase(components[0]));
                if (scheme != null)
                if (scheme != null
                    && scheme.passwordMatches(v, ByteString.valueOf(components[1])))
                {
                  if (scheme.passwordMatches(v.getValue(), ByteString.valueOf(
                      components[1])))
                  {
                    builder.add(av);
                    found = true;
                  }
                  builder.add(av);
                  found = true;
                }
              }
              else
@@ -1332,7 +1324,7 @@
        {
          if (currentPasswords == null)
          {
            currentPasswords = new LinkedList<AttributeValue>();
            currentPasswords = new LinkedList<ByteString>();
          }
          currentPasswords.add(v);
          numPasswords--;
@@ -1385,9 +1377,9 @@
      if (syntaxPolicy == AcceptRejectWarn.REJECT)
      {
        LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
        for (AttributeValue v : attr)
        for (ByteString v : attr)
        {
          if (!syntax.valueIsAcceptable(v.getValue(), invalidReason))
          if (!syntax.valueIsAcceptable(v, invalidReason))
          {
            if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired())
            {
@@ -1401,7 +1393,7 @@
              throw newDirectoryException(currentEntry,
                  ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                  ERR_MODIFY_ADD_INVALID_SYNTAX.get(
                      entryDN, attr.getName(), v.getValue(), invalidReason));
                      entryDN, attr.getName(), v, invalidReason));
            }
          }
        }
@@ -1409,9 +1401,9 @@
      else if (syntaxPolicy == AcceptRejectWarn.WARN)
      {
        LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
        for (AttributeValue v : attr)
        for (ByteString v : attr)
        {
          if (!syntax.valueIsAcceptable(v.getValue(), invalidReason))
          if (!syntax.valueIsAcceptable(v, invalidReason))
          {
            // FIXME remove next line of code. According to Matt, since this is
            // just a warning, the code should not set the resultCode
@@ -1424,7 +1416,7 @@
            else
            {
              logger.error(ERR_MODIFY_ADD_INVALID_SYNTAX,
                  entryDN, attr.getName(), v.getValue(), invalidReason);
                  entryDN, attr.getName(), v, invalidReason);
            }
            invalidReason = new LocalizableMessageBuilder();
          }
@@ -1443,7 +1435,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<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    modifiedEntry.addAttribute(attr, duplicateValues);
    if (!duplicateValues.isEmpty() && !permissiveModify)
    {
@@ -1473,14 +1465,14 @@
    Reject.ifFalse(attrType.isObjectClass());
    final MatchingRule eqRule = attrType.getEqualityMatchingRule();
    for (AttributeValue v : attr)
    for (ByteString v : attr)
    {
      String name = v.getValue().toString();
      String name = v.toString();
      String lowerName;
      try
      {
        lowerName = eqRule.normalizeAttributeValue(v.getValue()).toString();
        lowerName = eqRule.normalizeAttributeValue(v).toString();
      }
      catch (Exception e)
      {
@@ -1524,7 +1516,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<AttributeValue> missingValues = new LinkedList<AttributeValue>();
    List<ByteString> missingValues = new LinkedList<ByteString>();
    boolean attrExists = modifiedEntry.removeAttribute(attr, missingValues);
    if (attrExists)
@@ -1592,9 +1584,9 @@
      if (syntaxPolicy == AcceptRejectWarn.REJECT)
      {
        LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
        for (AttributeValue v : attr)
        for (ByteString v : attr)
        {
          if (!syntax.valueIsAcceptable(v.getValue(), invalidReason))
          if (!syntax.valueIsAcceptable(v, invalidReason))
          {
            if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired())
            {
@@ -1608,7 +1600,7 @@
              throw newDirectoryException(currentEntry,
                  ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                  ERR_MODIFY_REPLACE_INVALID_SYNTAX.get(
                      entryDN, attr.getName(), v.getValue(), invalidReason));
                      entryDN, attr.getName(), v, invalidReason));
            }
          }
        }
@@ -1616,9 +1608,9 @@
      else if (syntaxPolicy == AcceptRejectWarn.WARN)
      {
        LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
        for (AttributeValue v : attr)
        for (ByteString v : attr)
        {
          if (!syntax.valueIsAcceptable(v.getValue(), invalidReason))
          if (!syntax.valueIsAcceptable(v, invalidReason))
          {
            setResultCode(ResultCode.INVALID_ATTRIBUTE_SYNTAX);
            if (!syntax.isHumanReadable() || syntax.isBEREncodingRequired())
@@ -1630,7 +1622,7 @@
            else
            {
              logger.error(ERR_MODIFY_REPLACE_INVALID_SYNTAX,
                  entryDN, attr.getName(), v.getValue(), invalidReason);
                  entryDN, attr.getName(), v, invalidReason);
            }
            invalidReason = new LocalizableMessageBuilder();
          }
@@ -1701,12 +1693,12 @@
    }
    MatchingRule eqRule = attr.getAttributeType().getEqualityMatchingRule();
    AttributeValue v = attr.iterator().next();
    ByteString v = attr.iterator().next();
    long incrementValue;
    try
    {
      String nv = eqRule.normalizeAttributeValue(v.getValue()).toString();
      String nv = eqRule.normalizeAttributeValue(v).toString();
      incrementValue = Long.parseLong(nv);
    }
    catch (Exception e)
@@ -1714,7 +1706,7 @@
      logger.traceException(e);
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
          ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attr.getName(), v.getValue()), e);
          ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attr.getName(), v), e);
    }
    // Get the attribute that is to be incremented.
@@ -1728,13 +1720,12 @@
    // Increment each attribute value by the specified amount.
    AttributeBuilder builder = new AttributeBuilder(a, true);
    for (AttributeValue existingValue : a)
    for (ByteString existingValue : a)
    {
      String s = existingValue.getValue().toString();
      long currentValue;
      try
      {
        currentValue = Long.parseLong(s);
        currentValue = Long.parseLong(existingValue.toString());
      }
      catch (Exception e)
      {
@@ -1742,13 +1733,12 @@
        throw new DirectoryException(
            ResultCode.INVALID_ATTRIBUTE_SYNTAX,
            ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(
                entryDN, a.getName(), existingValue.getValue()),
            ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, a.getName(), existingValue),
            e);
      }
      long newValue = currentValue + incrementValue;
      builder.add(AttributeValues.create(t, String.valueOf(newValue)));
      builder.add(String.valueOf(newValue));
    }
    // Replace the existing attribute with the incremented version.
@@ -1820,10 +1810,7 @@
        {
          if (clearPasswords.isEmpty())
          {
            for (AttributeValue v : currentPasswords)
            {
              clearPasswords.add(v.getValue());
            }
            clearPasswords.addAll(currentPasswords);
          }
          else
          {
@@ -1833,21 +1820,9 @@
            // (like 0x04 for a standard universal octet string type versus 0x80
            // for a simple password in a bind operation).  So we have to
            // manually check for duplicates.
            for (AttributeValue v : currentPasswords)
            for (ByteString pw : currentPasswords)
            {
              ByteString pw = v.getValue();
              boolean found = false;
              for (ByteString s : clearPasswords)
              {
                if (s.equals(pw))
                {
                  found = true;
                  break;
                }
              }
              if (! found)
              if (!clearPasswords.contains(pw))
              {
                clearPasswords.add(pw);
              }
@@ -1855,11 +1830,11 @@
          }
        }
        for (AttributeValue v : newPasswords)
        for (ByteString v : newPasswords)
        {
          LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
          if (! pwPolicyState.passwordIsAcceptable(this, modifiedEntry,
                                   v.getValue(), clearPasswords, invalidReason))
                                   v, clearPasswords, invalidReason))
          {
            pwpErrorType =
                 PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY;
@@ -1877,9 +1852,9 @@
    {
      if (newPasswords != null)
      {
        for (AttributeValue v : newPasswords)
        for (ByteString v : newPasswords)
        {
          if (pwPolicyState.isPasswordInHistory(v.getValue()))
          if (pwPolicyState.isPasswordInHistory(v))
          {
            if (selfChange || (! pwPolicyState.getAuthenticationPolicy().
                                      isSkipValidationForAdministrators()))
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -36,6 +36,12 @@
import java.util.logging.Logger;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.opends.server.admin.client.ldap.LDAPConnection;
@@ -43,18 +49,15 @@
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.api.Backend;
import org.opends.server.api.WorkQueue;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.backends.MemoryBackend;
import org.opends.server.backends.jeb.*;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.*;
import org.opends.server.plugins.InvocationCounterPlugin;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.opends.server.protocols.ldap.BindRequestProtocolOp;
import org.opends.server.protocols.ldap.BindResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPMessage;
@@ -62,8 +65,6 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.dsconfig.DSConfig;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.FilePermission;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.EmbeddedUtils;
@@ -1924,4 +1925,21 @@
    return new ArrayList<T>(Arrays.asList(elems));
  }
  public static HashSet<PluginType> getPluginTypes(Entry e)
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    if (attrList != null)
    {
      for (Attribute a : attrList)
      {
        for (ByteString v : a)
        {
          pluginTypes.add(PluginType.forName(v.toString().toLowerCase()));
        }
      }
    }
    return pluginTypes;
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/ldap/MockLDAPConnection.java
@@ -43,8 +43,8 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.LdapName;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -161,6 +161,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void createEntry(LdapName dn, Attributes attributes)
      throws NamingException {
    throw new UnsupportedOperationException("createEntry");
@@ -171,6 +172,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void deleteSubtree(LdapName dn) throws NamingException {
    throw new UnsupportedOperationException("deleteSubtree");
  }
@@ -211,16 +213,16 @@
  @Override
  public Collection<LdapName> listEntries(LdapName dn, String filter) throws NamingException {
    MockEntry entry = getEntry(dn);
    if (entry == null) {
      throw new NameNotFoundException("could not find entry " + dn);
    } else {
      LinkedList<LdapName> names = new LinkedList<LdapName>();
      for (MockEntry child : entry.children) {
        names.add(new LdapName(child.getDN().toString()));
      }
      return names;
    }
    LinkedList<LdapName> names = new LinkedList<LdapName>();
    for (MockEntry child : entry.children)
    {
      names.add(new LdapName(child.getDN().toString()));
    }
    return names;
  }
@@ -228,6 +230,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void modifyEntry(LdapName dn, Attributes mods) throws NamingException {
    throw new UnsupportedOperationException("modifyEntry");
  }
@@ -316,8 +319,8 @@
    Attributes attributes = new BasicAttributes();
    for (org.opends.server.types.Attribute attribute : entry.getAttributes()) {
      BasicAttribute ba = new BasicAttribute(attribute.getName());
      for (AttributeValue value : attribute) {
        ba.add(value.getValue().toString());
      for (ByteString value : attribute) {
        ba.add(value.toString());
      }
      attributes.put(ba);
    }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/server/DefaultBehaviorTest.java
@@ -97,8 +97,7 @@
     */
    public TestChildCfg getChild(String expectedName) {
      Assert.assertNotNull(child);
      Assert.assertEquals(child.dn().rdn().getAttributeValue(0)
          .getValue().toString(), expectedName);
      Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName);
      return child;
    }
@@ -157,8 +156,7 @@
     */
    public TestChildCfg getChild(String expectedName) {
      Assert.assertNotNull(child);
      Assert.assertEquals(child.dn().rdn().getAttributeValue(0)
          .getValue().toString(), expectedName);
      Assert.assertEquals(child.dn().rdn().getAttributeValue(0).toString(), expectedName);
      return child;
    }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -29,15 +29,16 @@
import java.io.File;
import java.util.Map;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -5346,7 +5347,7 @@
    assertTrue(schemaEntry.hasAttribute(mnType));
    assertTrue(schemaEntry.hasAttribute(mtType));
    AttributeValue oldMTValue =
    ByteString oldMTValue =
         schemaEntry.getAttribute(mtType).get(0).iterator().next();
    String path = TestCaseUtils.createTempFile(
@@ -5379,7 +5380,7 @@
    assertTrue(schemaEntry.hasAttribute(mnType));
    assertTrue(schemaEntry.hasAttribute(mtType));
    AttributeValue newMTValue =
    ByteString newMTValue =
         schemaEntry.getAttribute(mtType).get(0).iterator().next();
    assertFalse(oldMTValue.equals(newMTValue));
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
@@ -943,17 +943,17 @@
          DN.valueOf("uid=user.0,ou=People,dc=test,dc=com"), LockMode.DEFAULT);
      assertNotNull(entry);
      for (AttributeValue value : entry.getAttribute("cn").get(0)) {
        assertEquals(value.getValue().toString(), "Testing Test");
      for (ByteString value : entry.getAttribute("cn").get(0)) {
        assertEquals(value.toString(), "Testing Test");
      }
      for (AttributeValue value : entry.getAttribute("sn").get(0)) {
        assertEquals(value.getValue().toString(), "Test");
      for (ByteString value : entry.getAttribute("sn").get(0)) {
        assertEquals(value.toString(), "Test");
      }
      for (AttributeValue value : entry.getAttribute("givenname").get(0)) {
        assertEquals(value.getValue().toString(), "Testing");
      for (ByteString value : entry.getAttribute("givenname").get(0)) {
        assertEquals(value.toString(), "Testing");
      }
      for (AttributeValue value : entry.getAttribute("employeenumber").get(0)) {
        assertEquals(value.getValue().toString(), "777");
      for (ByteString value : entry.getAttribute("employeenumber").get(0)) {
        assertEquals(value.toString(), "777");
      }
      AttributeType attribute =
@@ -1073,27 +1073,21 @@
          Attributes.create("title", "debugger")));
      final Attribute cnAttr = entry.getAttribute("cn").get(0);
      assertTrue(cnAttr.contains(AttributeValues.create(
              cnAttr.getAttributeType(), "Aaren Rigor")));
      assertTrue(cnAttr.contains(AttributeValues.create(
              cnAttr.getAttributeType(), "Aarenister Rigor")));
      assertFalse(cnAttr.contains(AttributeValues.create(
              cnAttr.getAttributeType(), "Aaren Atp")));
      assertTrue(cnAttr.contains(ByteString.valueOf("Aaren Rigor")));
      assertTrue(cnAttr.contains(ByteString.valueOf("Aarenister Rigor")));
      assertFalse(cnAttr.contains(ByteString.valueOf("Aaren Atp")));
      Set<String> options = Collections.singleton("lang-de");
      assertTrue(entry.getAttribute("givenname", options).get(0).contains(
          AttributeValues.create(entry.getAttribute("givenname", options).get(0)
              .getAttributeType(), "test")));
          ByteString.valueOf("test")));
      options = Collections.singleton("lang-cn");
      assertNull(entry.getAttribute("givenname", options));
      options = Collections.singleton("lang-es");
      assertTrue(entry.getAttribute("givenname", options).get(0).contains(
          AttributeValues.create(entry.getAttribute("givenname", options).get(0)
              .getAttributeType(), "newtest3")));
          ByteString.valueOf("newtest3")));
      options = Collections.singleton("lang-fr");
      assertTrue(entry.getAttribute("givenname", options).get(0).contains(
          AttributeValues.create(entry.getAttribute("givenname", options).get(0)
              .getAttributeType(), "test2")));
          ByteString.valueOf("test2")));
      assertTrue(entry.getAttribute("employeenumber").contains(
          Attributes.create("employeenumber", "222")));
@@ -1331,7 +1325,7 @@
    //No indexes should be used.
    String debugString =
        result.get(0).getAttribute("debugsearchindex").get(0).toString();
    assertTrue(debugString.contains("NOT-INDEXED"));
    assertThat(debugString).contains("not-indexed");
    resultCode = TestCaseUtils.applyModifications(true,
        "dn: ds-cfg-attribute=givenName,cn=Index," +
@@ -1509,7 +1503,7 @@
    //No indexes should be used.
    String debugString =
        result.get(0).getAttribute("debugsearchindex").get(0).toString();
    assertThat(debugString).contains("NOT-INDEXED");
    assertThat(debugString).contains("not-indexed");
  }
  @Test(dependsOnMethods = "testSearchNotIndexed")
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
@@ -26,8 +26,7 @@
 */
package org.opends.server.backends.jeb;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
import org.opends.server.tasks.TaskUtils;
import org.opends.server.core.DirectoryServer;
@@ -45,8 +44,7 @@
import java.io.ByteArrayOutputStream;
import java.util.*;
@SuppressWarnings("javadoc")
public class TestImportJob extends JebTestCase
{
  private String beID = "importRoot";
@@ -523,8 +521,7 @@
      AttributeType attribute = entry.getAttribute("cn").get(0)
          .getAttributeType();
      assertTrue(entry.hasValue(attribute, null,
          AttributeValues.create(attribute, "Annalee Bogard")));
      assertTrue(entry.hasValue(attribute, null, ByteString.valueOf("Annalee Bogard")));
      VerifyConfig verifyConfig = new VerifyConfig();
      verifyConfig.setBaseDN(DN.valueOf("dc=importtest1,dc=com"));
@@ -762,8 +759,7 @@
    if (attrType == null)
      attrType = DirectoryServer.getDefaultAttributeType(type);
    List<Attribute> attrList = e.getAttribute(attrType, null);
    AttributeValue v = attrList.get(0).iterator().next();
    long retVal = Long.parseLong(v.getValue().toString());
    return (retVal);
    ByteString v = attrList.get(0).iterator().next();
    return Long.parseLong(v.toString());
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestJebFormat.java
@@ -253,30 +253,7 @@
    // Encoded one-to-five byte number of attributes
    buffer.appendBERLength(numAttributes);
    // The attributes will be encoded as a sequence of:
    // - A UTF-8 byte representation of the attribute name.
    // - A zero delimiter
    // - A one-to-five byte number of values for the attribute
    // - A sequence of:
    //   - A one-to-five byte length for the value
    //   - A UTF-8 byte representation for the value
    for (List<Attribute> attrList : attributes.values())
    {
      for (Attribute a : attrList)
      {
        byte[] nameBytes = getBytes(a.getNameWithOptions());
        buffer.append(nameBytes);
        buffer.append((byte)0x00);
        buffer.appendBERLength(a.size());
        for(AttributeValue v : a)
        {
          buffer.appendBERLength(v.getValue().length());
          buffer.append(v.getValue());
        }
      }
    }
    append(buffer, attributes);
  }
    /**
@@ -387,27 +364,35 @@
    }
    else
    {
      // The attributes will be encoded as a sequence of:
      // - A UTF-8 byte representation of the attribute name.
      // - A zero delimiter
      // - A one-to-five byte number of values for the attribute
      // - A sequence of:
      //   - A one-to-five byte length for the value
      //   - A UTF-8 byte representation for the value
      for (List<Attribute> attrList : attributes.values())
      {
        for (Attribute a : attrList)
        {
          byte[] nameBytes = getBytes(a.getNameWithOptions());
          buffer.append(nameBytes);
          buffer.append((byte)0x00);
      append(buffer, attributes);
    }
  }
          buffer.appendBERLength(a.size());
          for(AttributeValue v : a)
          {
            buffer.appendBERLength(v.getValue().length());
            buffer.append(v.getValue());
          }
  /**
   * The attributes will be encoded as a sequence of:
   * - A UTF-8 byte representation of the attribute name.
   * - A zero delimiter
   * - A one-to-five byte number of values for the attribute
   * - A sequence of:
   *   - A one-to-five byte length for the value
   *   - A UTF-8 byte representation for the value
   */
  private void append(ByteStringBuilder buffer,
      Map<AttributeType, List<Attribute>> attributes)
  {
    for (List<Attribute> attrList : attributes.values())
    {
      for (Attribute a : attrList)
      {
        byte[] nameBytes = getBytes(a.getNameWithOptions());
        buffer.append(nameBytes);
        buffer.append((byte)0x00);
        buffer.appendBERLength(a.size());
        for (ByteString v : a)
        {
          buffer.appendBERLength(v.length());
          buffer.append(v);
        }
      }
    }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java
@@ -26,22 +26,25 @@
 */
package org.opends.server.backends.jeb;
import org.testng.annotations.DataProvider;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.jeb.RebuildConfig.RebuildMode;
import org.opends.server.tasks.TaskUtils;
import static org.opends.server.util.ServerConstants.OC_TOP;
import static org.opends.server.util.ServerConstants.OC_EXTENSIBLE_OBJECT;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import java.util.List;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.jeb.RebuildConfig.RebuildMode;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tasks.TaskUtils;
import org.opends.server.types.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@SuppressWarnings("javadoc")
public class TestRebuildJob extends JebTestCase
{
  private  String beID="rebuildRoot";
@@ -423,8 +426,7 @@
    if (attrType == null)
      attrType = DirectoryServer.getDefaultAttributeType(type);
    List<Attribute> attrList = e.getAttribute(attrType, null);
    AttributeValue v = attrList.get(0).iterator().next();
    long retVal = Long.parseLong(v.getValue().toString());
    return (retVal);
    ByteString v = attrList.get(0).iterator().next();
    return Long.parseLong(v.toString());
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVLVIndex.java
@@ -328,7 +328,7 @@
        int i = 0;
        for(SortValues values : expectedSortedValues)
        {
          AttributeValue[] attrValues = values.getValues();
          ByteString[] attrValues = values.getValues();
          AttributeType[] attrTypes = values.getTypes();
          for(int j = 0; j < attrValues.length; j++)
          {
@@ -345,7 +345,7 @@
            if(attrValues[j] != null)
            {
              MatchingRule eqRule = attrTypes[j].getEqualityMatchingRule();
              oValue = eqRule.normalizeAttributeValue(attrValues[j].getValue());
              oValue = eqRule.normalizeAttributeValue(attrValues[j]);
            }
            assertEquals(value, oValue);
          }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java
@@ -391,7 +391,7 @@
      // Add an incorrectly ordered values.
      SortValuesSet svs =
          vlvIndex.getSortValuesSet(null, 0, new AttributeValue[3], new AttributeType[3]);
          vlvIndex.getSortValuesSet(null, 0, new ByteString[3], new AttributeType[3]);
      long id = svs.getEntryIDs()[0];
      Entry entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT);
@@ -404,8 +404,8 @@
      // Muck up the values of another ID
      id = svs.getEntryIDs()[0];
      entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT);
      AttributeValue[] values = vlvIndex.getSortValues(entry);
      AttributeValue[] badValues = new AttributeValue[values.length];
      ByteString[] values = vlvIndex.getSortValues(entry);
      ByteString[] badValues = new ByteString[values.length];
      System.arraycopy(values, 1, badValues, 0, values.length - 1);
      badValues[badValues.length-1] = values[0];
      svs.remove(id, values, types);
@@ -694,8 +694,7 @@
      AttributeType[] types = vlvIndex.getSortTypes();
      // Remove an ID
      SortValuesSet svs =
          vlvIndex.getSortValuesSet(null, 0, new AttributeValue[3], types);
      SortValuesSet svs = vlvIndex.getSortValuesSet(null, 0, new ByteString[3], types);
      long id = svs.getEntryIDs()[0];
      Entry entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT);
      svs.remove(id, vlvIndex.getSortValues(entry), types);
@@ -707,8 +706,8 @@
      // Muck up the values of another ID
      id = svs.getEntryIDs()[0];
      entry = eContainer.getID2Entry().get(null, new EntryID(id), LockMode.DEFAULT);
      AttributeValue[] values = vlvIndex.getSortValues(entry);
      AttributeValue[] badValues = new AttributeValue[values.length];
      ByteString[] values = vlvIndex.getSortValues(entry);
      ByteString[] badValues = new ByteString[values.length];
      System.arraycopy(values, 1, badValues, 0, values.length - 1);
      badValues[badValues.length-1] = values[0];
      svs.remove(id, values, types);
@@ -877,9 +876,8 @@
    if (attrType == null)
      attrType = DirectoryServer.getDefaultAttributeType(type);
    List<Attribute> attrList = e.getAttribute(attrType, null);
    AttributeValue v = attrList.get(0).iterator().next();
    long retVal = Long.parseLong(v.getValue().toString());
    return (retVal);
    ByteString v = attrList.get(0).iterator().next();
    return Long.parseLong(v.toString());
  }
  /**
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/controls/MatchedValuesControlTest.java
@@ -148,20 +148,19 @@
    }
    //
    // ( AttributeType attributeType, AttributeValue assertionValue
    // ( AttributeType attributeType, ByteString assertionValue
    //
    AttributeType attType = DirectoryServer.getAttributeType(type);
    AttributeValue attVal = null;
    ByteString attVal = null;
    if (attType != null)
    {
      attVal = AttributeValues.create(attType, value);
      attVal = ByteString.valueOf(value);
    }
    // Check null, null
    try
    {
      mvf = MatchedValuesFilter.createEqualityFilter((AttributeType) null,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createEqualityFilter((AttributeType) null, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -176,8 +175,7 @@
    // Check type, null
    try
    {
      mvf = MatchedValuesFilter.createEqualityFilter(attType,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createEqualityFilter(attType, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -444,20 +442,19 @@
    }
    //
    // ( AttributeType attributeType, AttributeValue assertionValue
    // ( AttributeType attributeType, ByteString assertionValue
    //
    AttributeType attType = DirectoryServer.getAttributeType(type);
    AttributeValue attVal = null;
    ByteString attVal = null;
    if (attType != null)
    {
      attVal = AttributeValues.create(attType, value);
      attVal = ByteString.valueOf(value);
    }
    // Check null, null
    try
    {
      mvf = MatchedValuesFilter.createGreaterOrEqualFilter(
          (AttributeType) null, (AttributeValue) null);
      mvf = MatchedValuesFilter.createGreaterOrEqualFilter((AttributeType) null, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -472,8 +469,7 @@
    // Check type, null
    try
    {
      mvf = MatchedValuesFilter.createGreaterOrEqualFilter(attType,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createGreaterOrEqualFilter(attType, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -579,20 +575,19 @@
    ;
    //
    // ( AttributeType attributeType, AttributeValue assertionValue
    // ( AttributeType attributeType, ByteString assertionValue
    //
    AttributeType attType = DirectoryServer.getAttributeType(type);
    AttributeValue attVal = null ;
    ByteString attVal = null ;
    if (attType != null)
    {
      attVal = AttributeValues.create(attType, value);
      attVal = ByteString.valueOf(value);
    }
    // Check null, null
    try
    {
      mvf = MatchedValuesFilter.createLessOrEqualFilter((AttributeType) null,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createLessOrEqualFilter((AttributeType) null, null);
    }
    catch (NullPointerException e)
    {
@@ -606,8 +601,7 @@
    // Check type, null
    try
    {
      mvf = MatchedValuesFilter.createLessOrEqualFilter(attType,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createLessOrEqualFilter(attType, null);
    }
    catch (NullPointerException e)
    {
@@ -777,20 +771,19 @@
    }
    //
    // ( AttributeType attributeType, AttributeValue assertionValue
    // ( AttributeType attributeType, ByteString assertionValue
    //
    AttributeType attType = DirectoryServer.getAttributeType(type);
    AttributeValue attVal = null ;
    ByteString attVal = null ;
    if (attType != null)
    {
      attVal = AttributeValues.create(attType, value);
      attVal = ByteString.valueOf(value);
    }
    // Check null, null
    try
    {
      mvf = MatchedValuesFilter.createApproximateFilter((AttributeType) null,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createApproximateFilter((AttributeType) null, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -805,8 +798,7 @@
    // Check type, null
    try
    {
      mvf = MatchedValuesFilter.createApproximateFilter(attType,
          (AttributeValue) null);
      mvf = MatchedValuesFilter.createApproximateFilter(attType, null);
      assertTrue(false, "Expected NullPointerException");
    }
    catch (NullPointerException e)
@@ -881,16 +873,14 @@
    String          rawAttTypeTest = type ;
    AttributeType      attTypeTest = DirectoryServer.getAttributeType(type) ;
    String             matchingRuleIdTest = matchingRule.getOID() ;
    ByteString rawAttValueTest = (attTypeTest == null) ? null : ByteString.valueOf(value);
    AttributeValue     attValueTest = (attTypeTest == null) ? null : AttributeValues.create(attTypeTest, value);
    ByteString    attValueTest = (attTypeTest == null) ? null : ByteString.valueOf(value);
    //
    // parameter used for the test.
    String          rawAttTypeTestCurrent;
    AttributeType      attTypeTestCurrent ;
    String          rawMatchingRuleidTestCurrent ;
    MatchingRule        matchingRuleidTestCurrent ;
    ByteString      rawAttValueTestCurrent;
    AttributeValue     attValueTestCurrent;
    ByteString     attValueTestCurrent;
    for (int i= 0 ; i <= 7 ; i++)
@@ -898,7 +888,6 @@
      rawAttTypeTestCurrent = null;
      rawMatchingRuleidTestCurrent = null;
      matchingRuleidTestCurrent = null ;
      rawAttValueTestCurrent = null;
      attTypeTestCurrent = null;
      attValueTestCurrent = null ;
@@ -906,7 +895,6 @@
      if ((i & 0x4) != 0) rawAttTypeTestCurrent = rawAttTypeTest;
      if ((i & 0x2) != 0) rawMatchingRuleidTestCurrent = matchingRuleIdTest;
      if ((i & 0x2) != 0) matchingRuleidTestCurrent = matchingRule ;
      if ((i & 0x1) != 0) rawAttValueTestCurrent = rawAttValueTest;
      if ((i & 0x1) != 0) attValueTestCurrent = attValueTest;
      boolean exceptionExpected = (attTypeTestCurrent == null)
@@ -917,7 +905,7 @@
      {
        // Create filter with raw value
        mvf = MatchedValuesFilter.createExtensibleMatchFilter(rawAttTypeTestCurrent,
            rawMatchingRuleidTestCurrent, rawAttValueTestCurrent);
            rawMatchingRuleidTestCurrent, attValueTestCurrent);
        if ( exceptionExpected)
        {
          assertTrue(false, "Expected NullPointerException");
@@ -928,7 +916,7 @@
          assertEquals(mvf.getMatchType(),
              MatchedValuesFilter.EXTENSIBLE_MATCH_TYPE);
          assertEquals(rawMatchingRuleidTestCurrent, mvf.getMatchingRuleID());
          assertEquals(rawAttValueTestCurrent, mvf.getRawAssertionValue());
          assertEquals(attValueTestCurrent, mvf.getRawAssertionValue());
          mvf = MatchedValuesFilter.createExtensibleMatchFilter(
              attTypeTestCurrent, matchingRuleidTestCurrent, attValueTestCurrent);
@@ -941,10 +929,7 @@
      }
      catch (Throwable t)
      {
        if ( ! exceptionExpected)
        {
          assertTrue(false, "Exception not excepted" + t.getMessage());
        }
        assertTrue(exceptionExpected, "Exception not excepted" + t.getMessage());
      }
    }
  }
@@ -952,27 +937,18 @@
  /**
   * Check encode/decode method
   */
  private void checkEncodeDecode(MatchedValuesFilter mvf)
  private void checkEncodeDecode(MatchedValuesFilter mvf) throws Exception
  {
    ByteStringBuilder bsb = new ByteStringBuilder();
    ASN1Writer writer = ASN1.getWriter(bsb);
    try
    {
      mvf.encode(writer);
      MatchedValuesFilter newMvf = MatchedValuesFilter.decode(ASN1
          .getReader(bsb));
      assertEquals(newMvf.toString(), mvf.toString());
    }
    catch (Exception e)
    {
      assertTrue(false, "Unexpected LDAPException ; msg=" + e.getMessage());
    }
  }
  /**
   *
   */
  @DataProvider(name = "differentNormalization")
  public Object[][] differentNormalizationData() throws ParseException
  {
@@ -1000,18 +976,12 @@
        CERT_EXACT_ASSERTION}};
  }
  /**
   *
   */
  @Test(dataProvider = "differentNormalization")
  public void testDifferentNormalization(String type, ByteString value,
                                         String assertion)
  {
    MatchedValuesFilter mvf;
    AttributeType attrType = DirectoryServer.getAttributeType("usercertificate");
    AttributeValue attrValue = AttributeValues.create(attrType, value);
    mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(assertion));
    assertTrue(mvf.valueMatches(attrType, attrValue));
    MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOf(assertion));
    assertTrue(mvf.valueMatches(attrType, value));
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
@@ -26,9 +26,6 @@
 */
package org.opends.server.core;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.testng.Assert.*;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
@@ -36,6 +33,8 @@
import java.util.concurrent.locks.Lock;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
import org.opends.server.plugins.DisconnectClientPlugin;
@@ -47,13 +46,14 @@
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for add operations
 */
@@ -438,14 +438,12 @@
    boolean foundBar = false;
    for (Attribute attr : attrList)
    {
      if (attr.contains(AttributeValues.create(a.getAttributeType(),
                                           ByteString.valueOf("foo"))))
      if (attr.contains(ByteString.valueOf("foo")))
      {
        foundFoo = true;
      }
      if (attr.contains(AttributeValues.create(a.getAttributeType(),
                                                ByteString.valueOf("bar"))))
      if (attr.contains(ByteString.valueOf("bar")))
      {
        foundBar = true;
      }
@@ -1239,9 +1237,9 @@
    boolean found = false;
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        if (v.getValue().toString().equalsIgnoreCase("top"))
        if (v.toString().equalsIgnoreCase("top"))
        {
          found = true;
          break;
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
@@ -2045,9 +2045,9 @@
    boolean found = false;
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        assertEquals(Integer.parseInt(v.getValue().toString()), expectedValue);
        assertEquals(Integer.parseInt(v.toString()), expectedValue);
        found = true;
      }
    }
@@ -3515,7 +3515,7 @@
    String passwd = null;
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      for (ByteString v : a)
      {
        passwd = v.toString();
      }
@@ -3760,7 +3760,7 @@
    Attribute a = attrList.get(0);
    assertTrue(a.hasOption("binary"));
    assertEquals(a.size(), 1);
    assertEquals(Base64.encode(a.iterator().next().getValue()), certificateValue);
    assertEquals(Base64.encode(a.iterator().next()), certificateValue);
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/PluginConfigManagerTestCase.java
@@ -640,8 +640,7 @@
      expectedOrder.append(expectedNameOrder[i]);
      DN dn = pluginArray[i].getPluginEntryDN();
      String name =
           dn.rdn().getAttributeValue(0).getValue().toString().toLowerCase();
      String name = dn.rdn().getAttributeValue(0).toString().toLowerCase();
      actualOrder.append(name);
      if (! name.equals(expectedNameOrder[i]))
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryManagerTestCase.java
@@ -153,17 +153,13 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType(
            "c-l");
    AttributeType attrType = DirectoryServer.getAttributeType("c-l");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "Savoie")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie")));
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "fr")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
  }
@@ -246,8 +242,7 @@
      Attribute attribute = description.get(0);
      assertEquals(attribute.size(), 1);
      assertFalse(attribute.hasOptions());
      assertTrue(attribute.contains(AttributeValues.create(
          attribute.getAttributeType(), "inherited description")));
      assertTrue(attribute.contains(ByteString.valueOf("inherited description")));
    }
    finally
    {
@@ -307,19 +302,15 @@
    // Test Inherited Collective Attributes on test entry.
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType(
            "postaladdress");
    AttributeType attrType = DirectoryServer.getAttributeType("postaladdress");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType,
            "Sub City, Collective Street, AK 47")));
            ByteString.valueOf("Sub City, Collective Street, AK 47")));
    attrType = DirectoryServer.getAttributeType(
            "telephonenumber");
    attrType = DirectoryServer.getAttributeType("telephonenumber");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType,
            "+1 999 999 9999")));
            ByteString.valueOf("+1 999 999 9999")));
    // Cleanup.
    TestCaseUtils.deleteEntry(collectiveRDNInheritedSubentry.getName());
@@ -356,13 +347,10 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    AttributeType attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "ja")));
    assertFalse(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "fr")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    // virtual-overrides-real.
    values = new ArrayList<ByteString>();
@@ -377,13 +365,10 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "fr")));
    assertFalse(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "ja")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    // merge-real-and-virtual.
    values = new ArrayList<ByteString>();
@@ -398,13 +383,10 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "ja")));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "fr")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    // cleanup.
    values = new ArrayList<ByteString>();
@@ -444,11 +426,9 @@
    searchOperation.run();
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
    assertEquals(searchOperation.getEntriesSent(), 1);
    AttributeType attrType = DirectoryServer.getAttributeType(
            "collectiveattributesubentries");
    AttributeType attrType = DirectoryServer.getAttributeType("collectiveattributesubentries");
    assertTrue(searchOperation.getSearchEntries().getFirst().hasValue(
            attrType, null, AttributeValues.create(attrType,
            collectiveSubentry.getName().toNormalizedString())));
            attrType, null, ByteString.valueOf(collectiveSubentry.getName())));
  }
  @Test
@@ -478,14 +458,11 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType(
            "c-l");
    AttributeType attrType = DirectoryServer.getAttributeType("c-l");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "fr")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("preferredLanguage"));
@@ -498,14 +475,11 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType(
            "c-l");
    attrType = DirectoryServer.getAttributeType("c-l");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            AttributeValues.create(attrType, "Savoie")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie")));
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("excludeAllCollectiveAttributes"));
@@ -518,11 +492,9 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType(
            "preferredlanguage");
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType(
            "c-l");
    attrType = DirectoryServer.getAttributeType("c-l");
    assertFalse(entry.hasAttribute(attrType));
    // cleanup.
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java
@@ -40,9 +40,9 @@
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterClass;
@@ -475,9 +475,7 @@
    // for the user entry.
    assertTrue(testEntry.hasAttribute(attrType));
    assertTrue(testEntry.hasValue(attrType, null,
            AttributeValues.create(attrType,
            defaultPolicy.getDN(
            ).toString())));
            ByteString.valueOf(defaultPolicy.getDN().toString())));
    // Add new subentry policy with the
    // scope to apply to the user entry.
@@ -512,8 +510,7 @@
    assertTrue(testEntry.hasAttribute(attrType));
    assertTrue(testEntry.hasValue(attrType, null,
            AttributeValues.create(attrType,
            "cn=Temp Policy," + SUFFIX)));
            ByteString.valueOf("cn=Temp Policy," + SUFFIX)));
    // Remove subentry policy and make sure
    // default policy is in effect again.
@@ -525,8 +522,6 @@
    assertTrue(testEntry.hasAttribute(attrType));
    assertTrue(testEntry.hasValue(attrType, null,
            AttributeValues.create(attrType,
            defaultPolicy.getDN(
            ).toString())));
            ByteString.valueOf(defaultPolicy.getDN().toString())));
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
@@ -306,10 +306,8 @@
    for (int i = 0; i < rdn.getNumValues(); i++)
    {
      AttributeType attribute = rdn.getAttributeType(i);
      assertEquals(newEntry.hasValue(attribute, null, AttributeValues.create(
          attribute, "user.0")), user0Exists);
      assertEquals(newEntry.hasValue(attribute, null, AttributeValues.create(
          attribute, "user.test0")), userTest0Exists);
      assertEquals(newEntry.hasValue(attribute, null, ByteString.valueOf("user.0")), user0Exists);
      assertEquals(newEntry.hasValue(attribute, null, ByteString.valueOf("user.test0")), userTest0Exists);
    }
  }
@@ -395,8 +393,8 @@
    assertEquals(attrList.size(),1);
    // Because deleteOldRDN is true, the values from RDN and the entry have to be identical
    ByteString valueFromEntry = attrList.get(0).iterator().next().getValue();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue();
    ByteString valueFromEntry = attrList.get(0).iterator().next();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at);
    assertEquals(valueFromEntry,valueFromRDN);
    examineCompletedOperation(modifyDNOperation);
@@ -460,9 +458,10 @@
    assertEquals(attrList.size(),1);
    // Even though the value of the RDN changed, the representation of the entry's value should be preserved
    ByteString valueFromEntry = attrList.get(0).iterator().next().getValue();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue();
    assertEquals(valueFromEntry,ByteString.valueOf("userid.0"));
    ByteString valueFromEntry = attrList.get(0).iterator().next();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at);
    assertEquals(valueFromEntry, valueFromRDN);
    assertEquals(valueFromEntry, ByteString.valueOf("UserID.0"));
    examineCompletedOperation(modifyDNOperation);
    TestCaseUtils.deleteEntry(DN.valueOf("uid=UserID.0+cn=Test,ou=People,dc=example,dc=com"));
@@ -511,9 +510,10 @@
    // Even though the representation of the sn value differs in the RDN,
    // the representation of the entry's value should be preserved
    ByteString valueFromEntry = attrList.get(0).iterator().next().getValue();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at).getValue();
    assertEquals(valueFromEntry,ByteString.valueOf("Jensen"));
    ByteString valueFromEntry = attrList.get(0).iterator().next();
    ByteString valueFromRDN = newEntry.getName().rdn().getAttributeValue(at);
    assertEquals(valueFromEntry, valueFromRDN);
    assertEquals(valueFromEntry, ByteString.valueOf("JENSEN"));
    examineCompletedOperation(modifyDNOperation);
    TestCaseUtils.deleteEntry(DN.valueOf("uid=userid.0+sn=Jensen,ou=People,dc=example,dc=com"));
@@ -663,8 +663,8 @@
    for(Attribute attribute : newEntry.getAttribute("cn"))
    {
      assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar Test")));
      assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar")));
      assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar Test")));
      assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar")));
    }
    examineCompletedOPNoExtraPluginCounts(modifyDNOperation);
@@ -685,12 +685,12 @@
    assertNull(DirectoryServer.getEntry(DN.valueOf("cn=Aaccf Amar Test,dc=example,dc=com")));
    for(Attribute attribute : newOldEntry.getAttribute("cn"))
    {
      assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar Test")));
      assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "Aaccf Amar")));
      assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar Test")));
      assertTrue(attribute.contains(ByteString.valueOf("Aaccf Amar")));
    }
    for(Attribute attribute : newOldEntry.getAttribute("uid"))
    {
      assertTrue(attribute.contains(AttributeValues.create(attribute.getAttributeType(), "user.0")));
      assertTrue(attribute.contains(ByteString.valueOf("user.0")));
    }
    examineCompletedOPNoExtraPluginCounts(modifyDNOperation);
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntityTagVirtualAttributeProviderTestCase.java
@@ -29,7 +29,6 @@
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -62,9 +61,8 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
@@ -90,8 +88,7 @@
  private static final String DESCRIPTION = "description";
  private static final String ETAG = "etag";
  private final AttributeValue dummyValue = AttributeValues.create(
      ByteString.valueOf("dummy"), ByteString.valueOf("dummy"));
  private final ByteString dummyValue = ByteString.valueOf("dummy");
  private final EntityTagVirtualAttributeProvider provider = new EntityTagVirtualAttributeProvider();
  private boolean changeListenerRemoved = false;
  private boolean changeListenerAdded = false;
@@ -301,7 +298,7 @@
  {
    final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example");
    getEntityTag(e);
    getEntityTag(e, getRule());
  }
@@ -320,7 +317,8 @@
        "objectClass: top", "objectClass: domain", "dc: example1");
    final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example2,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example2");
    assertFalse(getEntityTag(e1).equals(getEntityTag(e2)));
    VirtualAttributeRule rule = getRule();
    assertFalse(getEntityTag(e1, rule).equals(getEntityTag(e2, rule)));
  }
@@ -339,7 +337,8 @@
    final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example",
        "modifyTimestamp: 20120222232918Z");
    assertEquals(getEntityTag(e1), getEntityTag(e2));
    VirtualAttributeRule rule = getRule();
    assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule));
  }
@@ -360,7 +359,8 @@
    final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example",
        "description: two", "description: one");
    assertEquals(getEntityTag(e1), getEntityTag(e2));
    VirtualAttributeRule rule = getRule();
    assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule));
  }
@@ -379,7 +379,8 @@
        "objectClass: top", "objectClass: domain", "dc: example");
    final Entry e2 = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example");
    assertEquals(getEntityTag(e1), getEntityTag(e2));
    VirtualAttributeRule rule = getRule();
    assertEquals(getEntityTag(e1, rule), getEntityTag(e2, rule));
  }
@@ -407,34 +408,12 @@
  {
    final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example");
    final AttributeValue value = getEntityTag(e);
    assertTrue(provider.hasAllValues(e, null,
        Collections.<AttributeValue> emptySet()));
    assertTrue(provider.hasAllValues(e, null, Collections.singleton(value)));
    assertFalse(provider.hasAllValues(e, null,
        Collections.singleton(dummyValue)));
    assertFalse(provider
        .hasAllValues(e, null, Arrays.asList(value, dummyValue)));
  }
  /**
   * Tests hasAnyValues() membership.
   *
   * @throws Exception
   *           If an unexpected exception occurred.
   */
  @Test
  public void testHasAnyValue() throws Exception
  {
    final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example");
    final AttributeValue value = getEntityTag(e);
    assertTrue(provider.hasAnyValue(e, null, Collections.singleton(value)));
    assertFalse(provider
        .hasAnyValue(e, null, Collections.singleton(dummyValue)));
    assertTrue(provider.hasAnyValue(e, null, Arrays.asList(value, dummyValue)));
    VirtualAttributeRule rule = getRule();
    final ByteString value = getEntityTag(e, rule);
    assertTrue(provider.hasAllValues(e, rule, Collections.<ByteString> emptySet()));
    assertTrue(provider.hasAllValues(e, rule, Collections.singleton(value)));
    assertFalse(provider.hasAllValues(e, rule, Collections.singleton(dummyValue)));
    assertFalse(provider.hasAllValues(e, rule, Arrays.asList(value, dummyValue)));
  }
@@ -461,9 +440,10 @@
  {
    final Entry e = TestCaseUtils.makeEntry("dn: dc=example,dc=com",
        "objectClass: top", "objectClass: domain", "dc: example");
    final AttributeValue value = getEntityTag(e);
    assertTrue(provider.hasValue(e, null, value));
    assertFalse(provider.hasValue(e, null, dummyValue));
    VirtualAttributeRule rule = getRule();
    final ByteString value = getEntityTag(e, rule);
    assertTrue(provider.hasValue(e, rule, value));
    assertFalse(provider.hasValue(e, rule, dummyValue));
  }
@@ -884,18 +864,17 @@
  private AttributeValue getEntityTag(final Entry e)
  private ByteString getEntityTag(final Entry e, VirtualAttributeRule rule)
  {
    final Set<AttributeValue> values = provider.getValues(e, null);
    final Attribute values = provider.getValues(e, rule);
    assertEquals(values.size(), 1);
    final AttributeValue value = values.iterator().next();
    final ByteString bs = value.getValue();
    assertEquals(bs.length(), 16);
    final ByteString value = values.iterator().next();
    assertEquals(value.length(), 16);
    boolean gotNonZeroByte = false;
    for (int i = 0; i < 16; i++)
    {
      assertTrue(StaticUtils.isHexDigit(bs.byteAt(i)));
      if (bs.byteAt(i) != 0x30)
      assertTrue(StaticUtils.isHexDigit(value.byteAt(i)));
      if (value.byteAt(i) != 0x30)
      {
        gotNonZeroByte = true;
      }
@@ -904,4 +883,14 @@
    return value;
  }
  private VirtualAttributeRule getRule()
  {
    AttributeType type = DirectoryServer.getAttributeType("etag", false);
    return new VirtualAttributeRule(type, provider,
        Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
        Collections.<DN>emptySet(),
        Collections.<SearchFilter>emptySet(),
        VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL);
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
@@ -30,7 +30,6 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
@@ -38,6 +37,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -133,8 +133,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(entryDNType,
                                               entryDN.toNormalizedString())));
      assertTrue(a.contains(ByteString.valueOf(entryDN.toNormalizedString())));
    }
  }
@@ -424,18 +423,10 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, getRule(provider));
    assertNotNull(values);
    assertEquals(values.size(), 1);
    assertTrue(values.contains(AttributeValues.create(entryDNType, "o=test")));
    assertTrue(values.contains(ByteString.valueOf("o=test")));
  }
@@ -460,15 +451,7 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule));
    assertTrue(provider.hasValue(entry, getRule(provider)));
  }
@@ -493,16 +476,18 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
    assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=test")));
  }
  private VirtualAttributeRule getRule(VirtualAttributeProvider<?> provider)
  {
    return new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(entryDNType, "o=test")));
                  VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL);
  }
@@ -527,197 +512,7 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(entryDNType, "o=not test")));
  }
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  {
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(entryDNType, "o=test"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(entryDNType, "o=not test"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(entryDNType, "o=test"));
    values.add(AttributeValues.create(entryDNType, "o=not test"));
    values.add(AttributeValues.create(entryDNType, "o=not test either"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(entryDNType, "o=not test"));
    values.add(AttributeValues.create(entryDNType, "o=not test either"));
    values.add(AttributeValues.create(entryDNType, "o=still not test"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("o=not test")));
  }
@@ -742,18 +537,10 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedList<ByteString> subAny = new LinkedList<ByteString>();
    subAny.add(ByteString.valueOf("="));
    assertEquals(provider.matchesSubstring(entry, rule, null, subAny, null),
    assertEquals(provider.matchesSubstring(entry, getRule(provider), null, subAny, null),
                 ConditionResult.UNDEFINED);
  }
@@ -779,16 +566,8 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(entryDNType, "o=test2");
    assertEquals(provider.greaterThanOrEqualTo(entry, rule, value),
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.greaterThanOrEqualTo(entry, getRule(provider), value),
                 ConditionResult.UNDEFINED);
  }
@@ -814,16 +593,8 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(entryDNType, "o=test2");
    assertEquals(provider.lessThanOrEqualTo(entry, rule, value),
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.lessThanOrEqualTo(entry, getRule(provider), value),
                 ConditionResult.UNDEFINED);
  }
@@ -849,16 +620,8 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(entryDNType, "o=test2");
    assertEquals(provider.approximatelyEqualTo(entry, rule, value),
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.approximatelyEqualTo(entry, getRule(provider), value),
                 ConditionResult.UNDEFINED);
  }
@@ -917,13 +680,7 @@
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    VirtualAttributeRule rule = getRule(provider);
    SearchFilter filter = SearchFilter.createFilterFromString(filterString);
@@ -970,13 +727,7 @@
    EntryDNVirtualAttributeProvider provider =
         new EntryDNVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryDNType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    VirtualAttributeRule rule = getRule(provider);
    SearchFilter filter = SearchFilter.createFilterFromString(filterString);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
@@ -30,10 +30,11 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
@@ -43,7 +44,6 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -133,7 +133,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(entryUUIDType, uuidString)));
      assertTrue(a.contains(ByteString.valueOf(uuidString)));
    }
  }
@@ -177,7 +177,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertFalse(a.contains(AttributeValues.create(entryUUIDType, uuidString)));
      assertFalse(a.contains(ByteString.valueOf(uuidString)));
    }
  }
@@ -478,10 +478,10 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, rule);
    assertNotNull(values);
    assertEquals(values.size(), 1);
    assertTrue(values.contains(AttributeValues.create(entryUUIDType, uuidString)));
    assertTrue(values.contains(ByteString.valueOf(uuidString)));
  }
@@ -549,9 +549,7 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(entryUUIDType,
                                                    uuidString)));
    assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(uuidString)));
  }
@@ -584,193 +582,6 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(entryUUIDType, "wrong")));
  }
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  {
    EntryUUIDVirtualAttributeProvider provider =
         new EntryUUIDVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryUUIDType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString();
    EntryUUIDVirtualAttributeProvider provider =
         new EntryUUIDVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryUUIDType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(entryUUIDType, uuidString));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    EntryUUIDVirtualAttributeProvider provider =
         new EntryUUIDVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryUUIDType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(entryUUIDType, "wrong"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString();
    EntryUUIDVirtualAttributeProvider provider =
         new EntryUUIDVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryUUIDType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(entryUUIDType, uuidString));
    values.add(AttributeValues.create(entryUUIDType, "wrong"));
    values.add(AttributeValues.create(entryUUIDType, "also wrong"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    EntryUUIDVirtualAttributeProvider provider =
         new EntryUUIDVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(entryUUIDType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(entryUUIDType, "wrong"));
    values.add(AttributeValues.create(entryUUIDType, "also wrong"));
    values.add(AttributeValues.create(entryUUIDType, "still wrong"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("wrong")));
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
@@ -143,7 +143,7 @@
         "ds-cfg-match-attribute: uid");
    AttributeType t = DirectoryServer.getAttributeType("ds-cfg-match-base-dn");
    e.addAttribute(Attributes.empty(t), new ArrayList<AttributeValue>());
    e.addAttribute(Attributes.empty(t), new ArrayList<ByteString>());
    entries.add(e);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.extensions;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -35,18 +33,17 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -59,8 +56,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * A set of test cases for the governing structure rule virtual attribute
 * provider.
@@ -197,8 +192,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(governingStructureRuleType,
                              ruleId)));
      assertTrue(a.contains(ByteString.valueOf(ruleId)));
    }
  }
@@ -489,19 +483,10 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, getRule(provider));
    assertNotNull(values);
    assertEquals(values.size(), 1);
    assertTrue(values.contains(AttributeValues.create(governingStructureRuleType,
                                  "22")));
    assertTrue(values.contains(ByteString.valueOf("22")));
  }
@@ -526,15 +511,7 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule));
    assertTrue(provider.hasValue(entry, getRule(provider)));
  }
@@ -559,16 +536,7 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(governingStructureRuleType,"22")));
    assertTrue(provider.hasValue(entry, getRule(provider), ByteString.valueOf("22")));
  }
@@ -593,198 +561,16 @@
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(governingStructureRuleType,
                                        "1")));
    assertFalse(provider.hasValue(entry, getRule(provider), ByteString.valueOf("1")));
  }
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  private VirtualAttributeRule getRule(VirtualAttributeProvider<?> provider)
  {
    GoverningStructureRuleVirtualAttributeProvider provider =
         new GoverningStructureRuleVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectclass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
    return new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    GoverningStructureRuleVirtualAttributeProvider provider =
         new GoverningStructureRuleVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(governingStructureRuleType, "22"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    GoverningStructureRuleVirtualAttributeProvider provider =
         new GoverningStructureRuleVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectclass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(governingStructureRuleType, "1"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    GoverningStructureRuleVirtualAttributeProvider provider =
         new GoverningStructureRuleVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(governingStructureRuleType, "22"));
    values.add(AttributeValues.create(governingStructureRuleType, "1"));
    values.add(AttributeValues.create(governingStructureRuleType,"2"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    GoverningStructureRuleVirtualAttributeProvider provider =
         new GoverningStructureRuleVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectclass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(governingStructureRuleType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(governingStructureRuleType, "1"));
    values.add(AttributeValues.create(governingStructureRuleType, "2"));
    values.add(AttributeValues.create(governingStructureRuleType,"3"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
                  VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL);
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
@@ -225,11 +225,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(
          ByteString.valueOf(toUpperCase(String.valueOf(hasSubs))),
          ByteString.valueOf(toUpperCase(String.valueOf(hasSubs))))));
      assertTrue(a.contains(AttributeValues.create(hasSubordinatesType,
          toUpperCase(String.valueOf(hasSubs)))));
      assertTrue(a.contains(ByteString.valueOf(toUpperCase(String.valueOf(hasSubs)))));
    }
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java
@@ -40,8 +40,6 @@
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -134,11 +132,9 @@
      assertEquals(a.size(), 1);
      assertTrue(!a.isEmpty());
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test static group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid")));
      assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("invalid")));
    }
    InternalClientConnection conn =
@@ -200,11 +196,9 @@
      assertEquals(a.size(), 1);
      assertTrue(!a.isEmpty());
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test static group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid")));
      assertTrue(a.contains(ByteString.valueOf("cn=test static group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("invalid")));
    }
    InternalClientConnection conn =
@@ -265,11 +259,9 @@
      assertEquals(a.size(), 1);
      assertTrue(!a.isEmpty());
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                      "cn=test dynamic group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid")));
      assertTrue(a.contains(ByteString.valueOf("cn=test dynamic group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("invalid")));
    }
    InternalClientConnection conn =
@@ -355,15 +347,11 @@
      assertEquals(a.size(), 2);
      assertTrue(!a.isEmpty());
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 1,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=test group 2,ou=groups,o=test")));
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 3,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("invalid")));
    }
    InternalClientConnection conn =
@@ -474,21 +462,14 @@
      assertEquals(a.size(), 4);
      assertTrue(!a.isEmpty());
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 1,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=test group 2,ou=groups,o=test")));
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 3,ou=groups,o=test")));
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 4,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=test group 5,ou=groups,o=test")));
      assertTrue(a.contains(AttributeValues.create(isMemberOfType,
                                     "cn=test group 6,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType,
                                      "cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(AttributeValues.create(isMemberOfType, "invalid")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 1,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=test group 2,ou=groups,o=test")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 3,ou=groups,o=test")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 4,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=test group 5,ou=groups,o=test")));
      assertTrue(a.contains(ByteString.valueOf("cn=test group 6,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("cn=not a group,ou=groups,o=test")));
      assertFalse(a.contains(ByteString.valueOf("invalid")));
    }
    InternalClientConnection conn =
@@ -534,346 +515,6 @@
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    TestCaseUtils.addEntries(
      "dn: ou=People,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: People",
      "",
      "dn: uid=test.user,ou=People,o=test",
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
      "objectClass: inetOrgPerson",
      "uid: test.user",
      "givenName: Test",
      "sn: User",
      "cn: Test User",
      "userPassword: password",
      "",
      "dn: ou=Groups,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: Groups",
      "",
      "dn: cn=Test Static Group,ou=Groups,o=test",
      "objectClass: top",
      "objectClass: groupOfNames",
      "cn: Test Static Group",
      "member: uid=test.user,ou=People,o=test");
    Entry e =
         DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test"));
    IsMemberOfVirtualAttributeProvider provider =
         new IsMemberOfVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(isMemberOfType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(e, rule,
                                     Collections.<AttributeValue>emptySet()));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    TestCaseUtils.addEntries(
      "dn: ou=People,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: People",
      "",
      "dn: uid=test.user,ou=People,o=test",
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
      "objectClass: inetOrgPerson",
      "uid: test.user",
      "givenName: Test",
      "sn: User",
      "cn: Test User",
      "userPassword: password",
      "",
      "dn: ou=Groups,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: Groups",
      "",
      "dn: cn=Test Static Group,ou=Groups,o=test",
      "objectClass: top",
      "objectClass: groupOfNames",
      "cn: Test Static Group",
      "member: uid=test.user,ou=People,o=test");
    Entry e =
         DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test"));
    IsMemberOfVirtualAttributeProvider provider =
         new IsMemberOfVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(isMemberOfType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test static group,ou=groups,o=test"));
    assertTrue(provider.hasAnyValue(e, rule, values));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    TestCaseUtils.addEntries(
      "dn: ou=People,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: People",
      "",
      "dn: uid=test.user,ou=People,o=test",
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
      "objectClass: inetOrgPerson",
      "uid: test.user",
      "givenName: Test",
      "sn: User",
      "cn: Test User",
      "userPassword: password",
      "",
      "dn: ou=Groups,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: Groups",
      "",
      "dn: cn=Test Static Group,ou=Groups,o=test",
      "objectClass: top",
      "objectClass: groupOfNames",
      "cn: Test Static Group",
      "member: uid=test.user,ou=People,o=test");
    Entry e =
         DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test"));
    IsMemberOfVirtualAttributeProvider provider =
         new IsMemberOfVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(isMemberOfType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test dynamic group,ou=groups,o=test"));
    assertFalse(provider.hasAnyValue(e, rule, values));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    TestCaseUtils.addEntries(
      "dn: ou=People,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: People",
      "",
      "dn: uid=test.user,ou=People,o=test",
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
      "objectClass: inetOrgPerson",
      "uid: test.user",
      "givenName: Test",
      "sn: User",
      "cn: Test User",
      "userPassword: password",
      "",
      "dn: ou=Groups,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: Groups",
      "",
      "dn: cn=Test Static Group,ou=Groups,o=test",
      "objectClass: top",
      "objectClass: groupOfNames",
      "cn: Test Static Group",
      "member: uid=test.user,ou=People,o=test");
    Entry e =
         DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test"));
    IsMemberOfVirtualAttributeProvider provider =
         new IsMemberOfVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(isMemberOfType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test static group,ou=groups,o=test"));
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test dynamic group,ou=groups,o=test"));
    assertTrue(provider.hasAnyValue(e, rule, values));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    TestCaseUtils.addEntries(
      "dn: ou=People,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: People",
      "",
      "dn: uid=test.user,ou=People,o=test",
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
      "objectClass: inetOrgPerson",
      "uid: test.user",
      "givenName: Test",
      "sn: User",
      "cn: Test User",
      "userPassword: password",
      "",
      "dn: ou=Groups,o=test",
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: Groups",
      "",
      "dn: cn=Test Static Group,ou=Groups,o=test",
      "objectClass: top",
      "objectClass: groupOfNames",
      "cn: Test Static Group",
      "member: uid=test.user,ou=People,o=test");
    Entry e =
         DirectoryServer.getEntry(DN.valueOf("uid=test.user,ou=People,o=test"));
    IsMemberOfVirtualAttributeProvider provider =
         new IsMemberOfVirtualAttributeProvider();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(isMemberOfType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test nonstatic group,ou=groups,o=test"));
    values.add(AttributeValues.create(isMemberOfType,
                                  "cn=test dynamic group,ou=groups,o=test"));
    assertFalse(provider.hasAnyValue(e, rule, values));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test static group,ou=groups,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
   * Tests the {@code matchesSubstring} method to ensure that it returns a
   * result of "undefined".
   *
@@ -938,7 +579,7 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2");
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.greaterThanOrEqualTo(entry, rule, value),
                 ConditionResult.UNDEFINED);
  }
@@ -973,7 +614,7 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2");
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.lessThanOrEqualTo(entry, rule, value),
                 ConditionResult.UNDEFINED);
  }
@@ -1008,7 +649,7 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    AttributeValue value = AttributeValues.create(isMemberOfType, "o=test2");
    ByteString value = ByteString.valueOf("o=test2");
    assertEquals(provider.approximatelyEqualTo(entry, rule, value),
                 ConditionResult.UNDEFINED);
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
@@ -226,11 +226,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(
          ByteString.valueOf(String.valueOf(count)),
          ByteString.valueOf(String.valueOf(count)))));
      assertTrue(a.contains(AttributeValues.create(numSubordinatesType,
                                               String.valueOf(count))));
      assertTrue(a.contains(ByteString.valueOf(String.valueOf(count))));
    }
  }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordExpirationTimeVirtualAttributeProviderTestCase.java
@@ -32,6 +32,7 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
@@ -237,15 +238,14 @@
    Attribute attr = attrs.get(0);
    assertNotNull(attr);
    Iterator<AttributeValue> it = attr.iterator();
    Iterator<ByteString> it = attr.iterator();
    assertTrue(it.hasNext());
    AttributeValue val = it.next();
    ByteString val = it.next();
    conn.disconnect(DisconnectReason.UNBIND, true, LocalizableMessage.EMPTY);
    return
      GeneralizedTimeSyntax.decodeGeneralizedTimeValue(val.getValue());
    return GeneralizedTimeSyntax.decodeGeneralizedTimeValue(val);
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.extensions;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -35,7 +33,6 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
@@ -45,8 +42,7 @@
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -58,8 +54,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * A set of test cases for the structural object class virtual attribute
 * provider.
@@ -165,8 +159,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(structuralObjectClassType,
                              e.getStructuralObjectClass().getNameOrOID())));
      assertTrue(a.contains(ByteString.valueOf(e.getStructuralObjectClass().getNameOrOID())));
    }
  }
@@ -444,8 +437,7 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testGetValues()
         throws Exception
  public void testGetValues() throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
@@ -465,11 +457,10 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, rule);
    assertNotNull(values);
    assertEquals(values.size(), 1);
    assertTrue(values.contains(AttributeValues.create(structuralObjectClassType,
                                  entry.getStructuralObjectClass().getNameOrOID())));
    assertTrue(values.contains(ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID())));
  }
@@ -536,8 +527,7 @@
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(structuralObjectClassType,
                          entry.getStructuralObjectClass().getNameOrOID())));
        ByteString.valueOf(entry.getStructuralObjectClass().getNameOrOID())));
  }
@@ -570,193 +560,6 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(structuralObjectClassType,
                                        "inetorgperson")));
  }
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(structuralObjectClassType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(structuralObjectClassType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(structuralObjectClassType, "organization"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(structuralObjectClassType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(structuralObjectClassType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(structuralObjectClassType, "organization"));
    values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson"));
    values.add(AttributeValues.create(structuralObjectClassType,
                                  "top"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    StructuralObjectClassVirtualAttributeProvider provider =
         new StructuralObjectClassVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(structuralObjectClassType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(structuralObjectClassType, "inetorgperson"));
    values.add(AttributeValues.create(structuralObjectClassType,
                                  "top"));
    values.add(AttributeValues.create(structuralObjectClassType,
                                  "domain"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("inetorgperson")));
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.extensions;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -35,7 +33,6 @@
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
@@ -45,8 +42,7 @@
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -58,8 +54,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * A set of test cases for the subschemaSubentry virtual attribute provider.
 */
@@ -143,8 +137,7 @@
    {
      assertTrue(!a.isEmpty());
      assertEquals(a.size(), 1);
      assertTrue(a.contains(AttributeValues.create(subschemaSubentryType,
                                               "cn=schema")));
      assertTrue(a.contains(ByteString.valueOf("cn=schema")));
    }
  }
@@ -443,11 +436,10 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, rule);
    assertNotNull(values);
    assertEquals(values.size(), 1);
    assertTrue(values.contains(AttributeValues.create(subschemaSubentryType,
                                                  "cn=schema")));
    assertTrue(values.contains(ByteString.valueOf("cn=schema")));
  }
@@ -513,9 +505,7 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(subschemaSubentryType,
                                                    "cn=schema")));
    assertTrue(provider.hasValue(entry, rule, ByteString.valueOf("cn=schema")));
  }
@@ -548,193 +538,6 @@
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(subschemaSubentryType,
                                        "cn=not schema")));
  }
  /**
   * Tests the {@code hasAnyValue} method with an empty set of values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueEmptySet()
         throws Exception
  {
    SubschemaSubentryVirtualAttributeProvider provider =
         new SubschemaSubentryVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(subschemaSubentryType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * the correct value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyCorrect()
         throws Exception
  {
    SubschemaSubentryVirtualAttributeProvider provider =
         new SubschemaSubentryVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(subschemaSubentryType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(subschemaSubentryType, "cn=schema"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing only
   * an incorrect value.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueOnlyIncorrect()
         throws Exception
  {
    SubschemaSubentryVirtualAttributeProvider provider =
         new SubschemaSubentryVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(subschemaSubentryType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(1);
    values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of values containing the
   * correct value as well as multiple incorrect values.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueIncludesCorrect()
         throws Exception
  {
    SubschemaSubentryVirtualAttributeProvider provider =
         new SubschemaSubentryVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(subschemaSubentryType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(subschemaSubentryType, "cn=schema"));
    values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema"));
    values.add(AttributeValues.create(subschemaSubentryType,
                                  "cn=not schema either"));
    assertTrue(provider.hasAnyValue(entry, rule, values));
  }
  /**
   * Tests the {@code hasAnyValue} method with a set of multiple values, none of
   * which are correct.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testHasAnyValueMissingCorrect()
         throws Exception
  {
    SubschemaSubentryVirtualAttributeProvider provider =
         new SubschemaSubentryVirtualAttributeProvider();
    Entry entry = TestCaseUtils.makeEntry(
      "dn: o=test",
      "objectClass: top",
      "objectClass: organization",
      "o: test");
    entry.processVirtualAttributes();
    VirtualAttributeRule rule =
         new VirtualAttributeRule(subschemaSubentryType, provider,
                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
                  Collections.<DN>emptySet(),
                  Collections.<SearchFilter>emptySet(),
                  VirtualAttributeCfgDefn.ConflictBehavior.
                       VIRTUAL_OVERRIDES_REAL);
    LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>(3);
    values.add(AttributeValues.create(subschemaSubentryType, "cn=not schema"));
    values.add(AttributeValues.create(subschemaSubentryType,
                                  "cn=not schema either"));
    values.add(AttributeValues.create(subschemaSubentryType,
                                  "cn=still not schema"));
    assertFalse(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("cn=not schema")));
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java
@@ -29,6 +29,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
@@ -277,8 +278,7 @@
      Attribute attr = attrList.get(0);
      assertEquals(attr.size(), 1);
      assertTrue(attr.contains(AttributeValues.create(descriptionType,
          value)));
      assertTrue(attr.contains(ByteString.valueOf(value)));
    }
    finally
    {
@@ -350,10 +350,8 @@
      Attribute attr = attrList.get(0);
      assertEquals(attr.size(), 2);
      assertTrue(attr.contains(AttributeValues.create(descriptionType,
          value1)));
      assertTrue(attr.contains(AttributeValues.create(descriptionType,
          value2)));
      assertTrue(attr.contains(ByteString.valueOf(value1)));
      assertTrue(attr.contains(ByteString.valueOf(value2)));
    }
    finally
    {
@@ -425,8 +423,7 @@
      Attribute attr = attrList.get(0);
      assertEquals(attr.size(), 1);
      assertTrue(attr.contains(AttributeValues.create(descriptionType,
          realValue)));
      assertTrue(attr.contains(ByteString.valueOf(realValue)));
    }
    finally
    {
@@ -498,8 +495,7 @@
      Attribute attr = attrList.get(0);
      assertEquals(attr.size(), 1);
      assertTrue(attr.contains(AttributeValues.create(descriptionType,
          virtualValue)));
      assertTrue(attr.contains(ByteString.valueOf(virtualValue)));
    }
    finally
    {
@@ -572,10 +568,8 @@
      Attribute a = attrList.get(0);
      assertEquals(a.size(), 2);
      assertTrue(a.contains(AttributeValues.create(
          descriptionType, realValue)));
      assertTrue(a.contains(AttributeValues.create(
          descriptionType, virtualValue)));
      assertTrue(a.contains(ByteString.valueOf(realValue)));
      assertTrue(a.contains(ByteString.valueOf(virtualValue)));
    }
    finally
@@ -658,10 +652,8 @@
      Attribute a = attrList.get(0);
      assertEquals(a.size(), 2);
      assertTrue(a.contains(AttributeValues.create(
          descriptionType, realValue)));
      assertTrue(a.contains(AttributeValues.create(
          descriptionType, virtualValue)));
      assertTrue(a.contains(ByteString.valueOf(realValue)));
      assertTrue(a.contains(ByteString.valueOf(virtualValue)));
    }
    finally
    {
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/VirtualStaticGroupTestCase.java
@@ -26,14 +26,14 @@
 */
package org.opends.server.extensions;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
@@ -42,7 +42,6 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -638,17 +637,12 @@
    assertTrue(provider.isMultiValued());
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, rule);
    assertNotNull(values);
    assertFalse(values.isEmpty());
    assertTrue(provider.hasValue(entry, rule));
    assertTrue(provider.hasValue(entry, rule,
        AttributeValues.create(memberType, u1.toString())));
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(memberType, ne.toString())));
    assertTrue(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
    assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString())));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString())));
    assertEquals(provider.matchesSubstring(entry, rule, null, null, null),
                 ConditionResult.UNDEFINED);
    assertEquals(provider.greaterThanOrEqualTo(entry, rule, null),
@@ -712,17 +706,12 @@
    assertTrue(provider.isMultiValued());
    Set<AttributeValue> values = provider.getValues(entry, rule);
    Attribute values = provider.getValues(entry, rule);
    assertNotNull(values);
    assertTrue(values.isEmpty());
    assertFalse(provider.hasValue(entry, rule));
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(memberType, u1.toString())));
    assertFalse(provider.hasValue(entry, rule,
        AttributeValues.create(memberType, ne.toString())));
    assertFalse(provider.hasAnyValue(entry, rule, values));
    assertFalse(provider.hasAnyValue(entry, rule,
                                     Collections.<AttributeValue>emptySet()));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(u1.toString())));
    assertFalse(provider.hasValue(entry, rule, ByteString.valueOf(ne.toString())));
    assertEquals(provider.matchesSubstring(entry, rule, null, null, null),
                 ConditionResult.UNDEFINED);
    assertEquals(provider.greaterThanOrEqualTo(entry, rule, null),
@@ -770,9 +759,7 @@
    Attribute a = e.getAttribute(memberType).get(0);
    assertEquals(a.size(), 4);
    AttributeValue v = AttributeValues.create(memberType, u1.toString());
    assertTrue(a.contains(v));
    assertTrue(a.contains(ByteString.valueOf(u1.toString())));
    cleanUp();
  }
@@ -801,7 +788,7 @@
    Attribute a = e.getAttribute(memberType).get(0);
    assertEquals(a.size(), 1);
    AttributeValue v = AttributeValues.create(memberType, u4.toString());
    ByteString v = ByteString.valueOf(u4.toString());
    assertTrue(a.contains(v));
    InternalClientConnection conn =
@@ -843,7 +830,7 @@
    Attribute a = e.getAttribute(memberType).get(0);
    assertEquals(a.size(), 1);
    AttributeValue v = AttributeValues.create(memberType, u4.toString());
    ByteString v = ByteString.valueOf(u4.toString());
    assertTrue(a.contains(v));
@@ -866,7 +853,7 @@
    a = e.getAttribute(memberType).get(0);
    assertEquals(a.size(), 0);
    v = AttributeValues.create(memberType, u4.toString());
    v = ByteString.valueOf(u4.toString());
    assertTrue(a.contains(v));
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/AttributeCleanupPluginTestCase.java
@@ -27,28 +27,28 @@
package org.opends.server.plugins;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.AttributeCleanupPluginCfgDefn;
import org.opends.server.admin.std.server.AttributeCleanupPluginCfg;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.TestCaseUtils.*;
import static org.testng.Assert.*;
/**
@@ -194,21 +194,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
    throws ConfigException, InitializationException
  {
    Set<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    assertNotNull(attrList);
    for (Attribute attr : attrList)
    {
      for (AttributeValue value : attr)
      {
        pluginTypes.add(
          PluginType.forName(
            value.getValue().toString().toLowerCase()));
      }
    }
    Set<PluginType> pluginTypes = getPluginTypes(e);
    assertTrue(!pluginTypes.isEmpty());
    AttributeCleanupPluginCfg config =
@@ -686,28 +672,4 @@
    fail();
  }
  /**
   * Helper method to get the plugin types from the configuration entry.
   *
   * @param e Configuration entry.
   * @return Set of plugin types.
   */
  private Set<PluginType> getPluginTypes(Entry e)
  {
    Set<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for(Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
      pluginTypes.add(
        PluginType.forName(v.getValue().toString().toLowerCase()));
      }
    }
    return pluginTypes;
  }
}
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -45,9 +45,7 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.Entry;
@@ -133,7 +131,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -141,17 +139,7 @@
  public void testInitializeWithValidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    EntryUUIDPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -168,7 +156,7 @@
   * Tests the process of initializing the server with valid configurations but
   * without the entryUUID attribute type defined in the server.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -180,18 +168,7 @@
                                                                   false);
    DirectoryServer.deregisterAttributeType(entryUUIDType);
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    EntryUUIDPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -252,7 +229,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -261,17 +238,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    EntryUUIDPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/LDAPADListPluginTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.plugins;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -46,8 +44,6 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -57,8 +53,6 @@
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.plugins.LDAPADListPlugin class.
@@ -114,7 +108,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -122,16 +116,7 @@
  public void testInitializeWithValidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    LDAPAttributeDescriptionListPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -197,7 +182,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -206,20 +191,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    if (attrList != null)
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        {
          pluginTypes.add(PluginType.forName(
              v.getValue().toString().toLowerCase()));
        }
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    LDAPAttributeDescriptionListPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/LastModPluginTestCase.java
@@ -47,9 +47,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DN;
@@ -147,7 +145,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -155,17 +153,7 @@
  public void testInitializeWithValidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    LastModPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -182,7 +170,7 @@
   * Tests the process of initializing the server with valid configurations but
   * without the lastmod schema defined in the server.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -190,14 +178,10 @@
  public void testInitializeWithValidConfigsWithoutSchema(Entry e)
         throws Exception
  {
    AttributeType ctType = DirectoryConfig.getAttributeType("createtimestamp",
                                                            false);
    AttributeType cnType = DirectoryConfig.getAttributeType("creatorsname",
                                                            false);
    AttributeType mtType = DirectoryConfig.getAttributeType("modifytimestamp",
                                                            false);
    AttributeType mnType = DirectoryConfig.getAttributeType("modifiersname",
                                                            false);
    AttributeType ctType = DirectoryConfig.getAttributeType("createtimestamp", false);
    AttributeType cnType = DirectoryConfig.getAttributeType("creatorsname", false);
    AttributeType mtType = DirectoryConfig.getAttributeType("modifytimestamp", false);
    AttributeType mnType = DirectoryConfig.getAttributeType("modifiersname", false);
    DirectoryServer.deregisterAttributeType(ctType);
    DirectoryServer.deregisterAttributeType(cnType);
@@ -205,17 +189,7 @@
    DirectoryServer.deregisterAttributeType(mnType);
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    LastModPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -280,7 +254,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -289,17 +263,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    LastModPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/PasswordPolicyImportPluginTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.plugins;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -40,8 +38,6 @@
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
@@ -49,8 +45,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * This class defines a set of tests for the
 * org.opends.server.plugins.PasswordPolicyImportPluginTestCase class.
@@ -160,7 +154,7 @@
  /**
   * Tests the process of initializing the server with valid configurations.
   *
   * @param  entry  The configuration entry to use for the initialization.
   * @param  e  The configuration entry to use for the initialization.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
@@ -168,16 +162,7 @@
  public void testInitializeWithValidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
      {
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    PasswordPolicyImportPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
@@ -243,20 +228,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    if (attrList != null)
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        {
          pluginTypes.add(PluginType.forName(
              v.getValue().toString().toLowerCase()));
        }
      }
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    PasswordPolicyImportPluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
@@ -32,8 +32,11 @@
import java.util.LinkedList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
@@ -41,13 +44,16 @@
import org.opends.server.admin.std.server.ReferentialIntegrityPluginCfg;
import org.opends.server.api.Group;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.controls.SubtreeDeleteControl;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.opends.server.types.RDN;
import org.testng.annotations.*;
import static org.testng.Assert.*;
@@ -529,13 +535,7 @@
  public void testInitializeWithValidConfigs(Entry e)
          throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList){
      for (AttributeValue v : a)
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    ReferentialIntegrityPluginCfg configuration =
            AdminTestCaseUtils.getConfiguration(
                    ReferentialIntegrityPluginCfgDefn.getInstance(), e);
@@ -793,13 +793,7 @@
  public void testInitializeWithInValidConfigs(Entry e)
          throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList){
      for (AttributeValue v : a)
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    ReferentialIntegrityPluginCfg configuration =
            AdminTestCaseUtils.getConfiguration(
                    ReferentialIntegrityPluginCfgDefn.getInstance(), e);
@@ -812,7 +806,6 @@
   * Ensures that the Directory Server is running.
   *
   * @throws  Exception  If an unexpected problem occurs.
   *
   */
  @BeforeClass()
  public void startServer()
@@ -1186,7 +1179,7 @@
            null);
    for (SearchResultEntry entry : operation.getSearchEntries()) {
      for(String dn : dns) {
        AttributeValue value = AttributeValues.create(type, dn);
        ByteString value = ByteString.valueOf(dn);
        assertEquals(entry.hasValue(type, null, value), expected);
      }
    }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/SambaPasswordPluginTestCase.java
@@ -24,7 +24,6 @@
 *      Copyright 2011-2012 profiq s.r.o.
 *      Portions Copyright 2011-2014 ForgeRock AS.
 */
package org.opends.server.plugins;
import java.util.LinkedList;
@@ -32,8 +31,10 @@
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ExtendedOperation;
@@ -43,7 +44,6 @@
import org.opends.server.plugins.SambaPasswordPlugin.TimeStampProvider;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.ServerConstants;
import org.testng.annotations.*;
@@ -252,7 +252,7 @@
    boolean foundNTPassword = false;
    for (Attribute a : sambaAttribute)
    {
      for (AttributeValue val : a)
      for (ByteString val : a)
      {
        foundNTPassword = true;
        assertEquals(val.toString(), ntPassword);
@@ -265,7 +265,7 @@
    boolean foundLMPassword = false;
    for (Attribute a : sambaAttribute)
    {
      for (AttributeValue val : a)
      for (ByteString val : a)
      {
        foundLMPassword = true;
        assertEquals(val.toString(), lmPassword);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/UniqueAttributePluginTestCase.java
@@ -30,20 +30,20 @@
import java.util.LinkedList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.UniqueAttributePluginCfgDefn;
import org.opends.server.admin.std.server.UniqueAttributePluginCfg;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.*;
import static org.testng.Assert.*;
@@ -213,13 +213,7 @@
  public void testInitializeWithValidConfigs(Entry e)
          throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList){
      for (AttributeValue v : a)
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    UniqueAttributePluginCfg configuration =
            AdminTestCaseUtils.getConfiguration(
                    UniqueAttributePluginCfgDefn.getInstance(), e);
@@ -331,14 +325,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    HashSet<PluginType> pluginTypes = new HashSet<PluginType>();
    List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type");
    for (Attribute a : attrList)
    {
      for (AttributeValue v : a)
        pluginTypes.add(PluginType.forName(
            v.getValue().toString().toLowerCase()));
    }
    HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e);
    UniqueAttributePluginCfg configuration =
         AdminTestCaseUtils.getConfiguration(
              UniqueAttributePluginCfgDefn.getInstance(), e);
@@ -762,7 +749,7 @@
    AttributeType attrType = getAttrType(attrTypeString);
    AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString);
    for(String valString : attrValStrings) {
      builder.add(AttributeValues.create(attrType, valString));
      builder.add(valString);
    }
    mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute()));
    InternalClientConnection conn =
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestAddResponseProtocolOp.java
@@ -27,6 +27,7 @@
package org.opends.server.protocols.ldap;
import org.forgerock.opendj.io.*;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteStringBuilder;
@@ -78,13 +79,8 @@
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
    ByteString attributeValue = ByteString.valueOf("testValue");
    dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) });
  }
  /**
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestCompareResponseProtocolOp.java
@@ -26,20 +26,23 @@
 */
package org.opends.server.protocols.ldap;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.*;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import static org.opends.server.util.ServerConstants.EOL;
import org.forgerock.i18n.LocalizableMessage;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.CompareRequestProtocolOp class.
@@ -80,12 +83,8 @@
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
    ByteString attributeValue = ByteString.valueOf("testValue");
    dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) });
  }
  /**
@@ -123,8 +122,6 @@
  public void testConstructors() throws Exception
  {
    CompareResponseProtocolOp compareResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    compareResponse = new CompareResponseProtocolOp(resultCode);
    assertEquals(compareResponse.getResultCode(), resultCode);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestDeleteResponseProtocolOp.java
@@ -26,18 +26,23 @@
 */
package org.opends.server.protocols.ldap;
import static org.testng.Assert.*;
import org.testng.annotations.*;
import org.forgerock.opendj.io.*;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.util.ServerConstants.EOL;
import org.forgerock.i18n.LocalizableMessage;
import java.util.ArrayList;
import java.util.Iterator;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.DeleteResponseProtocolOp class.
@@ -73,15 +78,10 @@
  public void setupDN()
  {
    //Setup the DN to use in the response tests.
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
    ByteString attributeValue = ByteString.valueOf("testValue");
    dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) });
  }
  /**
@@ -119,8 +119,6 @@
  public void testConstructors() throws Exception
  {
    DeleteResponseProtocolOp deleteResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    deleteResponse = new DeleteResponseProtocolOp(resultCode);
    assertEquals(deleteResponse.getResultCode(), resultCode);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyDNResponseProtocolOp.java
@@ -26,21 +26,24 @@
 */
package org.opends.server.protocols.ldap;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.server.DirectoryServerTestCase;
import org.forgerock.i18n.LocalizableMessage;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.ModifyDNResponseProtocolOp class.
@@ -77,15 +80,10 @@
  public void setupDN()
  {
    //Setup the DN to use in the response tests.
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
    ByteString attributeValue = ByteString.valueOf("testValue");
    dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) });
  }
  /**
@@ -123,8 +121,6 @@
  public void testConstructors() throws Exception
  {
    ModifyDNResponseProtocolOp modifyResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    modifyResponse = new ModifyDNResponseProtocolOp(resultCode);
    assertEquals(modifyResponse.getResultCode(), resultCode);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyResponseProtocolOp.java
@@ -26,20 +26,23 @@
 */
package org.opends.server.protocols.ldap;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.forgerock.i18n.LocalizableMessage;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.ModifyResponseProtocolOp class.
@@ -80,12 +83,8 @@
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
    ByteString attributeValue = ByteString.valueOf("testValue");
    dn = new DN(new RDN[] { RDN.create(attribute, attributeValue) });
  }
  /**
@@ -123,8 +122,6 @@
  public void testConstructors() throws Exception
  {
    ModifyResponseProtocolOp modifyResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    modifyResponse = new ModifyResponseProtocolOp(resultCode);
    assertEquals(modifyResponse.getResultCode(), resultCode);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
@@ -32,6 +32,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.MemoryBackend;
import org.opends.server.core.DirectoryServer;
@@ -46,7 +47,10 @@
import org.opends.server.replication.server.ReplServerFakeConfiguration;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.types.*;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -149,7 +153,7 @@
      {
        entry.removeAttribute(uidType);
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<AttributeValue>());
                           new LinkedList<ByteString>());
        addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN);
        AddMsg addMsg =
          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
@@ -288,7 +292,7 @@
      entry.removeAttribute(uidType);
      entry.addAttribute(Attributes.create("entryuuid",
                         stringUID(renamedEntryUuid)),
                         new LinkedList<AttributeValue>());
                         new LinkedList<ByteString>());
      DN addDN = DN.valueOf("dc=moddndel" + "," + TEST_ROOT_DN_STRING);
      AddMsg addMsg =
          new AddMsg(gen.newCSN(), addDN, stringUID(renamedEntryUuid),
@@ -415,7 +419,7 @@
        // add the entry a first time
        entry.removeAttribute(uidType);
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<AttributeValue>());
                           new LinkedList<ByteString>());
        DN addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
        AddMsg addMsg =
          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
@@ -432,7 +436,7 @@
        // add again the entry with a new entryuuid.
        entry.removeAttribute(uidType);
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)),
                           new LinkedList<AttributeValue>());
                           new LinkedList<ByteString>());
        addMsg =
          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1025),
                     stringUID(1),
@@ -536,7 +540,7 @@
        // add the entry
        entry.removeAttribute(uidType);
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<AttributeValue>());
                           new LinkedList<ByteString>());
        addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
        AddMsg addMsg =
          new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1),
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -468,7 +468,7 @@
        Attribute attr = attrs.get(0);
        if (attr.size() == 1)
        {
          return Long.decode(attr.iterator().next().getValue().toString());
          return Long.decode(attr.iterator().next().toString());
        }
      }
    }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -33,6 +33,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
@@ -525,10 +526,7 @@
          if ((tmpAttrList != null) && (!tmpAttrList.isEmpty()))
          {
            Attribute tmpAttr = tmpAttrList.get(0);
            AttributeType attrType =
              DirectoryServer.getAttributeType(attrTypeStr, true);
            found = tmpAttr.contains(AttributeValues.create(attrType, valueString));
            found = tmpAttr.contains(ByteString.valueOf(valueString));
          }
        }
      }
@@ -828,9 +826,9 @@
        if (newEntry != null)
        {
          Attribute attribute = newEntry.getAttribute("entryuuid").get(0);
          for (AttributeValue val : attribute)
          for (ByteString val : attribute)
          {
            found = val.getValue().toString();
            found = val.toString();
            break;
          }
        }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -434,8 +434,7 @@
      // Read the entry back to get its UUID.
      Entry entry = DirectoryServer.getEntry(dn1);
      List<Attribute> attrs = entry.getAttribute(entryuuidType);
      String entryuuid =
          attrs.get(0).iterator().next().getValue().toString();
      String entryuuid = attrs.get(0).iterator().next().toString();
      // A change on a first server.
      long changeTime = TimeThread.getTime();
@@ -471,8 +470,7 @@
      // Read the entry to see how the conflict was resolved.
      entry = DirectoryServer.getEntry(dn1);
      attrs = entry.getAttribute(attrType);
      String attrValue1 =
          attrs.get(0).iterator().next().getValue().toString();
      String attrValue1 = attrs.get(0).iterator().next().toString();
      // the value should be the last (time t2) value added
      assertEquals(attrValue1, "B");
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -37,6 +37,7 @@
import org.assertj.core.data.MapEntry;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
@@ -1497,7 +1498,7 @@
    // Parse and store values
    Map<Integer,Integer> resultMap = new HashMap<Integer,Integer>();
    for (AttributeValue val : attrs.get(0))
    for (ByteString val : attrs.get(0))
    {
      StringTokenizer strtok = new StringTokenizer(val.toString(), ":");
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AttrInfoTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS.
 *      Portions Copyright 2013-2014 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -33,8 +33,7 @@
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Attributes;
import org.opends.server.util.TimeThread;
import org.testng.annotations.DataProvider;
@@ -55,11 +54,9 @@
  @DataProvider(name = "attrInfo")
  public Object[][] createData()
  {
    AttributeType type = DirectoryServer.getAttributeType("description");
    AttributeValue att1 = AttributeValues.create(type, "string");
    AttributeValue att2 = AttributeValues.create(type, "value");
    AttributeValue att3 = AttributeValues.create(type, "again");
    ByteString att1 = ByteString.valueOf("string");
    ByteString att2 = ByteString.valueOf("value");
    ByteString att3 = ByteString.valueOf("again");
    CSN del1 = new CSN(1,  0,  1);
    CSN del2 = new CSN(1,  1,  1);
@@ -81,9 +78,7 @@
   * Create a AttrInfo and check the methods
   */
  @Test(dataProvider = "attrInfo")
  public void attrInfo(
      AttributeValue att, CSN deleteTime, CSN updateTime)
      throws Exception
  public void attrInfo(ByteString att, CSN deleteTime, CSN updateTime) throws Exception
  {
    // Create an empty AttrInfo
    AttrHistoricalMultiple attrInfo1 = new AttrHistoricalMultiple();
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -35,10 +35,12 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.task.Task;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSNGenerator;
@@ -51,7 +53,6 @@
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -663,7 +664,7 @@
        Attribute attr = attrs.get(0);
        if (attr.size() == 1)
        {
          return Long.decode(attr.iterator().next().getValue().toString());
          return Long.decode(attr.iterator().next().toString());
        }
      }
    }
@@ -892,10 +893,10 @@
    assertEquals(attrs.size(), 1);
    Attribute attr = attrs.get(0);
    assertNotNull(attr);
    Iterator<AttributeValue> attrValues = attr.iterator();
    Iterator<ByteString> attrValues = attr.iterator();
    assertNotNull(attrValues);
    assertTrue(attrValues.hasNext());
    AttributeValue attrValue = attrValues.next();
    ByteString attrValue = attrValues.next();
    assertNotNull(attrValue);
    assertFalse(attrValues.hasNext());
    assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " +
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -35,10 +35,10 @@
import org.assertj.core.api.Assertions;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.AssuredType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
@@ -155,8 +155,7 @@
    List<Attribute> attrs1 = entry.getAttribute(histType);
      Assertions.assertThat(attrs1).isNotEmpty();
    String histValue =
      attrs1.get(0).iterator().next().getValue().toString();
    String histValue = attrs1.get(0).iterator().next().toString();
    logger.error(LocalizableMessage.raw("First historical value:" + histValue));
@@ -173,8 +172,8 @@
    List<Attribute> attrs2 = entry2.getAttribute(histType);
      Assertions.assertThat(attrs2).isNotEmpty();
    for (AttributeValue av : attrs2.get(0)) {
      logger.error(LocalizableMessage.raw("Second historical value:" + av.getValue()));
    for (ByteString av : attrs2.get(0)) {
      logger.error(LocalizableMessage.raw("Second historical value: %s", av));
    }
    LinkedList<ReplicationMsg> opList = new LinkedList<ReplicationMsg>();
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
@@ -32,6 +32,7 @@
import org.assertj.core.api.Assertions;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
@@ -45,7 +46,6 @@
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -327,7 +327,7 @@
  {
    Entry entry = DirectoryServer.getEntry(dn);
    List<Attribute> attrs = entry.getAttribute(attrType);
    return attrs.get(0).iterator().next().getValue().toString();
    return attrs.get(0).iterator().next().toString();
  }
  private static void publishModify(ReplicationBroker broker, CSN changeNum,
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.UUID;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DirectoryServer;
@@ -359,7 +360,7 @@
    builder.add("value1");
    builder.add("value2");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
@@ -414,7 +415,7 @@
    builder.add("value3");
    builder.add("value4");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
@@ -460,7 +461,7 @@
    // Create a single valued attribute with value : "value1"
    // add this attribute to the entry.
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    Attribute attribute = Attributes.create(EMPLOYEENUMBER, "value1");
    entry.addAttribute(attribute, duplicateValues);
@@ -493,7 +494,7 @@
    // Create a single valued attribute with value : "value1"
    // add this attribute to the entry.
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    Attribute attribute = Attributes.create(EMPLOYEENUMBER, "value1");
    entry.addAttribute(attribute, duplicateValues);
@@ -531,7 +532,7 @@
    builder.add("value1");
    builder.add("value2");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
    // load historical from the entry
@@ -580,7 +581,7 @@
    // Create a single valued attribute with value : "value1"
    // add this attribute to the entry.
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    Attribute attribute = Attributes.create(DISPLAYNAME, "value1");
    entry.addAttribute(attribute, duplicateValues);
    Attribute attrDel = buildSyncHist(DISPLAYNAME,
@@ -663,7 +664,7 @@
    builder.add("value3");
    builder.add("value4");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
    // load historical from the entry
@@ -741,7 +742,7 @@
    builder.add("value3");
    builder.add("value4");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
    // load historical from the entry
@@ -803,7 +804,7 @@
    // Create a single valued attribute with value : "value1"
    // add this attribute to the entry.
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    Attribute attribute = Attributes.create(DISPLAYNAME, "value1");
    entry.addAttribute(attribute, duplicateValues);
@@ -890,13 +891,13 @@
    EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry);
    // simulate a add of the description attribute done at time t10
    testModify(entry, hist, 10, true, buildMod(DESCRIPTION, ModificationType.ADD, "init value"));
    testModify(entry, hist, 10, true, buildMod(DESCRIPTION, ModificationType.ADD, "Init Value"));
    Attribute attr = buildSyncHist(DESCRIPTION,
        ":000000000000000a000000000000:add:init value");
        ":000000000000000a000000000000:add:Init Value");
    assertEquals(hist.encodeAndPurge(), attr);
    // Now simulate a del and a add in the same operation
    attr = Attributes.create(DESCRIPTION, "init value");
    attr = Attributes.create(DESCRIPTION, "Init Value");
    Modification mod1 = new Modification(ModificationType.DELETE, attr);
    attr = Attributes.create(DESCRIPTION, "Init Value");
@@ -997,7 +998,7 @@
    EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry);
    // Now simulate a del and a add in the same operation
    Attribute attr = Attributes.create(DESCRIPTION, "init value");
    Attribute attr = Attributes.create(DESCRIPTION, "Init Value");
    Modification mod1 = new Modification(ModificationType.ADD, attr);
    attr = Attributes.create(DESCRIPTION, "Init Value");
@@ -1220,8 +1221,8 @@
    assertEquals(size, mods.size());
    Modification newMod = mods.get(0);
    assertTrue(newMod.getModificationType().equals(modType));
    AttributeValue val = newMod.getAttribute().iterator().next();
    assertEquals(val.getValue().toString(), value);
    ByteString val = newMod.getAttribute().iterator().next();
    assertEquals(val.toString(), value);
  }
  /**
@@ -1426,7 +1427,7 @@
    assertEquals(expectedValues.length, attr.size());
    for (String value : expectedValues)
    {
      attr.contains(AttributeValues.create(attr.getAttributeType(), value));
      attr.contains(ByteString.valueOf(value));
    }
  }
@@ -1566,7 +1567,7 @@
    builder.add("value1");
    builder.add("value2");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
    // load historical from the entry
@@ -1625,7 +1626,7 @@
    builder.add("value2");
    builder.add("value3");
    List<AttributeValue> duplicateValues = new LinkedList<AttributeValue>();
    List<ByteString> duplicateValues = new LinkedList<ByteString>();
    entry.addAttribute(builder.toAttribute(), duplicateValues);
    // load historical from the entry
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ValueInfoTest.java
@@ -22,16 +22,13 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 *      Portions Copyright 2013-2014 ForgeRock AS
 */
package org.opends.server.replication.plugin;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.AttributeValues;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.TimeThread;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -50,11 +47,9 @@
   */
  @DataProvider(name = "valueInfo")
  public Object[][] createData() {
    AttributeType type = DirectoryServer.getAttributeType("description");
    AttributeValue att1 = AttributeValues.create(type, "string");
    AttributeValue att2 = AttributeValues.create(type, "value");
    AttributeValue att3 = AttributeValues.create(type, "again");
    ByteString att1 = ByteString.valueOf("string");
    ByteString att2 = ByteString.valueOf("value");
    ByteString att3 = ByteString.valueOf("again");
    CSN del1 = new CSN(1,  0,  1);
    CSN del2 = new CSN(1,  1,  1);
@@ -75,12 +70,11 @@
   * Create a ValueInfo and check the methods
   */
  @Test(dataProvider = "valueInfo")
  public void valueInfo(AttributeValue value, CSN csnUpdate, CSN csnDelete) throws Exception
  public void valueInfo(ByteString value, CSN csnUpdate, CSN csnDelete) throws Exception
  {
    AttributeType type = DirectoryServer.getAttributeType("description");
    AttrValueHistorical valInfo1 = new AttrValueHistorical(value, csnUpdate, csnDelete);
    AttrValueHistorical valInfo2 = new AttrValueHistorical(value, csnUpdate, csnUpdate);
    AttrValueHistorical valInfo3 = new AttrValueHistorical(AttributeValues.create(type,"Test"),
    AttrValueHistorical valInfo3 = new AttrValueHistorical(ByteString.valueOf("Test"),
            csnUpdate, csnUpdate);
    // Check equals
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
@@ -1239,8 +1239,7 @@
      return null;
    }
    Attribute a = attrs.iterator().next();
    AttributeValue av = a.iterator().next();
    return av.toString();
    return a.iterator().next().toString();
  }
  private static void checkValues(Entry entry, String attrName,
@@ -1248,7 +1247,7 @@
  {
    for (Attribute a : entry.getAttribute(attrName))
    {
      for (AttributeValue av : a)
      for (ByteString av : a)
      {
        assertThat(expectedValues)
            .as("In entry " + entry + " incorrect value for attr '" + attrName + "'")
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/GenericSchemaTestCase.java
@@ -43,7 +43,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NameForm;
@@ -199,11 +199,10 @@
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          AttributeType at = AttributeTypeSyntax.decodeAttributeType(
                                  v.getValue(), DirectoryServer.getSchema(),
                                  true);
              v, DirectoryServer.getSchema(),true);
          if (! isNumericOID(at.getOID()))
          {
            invalidOIDs.add(at.getNameOrOID());
@@ -277,11 +276,10 @@
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          ObjectClass oc = ObjectClassSyntax.decodeObjectClass(
                                v.getValue(), DirectoryServer.getSchema(),
                                true);
              v, DirectoryServer.getSchema(), true);
          if (! isNumericOID(oc.getOID()))
          {
            invalidOIDs.add(oc.getNameOrOID());
@@ -354,10 +352,10 @@
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a)
        for (ByteString v : a)
        {
          NameForm nf = NameFormSyntax.decodeNameForm(v.getValue(),
                             DirectoryServer.getSchema(), true);
          NameForm nf = NameFormSyntax.decodeNameForm(
              v, DirectoryServer.getSchema(), true);
          if (! isNumericOID(nf.getOID()))
          {
            invalidOIDs.add(nf.getNameOrOID());
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
@@ -38,7 +38,6 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -254,7 +253,7 @@
      //An entry must be returned.
      assertNotNull(e);
      Attribute attr = e.getAttribute("ldapsyntaxes").get(0);
      Iterator<AttributeValue> iter = attr.iterator();
      Iterator<ByteString> iter = attr.iterator();
      //There are other ways of doing it but we will extract the OID
      //from the attribute values and then check to see if our
@@ -262,9 +261,8 @@
      List<String> syntaxList = new ArrayList<String>();
      while(iter.hasNext())
      {
        AttributeValue val = iter.next();
        //parse the OIDs.
        syntaxList.add(getOIDFromLdapSyntax(val.toString()));
        syntaxList.add(getOIDFromLdapSyntax(iter.next().toString()));
      }
      //Check if we find our OID.
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/UTCTimeSyntaxTest.java
@@ -31,9 +31,8 @@
import java.util.Date;
import java.util.TimeZone;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.api.AttributeSyntax;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -127,8 +126,8 @@
         throws Exception
  {
    Date d = new Date();
    AttributeValue timeValue = UTCTimeSyntax.createUTCTimeValue(d);
    Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(timeValue.getValue());
    ByteString timeValue = UTCTimeSyntax.createUTCTimeValue(d);
    Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(timeValue);
    // UTCTime does not have support for sub-second values, so we need to make
    // sure that the decoded value is within 1000 milliseconds.
@@ -151,7 +150,7 @@
    // values from 50 through 99 inclusive shall have 1900 added to it
    for (int yy = 50; yy <= 99; yy++) {
      String utcString = String.format("%02d0819120000Z", new Integer(yy));
      String utcString = String.format("%02d0819120000Z", yy);
      Date decodedDate = UTCTimeSyntax.decodeUTCTimeValue(ByteString.valueOf(utcString));
      cal.clear();
      cal.setTime(decodedDate);
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/DummyTask.java
@@ -34,7 +34,7 @@
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -81,9 +81,9 @@
      {
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          for (ByteString v : a)
          {
            sleepTime = Long.parseLong(v.getValue().toString());
            sleepTime = Long.parseLong(v.toString());
          }
        }
      }
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeBuilderTest.java
@@ -48,51 +48,20 @@
{
  /** CN attribute type used in all tests. */
  private AttributeType cnType = null;
  private AttributeType cnType;
  /** CN attribute value used in all tests. */
  private AttributeValue cnValue = null;
  private ByteString cnValue;
  private final String[] noOptions = new String[] {};
  private final String[] noValues = new String[] {};
  private final String[] oneOption = new String[]
  {
    "option1"
  };
  private final String[] oneValue = new String[]
  {
    "value1"
  };
  private final String[] replaceValues = new String[]
  {
      "value2", "value4"
  };
  private final String[] threeOptions = new String[]
  {
      "option1", "option2", "option3"
  };
  private final String[] threeValues = new String[]
  {
      "value1", "value2", "value3"
  };
  private final String[] twoOptions = new String[]
  {
      "option1", "option2"
  };
  private final String[] twoValues = new String[]
  {
      "value1", "value2"
  };
  private final String[] oneOption = new String[] { "option1" };
  private final String[] oneValue = new String[] { "value1" };
  private final String[] replaceValues = new String[] { "value2", "value4" };
  private final String[] threeOptions = new String[] { "option1", "option2", "option3" };
  private final String[] threeValues = new String[] { "value1", "value2", "value3" };
  private final String[] twoOptions = new String[] { "option1", "option2" };
  private final String[] twoValues = new String[] { "value1", "value2" };
  /**
   * Attribute data provider.
@@ -133,10 +102,7 @@
            cnType,
            "cn",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            8,
@@ -144,10 +110,7 @@
            cnType,
            "cn",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            9,
@@ -155,10 +118,7 @@
            cnType,
            "cn",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            10,
@@ -166,10 +126,7 @@
            cnType,
            "CN",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            11,
@@ -177,10 +134,7 @@
            cnType,
            "CN",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            12,
@@ -188,10 +142,7 @@
            cnType,
            "CN",
            noOptions,
            new String[]
            {
              cnValue.getValue().toString()
            }
            new String[] { cnValue.toString() }
        },
        {
            13,
@@ -580,7 +531,7 @@
    cnType = DirectoryServer.getAttributeType("cn");
    Assert.assertNotNull(cnType);
    cnValue = AttributeValues.create(cnType, "john doe");
    cnValue = ByteString.valueOf("john doe");
  }
@@ -604,8 +555,8 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value1")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
  }
@@ -619,27 +570,23 @@
    AttributeBuilder builder = new AttributeBuilder(cnType);
    // Note duplicate values.
    Assert.assertTrue(builder.addAll(Arrays.asList(AttributeValues.create(cnType,
        "value1"), AttributeValues.create(cnType, "value1"), AttributeValues.create(
        cnType, "value2"))));
    Assert.assertTrue(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2"))));
    Assert.assertEquals(builder.size(), 2);
    // Add same values.
    Assert.assertFalse(builder.addAll(Arrays.asList(AttributeValues.create(cnType,
        "value1"), AttributeValues.create(cnType, "value1"), AttributeValues.create(
        cnType, "value2"))));
    Assert.assertFalse(builder.addAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value1"), ByteString.valueOf("value2"))));
    Assert.assertEquals(builder.size(), 2);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value1")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
  }
  /**
   * Tests {@link AttributeBuilder#add(AttributeValue)}.
   * Tests {@link AttributeBuilder#add(ByteString)}.
   */
  @Test
  public void testAttributeBuilderAddAttributeValue() throws Exception
@@ -652,13 +599,13 @@
    Assert.assertFalse(builder.add(cnValue));
    Assert.assertEquals(builder.size(), 1);
    Assert.assertTrue(builder.add(AttributeValues.create(cnType, "jane doe")));
    Assert.assertTrue(builder.add(ByteString.valueOf("jane doe")));
    Assert.assertEquals(builder.size(), 2);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(cnValue));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "jane doe")));
    Assert.assertTrue(a.contains(ByteString.valueOf("jane doe")));
  }
@@ -682,8 +629,8 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value1")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value1")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
  }
@@ -707,8 +654,8 @@
    Attribute a = builder.toAttribute();
    assertEquals(a.size(), 2);
    assertTrue(a.contains(AttributeValues.create(cnType, "value1")));
    assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    assertTrue(a.contains(ByteString.valueOf("value1")));
    assertTrue(a.contains(ByteString.valueOf("value2")));
  }
@@ -733,7 +680,7 @@
  /**
   * Tests {@link AttributeBuilder#contains(AttributeValue)}.
   * Tests {@link AttributeBuilder#contains(ByteString)}.
   */
  @Test
  public void testAttributeBuilderContains() throws Exception
@@ -742,9 +689,9 @@
    builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues));
    Assert.assertTrue(builder.contains(AttributeValues.create(cnType, "value1")));
    Assert.assertTrue(builder.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertFalse(builder.contains(AttributeValues.create(cnType, "value3")));
    Assert.assertTrue(builder.contains(ByteString.valueOf("value1")));
    Assert.assertTrue(builder.contains(ByteString.valueOf("value2")));
    Assert.assertFalse(builder.contains(ByteString.valueOf("value3")));
  }
@@ -759,12 +706,11 @@
    builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues));
    AttributeValue av1 = AttributeValues.create(cnType, "value1");
    AttributeValue av2 = AttributeValues.create(cnType, "value2");
    AttributeValue av3 = AttributeValues.create(cnType, "value3");
    ByteString av1 = ByteString.valueOf("value1");
    ByteString av2 = ByteString.valueOf("value2");
    ByteString av3 = ByteString.valueOf("value3");
    Assert.assertTrue(builder.containsAll(Collections
        .<AttributeValue> emptySet()));
    Assert.assertTrue(builder.containsAll(Collections.<ByteString> emptySet()));
    Assert.assertTrue(builder.containsAll(Collections.singleton(av1)));
    Assert.assertTrue(builder.containsAll(Collections.singleton(av2)));
@@ -868,8 +814,7 @@
    builder.add("value1");
    Assert.assertTrue(builder.iterator().hasNext());
    Assert.assertEquals(builder.iterator().next(), AttributeValues.create(cnType,
        "value1"));
    Assert.assertEquals(builder.iterator().next(), ByteString.valueOf("value1"));
  }
@@ -905,7 +850,7 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 1);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value3")));
  }
@@ -921,34 +866,31 @@
    builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues));
    // Remove existing values.
    Assert.assertTrue(builder.removeAll(Arrays.asList(AttributeValues.create(
        cnType, "value1"), AttributeValues.create(cnType, "value2"))));
    Assert.assertTrue(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2"))));
    Assert.assertEquals(builder.size(), 1);
    // Remove removed values.
    Assert.assertFalse(builder.removeAll(Arrays.asList(AttributeValues.create(
        cnType, "value1"), AttributeValues.create(cnType, "value2"))));
    Assert.assertFalse(builder.removeAll(Arrays.asList(ByteString.valueOf("value1"), ByteString.valueOf("value2"))));
    Assert.assertEquals(builder.size(), 1);
    // Remove nothing.
    Assert.assertFalse(builder.removeAll(Collections
        .<AttributeValue> emptySet()));
    Assert.assertFalse(builder.removeAll(Collections.<ByteString> emptySet()));
    Assert.assertEquals(builder.size(), 1);
    // Remove non existent value.
    Assert.assertFalse(builder.removeAll(Collections
        .singleton(AttributeValues.create(cnType, "value4"))));
        .singleton(ByteString.valueOf("value4"))));
    Assert.assertEquals(builder.size(), 1);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 1);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value3")));
  }
  /**
   * Tests {@link AttributeBuilder#remove(AttributeValue)}.
   * Tests {@link AttributeBuilder#remove(ByteString)}.
   */
  @Test
  public void testAttributeBuilderRemoveAttributeValue() throws Exception
@@ -957,21 +899,21 @@
    builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues));
    Assert.assertTrue(builder.remove(AttributeValues.create(cnType, "value1")));
    Assert.assertTrue(builder.remove(ByteString.valueOf("value1")));
    Assert.assertEquals(builder.size(), 2);
    // Already removed.
    Assert.assertFalse(builder.remove(AttributeValues.create(cnType, "value1")));
    Assert.assertFalse(builder.remove(ByteString.valueOf("value1")));
    Assert.assertEquals(builder.size(), 2);
    // Non existent.
    Assert.assertFalse(builder.remove(AttributeValues.create(cnType, "value4")));
    Assert.assertFalse(builder.remove(ByteString.valueOf("value4")));
    Assert.assertEquals(builder.size(), 2);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value3")));
  }
@@ -999,8 +941,8 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value3")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value3")));
  }
@@ -1019,8 +961,8 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value4")));
  }
@@ -1035,21 +977,20 @@
    builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues));
    // Note duplicate values.
    builder.replaceAll(Arrays.asList(AttributeValues.create(cnType, "value2"),
        AttributeValues.create(cnType, "value2"), AttributeValues.create(cnType,
            "value4")));
    builder.replaceAll(Arrays.asList(ByteString.valueOf("value2"),
        ByteString.valueOf("value2"), ByteString.valueOf("value4")));
    Assert.assertEquals(builder.size(), 2);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 2);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value2")));
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value2")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value4")));
  }
  /**
   * Tests {@link AttributeBuilder#replace(AttributeValue)}.
   * Tests {@link AttributeBuilder#replace(ByteString)}.
   */
  @Test
  public void testAttributeBuilderReplaceAttributeValue() throws Exception
@@ -1057,12 +998,12 @@
    AttributeBuilder builder = new AttributeBuilder(cnType);
    builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues));
    builder.replace(AttributeValues.create(cnType, "value4"));
    builder.replace(ByteString.valueOf("value4"));
    Assert.assertEquals(builder.size(), 1);
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 1);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value4")));
  }
@@ -1081,7 +1022,7 @@
    Attribute a = builder.toAttribute();
    Assert.assertEquals(a.size(), 1);
    Assert.assertTrue(a.contains(AttributeValues.create(cnType, "value4")));
    Assert.assertTrue(a.contains(ByteString.valueOf("value4")));
  }
@@ -1206,7 +1147,7 @@
  /**
   * Tests {@link Attribute#contains(AttributeValue)}.
   * Tests {@link Attribute#contains(ByteString)}.
   *
   * @param testCase
   *          Test case index (useful for debugging).
@@ -1229,14 +1170,13 @@
    // Check contains().
    for (String value : values)
    {
      Assert.assertTrue(a.contains(AttributeValues.create(type, value)));
      Assert.assertTrue(a.contains(ByteString.valueOf(value)));
      // Assumes internal normalization to lower-case.
      Assert.assertTrue(a
          .contains(AttributeValues.create(type, value.toUpperCase())));
      Assert.assertTrue(a.contains(ByteString.valueOf(value.toUpperCase())));
    }
    Assert.assertFalse(a.contains(AttributeValues.create(type, "xxxx")));
    Assert.assertFalse(a.contains(ByteString.valueOf("xxxx")));
  }
@@ -1263,31 +1203,31 @@
      throws Exception
  {
    // Check containsAll().
    Set<AttributeValue> expectedValues = new HashSet<AttributeValue>();
    Set<ByteString> expectedValues = new HashSet<ByteString>();
    for (String value : values)
    {
      expectedValues.add(AttributeValues.create(type, value));
      expectedValues.add(ByteString.valueOf(value));
    }
    Assert.assertTrue(a.containsAll(Collections.<AttributeValue> emptySet()));
    Assert.assertTrue(a.containsAll(Collections.<ByteString> emptySet()));
    Assert.assertTrue(a.containsAll(expectedValues));
    if (values.length > 1)
    {
      Set<AttributeValue> subSet = new HashSet<AttributeValue>(expectedValues);
      Set<ByteString> subSet = new HashSet<ByteString>(expectedValues);
      subSet.remove(subSet.iterator());
      Assert.assertTrue(a.containsAll(subSet));
    }
    Set<AttributeValue> bigSet = new HashSet<AttributeValue>(expectedValues);
    bigSet.add(AttributeValues.create(type, "xxxx"));
    Set<ByteString> bigSet = new HashSet<ByteString>(expectedValues);
    bigSet.add(ByteString.valueOf("xxxx"));
    Assert.assertFalse(a.containsAll(bigSet));
    expectedValues.clear();
    for (String value : values)
    {
      // Assumes internal normalization to lower-case.
      expectedValues.add(AttributeValues.create(type, value.toUpperCase()));
      expectedValues.add(ByteString.valueOf(value.toUpperCase()));
    }
    Assert.assertTrue(a.containsAll(expectedValues));
  }
@@ -1683,13 +1623,14 @@
    else
    {
      // Values must be returned in the correct order.
      Iterator<AttributeValue> i = a.iterator();
      Iterator<ByteString> i = a.iterator();
      for (String value : values)
      {
        Assert.assertTrue(i.hasNext());
        AttributeValue v = i.next();
        Assert.assertEquals(v, AttributeValues.create(type, value));
        ByteString v = i.next();
        ByteString nv = a.getAttributeType().getEqualityMatchingRule().normalizeAttributeValue(v);
        Assert.assertEquals(nv, ByteString.valueOf(value));
        try
        {
Diff truncated after the above file
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributesTest.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/EntrySchemaCheckingTestCase.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/SearchFilterTests.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeValue.java (deleted) opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestEntry.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestRDN.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/TestLDIFReader.java