From 0e52d359d661d2fd95fa5c28058353f5d121173c Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 20 Sep 2012 22:32:04 +0000
Subject: [PATCH] Fix OPENDJ-597: Remove superfluous ByteString based constructors

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java                                        |   42 ------
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java                |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java                 |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java             |   10 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java        |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java  |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java                                      |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java                                             |    8 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java            |    7 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java                                |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java                        |   12 +
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java                            |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java                                |   14 --
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java                            |    9 -
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java                        |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java |   22 +-
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java                                          |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java                                       |    4 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java                    |    5 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java                                                  |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java                    |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java                 |   29 +---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java                                      |   17 +
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java        |    3 
 opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java                           |    9 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java                  |    7 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java                        |    7 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java                                              |   25 +--
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java                                    |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java |    6 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java                    |   20 +-
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java             |   37 ++---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java              |   22 --
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java                                    |    9 
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java                                                |    6 
 35 files changed, 145 insertions(+), 247 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java
index 2c2a2c3..ce2086c 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java
@@ -188,10 +188,10 @@
     /**
      * {@inheritDoc}
      */
-    public boolean addAll(final Collection<? extends ByteString> values,
-            final Collection<? super ByteString> duplicateValues) {
+    public <T> boolean addAll(final Collection<T> values,
+            final Collection<? super T> duplicateValues) {
         boolean modified = false;
-        for (final ByteString value : values) {
+        for (final T value : values) {
             if (add(value)) {
                 modified = true;
             } else if (duplicateValues != null) {
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java
index 0112e4c..566bc19 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java
@@ -80,7 +80,7 @@
      */
     @Override
     public boolean containsAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         final Attribute a = getAttribute(attribute.getAttributeDescription());
         if (a == null) {
             if (missingValues != null) {
@@ -212,7 +212,7 @@
      */
     @Override
     public boolean removeAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         final Iterator<Attribute> i = getAllAttributes().iterator();
         final AttributeDescription attributeDescription = attribute.getAttributeDescription();
         while (i.hasNext()) {
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java
index e6d23e1..3be8e92 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java
@@ -58,7 +58,7 @@
      */
     @Override
     public final boolean addAttribute(final Attribute attribute,
-            final Collection<ByteString> duplicateValues) {
+            final Collection<? super ByteString> duplicateValues) {
         final AttributeDescription attributeDescription = attribute.getAttributeDescription();
         final Attribute oldAttribute = getAttribute(attributeDescription);
         if (oldAttribute != null) {
@@ -121,7 +121,7 @@
      */
     @Override
     public final boolean removeAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         final AttributeDescription attributeDescription = attribute.getAttributeDescription();
         if (attribute.isEmpty()) {
             if (attributes.remove(attributeDescription) != null) {
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java
index 931e041..c7ace49 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java
@@ -40,21 +40,8 @@
  * equality matching rule associated with the attribute description.
  * <p>
  * Any methods which accept {@code Object} based attribute values convert the
- * attribute values to instances of {@code ByteString} as follows:
- *
- * <pre>
- * Object object = ...;
- * ByteString value = null;
- * if (object instanceof ByteSequence)
- * {
- *   value = ((ByteSequence)object).toByteString();
- * }
- * else
- * {
- *   value = ByteString.valueOf(object.toString());
- * }
- * </pre>
- * <p>
+ * attribute values to instances of {@code ByteString} using
+ * {@link ByteString#valueOf(Object)}.
  */
 public interface Attribute extends Set<ByteString> {
     // TODO: matching against attribute value assertions.
@@ -121,7 +108,12 @@
      * attribute if they are not already present (optional operation). Any
      * attribute values which are already present will be added to
      * {@code duplicateValues} if specified.
+     * <p>
+     * Any attribute values which are not instances of {@code ByteString} will
+     * be converted using the {@link ByteString#valueOf(Object)} method.
      *
+     * @param <T>
+     *            The type of the attribute value objects being added.
      * @param values
      *            The attribute values to be added to this attribute.
      * @param duplicateValues
@@ -134,8 +126,7 @@
      * @throws NullPointerException
      *             If {@code values} was {@code null}.
      */
-    boolean addAll(Collection<? extends ByteString> values,
-            Collection<? super ByteString> duplicateValues);
+    <T> boolean addAll(Collection<T> values, Collection<? super T> duplicateValues);
 
     /**
      * Removes all of the attribute values from this attribute (optional
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
index 49360e3..5311bdc 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
@@ -123,8 +123,8 @@
         }
 
         @Override
-        public boolean addAll(final Collection<? extends ByteString> values,
-                final Collection<? super ByteString> duplicateValues) {
+        public <T> boolean addAll(final Collection<T> values,
+                final Collection<? super T> duplicateValues) {
             return attribute.addAll(values, duplicateValues);
         }
 
@@ -330,8 +330,8 @@
         }
 
         @Override
-        public boolean addAll(final Collection<? extends ByteString> values,
-                final Collection<? super ByteString> duplicateValues) {
+        public <T> boolean addAll(final Collection<T> values,
+                final Collection<? super T> duplicateValues) {
             throw new UnsupportedOperationException();
         }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java
index 1a6b6bf..de5fcb4 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java
@@ -75,7 +75,7 @@
          */
         @Override
         public boolean addAttribute(final Attribute attribute,
-                final Collection<ByteString> duplicateValues) {
+                final Collection<? super ByteString> duplicateValues) {
             throw new UnsupportedOperationException();
         }
 
@@ -94,7 +94,7 @@
 
         @Override
         public boolean containsAttribute(final Attribute attribute,
-                final Collection<ByteString> missingValues) {
+                final Collection<? super ByteString> missingValues) {
             return entry.containsAttribute(attribute, missingValues);
         }
 
@@ -195,7 +195,7 @@
          */
         @Override
         public boolean removeAttribute(final Attribute attribute,
-                final Collection<ByteString> missingValues) {
+                final Collection<? super ByteString> missingValues) {
             throw new UnsupportedOperationException();
         }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java
index 6a5aabf..eccd7e6 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java
@@ -123,7 +123,7 @@
      * @throws NullPointerException
      *             If {@code attribute} was {@code null}.
      */
-    boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues);
+    boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues);
 
     /**
      * Ensures that this entry contains the provided attribute and values
@@ -191,7 +191,7 @@
      * @throws NullPointerException
      *             If {@code attribute} was {@code null}.
      */
-    boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * Returns {@code true} if this entry contains all of the attribute values
@@ -380,7 +380,7 @@
      * @throws NullPointerException
      *             If {@code attribute} was {@code null}.
      */
-    boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * Removes the named attribute from this entry if it is present (optional
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java
index 375b6ae..1a4458e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java
@@ -636,27 +636,6 @@
      * {@inheritDoc}
      */
     @Override
-    public boolean addAll(final Collection<? extends ByteString> values,
-            final Collection<? super ByteString> duplicateValues) {
-        Validator.ensureNotNull(values);
-
-        // TODO: could optimize if objects is a LinkedAttribute having the same
-        // equality matching rule.
-        boolean modified = false;
-        for (final ByteString value : values) {
-            if (add(value)) {
-                modified = true;
-            } else if (duplicateValues != null) {
-                duplicateValues.add(value);
-            }
-        }
-        return modified;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public void clear() {
         pimpl.clear(this);
     }
@@ -716,27 +695,6 @@
      * {@inheritDoc}
      */
     @Override
-    public <T> boolean removeAll(final Collection<T> values,
-            final Collection<? super T> missingValues) {
-        Validator.ensureNotNull(values);
-
-        // TODO: could optimize if objects is a LinkedAttribute having the same
-        // equality matching rule.
-        boolean modified = false;
-        for (final T value : values) {
-            if (remove(ByteString.valueOf(value))) {
-                modified = true;
-            } else if (missingValues != null) {
-                missingValues.add(value);
-            }
-        }
-        return modified;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public <T> boolean retainAll(final Collection<T> values,
             final Collection<? super T> missingValues) {
         Validator.ensureNotNull(values);
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java
index 6feb17e..8683f7c 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java
@@ -65,7 +65,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues);
+    boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues);
 
     /**
      * {@inheritDoc}
@@ -85,7 +85,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * {@inheritDoc}
@@ -141,7 +141,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * {@inheritDoc}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java
index 97c8a6c..a350974 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java
@@ -91,7 +91,7 @@
      * {@inheritDoc}
      */
     public boolean addAttribute(final Attribute attribute,
-            final Collection<ByteString> duplicateValues) {
+            final Collection<? super ByteString> duplicateValues) {
         return entry.addAttribute(attribute, duplicateValues);
     }
 
@@ -115,7 +115,7 @@
      * {@inheritDoc}
      */
     public boolean containsAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         return entry.containsAttribute(attribute, missingValues);
     }
 
@@ -179,7 +179,7 @@
      * {@inheritDoc}
      */
     public boolean removeAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         return entry.removeAttribute(attribute, missingValues);
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java
index 6235f24..ad425d9 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java
@@ -110,20 +110,6 @@
 
     /**
      * Sets the assertion value to be compared.
-     *
-     * @param value
-     *            The assertion value to be compared.
-     * @return This compare request.
-     * @throws UnsupportedOperationException
-     *             If this compare request does not permit the assertion value
-     *             to be set.
-     * @throws NullPointerException
-     *             If {@code value} was {@code null}.
-     */
-    CompareRequest setAssertionValue(ByteString value);
-
-    /**
-     * Sets the assertion value to be compared.
      * <p>
      * If the assertion value is not an instance of {@code ByteString} then it
      * will be converted using the {@link ByteString#valueOf(Object)} method.
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java
index 85b6c4e..6b18f35 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java
@@ -113,15 +113,6 @@
     /**
      * {@inheritDoc}
      */
-    public CompareRequest setAssertionValue(final ByteString value) {
-        Validator.ensureNotNull(value);
-        this.assertionValue = value;
-        return this;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public CompareRequest setAssertionValue(final Object value) {
         Validator.ensureNotNull(value);
         this.assertionValue = ByteString.valueOf(value);
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java
index ae5c6bb..f597a1e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java
@@ -106,14 +106,18 @@
     /**
      * Sets the value, if any, associated with this extended request. Its format
      * is defined by the specification of this extended request.
+     * <p>
+     * If {@code value} is not an instance of {@code ByteString} then it will be
+     * converted using the {@link ByteString#valueOf(Object)} method.
      *
-     * @param bytes
-     *            The value associated with this extended request, or
-     *            {@code null} if there is no value.
+     * @param value
+     *            TThe value associated with this extended request, or
+     *            {@code null} if there is no value. Its format is defined by
+     *            the specification of this control.
      * @return This generic extended request.
      * @throws UnsupportedOperationException
      *             If this generic extended request does not permit the request
      *             value to be set.
      */
-    GenericExtendedRequest setValue(ByteString bytes);
+    GenericExtendedRequest setValue(Object value);
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java
index 9c3a919..4bc41c4 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java
@@ -56,7 +56,8 @@
                 return (GenericExtendedRequest) request;
             } else {
                 final GenericExtendedRequest newRequest =
-                        new GenericExtendedRequestImpl(request.getOID(), request.getValue());
+                        new GenericExtendedRequestImpl(request.getOID()).setValue(request
+                                .getValue());
 
                 for (final Control control : request.getControls()) {
                     newRequest.addControl(control);
@@ -97,27 +98,20 @@
     private static final GenericExtendedResultDecoder RESULT_DECODER =
             new GenericExtendedResultDecoder();
 
-    private ByteString requestValue = ByteString.empty();
-
+    private ByteString requestValue = null;
     private String requestName;
 
     /**
-     * Creates a new generic extended request using the provided name and
-     * optional value.
+     * Creates a new generic extended request using the provided name.
      *
      * @param requestName
      *            The dotted-decimal representation of the unique OID
      *            corresponding to this extended request.
-     * @param requestValue
-     *            The content of this generic extended request in a form defined
-     *            by the extended operation, or {@code null} if there is no
-     *            content.
      * @throws NullPointerException
      *             If {@code requestName} was {@code null}.
      */
-    GenericExtendedRequestImpl(final String requestName, final ByteString requestValue) {
+    GenericExtendedRequestImpl(final String requestName) {
         this.requestName = requestName;
-        this.requestValue = requestValue;
     }
 
     /**
@@ -179,8 +173,8 @@
     /**
      * {@inheritDoc}
      */
-    public GenericExtendedRequest setValue(final ByteString bytes) {
-        this.requestValue = bytes;
+    public GenericExtendedRequest setValue(final Object value) {
+        this.requestValue = value != null ? ByteString.valueOf(value) : null;
         return this;
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java
index e8194e0..938a869 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java
@@ -107,7 +107,7 @@
      * @return The desired password for the user, or {@code null} if a new
      *         password should be generated.
      */
-    ByteString getNewPassword();
+    byte[] getNewPassword();
 
     /**
      * {@inheritDoc}
@@ -120,7 +120,7 @@
      * @return The current password for the user, or {@code null} if the
      *         password is not known.
      */
-    ByteString getOldPassword();
+    byte[] getOldPassword();
 
     /**
      * {@inheritDoc}
@@ -172,7 +172,7 @@
      *             If this password modify extended request does not permit the
      *             new password to be set.
      */
-    PasswordModifyExtendedRequest setNewPassword(ByteString newPassword);
+    PasswordModifyExtendedRequest setNewPassword(byte[] newPassword);
 
     /**
      * Sets the desired password for the user. The password will be converted to
@@ -199,7 +199,7 @@
      *             If this password modify extended request does not permit the
      *             old password to be set.
      */
-    PasswordModifyExtendedRequest setOldPassword(ByteString oldPassword);
+    PasswordModifyExtendedRequest setOldPassword(byte[] oldPassword);
 
     /**
      * Sets the current password for the user. The password will be converted to
@@ -218,6 +218,9 @@
     /**
      * Sets the identity of the user whose password is to be modified. The
      * identity may or may not be a distinguished name.
+     * <p>
+     * If {@code userIdentity} is not an instance of {@code ByteString} then it
+     * will be converted using the {@link ByteString#valueOf(Object)} method.
      *
      * @param userIdentity
      *            The identity of the user whose password is to be modified, or
@@ -228,22 +231,6 @@
      *             If this password modify extended request does not permit the
      *             user identity to be set.
      */
-    PasswordModifyExtendedRequest setUserIdentity(ByteString userIdentity);
-
-    /**
-     * Sets the identity of the user whose password is to be modified. The
-     * identity may or may not be a distinguished name. The identity will be
-     * converted to a UTF-8 octet string.
-     *
-     * @param userIdentity
-     *            The identity of the user whose password is to be modified, or
-     *            {@code null} if the request should be applied to the user
-     *            currently associated with the session.
-     * @return This password modify request.
-     * @throws UnsupportedOperationException
-     *             If this password modify extended request does not permit the
-     *             user identity to be set.
-     */
-    PasswordModifyExtendedRequest setUserIdentity(String userIdentity);
+    PasswordModifyExtendedRequest setUserIdentity(Object userIdentity);
 
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java
index 00ab4b8..0420f48 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java
@@ -48,6 +48,8 @@
 import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult;
 import org.forgerock.opendj.ldap.responses.Responses;
 
+import com.forgerock.opendj.util.StaticUtils;
+
 /**
  * Password modify extended request implementation.
  */
@@ -71,11 +73,11 @@
                     }
                     if (reader.hasNextElement()
                             && (reader.peekType() == TYPE_PASSWORD_MODIFY_OLD_PASSWORD)) {
-                        newRequest.setOldPassword(reader.readOctetString());
+                        newRequest.setOldPassword(reader.readOctetString().toByteArray());
                     }
                     if (reader.hasNextElement()
                             && (reader.peekType() == TYPE_PASSWORD_MODIFY_NEW_PASSWORD)) {
-                        newRequest.setNewPassword(reader.readOctetString());
+                        newRequest.setNewPassword(reader.readOctetString().toByteArray());
                     }
                     reader.readEndSequence();
                 } catch (final IOException e) {
@@ -120,7 +122,8 @@
                         final ASN1Reader asn1Reader = ASN1.getReader(responseValue);
                         asn1Reader.readStartSequence();
                         if (asn1Reader.peekType() == TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD) {
-                            newResult.setGeneratedPassword(asn1Reader.readOctetString());
+                            newResult.setGeneratedPassword(asn1Reader.readOctetString()
+                                    .toByteArray());
                         }
                         asn1Reader.readEndSequence();
                     } catch (final IOException e) {
@@ -164,10 +167,8 @@
     private static final byte TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD = (byte) 0x80;
 
     private ByteString userIdentity = null;
-
-    private ByteString oldPassword = null;
-
-    private ByteString newPassword = null;
+    private byte[] oldPassword = null;
+    private byte[] newPassword = null;
 
     private static final ExtendedResultDecoder<PasswordModifyExtendedResult> RESULT_DECODER =
             new ResultDecoder();
@@ -197,7 +198,7 @@
     /**
      * {@inheritDoc}
      */
-    public ByteString getNewPassword() {
+    public byte[] getNewPassword() {
         return newPassword;
     }
 
@@ -212,7 +213,7 @@
     /**
      * {@inheritDoc}
      */
-    public ByteString getOldPassword() {
+    public byte[] getOldPassword() {
         return oldPassword;
     }
 
@@ -277,7 +278,7 @@
     /**
      * {@inheritDoc}
      */
-    public PasswordModifyExtendedRequest setNewPassword(final ByteString newPassword) {
+    public PasswordModifyExtendedRequest setNewPassword(final byte[] newPassword) {
         this.newPassword = newPassword;
         return this;
     }
@@ -286,14 +287,14 @@
      * {@inheritDoc}
      */
     public PasswordModifyExtendedRequest setNewPassword(final char[] newPassword) {
-        this.newPassword = (newPassword != null) ? ByteString.valueOf(newPassword) : null;
+        this.newPassword = (newPassword != null) ? StaticUtils.getBytes(newPassword) : null;
         return this;
     }
 
     /**
      * {@inheritDoc}
      */
-    public PasswordModifyExtendedRequest setOldPassword(final ByteString oldPassword) {
+    public PasswordModifyExtendedRequest setOldPassword(final byte[] oldPassword) {
         this.oldPassword = oldPassword;
         return this;
     }
@@ -302,22 +303,14 @@
      * {@inheritDoc}
      */
     public PasswordModifyExtendedRequest setOldPassword(final char[] oldPassword) {
-        this.oldPassword = (oldPassword != null) ? ByteString.valueOf(oldPassword) : null;
+        this.oldPassword = (oldPassword != null) ? StaticUtils.getBytes(oldPassword) : null;
         return this;
     }
 
     /**
      * {@inheritDoc}
      */
-    public PasswordModifyExtendedRequest setUserIdentity(final ByteString userIdentity) {
-        this.userIdentity = userIdentity;
-        return this;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public PasswordModifyExtendedRequest setUserIdentity(final String userIdentity) {
+    public PasswordModifyExtendedRequest setUserIdentity(final Object userIdentity) {
         this.userIdentity = (userIdentity != null) ? ByteString.valueOf(userIdentity) : null;
         return this;
     }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java
index 6d8aa97..605b1fa 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java
@@ -209,6 +209,9 @@
     /**
      * Creates a new compare request using the provided distinguished name,
      * attribute name, and assertion value.
+     * <p>
+     * If the assertion value is not an instance of {@code ByteString} then it
+     * will be converted using the {@link ByteString#valueOf(Object)} method.
      *
      * @param name
      *            The distinguished name of the entry to be compared.
@@ -222,9 +225,10 @@
      *             {@code assertionValue} was {@code null}.
      */
     public static CompareRequest newCompareRequest(final DN name,
-            final AttributeDescription attributeDescription, final ByteString assertionValue) {
+            final AttributeDescription attributeDescription, final Object assertionValue) {
         Validator.ensureNotNull(name, attributeDescription, assertionValue);
-        return new CompareRequestImpl(name, attributeDescription, assertionValue);
+        return new CompareRequestImpl(name, attributeDescription, ByteString
+                .valueOf(assertionValue));
     }
 
     /**
@@ -443,12 +447,15 @@
      */
     public static GenericExtendedRequest newGenericExtendedRequest(final String requestName) {
         Validator.ensureNotNull(requestName);
-        return new GenericExtendedRequestImpl(requestName, null);
+        return new GenericExtendedRequestImpl(requestName);
     }
 
     /**
      * Creates a new generic extended request using the provided name and
      * optional value.
+     * <p>
+     * If the request value is not an instance of {@code ByteString} then it
+     * will be converted using the {@link ByteString#valueOf(Object)} method.
      *
      * @param requestName
      *            The dotted-decimal representation of the unique OID
@@ -462,9 +469,9 @@
      *             If {@code requestName} was {@code null}.
      */
     public static GenericExtendedRequest newGenericExtendedRequest(final String requestName,
-            final ByteString requestValue) {
+            final Object requestValue) {
         Validator.ensureNotNull(requestName);
-        return new GenericExtendedRequestImpl(requestName, requestValue);
+        return new GenericExtendedRequestImpl(requestName).setValue(requestValue);
     }
 
     /**
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java
index c1436c4..1bb5327 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java
@@ -66,7 +66,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues) {
+    public boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) {
         throw new UnsupportedOperationException();
     }
 
@@ -78,7 +78,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues) {
+    public boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues) {
         return impl.containsAttribute(attribute, missingValues);
     }
 
@@ -135,7 +135,7 @@
         return impl.parseAttribute(attributeDescription);
     }
 
-    public boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues) {
+    public boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) {
         throw new UnsupportedOperationException();
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java
index a995166..733e4ee 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java
@@ -56,10 +56,6 @@
         return impl.getName();
     }
 
-    public CompareRequest setAssertionValue(ByteString value) {
-        throw new UnsupportedOperationException();
-    }
-
     public CompareRequest setAssertionValue(Object value) {
         throw new UnsupportedOperationException();
     }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java
index c30065e..5d9e89b 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java
@@ -27,7 +27,6 @@
 
 package org.forgerock.opendj.ldap.requests;
 
-import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.responses.GenericExtendedResult;
 
 /**
@@ -44,7 +43,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public GenericExtendedRequest setValue(ByteString bytes) {
+    public GenericExtendedRequest setValue(Object value) {
         throw new UnsupportedOperationException();
     }
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java
index 4ddead4..7f63a78 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java
@@ -29,6 +29,8 @@
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult;
 
+import com.forgerock.opendj.util.StaticUtils;
+
 /**
  * Unmodifiable password modify extended request implementation.
  */
@@ -40,12 +42,14 @@
         super(impl);
     }
 
-    public ByteString getNewPassword() {
-        return impl.getNewPassword();
+    public byte[] getNewPassword() {
+        // Defensive copy.
+        return StaticUtils.copyOfBytes(impl.getNewPassword());
     }
 
-    public ByteString getOldPassword() {
-        return impl.getOldPassword();
+    public byte[] getOldPassword() {
+        // Defensive copy.
+        return StaticUtils.copyOfBytes(impl.getOldPassword());
     }
 
     public ByteString getUserIdentity() {
@@ -56,7 +60,7 @@
         return impl.getUserIdentityAsString();
     }
 
-    public PasswordModifyExtendedRequest setNewPassword(ByteString newPassword) {
+    public PasswordModifyExtendedRequest setNewPassword(byte[] newPassword) {
         throw new UnsupportedOperationException();
     }
 
@@ -64,7 +68,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public PasswordModifyExtendedRequest setOldPassword(ByteString oldPassword) {
+    public PasswordModifyExtendedRequest setOldPassword(byte[] oldPassword) {
         throw new UnsupportedOperationException();
     }
 
@@ -72,11 +76,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public PasswordModifyExtendedRequest setUserIdentity(ByteString userIdentity) {
-        throw new UnsupportedOperationException();
-    }
-
-    public PasswordModifyExtendedRequest setUserIdentity(String userIdentity) {
+    public PasswordModifyExtendedRequest setUserIdentity(Object userIdentity) {
         throw new UnsupportedOperationException();
     }
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java
index 935dcb2..bb38f14 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java
@@ -148,8 +148,11 @@
     /**
      * Sets the value, if any, associated with this extended result. Its format
      * is defined by the specification of this extended result.
+     * <p>
+     * If {@code value} is not an instance of {@code ByteString} then it will be
+     * converted using the {@link ByteString#valueOf(Object)} method.
      *
-     * @param bytes
+     * @param value
      *            The value associated with this extended result, or
      *            {@code null} if there is no value.
      * @return This generic extended result.
@@ -157,6 +160,6 @@
      *             If this generic extended result does not permit the result
      *             value to be set.
      */
-    GenericExtendedResult setValue(ByteString bytes);
+    GenericExtendedResult setValue(Object value);
 
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java
index 27ed19d..9534edf 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java
@@ -39,7 +39,6 @@
         implements ExtendedResult, GenericExtendedResult {
 
     private String responseName = null;
-
     private ByteString responseValue = null;
 
     /**
@@ -101,8 +100,8 @@
     /**
      * {@inheritDoc}
      */
-    public GenericExtendedResult setValue(final ByteString bytes) {
-        this.responseValue = bytes;
+    public GenericExtendedResult setValue(final Object value) {
+        this.responseValue = value != null ? ByteString.valueOf(value) : null;
         return this;
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java
index 3162a04..b1f4211 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java
@@ -87,8 +87,11 @@
     /**
      * Sets the value, if any, associated with this intermediate response. Its
      * format is defined by the specification of this intermediate response.
+     * <p>
+     * If {@code value} is not an instance of {@code ByteString} then it will be
+     * converted using the {@link ByteString#valueOf(Object)} method.
      *
-     * @param bytes
+     * @param value
      *            The value associated with this intermediate response, or
      *            {@code null} if there is no value.
      * @return This generic intermediate response.
@@ -96,6 +99,6 @@
      *             If this intermediate response does not permit the response
      *             value to be set.
      */
-    GenericIntermediateResponse setValue(ByteString bytes);
+    GenericIntermediateResponse setValue(Object value);
 
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java
index 8c9a813..3f9f278 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java
@@ -39,25 +39,13 @@
         GenericIntermediateResponse {
 
     private String responseName = null;
-
     private ByteString responseValue = null;
 
     /**
-     * Creates a new generic intermediate response using the provided response
-     * name and value.
-     *
-     * @param responseName
-     *            The dotted-decimal representation of the unique OID
-     *            corresponding to this intermediate response, which may be
-     *            {@code null} indicating that none was provided.
-     * @param responseValue
-     *            The response value associated with this generic intermediate
-     *            response, which may be {@code null} indicating that none was
-     *            provided.
+     * Creates a new generic intermediate response with no name or value.
      */
-    GenericIntermediateResponseImpl(final String responseName, final ByteString responseValue) {
-        this.responseName = responseName;
-        this.responseValue = responseValue;
+    GenericIntermediateResponseImpl() {
+        // Nothing to do.
     }
 
     /**
@@ -110,8 +98,8 @@
     /**
      * {@inheritDoc}
      */
-    public GenericIntermediateResponse setValue(final ByteString bytes) {
-        this.responseValue = bytes;
+    public GenericIntermediateResponse setValue(final Object value) {
+        this.responseValue = value != null ? ByteString.valueOf(value) : null;
         return this;
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java
index c972f80..d36522f 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java
@@ -85,7 +85,7 @@
      * @return The newly generated password, or {@code null} if the password
      *         modify request failed or a generated password was not requested.
      */
-    ByteString getGeneratedPassword();
+    byte[] getGeneratedPassword();
 
     /**
      * {@inheritDoc}
@@ -148,7 +148,7 @@
      *             If this password modify extended result does not permit the
      *             generated password to be set.
      */
-    PasswordModifyExtendedResult setGeneratedPassword(ByteString password);
+    PasswordModifyExtendedResult setGeneratedPassword(byte[] password);
 
     /**
      * Sets the generated password. The password will be converted to a UTF-8
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java
index 5f03a30..8fdfbed 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java
@@ -35,13 +35,15 @@
 import org.forgerock.opendj.ldap.ByteStringBuilder;
 import org.forgerock.opendj.ldap.ResultCode;
 
+import com.forgerock.opendj.util.StaticUtils;
+
 /**
  * Password modify extended result implementation.
  */
 final class PasswordModifyExtendedResultImpl extends
         AbstractExtendedResult<PasswordModifyExtendedResult> implements
         PasswordModifyExtendedResult {
-    private ByteString password;
+    private byte[] password;
 
     /**
      * The ASN.1 element type that will be used to encode the genPasswd
@@ -71,7 +73,7 @@
     /**
      * {@inheritDoc}
      */
-    public ByteString getGeneratedPassword() {
+    public byte[] getGeneratedPassword() {
         return password;
     }
 
@@ -118,7 +120,7 @@
     /**
      * {@inheritDoc}
      */
-    public PasswordModifyExtendedResult setGeneratedPassword(final ByteString password) {
+    public PasswordModifyExtendedResult setGeneratedPassword(final byte[] password) {
         this.password = password;
         return this;
     }
@@ -127,7 +129,7 @@
      * {@inheritDoc}
      */
     public PasswordModifyExtendedResult setGeneratedPassword(final char[] password) {
-        this.password = (password != null) ? ByteString.valueOf(password) : null;
+        this.password = (password != null) ? StaticUtils.getBytes(password) : null;
         return this;
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java
index 4c461af..a72aa6b 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java
@@ -104,12 +104,15 @@
      * @return The new generic intermediate response.
      */
     public static GenericIntermediateResponse newGenericIntermediateResponse() {
-        return new GenericIntermediateResponseImpl(null, null);
+        return new GenericIntermediateResponseImpl();
     }
 
     /**
      * Creates a new generic intermediate response using the provided response
      * name and value.
+     * <p>
+     * If the response value is not an instance of {@code ByteString} then it
+     * will be converted using the {@link ByteString#valueOf(Object)} method.
      *
      * @param responseName
      *            The dotted-decimal representation of the unique OID
@@ -122,8 +125,8 @@
      * @return The new generic intermediate response.
      */
     public static GenericIntermediateResponse newGenericIntermediateResponse(
-            final String responseName, final ByteString responseValue) {
-        return new GenericIntermediateResponseImpl(responseName, responseValue);
+            final String responseName, final Object responseValue) {
+        return new GenericIntermediateResponseImpl().setOID(responseName).setValue(responseValue);
     }
 
     /**
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java
index 0d0db5b..a2c1a5a 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java
@@ -63,7 +63,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues);
+    boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues);
 
     /**
      * {@inheritDoc}
@@ -83,7 +83,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * {@inheritDoc}
@@ -139,7 +139,7 @@
     /**
      * {@inheritDoc}
      */
-    boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues);
+    boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues);
 
     /**
      * {@inheritDoc}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java
index 6d9372b..07c712e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java
@@ -86,7 +86,7 @@
      * {@inheritDoc}
      */
     public boolean addAttribute(final Attribute attribute,
-            final Collection<ByteString> duplicateValues) {
+            final Collection<? super ByteString> duplicateValues) {
         return entry.addAttribute(attribute, duplicateValues);
     }
 
@@ -110,7 +110,7 @@
      * {@inheritDoc}
      */
     public boolean containsAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         return entry.containsAttribute(attribute, missingValues);
     }
 
@@ -188,7 +188,7 @@
      * {@inheritDoc}
      */
     public boolean removeAttribute(final Attribute attribute,
-            final Collection<ByteString> missingValues) {
+            final Collection<? super ByteString> missingValues) {
         return entry.removeAttribute(attribute, missingValues);
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java
index 73c0c47..b1c0970 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java
@@ -27,8 +27,6 @@
 
 package org.forgerock.opendj.ldap.responses;
 
-import org.forgerock.opendj.ldap.ByteString;
-
 /**
  * Unmodifiable Generic extended result implementation.
  */
@@ -45,7 +43,7 @@
     }
 
     @Override
-    public GenericExtendedResult setValue(ByteString bytes) {
+    public GenericExtendedResult setValue(Object value) {
         throw new UnsupportedOperationException();
     }
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java
index 0201aab..785e9a6 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java
@@ -27,8 +27,6 @@
 
 package org.forgerock.opendj.ldap.responses;
 
-import org.forgerock.opendj.ldap.ByteString;
-
 /**
  * Unmodifiable Generic extended result implementation.
  */
@@ -45,7 +43,7 @@
     }
 
     @Override
-    public GenericIntermediateResponse setValue(ByteString bytes) {
+    public GenericIntermediateResponse setValue(Object value) {
         throw new UnsupportedOperationException();
     }
 }
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java
index 12d20cc..3410c33 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java
@@ -27,8 +27,6 @@
 
 package org.forgerock.opendj.ldap.responses;
 
-import org.forgerock.opendj.ldap.ByteString;
-
 /**
  * Unmodifiable Password modify extended result implementation.
  */
@@ -40,12 +38,12 @@
     }
 
     @Override
-    public ByteString getGeneratedPassword() {
+    public byte[] getGeneratedPassword() {
         return impl.getGeneratedPassword();
     }
 
     @Override
-    public PasswordModifyExtendedResult setGeneratedPassword(ByteString password) {
+    public PasswordModifyExtendedResult setGeneratedPassword(byte[] password) {
         throw new UnsupportedOperationException();
     }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java
index c3df90e..463d947 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java
@@ -61,7 +61,7 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues) {
+    public boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) {
         throw new UnsupportedOperationException();
     }
 
@@ -73,7 +73,8 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues) {
+    public boolean containsAttribute(Attribute attribute,
+            Collection<? super ByteString> missingValues) {
         return impl.containsAttribute(attribute, missingValues);
     }
 
@@ -130,7 +131,7 @@
         return impl.parseAttribute(attributeDescription);
     }
 
-    public boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues) {
+    public boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) {
         throw new UnsupportedOperationException();
     }
 
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
index 22762e6..6a883b1 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -32,7 +32,6 @@
 import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
 
 import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.ConnectionFactory;
 import org.forgerock.opendj.ldap.DecodeException;
@@ -255,15 +254,15 @@
         }
 
         if (currentPW.isPresent()) {
-            request.setOldPassword(ByteString.valueOf(currentPW.getValue()));
+            request.setOldPassword(currentPW.getValue().toCharArray());
         } else if (currentPWFile.isPresent()) {
-            request.setOldPassword(ByteString.valueOf(currentPWFile.getValue()));
+            request.setOldPassword(currentPWFile.getValue().toCharArray());
         }
 
         if (newPW.isPresent()) {
-            request.setNewPassword(ByteString.valueOf(newPW.getValue()));
+            request.setNewPassword(newPW.getValue().toCharArray());
         } else if (newPWFile.isPresent()) {
-            request.setNewPassword(ByteString.valueOf(newPWFile.getValue()));
+            request.setNewPassword(newPWFile.getValue().toCharArray());
         }
 
         PasswordModifyExtendedResult result;

--
Gitblit v1.10.0