From f6c69fffa854f47d14f0c5ac4650519607db209c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 07 Feb 2014 12:50:29 +0000
Subject: [PATCH] OPENDJ-1307 Migrate server ASN1 classes to SDK

---
 /dev/null |  710 -----------------------------------------------------------
 1 files changed, 0 insertions(+), 710 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1.java
deleted file mode 100644
index 61415d8..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.protocols.asn1;
-
-
-
-import static org.opends.server.util.ServerConstants.*;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.channels.ReadableByteChannel;
-
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.opendj.ldap.ByteSequenceReader;
-
-
-
-/**
- * This class contains various static factory methods for creating
- * ASN.1 readers and writers.
- *
- * @see ASN1Reader
- * @see ASN1Writer
- * @see ASN1ByteChannelReader
- */
-public final class ASN1
-{
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte array and
-   * having an unlimited maximum BER element size.
-   *
-   * @param array
-   *          The byte array to use.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(byte[] array)
-  {
-    return getReader(array, 0);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte array and
-   * having a user defined maximum BER element size.
-   *
-   * @param array
-   *          The byte array to use.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(byte[] array, int maxElementSize)
-  {
-    return getReader(ByteString.wrap(array), maxElementSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte sequence
-   * and having an unlimited maximum BER element size.
-   *
-   * @param sequence
-   *          The byte sequence to use.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(ByteSequence sequence)
-  {
-    return getReader(sequence, 0);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte sequence
-   * and having a user defined maximum BER element size.
-   *
-   * @param sequence
-   *          The byte sequence to use.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(ByteSequence sequence, int maxElementSize)
-  {
-    return new ASN1ByteSequenceReader(sequence.asReader(), maxElementSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte sequence reader
-   * and having an unlimited maximum BER element size.
-   *
-   * @param reader
-   *          The byte sequence reader to use.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(ByteSequenceReader reader)
-  {
-    return getReader(reader, 0);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided byte sequence reader
-   * and having a user defined maximum BER element size.
-   *
-   * @param reader
-   *          The byte sequence reader to use.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(ByteSequenceReader reader,
-                                     int maxElementSize)
-  {
-    return new ASN1ByteSequenceReader(reader, maxElementSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided input stream
-   * and having an unlimited maximum BER element size.
-   *
-   * @param stream
-   *          The input stream to use.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(InputStream stream)
-  {
-    return getReader(stream, 0);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 reader whose source is the provided input stream
-   * and having a user defined maximum BER element size.
-   *
-   * @param stream
-   *          The input stream to use.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   * @return The new ASN.1 reader.
-   */
-  public static ASN1Reader getReader(InputStream stream, int maxElementSize)
-  {
-    return new ASN1InputStreamReader(stream, maxElementSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 byte channel reader whose source is the provided
-   * readable byte channel, uses 4KB buffer, and having an unlimited
-   * maximum BER element size.
-   *
-   * @param channel
-   *          The readable byte channel to use.
-   * @return The new ASN.1 byte channel reader.
-   */
-  public static ASN1ByteChannelReader getReader(ReadableByteChannel channel)
-  {
-    return getReader(channel, 4096, 0);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 byte channel reader whose source is the provided
-   * readable byte channel, having a user defined buffer size, and
-   * user defined maximum BER element size.
-   *
-   * @param channel
-   *          The readable byte channel to use.
-   * @param bufferSize
-   *          The buffer size to use when reading from the channel.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   * @return The new ASN.1 byte channel reader.
-   */
-  public static ASN1ByteChannelReader getReader(ReadableByteChannel channel,
-      int bufferSize, int maxElementSize)
-  {
-    return new ASN1ByteChannelReader(channel, bufferSize, maxElementSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 writer whose destination is the provided byte
-   * string builder.
-   *
-   * @param builder
-   *          The byte string builder to use.
-   * @return The new ASN.1 writer.
-   */
-  public static ASN1Writer getWriter(ByteStringBuilder builder)
-  {
-    return getWriter(builder, DEFAULT_MAX_INTERNAL_BUFFER_SIZE);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 writer whose destination is the provided byte string builder.
-   *
-   * @param builder
-   *          The byte string builder to use.
-   * @param maxInternalBufferSize
-   *          The threshold capacity beyond which internal cached buffers used
-   *          for encoding and decoding protocol messages will be trimmed after
-   *          use.
-   * @return The new ASN.1 writer.
-   */
-  public static ASN1Writer getWriter(ByteStringBuilder builder,
-      int maxInternalBufferSize)
-  {
-    if (maxInternalBufferSize <= 0)
-    {
-      throw new IllegalArgumentException();
-    }
-    ByteSequenceOutputStream outputStream = new ByteSequenceOutputStream(
-        builder, maxInternalBufferSize);
-    return getWriter(outputStream, maxInternalBufferSize);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 writer whose destination is the provided output
-   * stream.
-   *
-   * @param stream
-   *          The output stream to use.
-   * @return The new ASN.1 writer.
-   */
-  public static ASN1Writer getWriter(OutputStream stream)
-  {
-    return getWriter(stream, DEFAULT_MAX_INTERNAL_BUFFER_SIZE);
-  }
-
-
-
-  /**
-   * Gets an ASN.1 writer whose destination is the provided output
-   * stream.
-   *
-   * @param stream
-   *          The output stream to use.
-   * @param maxInternalBufferSize
-   *          The threshold capacity beyond which internal cached buffers used
-   *          for encoding and decoding protocol messages will be trimmed after
-   *          use.
-   * @return The new ASN.1 writer.
-   */
-  public static ASN1Writer getWriter(OutputStream stream,
-      int maxInternalBufferSize)
-  {
-    if (maxInternalBufferSize <= 0)
-    {
-      throw new IllegalArgumentException();
-    }
-    return new ASN1OutputStreamWriter(stream, maxInternalBufferSize);
-  }
-
-
-
-  // Prevent instantiation.
-  private ASN1()
-  {
-    // Nothing to do.
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
deleted file mode 100644
index 205919e..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2014 ForgeRock AS.
- */
-package org.opends.server.protocols.asn1;
-
-import org.forgerock.opendj.ldap.ByteSequenceReader;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.opendj.ldap.ByteString;
-import java.nio.ByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.IllegalBlockingModeException;
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * This class is for reading ASN.1 elements from a readable byte
- * channel. It will handle all partial element reads from the channel
- * and save any unread ASN.1 elements if required. All data read from
- * the channel will be ready to be read as ASN.1 elements no matter
- * how many times the channel is read. However, to minimize the the
- * amount of memory used by this reader, the client should read ASN.1
- * elements as soon as they are read off the channel.
- * <p>
- * {@code ASN1ByteChannelReader}s are created using the factory
- * methods in {@link ASN1}.
- * <p>
- * The client should use this class in the following manner:
- *<p>
- * When NIO signals new data is available in the channel, the client
- * should call {@link #processChannelData()}.
- *<p>
- * If bytes are read from the channel, the client should call
- * {@link #elementAvailable()} to see if a complete element is ready to
- * be read. However, if no data is actually read, the client should
- * wait for the next signal and try again.
- * <p>
- * As long as a complete element is ready, the client should read the
- * appropriate ASN.1 element(s). Once no more complete elements are
- * available, the client should call {@link #processChannelData()}
- * again to read more data (if available).
- * <p>
- * <b>NOTE:</b> Since this reader is non blocking, reading ASN.1
- * elements before making sure they are ready could result in
- * {@link IllegalBlockingModeException}s being thrown while reading
- * ASN.1 elements. Once an exception is thrown, the state of the reader
- * is no longer stable and can not be used again.
- */
-public final class ASN1ByteChannelReader implements ASN1Reader
-{
-  // The byte channel to read from.
-  private final ReadableByteChannel byteChannel;
-
-  // The wrapped ASN.1 InputStream reader.
-  private final ASN1InputStreamReader reader;
-
-  // The NIO ByteStringBuilder that stores any immediate data read off
-  // the channel.
-  private final ByteBuffer byteBuffer;
-
-  // The save buffer used to store any unprocessed data waiting
-  // to be read as ASN.1 elements. (Usually due to reading
-  // incomplete elements from the channel).
-  private final ByteStringBuilder saveBuffer;
-
-  // The save buffer reader.
-  private final ByteSequenceReader saveBufferReader;
-
-  /**
-   * An adaptor class for reading from a save buffer and the NIO byte buffer
-   * sequentially using the InputStream interface.
-   *
-   * Since the NIO byte buffer is re-used when reading off the channel, any
-   * unused data will be appended to the save buffer before reading off the
-   * channel again. This reader will always read the save buffer first before
-   * the actual NIO byte buffer to ensure bytes are read in the same order
-   * as they are received.
-   *
-   * The read methods of this stream will throw an IllegalBlockingModeException
-   * if invoked when there are no data to read from the save buffer or the
-   * channel buffer.
-   *
-   * The stream will not support the mark or reset methods.
-   */
-  private final class CombinedBufferInputStream extends InputStream
-  {
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int available()
-    {
-      // The number of available bytes is the sum of the save buffer
-      // and the last read data in the NIO ByteStringBuilder.
-      return saveBufferReader.remaining() + byteBuffer.remaining();
-    }
-
-    /**
-     * Reads the next byte of data from the save buffer or channel buffer.
-     * The value byte is returned as an int in the range 0 to 255.
-     * If no byte is available in the save buffer or channel buffer,
-     * IllegalBlockingModeException will be thrown.
-     *
-     * @return the next byte of data.
-     * @throws IllegalBlockingModeException if there are more bytes available.
-     */
-    @Override
-    public int read()
-    {
-      if(saveBufferReader.remaining() > 0)
-      {
-        // Try saved buffer first
-        return 0xFF & saveBufferReader.get();
-      }
-      if(byteBuffer.remaining() > 0)
-      {
-        // Must still be on the channel buffer
-        return 0xFF & byteBuffer.get();
-      }
-
-      throw new IllegalBlockingModeException();
-    }
-
-    /**
-     * Reads up to len bytes of data from the save buffer or channel buffer
-     * into an array of bytes. An attempt is made to read as many as len bytes,
-     * but a smaller number may be read. The number of bytes actually read is
-     * returned as an integer.
-     *
-     * If b is null, a NullPointerException is thrown.
-     *
-     * If the length of b is zero, then no bytes are read and 0 is returned;
-     * otherwise, there is an attempt to read at least one byte. If no byte is
-     * available in the save buffer or channel buffer,
-     * IllegalBlockingModeException will be thrown; otherwise, at least one
-     * byte is read and stored into b.
-     *
-     * The first byte read is stored into element b[0], the next one into
-     * b[o1], and so on. The number of bytes read is, at most, equal to the
-     * length of b. Let k be the number of bytes actually read; these bytes
-     * will be stored in elements b[0] through b[k-1], leaving elements b[k]
-     * through b[b.length-1] unaffected.
-     *
-     * @return the total number of bytes read into the buffer.
-     * @throws IllegalBlockingModeException if there are more bytes available.
-     */
-    @Override
-    public int read(byte[] b)
-    {
-      return read(b, 0, b.length);
-    }
-
-    /**
-     * Reads up to len bytes of data from the save buffer or channel buffer
-     * into an array of bytes. An attempt is made to read as many as len bytes,
-     * but a smaller number may be read. The number of bytes actually read is
-     * returned as an integer.
-     *
-     * If b is null, a NullPointerException is thrown.
-     *
-     * If off is negative, or len is negative, or off+len is greater than the
-     * length of the array b, then an IndexOutOfBoundsException is thrown.
-     *
-     * If len is zero, then no bytes are read and 0 is returned; otherwise,
-     * there is an attempt to read at least one byte. If no byte is available
-     * in the save buffer or channel buffer, IllegalBlockingModeException will
-     * be thrown; otherwise, at least one byte is read and stored into b.
-     *
-     * The first byte read is stored into element b[off], the next one into
-     * b[off+1], and so on. The number of bytes read is, at most, equal to len.
-     * Let k be the number of bytes actually read; these bytes will be stored
-     * in elements b[off] through b[off+k-1], leaving elements b[off+k]
-     * through b[off+len-1] unaffected.
-     *
-     * In every case, elements b[0] through b[off] and elements b[off+len]
-     * through b[b.length-1] are unaffected.
-     *
-     * @return the total number of bytes read into the buffer.
-     * @throws IllegalBlockingModeException if there are more bytes available.
-     */
-    @Override
-    public int read(byte[] b, int off, int len)
-    {
-      if ((off < 0) || (len < 0) || (off + len > b.length))
-      {
-        throw new IndexOutOfBoundsException();
-      }
-
-      if(len == 0)
-      {
-        return 0;
-      }
-
-      int bytesCopied=0;
-      int getLen;
-      if(saveBufferReader.remaining() > 0)
-      {
-        // Copy out of the last saved buffer first
-        getLen = Math.min(saveBufferReader.remaining(), len);
-        saveBufferReader.get(b, off, getLen);
-        bytesCopied += getLen;
-      }
-      if(bytesCopied < len && byteBuffer.remaining() > 0)
-      {
-        // Copy out of the channel buffer if we haven't got
-        // everything we needed.
-        getLen = Math.min(byteBuffer.remaining(), len - bytesCopied);
-        byteBuffer.get(b, off + bytesCopied, getLen);
-        bytesCopied += getLen;
-      }
-      if(bytesCopied < len)
-      {
-        throw new IllegalBlockingModeException();
-      }
-
-      return bytesCopied;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public long skip(long length)
-    {
-      int bytesSkipped=0;
-      int len;
-      if(saveBufferReader.remaining() > 0)
-      {
-        // Skip in the last saved buffer first
-        len = Math.min(saveBufferReader.remaining(), (int)length);
-        saveBufferReader.position(saveBufferReader.position() + len);
-        bytesSkipped += len;
-      }
-      if(bytesSkipped < length && byteBuffer.remaining() > 0)
-      {
-        //Skip in the channel buffer if we haven't skipped enough.
-        len = Math.min(byteBuffer.remaining(), (int)length - bytesSkipped);
-        byteBuffer.position(byteBuffer.position() + len);
-        bytesSkipped += len;
-      }
-      if(bytesSkipped < length)
-      {
-        throw new IllegalBlockingModeException();
-      }
-
-      return bytesSkipped;
-    }
-  }
-
-  /**
-   * Creates a new ASN.1 byte channel reader whose source is the
-   * provided readable byte channel, having a user defined buffer
-   * size, and user defined maximum BER element size.
-   *
-   * @param channel
-   *          The readable byte channel to use.
-   * @param bufferSize
-   *          The buffer size to use when reading from the channel.
-   * @param maxElementSize
-   *          The max ASN.1 element size this reader will read.
-   */
-  ASN1ByteChannelReader(ReadableByteChannel channel, int bufferSize,
-      int maxElementSize)
-  {
-    this.byteChannel = channel;
-    this.byteBuffer = ByteBuffer.allocate(bufferSize);
-    this.byteBuffer.flip();
-    this.saveBuffer = new ByteStringBuilder();
-    this.saveBufferReader = saveBuffer.asReader();
-
-    CombinedBufferInputStream bufferStream = new CombinedBufferInputStream();
-    this.reader = new ASN1InputStreamReader(bufferStream, maxElementSize);
-  }
-
-  /**
-   * Process any new data on the channel so they can be read as ASN.1
-   * elements. This method should only be called when there are no
-   * more complete elements in the reader. Calling this method when
-   * there are complete elements still in the reader will result in
-   * unnecessary memory allocations to store any unread data. This
-   * method will perform the following operations:
-   * <ul>
-   * <li>Clear the save buffer if everything was read.
-   * <li>Append any unread data from the NIO byte buffer to the save
-   * buffer.
-   * <li>Clear the NIO byte buffer and read from the channel.
-   * </ul>
-   *
-   * @return The number of bytes read from the channel or -1 if
-   *         channel is closed.
-   * @throws IOException
-   *           If an exception occurs while reading from the channel.
-   */
-  public int processChannelData() throws IOException
-  {
-    // Clear the save buffer if we have read all of it
-    if (saveBufferReader.remaining() == 0)
-    {
-      saveBuffer.clear();
-      saveBufferReader.rewind();
-    }
-
-    // Append any unused data in the channel buffer to the save buffer
-    if (byteBuffer.remaining() > 0)
-    {
-      saveBuffer.append(byteBuffer, byteBuffer.remaining());
-    }
-
-    byteBuffer.clear();
-    try
-    {
-      int read = byteChannel.read(byteBuffer);
-      return read;
-    }
-    finally
-    {
-      // Make sure that the buffer is flipped even if the read fails in order to
-      // ensure that subsequent calls which query the remaining data return
-      // valid results.
-      byteBuffer.flip();
-    }
-  }
-
-  /**
-   * Determines if a complete ASN.1 element is ready to be read from
-   * channel.
-   *
-   * @return <code>true</code> if another complete element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean elementAvailable() throws ASN1Exception
-  {
-    return reader.elementAvailable();
-  }
-
-  /**
-   * Determines if the channel contains at least one ASN.1 element to be read.
-   *
-   * @return <code>true</code> if another element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean hasNextElement() throws ASN1Exception {
-    return reader.hasNextElement();
-  }
-
-  /**
-   * Returns {@code true} if this ASN.1 reader contains unread data.
-   *
-   * @return {@code true} if this ASN.1 reader contains unread data.
-   */
-  public boolean hasRemainingData()
-  {
-    return (saveBufferReader.remaining() != 0) || (byteBuffer.remaining() != 0);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int peekLength() throws ASN1Exception {
-    return reader.peekLength();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte peekType() throws ASN1Exception {
-    return reader.peekType();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean readBoolean() throws ASN1Exception {
-    return reader.readBoolean();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndExplicitTag() throws ASN1Exception {
-    reader.readEndExplicitTag();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSequence() throws ASN1Exception {
-    reader.readEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSet() throws ASN1Exception {
-    reader.readEndSet();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int readEnumerated() throws ASN1Exception {
-    return reader.readEnumerated();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public long readInteger() throws ASN1Exception {
-    return reader.readInteger();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readNull() throws ASN1Exception {
-    reader.readNull();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteString readOctetString() throws ASN1Exception {
-    return reader.readOctetString();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readOctetString(ByteStringBuilder buffer) throws ASN1Exception {
-    reader.readOctetString(buffer);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString() throws ASN1Exception {
-    return reader.readOctetStringAsString();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString(String charSet) throws ASN1Exception {
-    return reader.readOctetStringAsString(charSet);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartExplicitTag() throws ASN1Exception {
-    reader.readStartExplicitTag();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSequence() throws ASN1Exception {
-    reader.readStartSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSet() throws ASN1Exception {
-    reader.readStartSet();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void close() throws IOException {
-    reader.close();
-    byteChannel.close();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void skipElement() throws ASN1Exception
-  {
-    reader.skipElement();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java
deleted file mode 100644
index d90f6ee..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-import static org.opends.messages.ProtocolMessages.*;
-import static org.opends.server.protocols.ldap.LDAPConstants.*;
-
-import java.util.LinkedList;
-import java.io.IOException;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.ldap.ByteSequenceReader;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-/**
- * An ASN.1 reader that reads from a {@link ByteSequenceReader}.
- */
-final class ASN1ByteSequenceReader implements ASN1Reader
-{
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-  private int state = ELEMENT_READ_STATE_NEED_TYPE;
-  private byte peekType = 0;
-  private int peekLength = -1;
-  private final int maxElementSize;
-
-  private ByteSequenceReader reader;
-  private final LinkedList<ByteSequenceReader> readerStack;
-
-  /**
-   * Creates a new ASN1 reader whose source is the provided byte
-   * sequence reader and having a user defined maximum BER element
-   * size.
-   *
-   * @param reader
-   *          The byte sequence reader to be read.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   */
-  ASN1ByteSequenceReader(ByteSequenceReader reader, int maxElementSize)
-  {
-    this.reader = reader;
-    this.readerStack = new LinkedList<ByteSequenceReader>();
-    this.maxElementSize = maxElementSize;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte peekType() throws ASN1Exception
-  {
-    if(state == ELEMENT_READ_STATE_NEED_TYPE)
-    {
-      // Read just the type.
-      if(reader.remaining() <= 0)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_TRUCATED_TYPE_BYTE.get();
-        throw new ASN1Exception(message);
-      }
-      int type = reader.get();
-
-      peekType = (byte)type;
-      state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
-    }
-
-    return peekType;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int peekLength() throws ASN1Exception
-  {
-    peekType();
-
-    if(state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
-    {
-      needFirstLengthByteState(true);
-    }
-
-    return peekLength;
-  }
-
-  /**
-   * Determines if a complete ASN.1 element is waiting to be read from the
-   * byte sequence.
-   *
-   * @return <code>true</code> if another complete element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean elementAvailable() throws ASN1Exception
-  {
-    if(state == ELEMENT_READ_STATE_NEED_TYPE &&
-        !needTypeState(false)) {
-      return false;
-    }
-    if(state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE &&
-        !needFirstLengthByteState(false)) {
-      return false;
-    }
-
-    return peekLength <= reader.remaining();
-  }
-
-  /**
-   * Determines if the byte sequence contains at least one ASN.1 element to
-   * be read.
-   *
-   * @return <code>true</code> if another element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean hasNextElement() throws ASN1Exception
-  {
-    return state != ELEMENT_READ_STATE_NEED_TYPE || needTypeState(false);
-  }
-
-  /**
-   * Internal helper method reading the ASN.1 type byte and transition to
-   * the next state if successful.
-   *
-   * @param throwEofException <code>true</code> to throw an exception when
-   *                          the end of the sequence is encountered.
-   * @return <code>true</code> if the type byte was successfully read
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  private boolean needTypeState(boolean throwEofException)
-      throws ASN1Exception
-  {
-    // Read just the type.
-    if(reader.remaining() <= 0)
-    {
-      if(throwEofException)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_TRUCATED_TYPE_BYTE.get();
-        throw new ASN1Exception(message);
-      }
-      return false;
-    }
-    int type = reader.get();
-
-    peekType = (byte)type;
-    state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
-    return true;
-  }
-
-  /**
-   * Internal helper method reading the first length bytes and transition to
-   * the next state if successful.
-   *
-   * @param throwEofException <code>true</code> to throw an exception when
-   *                          the end of the sequence is encountered.
-   * @return <code>true</code> if the length bytes was successfully read
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  private boolean needFirstLengthByteState(boolean throwEofException)
-      throws ASN1Exception
-  {
-    if(reader.remaining() <= 0)
-    {
-      if(throwEofException)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_TRUNCATED_LENGTH_BYTE.get();
-        throw new ASN1Exception(message);
-      }
-      return false;
-    }
-    int readByte = reader.get();
-    peekLength = (readByte & 0x7F);
-    if (peekLength != readByte)
-    {
-      int lengthBytesNeeded = peekLength;
-      if (lengthBytesNeeded > 4)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_INVALID_NUM_LENGTH_BYTES.get(lengthBytesNeeded);
-        throw new ASN1Exception(message);
-      }
-
-      peekLength = 0x00;
-      if(reader.remaining() < lengthBytesNeeded)
-      {
-        if(throwEofException)
-        {
-          LocalizableMessage message =
-              ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
-          throw new ASN1Exception(message);
-        }
-        return false;
-      }
-
-      while(lengthBytesNeeded > 0)
-      {
-        readByte = reader.get();
-        peekLength = (peekLength << 8) | (readByte & 0xFF);
-        lengthBytesNeeded--;
-      }
-    }
-
-    // Make sure that the element is not larger than the maximum allowed
-    // message size.
-    if ((maxElementSize > 0) && (peekLength > maxElementSize))
-    {
-      LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get(
-          peekLength, maxElementSize);
-      throw new ASN1Exception(m);
-    }
-    state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
-    return true;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean readBoolean() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if (peekLength != 1)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_BOOLEAN_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-    int readByte = reader.get();
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-    return readByte != 0x00;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int readEnumerated() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if ((peekLength < 1) || (peekLength > 4))
-    {
-      LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    // From an implementation point of view, an enumerated value is
-    // equivalent to an integer.
-    return (int) readInteger();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public long readInteger() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if ((peekLength < 1) || (peekLength > 8))
-    {
-      LocalizableMessage message =
-          ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_INTEGER_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-    if(peekLength > 4)
-    {
-      long longValue = 0;
-      for (int i=0; i < peekLength; i++)
-      {
-        int readByte = reader.get();
-        if (i == 0 && readByte < 0)
-        {
-          longValue = 0xFFFFFFFFFFFFFFFFL;
-        }
-        longValue = (longValue << 8) | (readByte & 0xFF);
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return longValue;
-    }
-    else
-    {
-      int intValue = 0;
-      for (int i=0; i < peekLength; i++)
-      {
-        int readByte = reader.get();
-        if (i == 0 && readByte < 0)
-        {
-          intValue = 0xFFFFFFFF;
-        }
-        intValue = (intValue << 8) | (readByte & 0xFF);
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return intValue;
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readNull() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    // Make sure that the decoded length is exactly zero byte.
-    if (peekLength != 0)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteString readOctetString() throws ASN1Exception {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-    return reader.getByteString(peekLength);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString() throws ASN1Exception
-  {
-    // We could cache the UTF-8 CharSet if performance proves to be an
-    // issue.
-    return readOctetStringAsString("UTF-8");
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString(String charSet) throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-    return reader.getString(peekLength);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readOctetString(ByteStringBuilder buffer) throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    // Copy the value.
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-    buffer.append(reader, peekLength);
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSequence() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_SEQUENCE_SET_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    ByteSequenceReader subByteString = reader.getByteSequence(peekLength)
-        .asReader();
-    readerStack.addFirst(reader);
-    reader = subByteString;
-
-    // Reset the state
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartExplicitTag() throws ASN1Exception
-  {
-    // From an implementation point of view, an explicit tag is equivalent to a
-    // sequence, as it is a constructed type.
-    readStartSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSet() throws ASN1Exception
-  {
-    // From an implementation point of view, a set is equivalent to a
-    // sequence.
-    readStartSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSequence() throws ASN1Exception
-  {
-    if(readerStack.isEmpty())
-    {
-      LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get();
-      throw new ASN1Exception(message);
-    }
-
-    if(reader.remaining() > 0 && logger.isTraceEnabled())
-    {
-      logger.trace("Ignoring %d unused trailing bytes in " +
-          "ASN.1 SEQUENCE", reader.remaining());
-    }
-
-    reader = readerStack.removeFirst();
-
-    // Reset the state
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndExplicitTag() throws ASN1Exception
-  {
-    // From an implementation point of view, an explicit tag is equivalent to a
-    // sequence, as it is also a constructed type.
-    readEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSet() throws ASN1Exception
-  {
-    // From an implementation point of view, a set is equivalent to a
-    // sequence.
-    readEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void skipElement() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(reader.remaining() < peekLength)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-    reader.skip(peekLength);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void close() throws IOException
-  {
-    readerStack.clear();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Constants.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Constants.java
deleted file mode 100644
index 7efe936..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Constants.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2012 Forgerock AS
- */
-package org.opends.server.protocols.asn1;
-
-
-
-/**
- * This class defines a number of constants that may be used when interacting
- * with ASN.1 elements.
- */
-@org.opends.server.types.PublicAPI(
-     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
-     mayInstantiate=false,
-     mayExtend=false,
-     mayInvoke=true)
-public final class ASN1Constants
-{
-  /**
-   * The BER type that is assigned to the universal Boolean element.
-   */
-  public static final byte UNIVERSAL_BOOLEAN_TYPE = 0x01;
-
-
-
-  /**
-   * The BER type that is assigned to the universal integer type.
-   */
-  public static final byte UNIVERSAL_INTEGER_TYPE = 0x02;
-
-
-
-  /**
-   * The BER type that is assigned to the universal bit string type.
-   */
-  public static final byte UNIVERSAL_BIT_STRING_TYPE = 0x03;
-
-
-
-  /**
-   * The BER type that is assigned to the universal octet string type.
-   */
-  public static final byte UNIVERSAL_OCTET_STRING_TYPE = 0x04;
-
-
-
-  /**
-   * The BER type that is assigned to the universal null type.
-   */
-  public static final byte UNIVERSAL_NULL_TYPE = 0x05;
-
-
-
-  /**
-   * The BER type that is assigned to the universal enumerated type.
-   */
-  public static final byte UNIVERSAL_ENUMERATED_TYPE = 0x0A;
-
-
-
-  /**
-   * The BER type that is assigned to the universal sequence type.
-   */
-  public static final byte UNIVERSAL_SEQUENCE_TYPE = 0x30;
-
-
-
-  /**
-   * The BER type that is assigned to the universal set type.
-   */
-  public static final byte UNIVERSAL_SET_TYPE = 0x31;
-
-
-
-  /**
-   * The byte array that will be used for ASN.1 elements with no value.
-   */
-  public static final byte[] NO_VALUE = new byte[0];
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to zero out all bits except
-   * those used in the class.
-   */
-  public static final byte TYPE_MASK_ALL_BUT_CLASS = (byte) 0xC0;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is in the universal class.
-   */
-  public static final byte TYPE_MASK_UNIVERSAL = 0x00;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is in the application-specific class.
-   */
-  public static final byte TYPE_MASK_APPLICATION = 0x40;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is in the context-specific class.
-   */
-  public static final byte TYPE_MASK_CONTEXT = (byte) 0x80;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is in the private class.
-   */
-  public static final byte TYPE_MASK_PRIVATE = (byte) 0xC0;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to zero out all bits except
-   * the primitive/constructed bit.
-   */
-  public static final byte TYPE_MASK_ALL_BUT_PC = (byte) 0x20;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is a primitive.
-   */
-  public static final byte TYPE_MASK_PRIMITIVE = 0x00;
-
-
-
-  /**
-   * The bitmask that can be ANDed with the BER type to determine if the element
-   * is constructed.
-   */
-  public static final byte TYPE_MASK_CONSTRUCTED = 0x20;
-
-
-
-  /**
-   * The byte array containing the pre-encoded ASN.1 encoding for a boolean
-   * value of "false".
-   */
-  public static final byte[] BOOLEAN_VALUE_FALSE = { 0x00 };
-
-
-
-  /**
-   * The byte array containing the pre-encoded ASN.1 encoding for a boolean
-   * value of "false".
-   */
-  public static final byte[] BOOLEAN_VALUE_TRUE = { (byte) 0xFF };
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Exception.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Exception.java
deleted file mode 100644
index 71a2cf2..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Exception.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import org.opends.server.types.IdentifiedException;
-
-
-
-/**
- * This class defines an exception that may be thrown if a problem occurs while
- * interacting with an ASN.1 element.
- */
-@org.opends.server.types.PublicAPI(
-     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
-     mayInstantiate=true,
-     mayExtend=false,
-     mayInvoke=true)
-public final class ASN1Exception
-       extends IdentifiedException
-{
-  /**
-   * The serial version identifier required to satisfy the compiler because this
-   * class extends <CODE>java.lang.Exception</CODE>, which implements the
-   * <CODE>java.io.Serializable</CODE> interface.  This value was generated
-   * using the <CODE>serialver</CODE> command-line utility included with the
-   * Java SDK.
-   */
-  private static final long serialVersionUID = -2640197609704069110L;
-
-
-
-  /**
-   * Creates a new ASN.1 exception with the provided message.
-   *
-   * @param  message    The message that explains the problem that occurred.
-   */
-  public ASN1Exception(LocalizableMessage message)
-  {
-    super(message);
-  }
-
-
-
-  /**
-   * Creates a new ASN.1 exception with the provided message and root
-   * cause.
-   *
-   * @param  message    The message that explains the problem that occurred.
-   * @param  cause      The exception that was caught to trigger this exception.
-   */
-  public ASN1Exception(LocalizableMessage message, Throwable cause)
-  {
-    super(message, cause);
-  }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java
deleted file mode 100644
index 4d1da05..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java
+++ /dev/null
@@ -1,836 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-import static org.opends.messages.ProtocolMessages.*;
-import static org.opends.server.protocols.ldap.LDAPConstants.*;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedList;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.opends.server.util.SizeLimitInputStream;
-
-/**
- * An ASN1Reader that reads from an input stream.
- */
-final class ASN1InputStreamReader implements ASN1Reader
-{
-
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-  private int state = ELEMENT_READ_STATE_NEED_TYPE;
-  private byte peekType = 0;
-  private int peekLength = -1;
-  private int lengthBytesNeeded = 0;
-  private final int maxElementSize;
-
-  private InputStream in;
-  private final LinkedList<InputStream> streamStack;
-  private byte[] buffer;
-
-  /**
-   * Creates a new ASN1 reader whose source is the provided input
-   * stream and having a user defined maximum BER element size.
-   *
-   * @param stream
-   *          The input stream to be read.
-   * @param maxElementSize
-   *          The maximum BER element size, or <code>0</code> to
-   *          indicate that there is no limit.
-   */
-  ASN1InputStreamReader(InputStream stream, int maxElementSize)
-  {
-    this.in = stream;
-    this.streamStack = new LinkedList<InputStream>();
-    this.buffer = new byte[512];
-    this.maxElementSize = maxElementSize;
-  }
-
-  /**
-   * Determines if a complete ASN.1 element is ready to be read from the
-   * input stream without blocking.
-   *
-   * @return <code>true</code> if another complete element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean elementAvailable() throws ASN1Exception
-  {
-    try
-    {
-      if(state == ELEMENT_READ_STATE_NEED_TYPE &&
-          !needTypeState(false, false)) {
-        return false;
-      }
-      if(state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE &&
-          !needFirstLengthByteState(false, false)) {
-        return false;
-      }
-      if(state == ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES &&
-          !needAdditionalLengthBytesState(false, false)) {
-        return false;
-      }
-
-      return peekLength <= in.available();
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * Determines if the input stream contains at least one ASN.1 element to
-   * be read. This method will block until enough data is available on the
-   * stream to determine if an element is available.
-   *
-   * @return <code>true</code> if another element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean hasNextElement() throws ASN1Exception
-  {
-    try
-    {
-      if(!streamStack.isEmpty())
-      {
-        // We are reading a sub sequence. Return true as long as we haven't
-        // exausted the size limit for the sub sequence sub input stream.
-        SizeLimitInputStream subSq = (SizeLimitInputStream)in;
-        return (subSq.getSizeLimit() - subSq.getBytesRead() > 0);
-      }
-
-      return state != ELEMENT_READ_STATE_NEED_TYPE ||
-          needTypeState(true, false);
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * Internal helper method reading the ASN.1 type byte and transition to
-   * the next state if successful.
-   *
-   * @param isBlocking <code>true</code> to block if the type byte is not
-   *                   available or <code>false</code> to check for
-   *                   availability first.
-   * @param throwEofException <code>true</code> to throw an exception when
-   *                          an EOF is encountered or <code>false</code> to
-   *                          return false.
-   * @return <code>true</code> if the type byte was successfully read
-   * @throws IOException If an error occurs while reading from the stream.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  private boolean needTypeState(boolean isBlocking, boolean throwEofException)
-      throws IOException, ASN1Exception
-  {
-    // Read just the type.
-    if(!isBlocking && in.available() <= 0)
-    {
-      return false;
-    }
-
-    int type = in.read();
-    if(type == -1)
-    {
-      if(throwEofException)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_TRUCATED_TYPE_BYTE.get();
-        throw new ASN1Exception(message);
-      }
-      return false;
-    }
-
-    peekType = (byte)type;
-    state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
-    return true;
-  }
-
-  /**
-   * Internal helper method reading the first length bytes and transition to
-   * the next state if successful.
-   *
-   * @param isBlocking <code>true</code> to block if the type byte is not
-   *                   available or <code>false</code> to check for
-   *                   availability first.
-   * @param throwEofException <code>true</code> to throw an exception when
-   *                          an EOF is encountered or <code>false</code> to
-   *                          return false.
-   * @return <code>true</code> if the length bytes was successfully read
-   * @throws IOException If an error occurs while reading from the stream.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  private boolean needFirstLengthByteState(boolean isBlocking,
-                                           boolean throwEofException)
-      throws IOException, ASN1Exception
-  {
-    if(!isBlocking && in.available() <= 0)
-    {
-      return false;
-    }
-
-    int readByte = in.read();
-    if(readByte == -1)
-    {
-      if(throwEofException)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_TRUNCATED_LENGTH_BYTE.get();
-        throw new ASN1Exception(message);
-      }
-      return false;
-    }
-    peekLength = (readByte & 0x7F);
-    if (peekLength != readByte)
-    {
-      lengthBytesNeeded = peekLength;
-      if (lengthBytesNeeded > 4)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_INVALID_NUM_LENGTH_BYTES.get(lengthBytesNeeded);
-        throw new ASN1Exception(message);
-      }
-      peekLength = 0x00;
-
-      if(!isBlocking && in.available() < lengthBytesNeeded)
-      {
-        state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
-        return false;
-      }
-
-      while(lengthBytesNeeded > 0)
-      {
-        readByte = in.read();
-        if(readByte == -1)
-        {
-          state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
-          if(throwEofException)
-          {
-            LocalizableMessage message =
-                ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
-            throw new ASN1Exception(message);
-          }
-          return false;
-        }
-        peekLength = (peekLength << 8) | (readByte & 0xFF);
-        lengthBytesNeeded--;
-      }
-    }
-
-    // Make sure that the element is not larger than the maximum allowed
-    // message size.
-    if ((maxElementSize > 0) && (peekLength > maxElementSize))
-    {
-      LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get(
-          peekLength, maxElementSize);
-      throw new ASN1Exception(m);
-    }
-    state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
-    return true;
-  }
-
-  /**
-   * Internal helper method reading the additional ASN.1 length bytes and
-   * transition to the next state if successful.
-   *
-   * @param isBlocking <code>true</code> to block if the type byte is not
-   *                   available or <code>false</code> to check for
-   *                   availability first.
-   * @param throwEofException <code>true</code> to throw an exception when
-   *                          an EOF is encountered or <code>false</code> to
-   *                          return false.
-   * @return <code>true</code> if the length bytes was successfully read.
-   * @throws IOException If an error occurs while reading from the stream.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  private boolean needAdditionalLengthBytesState(boolean isBlocking,
-                                                 boolean throwEofException)
-      throws IOException, ASN1Exception
-  {
-    if(!isBlocking && in.available() < lengthBytesNeeded)
-    {
-      return false;
-    }
-
-    int readByte;
-    while(lengthBytesNeeded > 0)
-    {
-      readByte = in.read();
-      if(readByte == -1)
-      {
-        state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
-        if(throwEofException)
-        {
-          LocalizableMessage message =
-              ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
-          throw new ASN1Exception(message);
-        }
-        return false;
-      }
-      peekLength = (peekLength << 8) | (readByte & 0xFF);
-      lengthBytesNeeded--;
-    }
-
-    // Make sure that the element is not larger than the maximum allowed
-    // message size.
-    if ((maxElementSize > 0) && (peekLength > maxElementSize))
-    {
-      LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get(
-          peekLength, maxElementSize);
-      throw new ASN1Exception(m);
-    }
-    state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
-    return true;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte peekType() throws ASN1Exception
-  {
-    try
-    {
-      if(state == ELEMENT_READ_STATE_NEED_TYPE)
-      {
-        needTypeState(true, true);
-      }
-
-      return peekType;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int peekLength() throws ASN1Exception
-  {
-    peekType();
-
-    try
-    {
-      switch(state)
-      {
-        case ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE:
-          needFirstLengthByteState(true, true);
-          break;
-
-        case ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES:
-          needAdditionalLengthBytesState(true, true);
-      }
-
-      return peekLength;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean readBoolean() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if (peekLength != 1)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    try
-    {
-      int readByte = in.read();
-      if(readByte == -1)
-      {
-        LocalizableMessage message = ERR_ASN1_BOOLEAN_TRUNCATED_VALUE.get(peekLength);
-        throw new ASN1Exception(message);
-      }
-
-      if(logger.isTraceEnabled())
-      {
-        logger.trace("READ ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)",
-            peekType, peekLength, readByte != 0x00);
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return readByte != 0x00;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public int readEnumerated() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if ((peekLength < 1) || (peekLength > 4))
-    {
-      LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    // From an implementation point of view, an enumerated value is
-    // equivalent to an integer.
-    return (int) readInteger();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public long readInteger() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if ((peekLength < 1) || (peekLength > 8))
-    {
-      LocalizableMessage message =
-          ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    try
-    {
-      if(peekLength > 4)
-      {
-        long longValue = 0;
-        for (int i=0; i < peekLength; i++)
-        {
-          int readByte = in.read();
-          if(readByte == -1)
-          {
-            LocalizableMessage message =
-                ERR_ASN1_INTEGER_TRUNCATED_VALUE.get(peekLength);
-            throw new ASN1Exception(message);
-          }
-          if(i == 0 && ((byte)readByte) < 0)
-          {
-            longValue = 0xFFFFFFFFFFFFFFFFL;
-          }
-          longValue = (longValue << 8) | (readByte & 0xFF);
-        }
-
-        state = ELEMENT_READ_STATE_NEED_TYPE;
-        return longValue;
-      }
-      else
-      {
-        int intValue = 0;
-        for (int i=0; i < peekLength; i++)
-        {
-          int readByte = in.read();
-          if(readByte == -1)
-          {
-            LocalizableMessage message =
-                ERR_ASN1_INTEGER_TRUNCATED_VALUE.get(peekLength);
-            throw new ASN1Exception(message);
-          }
-          if (i == 0 && ((byte)readByte) < 0)
-          {
-            intValue = 0xFFFFFFFF;
-          }
-          intValue = (intValue << 8) | (readByte & 0xFF);
-        }
-
-        if(logger.isTraceEnabled())
-        {
-          logger.trace(
-              String.format("READ ASN.1 INTEGER(type=0x%x, length=%d, " +
-                  "value=%d)", peekType, peekLength, intValue));
-        }
-
-        state = ELEMENT_READ_STATE_NEED_TYPE;
-        return intValue;
-      }
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readNull() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    // Make sure that the decoded length is exactly zero byte.
-    if (peekLength != 0)
-    {
-      LocalizableMessage message =
-          ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength);
-      throw new ASN1Exception(message);
-    }
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("READ ASN.1 NULL(type=0x%x, length=%d)",
-              peekType, peekLength));
-    }
-
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteString readOctetString() throws ASN1Exception {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(peekLength == 0)
-    {
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return ByteString.empty();
-    }
-
-    try
-    {
-      // Copy the value and construct the element to return.
-      byte[] value = new byte[peekLength];
-      int bytesNeeded = peekLength;
-      int bytesRead;
-      while(bytesNeeded > 0)
-      {
-        bytesRead = in.read(value, peekLength - bytesNeeded, bytesNeeded);
-        if(bytesRead < 0)
-        {
-          LocalizableMessage message =
-            ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-          throw new ASN1Exception(message);
-        }
-
-        bytesNeeded -= bytesRead;
-      }
-
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("READ ASN.1 OCTETSTRING(type=0x%x, length=%d)",
-                peekType, peekLength));
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return ByteString.wrap(value);
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString() throws ASN1Exception
-  {
-    // We could cache the UTF-8 CharSet if performance proves to be an
-    // issue.
-    return readOctetStringAsString("UTF-8");
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String readOctetStringAsString(String charSet) throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(peekLength == 0)
-    {
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return "";
-    }
-
-    // Resize the temp buffer if needed
-    if(peekLength > buffer.length)
-    {
-      buffer = new byte[peekLength];
-    }
-
-    try
-    {
-      int bytesNeeded = peekLength;
-      int bytesRead;
-      while(bytesNeeded > 0)
-      {
-        bytesRead = in.read(buffer, peekLength - bytesNeeded, bytesNeeded);
-        if(bytesRead < 0)
-        {
-          LocalizableMessage message =
-            ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-          throw new ASN1Exception(message);
-        }
-        bytesNeeded -= bytesRead;
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-
-    String str;
-    try
-    {
-      str = new String(buffer, 0, peekLength, charSet);
-    }
-    catch (Exception e)
-    {
-      logger.traceException(e);
-
-      str = new String(buffer, 0, peekLength);
-    }
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("READ ASN.1 OCTETSTRING(type=0x%x, length=%d, " +
-              "value=%s)", peekType, peekLength, str));
-    }
-
-    return str;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readOctetString(ByteStringBuilder buffer) throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    if(peekLength == 0)
-    {
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-      return;
-    }
-
-    try
-    {
-      // Copy the value and construct the element to return.
-      int bytesNeeded = peekLength;
-      int bytesRead;
-      while(bytesNeeded > 0)
-      {
-        bytesRead = buffer.append(in, bytesNeeded);
-        if(bytesRead < 0)
-        {
-          LocalizableMessage message =
-            ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE.get(peekLength);
-          throw new ASN1Exception(message);
-        }
-        bytesNeeded -= bytesRead;
-      }
-
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("READ ASN.1 OCTETSTRING(type=0x%x, length=%d)",
-                peekType, peekLength));
-      }
-
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSequence() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    SizeLimitInputStream subStream =
-        new SizeLimitInputStream(in, peekLength);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("READ ASN.1 SEQUENCE(type=0x%x, length=%d)",
-              peekType, peekLength));
-    }
-
-    streamStack.addFirst(in);
-    in = subStream;
-
-    // Reset the state
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartExplicitTag() throws ASN1Exception
-  {
-    // From an implementation point of view, an explicit tag is equivalent to a
-    // sequence, as it is also a constructed type.
-    readStartSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readStartSet() throws ASN1Exception
-  {
-    // From an implementation point of view, a set is equivalent to a
-    // sequence.
-    readStartSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSequence() throws ASN1Exception
-  {
-    if(streamStack.isEmpty())
-    {
-      LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get();
-      throw new ASN1Exception(message);
-    }
-
-    // Ignore all unused trailing components.
-    SizeLimitInputStream subSq = (SizeLimitInputStream)in;
-    if(subSq.getSizeLimit() - subSq.getBytesRead() > 0)
-    {
-      if(logger.isTraceEnabled())
-      {
-        logger.trace("Ignoring %d unused trailing bytes in " +
-            "ASN.1 SEQUENCE", subSq.getSizeLimit() - subSq.getBytesRead());
-      }
-
-      try
-      {
-        subSq.skip(subSq.getSizeLimit() - subSq.getBytesRead());
-      }
-      catch(IOException ioe)
-      {
-        throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-      }
-    }
-
-    in = streamStack.removeFirst();
-
-    // Reset the state
-    state = ELEMENT_READ_STATE_NEED_TYPE;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndExplicitTag() throws ASN1Exception
-  {
-    // From an implementation point of view, an explicit tag is equivalent to a
-    // sequence, as it is also a constructed type.
-    readEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void readEndSet() throws ASN1Exception
-  {
-    // From an implementation point of view, a set is equivalent to a
-    // sequence.
-    readEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void skipElement() throws ASN1Exception
-  {
-    // Read the header if haven't done so already
-    peekLength();
-
-    try
-    {
-      long bytesSkipped = in.skip(peekLength);
-      if(bytesSkipped != peekLength)
-      {
-        LocalizableMessage message =
-            ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength);
-        throw new ASN1Exception(message);
-      }
-      state = ELEMENT_READ_STATE_NEED_TYPE;
-    }
-    catch(IOException ioe)
-    {
-      throw new ASN1Exception(ERR_ASN1_READ_ERROR.get(ioe), ioe);
-    }
-  }
-
-  /**
-   * Closes this ASN.1 reader and the underlying stream.
-   *
-   * @throws IOException if an I/O error occurs
-   */
-  public void close() throws IOException
-  {
-    // Calling close of SizeLimitInputStream should close the parent stream.
-    in.close();
-    streamStack.clear();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java
deleted file mode 100644
index a4c5c29..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.protocols.asn1;
-
-
-import static org.opends.server.protocols.asn1.ASN1Constants.*;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.opends.server.util.StaticUtils;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-/**
- * An ASN1Writer implementation that outputs to an outputstream.
- */
-final class ASN1OutputStreamWriter implements ASN1Writer
-{
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-  private final OutputStream rootStream;
-  private final ArrayList<ByteSequenceOutputStream> streamStack;
-  private final int maxInternalBufferSize;
-  private OutputStream out;
-  private int stackDepth;
-
-
-
-  /**
-   * Creates a new ASN.1 output stream reader.
-   *
-   * @param stream
-   *          The underlying output stream.
-   * @param maxInternalBufferSize
-   *          The threshold capacity beyond which internal cached buffers used
-   *          for encoding and decoding protocol messages will be trimmed after
-   *          use.
-   */
-  ASN1OutputStreamWriter(OutputStream stream, int maxInternalBufferSize)
-  {
-    this.out = stream;
-    this.rootStream = stream;
-    this.streamStack = new ArrayList<ByteSequenceOutputStream>();
-    this.stackDepth = -1;
-    this.maxInternalBufferSize = maxInternalBufferSize;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeInteger(int intValue) throws IOException
-  {
-    return writeInteger(UNIVERSAL_INTEGER_TYPE, intValue);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeInteger(byte type, int intValue) throws IOException
-  {
-    out.write(type);
-    if ((intValue < 0 && ((intValue & 0xFFFFFF80) == 0xFFFFFF80)) ||
-        (intValue & 0x0000007F) == intValue)
-    {
-      writeLength(1);
-      out.write((byte) (intValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 1, intValue));
-      }
-    }
-    else if ((intValue < 0 && ((intValue & 0xFFFF8000) == 0xFFFF8000)) ||
-        (intValue & 0x00007FFF) == intValue)
-    {
-      writeLength(2);
-      out.write((byte) ((intValue >> 8) & 0xFF));
-      out.write((byte) (intValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 2, intValue));
-      }
-    }
-    else if ((intValue < 0 && ((intValue & 0xFF800000) == 0xFF800000)) ||
-        (intValue & 0x007FFFFF) == intValue)
-    {
-      writeLength(3);
-      out.write((byte) ((intValue >> 16) & 0xFF));
-      out.write((byte) ((intValue >>  8) & 0xFF));
-      out.write((byte) (intValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 3, intValue));
-      }
-    }
-    else
-    {
-      writeLength(4);
-      out.write((byte) ((intValue >> 24) & 0xFF));
-      out.write((byte) ((intValue >> 16) & 0xFF));
-      out.write((byte) ((intValue >>  8) & 0xFF));
-      out.write((byte) (intValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 4, intValue));
-      }
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeInteger(long longValue) throws IOException
-  {
-    return writeInteger(UNIVERSAL_INTEGER_TYPE, longValue);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeInteger(byte type, long longValue) throws IOException
-  {
-    out.write(type);
-    if ((longValue < 0 &&
-         ((longValue & 0xFFFFFFFFFFFFFF80L) == 0xFFFFFFFFFFFFFF80L)) ||
-        (longValue & 0x000000000000007FL) == longValue)
-    {
-      writeLength(1);
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 1, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFFFFFFFFFFFF8000L) == 0xFFFFFFFFFFFF8000L)) ||
-             (longValue & 0x0000000000007FFFL) == longValue)
-    {
-      writeLength(2);
-      out.write((byte) ((longValue >> 8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 2, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFFFFFFFFFF800000L) == 0xFFFFFFFFFF800000L)) ||
-             (longValue & 0x00000000007FFFFFL) == longValue)
-    {
-      writeLength(3);
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 3, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFFFFFFFF80000000L) == 0xFFFFFFFF80000000L)) ||
-             (longValue & 0x000000007FFFFFFFL) == longValue)
-    {
-      writeLength(4);
-      out.write((byte) ((longValue >> 24) & 0xFF));
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 4, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFFFFFF8000000000L) == 0xFFFFFF8000000000L)) ||
-             (longValue & 0x0000007FFFFFFFFFL) == longValue)
-    {
-      writeLength(5);
-      out.write((byte) ((longValue >> 32) & 0xFF));
-      out.write((byte) ((longValue >> 24) & 0xFF));
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 5, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFFFF800000000000L) == 0xFFFF800000000000L)) ||
-             (longValue & 0x00007FFFFFFFFFFFL) == longValue)
-    {
-      writeLength(6);
-      out.write((byte) ((longValue >> 40) & 0xFF));
-      out.write((byte) ((longValue >> 32) & 0xFF));
-      out.write((byte) ((longValue >> 24) & 0xFF));
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 6, longValue));
-      }
-    }
-    else if ((longValue < 0 &&
-              ((longValue & 0xFF80000000000000L) == 0xFF80000000000000L)) ||
-             (longValue & 0x007FFFFFFFFFFFFFL) == longValue)
-    {
-      writeLength(7);
-      out.write((byte) ((longValue >> 48) & 0xFF));
-      out.write((byte) ((longValue >> 40) & 0xFF));
-      out.write((byte) ((longValue >> 32) & 0xFF));
-      out.write((byte) ((longValue >> 24) & 0xFF));
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 7, longValue));
-      }
-    }
-    else
-    {
-      writeLength(8);
-      out.write((byte) ((longValue >> 56) & 0xFF));
-      out.write((byte) ((longValue >> 48) & 0xFF));
-      out.write((byte) ((longValue >> 40) & 0xFF));
-      out.write((byte) ((longValue >> 32) & 0xFF));
-      out.write((byte) ((longValue >> 24) & 0xFF));
-      out.write((byte) ((longValue >> 16) & 0xFF));
-      out.write((byte) ((longValue >>  8) & 0xFF));
-      out.write((byte) (longValue & 0xFF));
-      if(logger.isTraceEnabled())
-      {
-        logger.trace(
-            String.format("WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)",
-                type, 8, longValue));
-      }
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeEnumerated(int intValue) throws IOException {
-    return writeInteger(UNIVERSAL_ENUMERATED_TYPE, intValue);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeBoolean(boolean booleanValue) throws IOException
-  {
-    return writeBoolean(UNIVERSAL_BOOLEAN_TYPE, booleanValue);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeBoolean(byte type, boolean booleanValue)
-      throws IOException
-  {
-    out.write(type);
-    writeLength(1);
-    out.write(booleanValue ? BOOLEAN_VALUE_TRUE : BOOLEAN_VALUE_FALSE);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace("WRITE ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)",
-          type, 1, booleanValue);
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeNull(byte type) throws IOException
-  {
-    out.write(type);
-    writeLength(0);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 NULL(type=0x%x, length=%d)",
-              type, 0));
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeNull() throws IOException
-  {
-    return writeNull(UNIVERSAL_NULL_TYPE);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(byte type, byte[] value,
-                                     int offset, int length)
-      throws IOException
-  {
-    out.write(type);
-    writeLength(length);
-    out.write(value, offset, length);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d)",
-              type, length));
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(byte[] value, int offset, int length)
-      throws IOException
-  {
-    return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value, offset, length);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(byte type, String value) throws IOException
-  {
-    out.write(type);
-
-    if(value == null)
-    {
-      writeLength(0);
-      return this;
-    }
-
-    byte[] bytes = StaticUtils.getBytes(value);
-    writeLength(bytes.length);
-    out.write(bytes);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d, " +
-              "value=%s)", type, bytes.length, value));
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(String value) throws IOException
-  {
-    return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(byte type, ByteSequence value)
-      throws IOException {
-    out.write(type);
-    writeLength(value.length());
-    value.copyTo(out);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d)",
-              type, value.length()));
-    }
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeOctetString(ByteSequence value) throws IOException {
-    return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeStartSet() throws IOException
-  {
-    return writeStartSet(UNIVERSAL_SET_TYPE);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeStartSet(byte type) throws IOException
-  {
-    // From an implementation point of view, a set is equivalent to a
-    // sequence.
-    return writeStartSequence(type);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeStartSequence() throws IOException
-  {
-    return writeStartSequence(UNIVERSAL_SEQUENCE_TYPE);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeStartSequence(byte type) throws IOException
-  {
-    // Write the type in current stream switch to next sub-stream
-    out.write(type);
-
-    // Increment the stack depth and get the sub-stream from the stack
-    ++stackDepth;
-
-    // Make sure we have a cached sub-stream at this depth
-    if(stackDepth >= streamStack.size())
-    {
-      ByteSequenceOutputStream subStream = new ByteSequenceOutputStream(
-          new ByteStringBuilder(), maxInternalBufferSize);
-      streamStack.add(subStream);
-      out = subStream;
-    }
-    else
-    {
-      ByteSequenceOutputStream childStream = streamStack.get(stackDepth);
-      childStream.reset(); // Precaution.
-      out = childStream;
-    }
-/*
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 START SEQUENCE(type=0x%x)",
-              type));
-    }
-    */
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeEndSet() throws IOException
-  {
-    return writeEndSequence();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ASN1Writer writeEndSequence() throws IOException
-  {
-    if(stackDepth < 0)
-    {
-      throw new IOException();
-    }
-
-    ByteSequenceOutputStream childStream = streamStack.get(stackDepth);
-
-    // Decrement the stack depth and get the parent stream
-    --stackDepth;
-
-    OutputStream parentStream = stackDepth < 0 ? rootStream :
-        streamStack.get(stackDepth);
-
-    // Switch to parent stream and reset the sub-stream
-    out = parentStream;
-
-    // Write the length and contents of the sub-stream
-    writeLength(childStream.length());
-    childStream.writeTo(parentStream);
-
-    if(logger.isTraceEnabled())
-    {
-      logger.trace(
-          String.format("WRITE ASN.1 END SEQUENCE(length=%d)",
-              childStream.length()));
-    }
-
-    childStream.reset();
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void close() throws IOException
-  {
-    try
-    {
-      flush();
-    }
-    finally
-    {
-      try
-      {
-        rootStream.close();
-      }
-      finally
-      {
-        // Reset for next usage in case where the root stream is reusable (e.g.
-        // ByteStringBuilder).
-        stackDepth = -1;
-        out = rootStream;
-      }
-    }
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public void flush() throws IOException
-  {
-    while (stackDepth >= 0)
-    {
-      writeEndSequence();
-    }
-    rootStream.flush();
-  }
-
-  /**
-   * Writes the provided value for use as the length of an ASN.1 element.
-   *
-   * @param  length  The length to encode for use in an ASN.1 element.
-   * @throws IOException if an error occurs while writing.
-   */
-  private void writeLength(int length) throws IOException
-  {
-    if (length < 128)
-    {
-      out.write((byte) length);
-    }
-    else if ((length & 0x000000FF) == length)
-    {
-      out.write((byte) 0x81);
-      out.write((byte) (length & 0xFF));
-    }
-    else if ((length & 0x0000FFFF) == length)
-    {
-      out.write((byte) 0x82);
-      out.write((byte) ((length >> 8) & 0xFF));
-      out.write((byte) (length & 0xFF));
-    }
-    else if ((length & 0x00FFFFFF) == length)
-    {
-      out.write((byte) 0x83);
-      out.write((byte) ((length >> 16) & 0xFF));
-      out.write((byte) ((length >>  8) & 0xFF));
-      out.write((byte) (length & 0xFF));
-    }
-    else
-    {
-      out.write((byte) 0x84);
-      out.write((byte) ((length >> 24) & 0xFF));
-      out.write((byte) ((length >> 16) & 0xFF));
-      out.write((byte) ((length >>  8) & 0xFF));
-      out.write((byte) (length & 0xFF));
-    }
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Reader.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Reader.java
deleted file mode 100644
index 0568e07..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Reader.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-
-
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-
-
-/**
- * An interface for decoding ASN.1 elements from a data source.
- * <p>
- * Methods for creating {@link ASN1Reader}s are provided in the
- * {@link ASN1} class.
- */
-public interface ASN1Reader extends Closeable
-{
-
-  /**
-   * Closes this ASN.1 reader.
-   *
-   * @throws IOException if an I/O error occurs
-   */
-  void close() throws IOException;
-
-
-
-  /**
-   * Determines if a complete ASN.1 element is waiting to be read.
-   *
-   * @return <code>true</code> if another complete element is available or
-   *         <code>false</code> otherwise.
-   * @throws ASN1Exception If an error occurs while trying to decode
-   *                       an ASN1 element.
-   */
-  public boolean elementAvailable() throws ASN1Exception;
-
-
-
-  /**
-   * Determines if at least one ASN.1 element is waiting to be read.
-   *
-   * @return <code>true</code> if another element is available or
-   *         <code>false</code> if the EOF is reached.
-   * @throws ASN1Exception
-   *           If an error occurs while trying to decode an ASN1
-   *           element.
-   */
-  boolean hasNextElement() throws ASN1Exception;
-
-
-
-  /**
-   * Gets the data length of the next element without actually reading
-   * the element and advancing the cursor.
-   *
-   * @return The data length of the next element or -1 if the EOF is
-   *         encountered.
-   * @throws ASN1Exception
-   *           If an error occurs while determining the length.
-   */
-  int peekLength() throws ASN1Exception;
-
-
-
-  /**
-   * Gets the BER type of the next element without actually reading
-   * the element and advancing the cursor.
-   *
-   * @return The BER type of the next element or -1 if the EOF is
-   *         encountered.
-   * @throws ASN1Exception
-   *           If an error occurs while determining the BER type.
-   */
-  byte peekType() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as a boolean and advance the cursor.
-   *
-   * @return The decoded boolean value.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as a boolean.
-   */
-  boolean readBoolean() throws ASN1Exception;
-
-
-
-  /**
-   * Finishes reading an explicit tag. Any elements not read in the
-   * explicit tag will be discarded.
-   *
-   * @throws ASN1Exception
-   *           If an error occurs while advancing to the end of the
-   *           explicit tag.
-   */
-  void readEndExplicitTag() throws ASN1Exception;
-
-
-
-  /**
-   * Finishes reading a sequence. Any elements not read in the
-   * sequence will be discarded.
-   *
-   * @throws ASN1Exception
-   *           If an error occurs while advancing to the end of the
-   *           sequence.
-   */
-  void readEndSequence() throws ASN1Exception;
-
-
-
-  /**
-   * Finishes reading a set. Any elements not read in the set will be
-   * discarded.
-   *
-   * @throws ASN1Exception
-   *           If an error occurs while advancing to the end of the set.
-   */
-  void readEndSet() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an enumerated value and advances
-   * the cursor.
-   *
-   * @return The decoded enumerated value.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an enumerated value.
-   */
-  int readEnumerated() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an integer and advances the
-   * cursor.
-   *
-   * @return The decoded integer value.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as a integer.
-   */
-  long readInteger() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as a null element and advances the
-   * cursor.
-   *
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an null element.
-   */
-  void readNull() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an octet string and advances the
-   * cursor.
-   *
-   * @return The decoded octet string value represented using a
-   *         {@link ByteString}.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an octet string.
-   */
-  ByteString readOctetString() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an octet string and advances the
-   * cursor. The data will be appended to the provided
-   * {@link ByteStringBuilder}.
-   *
-   * @param buffer
-   *          The {@link ByteStringBuilder} to append the data to.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an octet string.
-   */
-  void readOctetString(ByteStringBuilder buffer) throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an octet string and advances the
-   * cursor. The data will be decoded to a UTF-8 string. This method
-   * is equivalent to:
-   *
-   * <pre>
-   * readOctetStringAsString(&quot;UTF-8&quot;);
-   * </pre>
-   *
-   * @return The string representation of the octet string data.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an octet string.
-   */
-  String readOctetStringAsString() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an octet string and advances the
-   * cursor. The data will be decoded to a string using the provided
-   * character set.
-   *
-   * @param charSet
-   *          The character set to use in order to decode the data
-   *          into a string.
-   * @return The string representation of the octet string data.
-   * @throws ASN1Exception
-   *           If the element cannot be decoded as an octet string.
-   */
-  String readOctetStringAsString(String charSet) throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as an explicit tag. All further
-   * reads will read the elements in the explicit tag until
-   * {@link #readEndExplicitTag()} is called.
-   *
-   * @throws ASN1Exception
-   *           If the next element is not an explicit tag.
-   */
-  void readStartExplicitTag() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as a sequence. All further reads
-   * will read the elements in the sequence until
-   * {@link #readEndSequence()} is called.
-   *
-   * @throws ASN1Exception
-   *           If the next element is not a sequence.
-   */
-  void readStartSequence() throws ASN1Exception;
-
-
-
-  /**
-   * Reads the next ASN.1 element as a set. All further reads will read
-   * the elements in the sequence until {@link #readEndSet()} is called.
-   *
-   * @throws ASN1Exception
-   *           If the next element is not a set.
-   */
-  void readStartSet() throws ASN1Exception;
-
-
-
-  /**
-   * Advances this ASN.1 reader beyond the next ASN.1 element without
-   * decoding it.
-   *
-   * @throws ASN1Exception
-   *           If the next ASN.1 element could not be skipped.
-   */
-  void skipElement() throws ASN1Exception;
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Writer.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Writer.java
deleted file mode 100644
index 4a400c8..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ASN1Writer.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-
-
-
-import org.forgerock.opendj.ldap.ByteSequence;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.Flushable;
-
-
-/**
- * An interface for encoding ASN.1 elements to a data source.
- * <p>
- * Methods for creating {@link ASN1Writer}s are provided in the
- * {@link ASN1} class.
- */
-public interface ASN1Writer extends Closeable, Flushable
-{
-
-  /**
-   * Closes this ASN.1 writer, flushing it first. Closing a
-   * previously closed ASN.1 writer has no effect. Any unfinished
-   * sequences and/or sets will be ended.
-   *
-   * @throws IOException
-   *           If an error occurs while closing the writer.
-   */
-  public void close() throws IOException;
-
-  /**
-   * Flushes the writer. If the writer has saved any elements from the
-   * previous write methods in a buffer, write them immediately to their
-   * intended destination. Then, if that destination is another byte stream,
-   * flush it. Thus one flush() invocation will flush all the buffers in a
-   * chain of streams.
-   * <p/>
-   * If the intended destination of this stream is an abstraction provided
-   * by the underlying operating system, for example a file, then flushing
-   * the stream guarantees only that bytes previously written to the stream
-   * are passed to the operating system for writing; it does not guarantee
-   * that they are actually written to a physical device such as a disk drive.
-   *
-   * @throws IOException If an I/O error occurs
-   */
-  public void flush() throws IOException;
-
-
-
-  /**
-   * Writes a boolean element using the Universal Boolean ASN.1 type
-   * tag.
-   *
-   * @param booleanValue
-   *          The boolean value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeBoolean(boolean booleanValue) throws IOException;
-
-
-
-  /**
-   * Writes a boolean element using the provided type tag.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param booleanValue
-   *          The boolean value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeBoolean(byte type, boolean booleanValue) throws IOException;
-
-
-
-  /**
-   * Finish writing a sequence.
-   *
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeEndSequence() throws IOException;
-
-
-
-  /**
-   * Finish writing a set.
-   *
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeEndSet() throws IOException;
-
-
-
-  /**
-   * Writes an integer element using the provided type tag.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param intValue
-   *          The integer value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeInteger(byte type, int intValue) throws IOException;
-
-
-
-  /**
-   * Writes an integer element using the provided type tag.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param longValue
-   *          The integer value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeInteger(byte type, long longValue) throws IOException;
-
-
-
-  /**
-   * Writes an integer element using the Universal Integer ASN.1 type
-   * tag.
-   *
-   * @param intValue
-   *          The integer value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeInteger(int intValue) throws IOException;
-
-
-
-  /**
-   * Writes an integer element using the Universal Integer ASN.1 type
-   * tag.
-   *
-   * @param longValue
-   *          The integer value to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeInteger(long longValue) throws IOException;
-
-
-
-  /**
-   * Writes an enumerated element using the Universal Enumerated ASN.1 type
-   * tag.
-   *
-   * @param intValue
-   *          The integer value of the enumeration to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeEnumerated(int intValue) throws IOException;
-
-
-  /**
-   * Writes a null element using the Universal Null ASN.1 type tag.
-   *
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeNull() throws IOException;
-
-
-
-  /**
-   * Writes a null element using the provided type tag.
-   *
-   * @param type
-   *          The type tag to use.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeNull(byte type) throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the provided type tag and
-   * byte array.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param value
-   *          The byte array containing the data to write.
-   * @param offset
-   *          The offset in the byte array.
-   * @param length
-   *          The number of bytes to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(byte type, byte[] value, int offset, int length)
-      throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the provided type tag and
-   * byte sequence.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param value
-   *          The byte sequence containing the data to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(byte type, ByteSequence value) throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the provided type tag and
-   * the UTF-8 encoded bytes of the provided string.
-   *
-   * @param type
-   *          The type tag to use.
-   * @param value
-   *          The string to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(byte type, String value) throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the Universal Octet String
-   * ASN.1 type tag and the provided byte array.
-   *
-   * @param value
-   *          The byte array containing the data to write.
-   * @param offset
-   *          The offset in the byte array.
-   * @param length
-   *          The number of bytes to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(byte[] value, int offset, int length)
-      throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the Universal Octet String
-   * ASN.1 type tag and the provided byte sequence.
-   *
-   * @param value
-   *          The byte sequence containing the data to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(ByteSequence value) throws IOException;
-
-
-
-  /**
-   * Writes an octet string element using the Universal Octet String
-   * ASN.1 type tag and the UTF-8 encoded bytes of the provided
-   * string.
-   *
-   * @param value
-   *          The string to write.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeOctetString(String value) throws IOException;
-
-
-
-  /**
-   * Writes a sequence element using the Universal Sequence ASN.1 type
-   * tag. All further writes will be part of this set until
-   * {@link #writeEndSequence()} is called.
-   *
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeStartSequence() throws IOException;
-
-
-
-  /**
-   * Writes a sequence element using the provided type tag. All
-   * further writes will be part of this sequence until
-   * {@link #writeEndSequence()} is called.
-   *
-   * @param type
-   *          The type tag to use.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeStartSequence(byte type) throws IOException;
-
-
-
-  /**
-   * Writes a set element using the Universal Set type tag. All
-   * further writes will be part of this set until
-   * {@link #writeEndSet()} is called.
-   *
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeStartSet() throws IOException;
-
-
-
-  /**
-   * Writes a set element using the provided type tag. All further
-   * writes will be part of this set until {@link #writeEndSet()} is
-   * called.
-   *
-   * @param type
-   *          The type tag to use.
-   * @return a reference to this object.
-   * @throws IOException
-   *           If an error occurs while writing.
-   */
-  ASN1Writer writeStartSet(byte type) throws IOException;
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ByteSequenceOutputStream.java b/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ByteSequenceOutputStream.java
deleted file mode 100644
index b84c295..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/protocols/asn1/ByteSequenceOutputStream.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.protocols.asn1;
-
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * An adapter class that allows writing to an byte string builder
- * with the outputstream interface.
- */
-final class ByteSequenceOutputStream extends OutputStream {
-  private static final int BUFFER_INIT_SIZE = 32;
-
-  private final ByteStringBuilder buffer;
-  private final int maxInternalBufferSize;
-
-  /**
-   * Creates a new byte string builder output stream.
-   *
-   * @param buffer
-   *          The underlying byte string builder.
-   * @param maxInternalBufferSize
-   *          The threshold capacity beyond which internal cached buffers used
-   *          for encoding and decoding protocol messages will be trimmed after
-   *          use.
-   */
-  ByteSequenceOutputStream(ByteStringBuilder buffer, int maxInternalBufferSize)
-  {
-    this.buffer = buffer;
-    this.maxInternalBufferSize = Math.max(maxInternalBufferSize,
-        BUFFER_INIT_SIZE);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void write(int i) throws IOException {
-    buffer.append(((byte) (i & 0xFF)));
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void write(byte[] bytes) throws IOException {
-    buffer.append(bytes);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void write(byte[] bytes, int i, int i1) throws IOException {
-    buffer.append(bytes, i, i1);
-  }
-
-  /**
-   * Gets the length of the underlying byte string builder.
-   *
-   * @return The length of the underlying byte string builder.
-   */
-  int length() {
-    return buffer.length();
-  }
-
-
-
-  /**
-   * Writes the content of the underlying byte string builder to the
-   * provided output stream.
-   *
-   * @param stream
-   *          The output stream.
-   * @throws IOException
-   *           If an I/O error occurs. In particular, an {@code
-   *           IOException} is thrown if the output stream is closed.
-   */
-  void writeTo(OutputStream stream) throws IOException
-  {
-    buffer.copyTo(stream);
-  }
-
-  /**
-   * Resets this output stream such that the underlying byte string builder is
-   * empty, and also has a capacity which is not too big.
-   */
-  void reset()
-  {
-    buffer.clearAndTruncate(maxInternalBufferSize, BUFFER_INIT_SIZE);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void close() throws IOException {
-    reset();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/ByteSequence.java b/opendj3-server-dev/src/server/org/opends/server/types/ByteSequence.java
deleted file mode 100644
index 0c22dc1..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/types/ByteSequence.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.types;
-
-
-
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.WritableByteChannel;
-
-
-
-/**
- * A {@code ByteSequence} is a readable sequence of byte values. This
- * interface provides uniform, read-only access to many different
- * kinds of byte sequences.
- */
-public interface ByteSequence extends Comparable<ByteSequence>
-{
-
-  /**
-   * Returns a {@link ByteSequenceReader} which can be used to
-   * incrementally read and decode data from this byte sequence.
-   * <p>
-   * <b>NOTE:</b> any concurrent changes to the underlying byte
-   * sequence (if mutable) may cause subsequent reads to overrun and
-   * fail.
-   *
-   * @return The {@link ByteSequenceReader} which can be used to
-   *         incrementally read and decode data from this byte
-   *         sequence.
-   */
-  ByteSequenceReader asReader();
-
-
-
-  /**
-   * Returns a {@link ByteBuffer} which can be used to read data from this
-   * byte sequence.
-   * <p>
-   * <b>NOTE:</b> any concurrent changes to the underlying byte
-   * sequence (if mutable) may cause unexpected results.
-   *
-   * @return The {@link ByteBuffer} which can be used to read data from this
-   * byte sequence.
-   */
-  ByteBuffer asByteBuffer();
-
-
-
-  /**
-   * Returns the byte value at the specified index.
-   * <p>
-   * An index ranges from zero to {@code length() - 1}. The first byte
-   * value of the sequence is at index zero, the next at index one,
-   * and so on, as for array indexing.
-   *
-   * @param index
-   *          The index of the byte to be returned.
-   * @return The byte value at the specified index.
-   * @throws IndexOutOfBoundsException
-   *           If the index argument is negative or not less than
-   *           length().
-   */
-  byte byteAt(int index) throws IndexOutOfBoundsException;
-
-
-
-  /**
-   * Compares this byte sequence with the specified byte array
-   * sub-sequence for order. Returns a negative integer, zero, or a
-   * positive integer depending on whether this byte sequence is less
-   * than, equal to, or greater than the specified byte array
-   * sub-sequence.
-   *
-   * @param b
-   *          The byte array to compare.
-   * @param offset
-   *          The offset of the sub-sequence in the byte array to be
-   *          compared; must be non-negative and no larger than {@code
-   *          b.length} .
-   * @param length
-   *          The length of the sub-sequence in the byte array to be
-   *          compared; must be non-negative and no larger than {@code
-   *          b.length - offset}.
-   * @return A negative integer, zero, or a positive integer depending
-   *         on whether this byte sequence is less than, equal to, or
-   *         greater than the specified byte array sub-sequence.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative or if {@code length} is
-   *           negative or if {@code offset + length} is greater than
-   *           {@code b.length}.
-   */
-  int compareTo(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException;
-
-
-
-  /**
-   * Compares this byte sequence with the specified byte sequence for
-   * order. Returns a negative integer, zero, or a positive integer
-   * depending on whether this byte sequence is less than, equal to,
-   * or greater than the specified object.
-   *
-   * @param o
-   *          The byte sequence to be compared.
-   * @return A negative integer, zero, or a positive integer depending
-   *         on whether this byte sequence is less than, equal to, or
-   *         greater than the specified object.
-   */
-  int compareTo(ByteSequence o);
-
-
-
-  /**
-   * Copies the contents of this byte sequence to the provided byte
-   * array.
-   * <p>
-   * Copying will stop when either the entire content of this sequence
-   * has been copied or if the end of the provided byte array has been
-   * reached.
-   * <p>
-   * An invocation of the form:
-   *
-   * <pre>
-   * src.copyTo(b)
-   * </pre>
-   *
-   * Behaves in exactly the same way as the invocation:
-   *
-   * <pre>
-   * src.copyTo(b, 0);
-   * </pre>
-   *
-   * @param b
-   *          The byte array to which bytes are to be copied.
-   * @return The byte array.
-   */
-  byte[] copyTo(byte[] b);
-
-
-
-  /**
-   * Copies the contents of this byte sequence to the specified
-   * location in the provided byte array.
-   * <p>
-   * Copying will stop when either the entire content of this sequence
-   * has been copied or if the end of the provided byte array has been
-   * reached.
-   * <p>
-   * An invocation of the form:
-   *
-   * <pre>
-   * src.copyTo(b, offset)
-   * </pre>
-   *
-   * Behaves in exactly the same way as the invocation:
-   *
-   * <pre>
-   * int len = Math.min(src.length(), b.length - offset);
-   * for (int i = 0; i &lt; len; i++)
-   *   b[offset + i] = src.get(i);
-   * </pre>
-   *
-   * Except that it is potentially much more efficient.
-   *
-   * @param b
-   *          The byte array to which bytes are to be copied.
-   * @param offset
-   *          The offset within the array of the first byte to be
-   *          written; must be non-negative and no larger than
-   *          b.length.
-   * @return The byte array.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative.
-   */
-  byte[] copyTo(byte[] b, int offset)
-      throws IndexOutOfBoundsException;
-
-
-
-  /**
-   * Appends the entire contents of this byte sequence to the provided
-   * {@link ByteStringBuilder}.
-   *
-   * @param builder
-   *          The builder to copy to.
-   * @return The builder.
-   */
-  ByteStringBuilder copyTo(ByteStringBuilder builder);
-
-
-
-  /**
-   * Copies the entire contents of this byte sequence to the provided
-   * {@code OutputStream}.
-   *
-   * @param stream
-   *          The {@code OutputStream} to copy to.
-   * @return The {@code OutputStream}.
-   * @throws IOException
-   *           If an error occurs while writing to the {@code
-   *           OutputStream}.
-   */
-  OutputStream copyTo(OutputStream stream) throws IOException;
-
-
-
-  /**
-   * Copies the entire contents of this byte sequence to the provided
-   * {@code WritableByteChannel}.
-   *
-   * @param channel
-   *          The {@code WritableByteChannel} to copy to.
-   * @return The number of bytes written, possibly zero
-   * @throws IOException
-   *           If some other I/O error occurs
-   * @see WritableByteChannel#write(java.nio.ByteBuffer)
-   */
-  int copyTo(WritableByteChannel channel) throws IOException;
-
-
-
-  /**
-   * Indicates whether the provided byte array sub-sequence is equal
-   * to this byte sequence. In order for it to be considered equal,
-   * the provided byte array sub-sequence must contain the same bytes
-   * in the same order.
-   *
-   * @param b
-   *          The byte array for which to make the determination.
-   * @param offset
-   *          The offset of the sub-sequence in the byte array to be
-   *          compared; must be non-negative and no larger than {@code
-   *          b.length} .
-   * @param length
-   *          The length of the sub-sequence in the byte array to be
-   *          compared; must be non-negative and no larger than {@code
-   *          b.length - offset}.
-   * @return {@code true} if the content of the provided byte array
-   *         sub-sequence is equal to that of this byte sequence, or
-   *         {@code false} if not.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative or if {@code length} is
-   *           negative or if {@code offset + length} is greater than
-   *           {@code b.length}.
-   */
-  boolean equals(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException;
-
-
-
-  /**
-   * Indicates whether the provided object is equal to this byte
-   * sequence. In order for it to be considered equal, the provided
-   * object must be a byte sequence containing the same bytes in the
-   * same order.
-   *
-   * @param o
-   *          The object for which to make the determination.
-   * @return {@code true} if the provided object is a byte sequence
-   *         whose content is equal to that of this byte sequence, or
-   *         {@code false} if not.
-   */
-  boolean equals(Object o);
-
-
-
-  /**
-   * Returns a hash code for this byte sequence. It will be the sum of
-   * all of the bytes contained in the byte sequence.
-   *
-   * @return A hash code for this byte sequence.
-   */
-  int hashCode();
-
-
-
-  /**
-   * Returns the length of this byte sequence.
-   *
-   * @return The length of this byte sequence.
-   */
-  int length();
-
-
-
-  /**
-   * Returns a new byte sequence that is a subsequence of this byte
-   * sequence.
-   * <p>
-   * The subsequence starts with the byte value at the specified
-   * {@code start} index and ends with the byte value at index {@code
-   * end - 1}. The length (in bytes) of the returned sequence is
-   * {@code end - start}, so if {@code start == end} then an empty
-   * sequence is returned.
-   * <p>
-   * <b>NOTE:</b> changes to the underlying byte sequence (if mutable)
-   * may render the returned sub-sequence invalid.
-   *
-   * @param start
-   *          The start index, inclusive.
-   * @param end
-   *          The end index, exclusive.
-   * @return The newly created byte subsequence.
-   * @throws IndexOutOfBoundsException
-   *           If {@code start} or {@code end} are negative, if
-   *           {@code end} is greater than {@code length()}, or if
-   *           {@code start} is greater than {@code end}.
-   */
-  ByteSequence subSequence(int start, int end)
-      throws IndexOutOfBoundsException;
-
-
-
-  /**
-   * Returns a byte array containing the bytes in this sequence in the
-   * same order as this sequence. The length of the byte array will be
-   * the length of this sequence.
-   * <p>
-   * An invocation of the form:
-   *
-   * <pre>
-   * src.toByteArray()
-   * </pre>
-   *
-   * Behaves in exactly the same way as the invocation:
-   *
-   * <pre>
-   * src.copyTo(new byte[src.length()]);
-   * </pre>
-   *
-   * @return A byte array consisting of exactly this sequence of
-   *         bytes.
-   */
-  byte[] toByteArray();
-
-
-
-  /**
-   * Returns the {@link ByteString} representation of this byte
-   * sequence.
-   *
-   * @return The {@link ByteString} representation of this byte
-   *         sequence.
-   */
-  ByteString toByteString();
-
-
-
-  /**
-   * Returns the UTF-8 decoded string representation of this byte
-   * sequence. If UTF-8 decoding fails, the platform's default
-   * encoding will be used.
-   *
-   * @return The string representation of this byte sequence.
-   */
-  String toString();
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/ByteSequenceReader.java b/opendj3-server-dev/src/server/org/opends/server/types/ByteSequenceReader.java
deleted file mode 100644
index a3deed3..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/types/ByteSequenceReader.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.types;
-
-
-
-
-/**
- * An interface for iteratively reading date from a
- * {@link ByteSequence}. {@code ByteSequenceReader} must be created
- * using the associated {@code ByteSequence}'s
- * {@code asReader()} method.
- */
-public final class ByteSequenceReader
-{
-
-  // The current position in the byte sequence.
-  private int pos = 0;
-
-  // The underlying byte sequence.
-  private final ByteSequence sequence;
-
-
-
-  /**
-   * Creates a new byte sequence reader whose source is the provided
-   * byte sequence.
-   * <p>
-   * <b>NOTE:</b> any concurrent changes to the underlying byte
-   * sequence (if mutable) may cause subsequent reads to overrun and
-   * fail.
-   * <p>
-   * This constructor is package private: construction must be
-   * performed using {@link ByteSequence#asReader()}.
-   *
-   * @param sequence
-   *          The byte sequence to be read.
-   */
-  ByteSequenceReader(ByteSequence sequence)
-  {
-    this.sequence = sequence;
-  }
-
-
-
-  /**
-   * Relative get method. Reads the byte at the current position.
-   *
-   * @return The byte at this reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < 1}.
-   */
-  public byte get() throws IndexOutOfBoundsException
-  {
-    byte b = sequence.byteAt(pos);
-    pos++;
-    return b;
-  }
-
-
-
-  /**
-   * Relative bulk get method. This method transfers bytes from this
-   * reader into the given destination array. An invocation of this
-   * method of the form:
-   *
-   * <pre>
-   * src.get(b);
-   * </pre>
-   *
-   * Behaves in exactly the same way as the invocation:
-   *
-   * <pre>
-   * src.get(b, 0, b.length);
-   * </pre>
-   *
-   * @param b
-   *          The byte array into which bytes are to be written.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < b.length}.
-   */
-  public void get(byte[] b) throws IndexOutOfBoundsException
-  {
-    get(b, 0, b.length);
-  }
-
-
-
-  /**
-   * Relative bulk get method. Copies {@code length} bytes from this
-   * reader into the given array, starting at the current position of
-   * this reader and at the given {@code offset} in the array. The
-   * position of this reader is then incremented by {@code length}. In
-   * other words, an invocation of this method of the form:
-   *
-   * <pre>
-   * src.get(b, offset, length);
-   * </pre>
-   *
-   * Has exactly the same effect as the loop:
-   *
-   * <pre>
-   * for (int i = offset; i &lt; offset + length; i++)
-   *   b[i] = src.get();
-   * </pre>
-   *
-   * Except that it first checks that there are sufficient bytes in
-   * this buffer and it is potentially much more efficient.
-   *
-   * @param b
-   *          The byte array into which bytes are to be written.
-   * @param offset
-   *          The offset within the array of the first byte to be
-   *          written; must be non-negative and no larger than {@code
-   *          b.length}.
-   * @param length
-   *          The number of bytes to be written to the given array;
-   *          must be non-negative and no larger than {@code b.length}
-   *          .
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < length}.
-   */
-  public void get(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    if ((offset < 0) || (length < 0) || (offset + length > b.length)
-        || (length > remaining()))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    sequence.subSequence(pos, pos + length).copyTo(b, offset);
-    pos += length;
-  }
-
-
-
-  /**
-   * Relative get method for reading a multi-byte BER length. Reads
-   * the next one to five bytes at this reader's current position,
-   * composing them into a integer value and then increments the
-   * position by the number of bytes read.
-   *
-   * @return The integer value representing the length at this
-   *         reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request.
-   */
-  public int getBERLength() throws IndexOutOfBoundsException
-  {
-    // Make sure we have at least one byte to read.
-    int newPos = pos + 1;
-    if (newPos > sequence.length())
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    int length = (sequence.byteAt(pos) & 0x7F);
-    if (length != sequence.byteAt(pos))
-    {
-      // Its a multi-byte length
-      int numLengthBytes = length;
-      newPos = pos + 1 + numLengthBytes;
-      // Make sure we have the bytes needed
-      if (numLengthBytes > 4 || newPos > sequence.length())
-      {
-        // Shouldn't have more than 4 bytes
-        throw new IndexOutOfBoundsException();
-      }
-
-      length = 0x00;
-      for (int i = pos + 1; i < newPos; i++)
-      {
-        length = (length << 8) | (sequence.byteAt(i) & 0xFF);
-      }
-    }
-
-    pos = newPos;
-    return length;
-  }
-
-
-
-  /**
-   * Relative bulk get method. Returns a {@link ByteSequence} whose
-   * content is the next {@code length} bytes from this reader,
-   * starting at the current position of this reader. The position of
-   * this reader is then incremented by {@code length}.
-   * <p>
-   * <b>NOTE:</b> The value returned from this method should NEVER be
-   * cached as it prevents the contents of the underlying byte stream
-   * from being garbage collected.
-   *
-   * @param length
-   *          The length of the byte sequence to be returned.
-   * @return The byte sequence whose content is the next {@code
-   *         length} bytes from this reader.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < length}.
-   */
-  public ByteSequence getByteSequence(int length)
-      throws IndexOutOfBoundsException
-  {
-    int newPos = pos + length;
-    ByteSequence subSequence = sequence.subSequence(pos, newPos);
-    pos = newPos;
-    return subSequence;
-  }
-
-
-
-  /**
-   * Relative bulk get method. Returns a {@link ByteString} whose
-   * content is the next {@code length} bytes from this reader,
-   * starting at the current position of this reader. The position of
-   * this reader is then incremented by {@code length}.
-   * <p>
-   * An invocation of this method of the form:
-   *
-   * <pre>
-   * src.getByteString(length);
-   * </pre>
-   *
-   * Has exactly the same effect as:
-   *
-   * <pre>
-   * src.getByteSequence(length).toByteString();
-   * </pre>
-   *
-   * <b>NOTE:</b> The value returned from this method should NEVER be
-   * cached as it prevents the contents of the underlying byte stream
-   * from being garbage collected.
-   *
-   * @param length
-   *          The length of the byte string to be returned.
-   * @return The byte string whose content is the next {@code length}
-   *         bytes from this reader.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < length}.
-   */
-  public ByteString getByteString(int length)
-      throws IndexOutOfBoundsException
-  {
-    return getByteSequence(length).toByteString();
-  }
-
-
-
-  /**
-   * Relative get method for reading an short value. Reads the next
-   * 2 bytes at this reader's current position, composing them into
-   * an short value according to big-endian byte order, and then
-   * increments the position by two.
-   *
-   * @return The integer value at this reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < 2}.
-   */
-  public short getShort() throws IndexOutOfBoundsException
-  {
-    if (remaining() < 2)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    short v = 0;
-    for (int i = 0; i < 2; i++)
-    {
-      v <<= 8;
-      v |= (sequence.byteAt(pos++) & 0xFF);
-    }
-
-    return v;
-  }
-
-
-
-  /**
-   * Relative get method for reading an integer value. Reads the next
-   * four bytes at this reader's current position, composing them into
-   * an integer value according to big-endian byte order, and then
-   * increments the position by four.
-   *
-   * @return The integer value at this reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < 4}.
-   */
-  public int getInt() throws IndexOutOfBoundsException
-  {
-    if (remaining() < 4)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    int v = 0;
-    for (int i = 0; i < 4; i++)
-    {
-      v <<= 8;
-      v |= (sequence.byteAt(pos++) & 0xFF);
-    }
-
-    return v;
-  }
-
-
-
-  /**
-   * Relative get method for reading a long value. Reads the next
-   * eight bytes at this reader's current position, composing them
-   * into a long value according to big-endian byte order, and then
-   * increments the position by eight.
-   *
-   * @return The long value at this reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < 8}.
-   */
-  public long getLong() throws IndexOutOfBoundsException
-  {
-    if (remaining() < 8)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    long v = 0;
-    for (int i = 0; i < 8; i++)
-    {
-      v <<= 8;
-      v |= (sequence.byteAt(pos++) & 0xFF);
-    }
-
-    return v;
-  }
-
-
-
-  /**
-   * Relative get method for reading a UTF-8 encoded string. Reads the
-   * next number of specified bytes at this reader's current position,
-   * decoding them into a string using UTF-8 and then increments the
-   * position by the number of bytes read. If UTF-8 decoding fails,
-   * the platform's default encoding will be used.
-   *
-   * @param length
-   *          The number of bytes to read and decode.
-   * @return The string value at the reader's current position.
-   * @throws IndexOutOfBoundsException
-   *           If there are fewer bytes remaining in this reader than
-   *           are required to satisfy the request, that is, if
-   *           {@code remaining() < length}.
-   */
-  public String getString(int length) throws IndexOutOfBoundsException
-  {
-    if (remaining() < length)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    int newPos = pos + length;
-    String str = sequence.subSequence(pos, pos + length).toString();
-    pos = newPos;
-    return str;
-  }
-
-
-
-  /**
-   * Returns this reader's position.
-   *
-   * @return The position of this reader.
-   */
-  public int position()
-  {
-    return pos;
-  }
-
-
-
-  /**
-   * Sets this reader's position.
-   *
-   * @param pos
-   *          The new position value; must be non-negative and no
-   *          larger than the length of the underlying byte sequence.
-   * @throws IndexOutOfBoundsException
-   *           If the position is negative or larger than the length
-   *           of the underlying byte sequence.
-   */
-  public void position(int pos) throws IndexOutOfBoundsException
-  {
-    if (pos > sequence.length() || pos < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    this.pos = pos;
-  }
-
-
-
-  /**
-   * Returns the number of bytes between the current position and the
-   * end of the underlying byte sequence.
-   *
-   * @return The number of bytes between the current position and the
-   *         end of the underlying byte sequence.
-   */
-  public int remaining()
-  {
-    return sequence.length() - pos;
-  }
-
-
-
-  /**
-   * Rewinds this reader's position to zero.
-   * <p>
-   * An invocation of this method of the form:
-   *
-   * <pre>
-   * src.rewind();
-   * </pre>
-   *
-   * Has exactly the same effect as:
-   *
-   * <pre>
-   * src.position(0);
-   * </pre>
-   */
-  public void rewind()
-  {
-    position(0);
-  }
-
-
-
-  /**
-   * Skips the given number of bytes. Negative values are allowed.
-   * <p>
-   * An invocation of this method of the form:
-   *
-   * <pre>
-   * src.skip(length);
-   * </pre>
-   *
-   * Has exactly the same effect as:
-   *
-   * <pre>
-   * src.position(position() + length);
-   * </pre>
-   *
-   * @param length
-   *          The number of bytes to skip.
-   * @throws IndexOutOfBoundsException
-   *           If the new position is less than 0 or greater than the
-   *           length of the underlying byte sequence.
-   */
-  public void skip(int length) throws IndexOutOfBoundsException
-  {
-    position(pos + length);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String toString() {
-    return sequence.toString();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/ByteString.java b/opendj3-server-dev/src/server/org/opends/server/types/ByteString.java
deleted file mode 100644
index 52d5d76..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/types/ByteString.java
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.types;
-
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.WritableByteChannel;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.util.StaticUtils;
-
-
-
-/**
- * An immutable sequence of bytes backed by a byte array.
- */
-public final class ByteString implements ByteSequence
-{
-
-  // Singleton empty byte string.
-  private static final ByteString EMPTY = wrap(new byte[0]);
-
-  // Used for tracing exceptions.
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-
-
-  /**
-   * Returns an empty byte string.
-   *
-   * @return An empty byte string.
-   */
-  public static ByteString empty()
-  {
-    return EMPTY;
-  }
-
-
-
-  /**
-   * Returns a byte string containing the big-endian encoded bytes of
-   * the provided integer.
-   *
-   * @param i
-   *          The integer to encode.
-   * @return The byte string containing the big-endian encoded bytes
-   *         of the provided integer.
-   */
-  public static ByteString valueOf(int i)
-  {
-    byte[] bytes = new byte[4];
-    for (int j = 3; j >= 0; j--)
-    {
-      bytes[j] = (byte) (i & 0xFF);
-      i >>>= 8;
-    }
-    return wrap(bytes);
-  }
-
-
-
-  /**
-   * Returns a byte string containing the big-endian encoded bytes of
-   * the provided long.
-   *
-   * @param l
-   *          The long to encode.
-   * @return The byte string containing the big-endian encoded bytes
-   *         of the provided long.
-   */
-  public static ByteString valueOf(long l)
-  {
-    byte[] bytes = new byte[8];
-    for (int i = 7; i >= 0; i--)
-    {
-      bytes[i] = (byte) (l & 0xFF);
-      l >>>= 8;
-    }
-    return wrap(bytes);
-  }
-
-
-
-  /**
-   * Returns a byte string containing the UTF-8 encoded bytes of the
-   * provided string.
-   *
-   * @param s
-   *          The string to use.
-   * @return The byte string with the encoded bytes of the provided
-   *         string.
-   */
-  public static ByteString valueOf(String s)
-  {
-    return wrap(StaticUtils.getBytes(s));
-  }
-
-
-
-  /**
-   * Returns a byte string that wraps the provided byte array.
-   * <p>
-   * <b>NOTE:</b> this method takes ownership of the provided byte
-   * array and, therefore, the byte array MUST NOT be altered directly
-   * after this method returns.
-   *
-   * @param b
-   *          The byte array to wrap.
-   * @return The byte string that wraps the given byte array.
-   */
-  public static ByteString wrap(byte[] b)
-  {
-    return new ByteString(b, 0, b.length);
-  }
-
-
-
-  /**
-   * Returns a byte string that wraps a subsequence of the provided
-   * byte array.
-   * <p>
-   * <b>NOTE:</b> this method takes ownership of the provided byte
-   * array and, therefore, the byte array MUST NOT be altered directly
-   * after this method returns.
-   *
-   * @param b
-   *          The byte array to wrap.
-   * @param offset
-   *          The offset of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length} .
-   * @param length
-   *          The length of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length -
-   *          offset}.
-   * @return The byte string that wraps the given byte array.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative or if {@code length} is
-   *           negative or if {@code offset + length} is greater than
-   *           {@code b.length}.
-   */
-  public static ByteString wrap(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    checkArrayBounds(b, offset, length);
-    return new ByteString(b, offset, length);
-  }
-
-
-
-  /**
-   * Checks the array bounds of the provided byte array sub-sequence,
-   * throwing an {@code IndexOutOfBoundsException} if they are
-   * illegal.
-   *
-   * @param b
-   *          The byte array.
-   * @param offset
-   *          The offset of the byte array to be checked; must be
-   *          non-negative and no larger than {@code b.length}.
-   * @param length
-   *          The length of the byte array to be checked; must be
-   *          non-negative and no larger than {@code b.length -
-   *          offset}.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative or if {@code length} is
-   *           negative or if {@code offset + length} is greater than
-   *           {@code b.length}.
-   */
-  static void checkArrayBounds(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    if ((offset < 0) || (offset > b.length) || (length < 0)
-        || ((offset + length) > b.length) || ((offset + length) < 0))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-  }
-
-
-
-  /**
-   * Compares two byte array sub-sequences and returns a value that
-   * indicates their relative order.
-   *
-   * @param b1
-   *          The byte array containing the first sub-sequence.
-   * @param offset1
-   *          The offset of the first byte array sub-sequence.
-   * @param length1
-   *          The length of the first byte array sub-sequence.
-   * @param b2
-   *          The byte array containing the second sub-sequence.
-   * @param offset2
-   *          The offset of the second byte array sub-sequence.
-   * @param length2
-   *          The length of the second byte array sub-sequence.
-   * @return A negative integer if first byte array sub-sequence
-   *         should come before the second byte array sub-sequence in
-   *         ascending order, a positive integer if the first byte
-   *         array sub-sequence should come after the byte array
-   *         sub-sequence in ascending order, or zero if there is no
-   *         difference between the two byte array sub-sequences with
-   *         regard to ordering.
-   */
-  static int compareTo(byte[] b1, int offset1, int length1, byte[] b2,
-      int offset2, int length2)
-  {
-    int count = Math.min(length1, length2);
-    int i = offset1;
-    int j = offset2;
-    while (count-- != 0)
-    {
-      int firstByte = 0xFF & b1[i++];
-      int secondByte = 0xFF & b2[j++];
-      if (firstByte != secondByte)
-      {
-        return firstByte - secondByte;
-      }
-    }
-    return length1 - length2;
-  }
-
-
-
-  /**
-   * Indicates whether two byte array sub-sequences are equal. In
-   * order for them to be considered equal, they must contain the same
-   * bytes in the same order.
-   *
-   * @param b1
-   *          The byte array containing the first sub-sequence.
-   * @param offset1
-   *          The offset of the first byte array sub-sequence.
-   * @param length1
-   *          The length of the first byte array sub-sequence.
-   * @param b2
-   *          The byte array containing the second sub-sequence.
-   * @param offset2
-   *          The offset of the second byte array sub-sequence.
-   * @param length2
-   *          The length of the second byte array sub-sequence.
-   * @return {@code true} if the two byte array sub-sequences have the
-   *         same content, or {@code false} if not.
-   */
-  static boolean equals(byte[] b1, int offset1, int length1,
-      byte[] b2, int offset2, int length2)
-  {
-    if (length1 != length2)
-    {
-      return false;
-    }
-
-    int i = offset1;
-    int j = offset2;
-    int count = length1;
-    while (count-- != 0)
-    {
-      if (b1[i++] != b2[j++])
-      {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-
-
-  /**
-   * Returns a hash code for the provided byte array sub-sequence.
-   *
-   * @param b
-   *          The byte array.
-   * @param offset
-   *          The offset of the byte array sub-sequence.
-   * @param length
-   *          The length of the byte array sub-sequence.
-   * @return A hash code for the provided byte array sub-sequence.
-   */
-  static int hashCode(byte[] b, int offset, int length)
-  {
-    int hashCode = 1;
-    int i = offset;
-    int count = length;
-    while (count-- != 0)
-    {
-      hashCode = 31 * hashCode + b[i++];
-    }
-    return hashCode;
-  }
-
-
-
-  /**
-   * Returns the UTF-8 decoded string representation of the provided
-   * byte array sub-sequence. If UTF-8 decoding fails, the platform's
-   * default encoding will be used.
-   *
-   * @param b
-   *          The byte array.
-   * @param offset
-   *          The offset of the byte array sub-sequence.
-   * @param length
-   *          The length of the byte array sub-sequence.
-   * @return The string representation of the byte array sub-sequence.
-   */
-  static String toString(byte[] b, int offset, int length)
-  {
-    String stringValue;
-    try
-    {
-      stringValue = new String(b, offset, length, "UTF-8");
-    }
-    catch (Exception e)
-    {
-      logger.traceException(e);
-
-      stringValue = new String(b, offset, length);
-    }
-
-    return stringValue;
-  }
-
-  // The buffer where data is stored.
-  private final byte[] buffer;
-
-  // The number of bytes to expose from the buffer.
-  private final int length;
-
-  // The start index of the range of bytes to expose through this byte
-  // string.
-  private final int offset;
-
-
-
-  /**
-   * Creates a new byte string that wraps a subsequence of the
-   * provided byte array.
-   * <p>
-   * <b>NOTE:</b> this method takes ownership of the provided byte
-   * array and, therefore, the byte array MUST NOT be altered directly
-   * after this method returns.
-   *
-   * @param b
-   *          The byte array to wrap.
-   * @param offset
-   *          The offset of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length} .
-   * @param length
-   *          The length of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length -
-   *          offset}.
-   */
-  private ByteString(byte[] b, int offset, int length)
-  {
-    this.buffer = b;
-    this.offset = offset;
-    this.length = length;
-  }
-
-
-
-  /**
-   * Returns a {@link ByteSequenceReader} which can be used to
-   * incrementally read and decode data from this byte string.
-   *
-   * @return The {@link ByteSequenceReader} which can be used to
-   *         incrementally read and decode data from this byte string.
-   */
-  public ByteSequenceReader asReader()
-  {
-    return new ByteSequenceReader(this);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte byteAt(int index) throws IndexOutOfBoundsException
-  {
-    if (index >= length || index < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    return buffer[offset + index];
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int compareTo(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    checkArrayBounds(b, offset, length);
-    return compareTo(this.buffer, this.offset, this.length,
-        b, offset, length);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int compareTo(ByteSequence o)
-  {
-    if (this == o) return 0;
-    return -(o.compareTo(buffer, offset, length));
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] copyTo(byte[] b)
-  {
-    copyTo(b, 0);
-    return b;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] copyTo(byte[] b, int offset)
-      throws IndexOutOfBoundsException
-  {
-    if (offset < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    System.arraycopy(buffer, this.offset, b, offset,
-        Math.min(length, b.length - offset));
-    return b;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteStringBuilder copyTo(ByteStringBuilder builder)
-  {
-    builder.append(buffer, offset, length);
-    return builder;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public OutputStream copyTo(OutputStream stream) throws IOException
-  {
-    stream.write(buffer, offset, length);
-    return stream;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int copyTo(WritableByteChannel channel) throws IOException
-  {
-    return channel.write(ByteBuffer.wrap(buffer, offset, length));
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean equals(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    checkArrayBounds(b, offset, length);
-    return equals(this.buffer, this.offset, this.length,
-        b, offset, length);
-  }
-
-
-
-  /**
-   * Indicates whether the provided object is equal to this byte
-   * string. In order for it to be considered equal, the provided
-   * object must be a byte sequence containing the same bytes in the
-   * same order.
-   *
-   * @param o
-   *          The object for which to make the determination.
-   * @return {@code true} if the provided object is a byte sequence
-   *         whose content is equal to that of this byte string, or
-   *         {@code false} if not.
-   */
-  @Override
-  public boolean equals(Object o)
-  {
-    if (this == o)
-    {
-      return true;
-    }
-    else if (o instanceof ByteSequence)
-    {
-      ByteSequence other = (ByteSequence) o;
-      return other.equals(buffer, offset, length);
-    }
-    else
-    {
-      return false;
-    }
-  }
-
-
-
-  /**
-   * Returns a hash code for this byte string. It will be the sum of
-   * all of the bytes contained in the byte string.
-   *
-   * @return A hash code for this byte string.
-   */
-  @Override
-  public int hashCode()
-  {
-    return hashCode(buffer, offset, length);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int length()
-  {
-    return length;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteString subSequence(int start, int end)
-      throws IndexOutOfBoundsException
-  {
-    if ((start < 0) || (start > end) || (end > length))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    return new ByteString(buffer, offset + start, end - start);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] toByteArray()
-  {
-    return copyTo(new byte[length]);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteString toByteString()
-  {
-    return this;
-  }
-
-
-
-  /**
-   * Returns a string representation of the contents of this byte
-   * sequence using hexadecimal characters and a space between each
-   * byte.
-   *
-   * @return A string representation of the contents of this byte
-   *         sequence using hexadecimal characters.
-   */
-  public String toHexString()
-  {
-    StringBuilder builder = new StringBuilder((length - 1) * 3 + 2);
-    builder.append(StaticUtils.byteToHex(buffer[offset]));
-
-    for (int i = 1; i < length; i++)
-    {
-      builder.append(" ");
-      builder.append(StaticUtils.byteToHex(buffer[offset + i]));
-    }
-
-    return builder.toString();
-  }
-
-  /**
-   * Returns the integer value represented by the first four bytes of
-   * this byte string in big-endian order.
-   *
-   * @return The integer value represented by the first four bytes of
-   *         this byte string in big-endian order.
-   * @throws IndexOutOfBoundsException
-   *           If this byte string has less than four bytes.
-   */
-  public int toInt() throws IndexOutOfBoundsException
-  {
-    if (length < 4)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    int v = 0;
-    for (int i = 0; i < 4; i++)
-    {
-      v <<= 8;
-      v |= (buffer[offset + i] & 0xFF);
-    }
-    return v;
-  }
-
-
-
-  /**
-   * Returns the long value represented by the first eight bytes of
-   * this byte string in big-endian order.
-   *
-   * @return The long value represented by the first eight bytes of
-   *         this byte string in big-endian order.
-   * @throws IndexOutOfBoundsException
-   *           If this byte string has less than eight bytes.
-   */
-  public long toLong() throws IndexOutOfBoundsException
-  {
-    if (length < 8)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    long v = 0;
-    for (int i = 0; i < 8; i++)
-    {
-      v <<= 8;
-      v |= (buffer[offset + i] & 0xFF);
-    }
-    return v;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String toString()
-  {
-    return toString(buffer, offset, length);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public ByteBuffer asByteBuffer()
-  {
-    return ByteBuffer.wrap(buffer, offset, length).asReadOnlyBuffer();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/ByteStringBuilder.java b/opendj3-server-dev/src/server/org/opends/server/types/ByteStringBuilder.java
deleted file mode 100644
index 7a8e4b9..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/types/ByteStringBuilder.java
+++ /dev/null
@@ -1,1300 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.types;
-
-
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
-import java.util.zip.DataFormatException;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-
-
-/**
- * A mutable sequence of bytes backed by a byte array.
- */
-public final class ByteStringBuilder implements ByteSequence
-{
-
-  /**
-   * A sub-sequence of the parent byte string builder. The
-   * sub-sequence will be robust against all updates to the byte
-   * string builder except for invocations of the method {@code
-   * clear()}.
-   */
-  private final class SubSequence implements ByteSequence
-  {
-
-    // The length of the sub-sequence.
-    private final int subLength;
-
-    // The offset of the sub-sequence.
-    private final int subOffset;
-
-
-
-    /**
-     * Creates a new sub-sequence.
-     *
-     * @param offset
-     *          The offset of the sub-sequence.
-     * @param length
-     *          The length of the sub-sequence.
-     */
-    private SubSequence(int offset, int length)
-    {
-      this.subOffset = offset;
-      this.subLength = length;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ByteSequenceReader asReader()
-    {
-      return new ByteSequenceReader(this);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public byte byteAt(int index) throws IndexOutOfBoundsException
-    {
-      if (index >= subLength || index < 0)
-      {
-        throw new IndexOutOfBoundsException();
-      }
-
-      // Protect against reallocation: use builder's buffer.
-      return buffer[subOffset + index];
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public int compareTo(byte[] b, int offset, int length)
-        throws IndexOutOfBoundsException
-    {
-      ByteString.checkArrayBounds(b, offset, length);
-
-      // Protect against reallocation: use builder's buffer.
-      return ByteString.compareTo(buffer, subOffset, subLength,
-          b, offset, length);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public int compareTo(ByteSequence o)
-    {
-      if (this == o) return 0;
-
-      // Protect against reallocation: use builder's buffer.
-      return -(o.compareTo(buffer, subOffset, subLength));
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public byte[] copyTo(byte[] b)
-    {
-      copyTo(b, 0);
-      return b;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public byte[] copyTo(byte[] b, int offset)
-        throws IndexOutOfBoundsException
-    {
-      if (offset < 0)
-      {
-        throw new IndexOutOfBoundsException();
-      }
-
-      // Protect against reallocation: use builder's buffer.
-      System.arraycopy(buffer, subOffset, b, offset,
-          Math.min(subLength, b.length - offset));
-      return b;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ByteStringBuilder copyTo(ByteStringBuilder builder)
-    {
-      // Protect against reallocation: use builder's buffer.
-      return builder.append(buffer, subOffset, subLength);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public OutputStream copyTo(OutputStream stream) throws IOException
-    {
-      // Protect against reallocation: use builder's buffer.
-      stream.write(buffer, subOffset, subLength);
-      return stream;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public int copyTo(WritableByteChannel channel) throws IOException
-    {
-      return channel.write(ByteBuffer.wrap(buffer, subOffset, subLength));
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(byte[] b, int offset, int length)
-        throws IndexOutOfBoundsException
-    {
-      ByteString.checkArrayBounds(b, offset, length);
-
-      // Protect against reallocation: use builder's buffer.
-      return ByteString.equals(buffer, subOffset, subLength,
-          b, offset, length);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean equals(Object o)
-    {
-      if (this == o)
-      {
-        return true;
-      }
-      else if (o instanceof ByteSequence)
-      {
-        ByteSequence other = (ByteSequence) o;
-
-        // Protect against reallocation: use builder's buffer.
-        return other.equals(buffer, subOffset, subLength);
-      }
-      else
-      {
-        return false;
-      }
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int hashCode()
-    {
-      // Protect against reallocation: use builder's buffer.
-      return ByteString.hashCode(buffer, subOffset, subLength);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public int length()
-    {
-      return subLength;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ByteSequence subSequence(int start, int end)
-        throws IndexOutOfBoundsException
-    {
-      if ((start < 0) || (start > end) || (end > subLength))
-      {
-        throw new IndexOutOfBoundsException();
-      }
-
-      return new SubSequence(subOffset + start, end - start);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public byte[] toByteArray()
-    {
-      return copyTo(new byte[subLength]);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ByteString toByteString()
-    {
-      // Protect against reallocation: use builder's buffer.
-      byte[] b = new byte[subLength];
-      System.arraycopy(buffer, subOffset, b, 0, subLength);
-      return ByteString.wrap(b);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String toString()
-    {
-      // Protect against reallocation: use builder's buffer.
-      return ByteString.toString(buffer, subOffset, subLength);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ByteBuffer asByteBuffer()
-    {
-      return ByteBuffer.wrap(buffer, subOffset, subLength);
-    }
-  }
-
-  // Used for tracing exceptions.
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-  // The buffer where data is stored.
-  private byte[] buffer;
-
-  // The number of bytes to expose from the buffer.
-  private int length;
-
-
-
-  /**
-   * Creates a new byte string builder with an initial capacity of 32
-   * bytes.
-   */
-  public ByteStringBuilder()
-  {
-    // Initially create a 32 byte buffer.
-    this(32);
-  }
-
-
-
-  /**
-   * Creates a new byte string builder with the specified initial
-   * capacity.
-   *
-   * @param capacity
-   *          The initial capacity.
-   * @throws IllegalArgumentException
-   *           If the {@code capacity} is negative.
-   */
-  public ByteStringBuilder(int capacity)
-      throws IllegalArgumentException
-  {
-    if (capacity < 0)
-    {
-      throw new IllegalArgumentException();
-    }
-
-    this.buffer = new byte[capacity];
-    this.length = 0;
-  }
-
-
-
-  /**
-   * Appends the provided byte to this byte string builder.
-   *
-   * @param b
-   *          The byte to be appended to this byte string builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(byte b)
-  {
-    ensureAdditionalCapacity(1);
-    buffer[length++] = b;
-    return this;
-  }
-
-
-
-  /**
-   * Appends the provided byte array to this byte string builder.
-   * <p>
-   * An invocation of the form:
-   *
-   * <pre>
-   * src.append(b)
-   * </pre>
-   *
-   * Behaves in exactly the same way as the invocation:
-   *
-   * <pre>
-   * src.append(b, 0, b.length);
-   * </pre>
-   *
-   * @param b
-   *          The byte array to be appended to this byte string
-   *          builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(byte[] b)
-  {
-    return append(b, 0, b.length);
-  }
-
-
-
-  /**
-   * Appends the provided byte array to this byte string builder.
-   *
-   * @param b
-   *          The byte array to be appended to this byte string
-   *          builder.
-   * @param offset
-   *          The offset of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length} .
-   * @param length
-   *          The length of the byte array to be used; must be
-   *          non-negative and no larger than {@code b.length -
-   *          offset}.
-   * @return This byte string builder.
-   * @throws IndexOutOfBoundsException
-   *           If {@code offset} is negative or if {@code length} is
-   *           negative or if {@code offset + length} is greater than
-   *           {@code b.length}.
-   */
-  public ByteStringBuilder append(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    ByteString.checkArrayBounds(b, offset, length);
-
-    if (length != 0)
-    {
-      ensureAdditionalCapacity(length);
-      System.arraycopy(b, offset, buffer, this.length, length);
-      this.length += length;
-    }
-
-    return this;
-  }
-
-
-
-  /**
-   * Appends the provided {@code ByteBuffer} to this byte string
-   * builder.
-   *
-   * @param buffer
-   *          The byte buffer to be appended to this byte string
-   *          builder.
-   * @param length
-   *          The number of bytes to be appended from {@code buffer}.
-   * @return This byte string builder.
-   * @throws IndexOutOfBoundsException
-   *           If {@code length} is less than zero or greater than
-   *           {@code buffer.remaining()}.
-   */
-  public ByteStringBuilder append(ByteBuffer buffer, int length)
-      throws IndexOutOfBoundsException
-  {
-    if ((length < 0) || (length > buffer.remaining()))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    if (length != 0)
-    {
-      ensureAdditionalCapacity(length);
-      buffer.get(this.buffer, this.length, length);
-      this.length += length;
-    }
-
-    return this;
-  }
-
-
-
-  /**
-   * Appends the provided {@link ByteSequence} to this byte string
-   * builder.
-   *
-   * @param bytes
-   *          The byte sequence to be appended to this byte string
-   *          builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(ByteSequence bytes)
-  {
-    return bytes.copyTo(this);
-  }
-
-
-
-  /**
-   * Appends the provided {@link ByteSequenceReader} to this byte
-   * string builder.
-   *
-   * @param reader
-   *          The byte sequence reader to be appended to this byte
-   *          string builder.
-   * @param length
-   *          The number of bytes to be appended from {@code reader}.
-   * @return This byte string builder.
-   * @throws IndexOutOfBoundsException
-   *           If {@code length} is less than zero or greater than
-   *           {@code reader.remaining()}.
-   */
-  public ByteStringBuilder append(
-      ByteSequenceReader reader, int length)
-      throws IndexOutOfBoundsException
-  {
-    if ((length < 0) || (length > reader.remaining()))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    if (length != 0)
-    {
-      ensureAdditionalCapacity(length);
-      reader.get(buffer, this.length, length);
-      this.length += length;
-    }
-
-    return this;
-  }
-
-
-
-  /**
-   * Appends the provided {@code InputStream} to this byte string
-   * builder.
-   *
-   * @param stream
-   *          The input stream to be appended to this byte string
-   *          builder.
-   * @param length
-   *          The maximum number of bytes to be appended from {@code
-   *          stream}.
-   * @return The number of bytes read from the input stream, or
-   *         {@code -1} if the end of the input stream has been
-   *         reached.
-   * @throws IndexOutOfBoundsException
-   *           If {@code length} is less than zero.
-   * @throws IOException
-   *           If an I/O error occurs.
-   */
-  public int append(InputStream stream, int length)
-      throws IndexOutOfBoundsException, IOException
-  {
-    if (length < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    ensureAdditionalCapacity(length);
-    int bytesRead = stream.read(buffer, this.length, length);
-    if (bytesRead > 0)
-    {
-      this.length += bytesRead;
-    }
-
-    return bytesRead;
-  }
-
-
-
-  /**
-   * Appends the provided {@code ReadableByteChannel} to this byte string
-   * builder.
-   *
-   * @param channel
-   *          The {@code ReadableByteChannel} to be appended to this byte string
-   *          builder.
-   * @param length
-   *          The maximum number of bytes to be appended from {@code channel}.
-   * @return The number of bytes read, possibly zero, or {@code -1} if the
-   *         channel has reached end-of-stream
-   * @throws IOException
-   *           If some other I/O error occurs
-   * @throws IndexOutOfBoundsException
-   *           If {@code length} is less than zero.
-   * @see ReadableByteChannel#read(ByteBuffer)
-   */
-  public int append(ReadableByteChannel channel, int length)
-      throws IndexOutOfBoundsException, IOException
-  {
-    if (length < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    ensureAdditionalCapacity(length);
-    int bytesRead = channel.read(ByteBuffer.wrap(buffer, this.length, length));
-    if (bytesRead > 0)
-    {
-      this.length += bytesRead;
-    }
-    return bytesRead;
-  }
-
-
-
-  /**
-   * Appends the big-endian encoded bytes of the provided short to
-   * this byte string builder.
-   *
-   * @param i
-   *          The short whose big-endian encoding is to be appended
-   *          to this byte string builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(short i)
-  {
-    ensureAdditionalCapacity(2);
-    for (int j = length + 1; j >= length; j--)
-    {
-      buffer[j] = (byte) (i & 0xFF);
-      i >>>= 8;
-    }
-    length += 2;
-    return this;
-  }
-
-
-
-  /**
-   * Appends the big-endian encoded bytes of the provided integer to
-   * this byte string builder.
-   *
-   * @param i
-   *          The integer whose big-endian encoding is to be appended
-   *          to this byte string builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(int i)
-  {
-    ensureAdditionalCapacity(4);
-    for (int j = length + 3; j >= length; j--)
-    {
-      buffer[j] = (byte) (i & 0xFF);
-      i >>>= 8;
-    }
-    length += 4;
-    return this;
-  }
-
-
-
-  /**
-   * Appends the big-endian encoded bytes of the provided long to this
-   * byte string builder.
-   *
-   * @param l
-   *          The long whose big-endian encoding is to be appended to
-   *          this byte string builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(long l)
-  {
-    ensureAdditionalCapacity(8);
-    for (int i = length + 7; i >= length; i--)
-    {
-      buffer[i] = (byte) (l & 0xFF);
-      l >>>= 8;
-    }
-    length += 8;
-    return this;
-  }
-
-
-
-  /**
-   * Appends the UTF-8 encoded bytes of the provided string to this
-   * byte string builder.
-   *
-   * @param s
-   *          The string whose UTF-8 encoding is to be appended to
-   *          this byte string builder.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder append(String s)
-  {
-    if (s == null)
-    {
-      return this;
-    }
-
-    // Assume that each char is 1 byte
-    int len = s.length();
-    ensureAdditionalCapacity(len);
-
-    for (int i = 0; i < len; i++)
-    {
-      char c = s.charAt(i);
-      byte b = (byte) (c & 0x0000007F);
-
-      if (c == b)
-      {
-        buffer[this.length + i] = b;
-      }
-      else
-      {
-        // There is a multi-byte char. Defer to JDK
-        try
-        {
-          return append(s.getBytes("UTF-8"));
-        }
-        catch (Exception e)
-        {
-          logger.traceException(e);
-          return append(s.getBytes());
-        }
-      }
-    }
-
-    // The 1 byte char assumption was correct
-    this.length += len;
-    return this;
-  }
-
-
-
-  /**
-   * Appends the ASN.1 BER length encoding representation of the
-   * provided integer to this byte string builder.
-   *
-   * @param length
-   *          The value to encode using the BER length encoding rules.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder appendBERLength(int length)
-  {
-    if ((length & 0x0000007F) == length)
-    {
-      ensureAdditionalCapacity(1);
-
-      buffer[this.length++] = ((byte) (length & 0xFF));
-    }
-    else if ((length & 0x000000FF) == length)
-    {
-      ensureAdditionalCapacity(2);
-
-      buffer[this.length++] = ((byte) 0x81);
-      buffer[this.length++] = ((byte) (length & 0xFF));
-    }
-    else if ((length & 0x0000FFFF) == length)
-    {
-      ensureAdditionalCapacity(3);
-
-      buffer[this.length++] = ((byte) 0x82);
-      buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
-      buffer[this.length++] = ((byte) (length & 0xFF));
-    }
-    else if ((length & 0x00FFFFFF) == length)
-    {
-      ensureAdditionalCapacity(4);
-
-      buffer[this.length++] = ((byte) 0x83);
-      buffer[this.length++] = ((byte) ((length >> 16) & 0xFF));
-      buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
-      buffer[this.length++] = ((byte) (length & 0xFF));
-    }
-    else
-    {
-      ensureAdditionalCapacity(5);
-
-      buffer[this.length++] = ((byte) 0x84);
-      buffer[this.length++] = ((byte) ((length >> 24) & 0xFF));
-      buffer[this.length++] = ((byte) ((length >> 16) & 0xFF));
-      buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
-      buffer[this.length++] = ((byte) (length & 0xFF));
-    }
-    return this;
-  }
-
-
-
-  /**
-   * Returns a {@link ByteSequenceReader} which can be used to
-   * incrementally read and decode data from this byte string builder.
-   * <p>
-   * <b>NOTE:</b> all concurrent updates to this byte string builder
-   * are supported with the exception of {@link #clear()}. Any
-   * invocations of {@link #clear()} must be accompanied by a
-   * subsequent call to {@code ByteSequenceReader.rewind()}.
-   *
-   * @return The {@link ByteSequenceReader} which can be used to
-   *         incrementally read and decode data from this byte string
-   *         builder.
-   * @see #clear()
-   */
-  public ByteSequenceReader asReader()
-  {
-    return new ByteSequenceReader(this);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte byteAt(int index) throws IndexOutOfBoundsException
-  {
-    if (index >= length || index < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    return buffer[index];
-  }
-
-
-
-  /**
-   * Returns the current capacity of this byte string builder. The capacity may
-   * increase as more data is appended.
-   *
-   * @return The current capacity of this byte string builder.
-   */
-  public int capacity()
-  {
-    return buffer.length;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int compareTo(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    ByteString.checkArrayBounds(b, offset, length);
-    return ByteString.compareTo(this.buffer, 0, this.length,
-        b, offset, length);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int compareTo(ByteSequence o)
-  {
-    if (this == o) return 0;
-    return -(o.compareTo(buffer, 0, length));
-  }
-
-
-
-  /**
-   * Sets the length of this byte string builder to zero.
-   * <p>
-   * <b>NOTE:</b> if this method is called, then {@code
-   * ByteSequenceReader.rewind()} must also be called on any
-   * associated byte sequence readers in order for them to remain
-   * valid.
-   *
-   * @return This byte string builder.
-   * @see #asReader()
-   */
-  public ByteStringBuilder clear()
-  {
-    length = 0;
-    return this;
-  }
-
-
-
-  /**
-   * Sets the length of this byte string builder to zero, and resets the
-   * capacity to the specified size.
-   * <p>
-   * <b>NOTE:</b> if this method is called, then
-   * {@code ByteSequenceReader.rewind()} must also be called on any associated
-   * byte sequence readers in order for them to remain valid.
-   *
-   * @param capacity
-   *          The new capacity.
-   * @return This byte string builder.
-   * @throws IllegalArgumentException
-   *           If the {@code capacity} is negative.
-   * @see #asReader()
-   */
-  public ByteStringBuilder clear(int capacity) throws IllegalArgumentException
-  {
-    if (capacity < 0)
-    {
-      throw new IllegalArgumentException();
-    }
-    if (capacity != buffer.length)
-    {
-      buffer = new byte[capacity];
-    }
-    length = 0;
-    return this;
-  }
-
-
-
-  /**
-   * Attempts to compress the data in this buffer into the given
-   * buffer. Note that if compression was not successful, then the
-   * destination buffer will remain unchanged.
-   *
-   * @param output
-   *          The destination buffer of compressed data.
-   * @param cryptoManager
-   *          The cryptoManager to use to compress the data.
-   * @return <code>true</code> if compression was successful or
-   *         <code>false</code> otherwise.
-   */
-  public boolean compress(ByteStringBuilder output,
-                          CryptoManager cryptoManager)
-  {
-    // Make sure the free space in the destination buffer is at least
-    // as big as this.
-    output.ensureAdditionalCapacity(length);
-
-    int compressedSize = cryptoManager.compress(buffer, 0, length,
-        output.buffer, output.length, output.buffer.length - output.length);
-
-    if (compressedSize != -1)
-    {
-      if (logger.isTraceEnabled())
-      {
-        logger.trace("Compression %d/%d%n", compressedSize,
-            length);
-      }
-
-      output.length += compressedSize;
-      return true;
-    }
-
-    return false;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] copyTo(byte[] b)
-  {
-    copyTo(b, 0);
-    return b;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] copyTo(byte[] b, int offset)
-      throws IndexOutOfBoundsException
-  {
-    if (offset < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    System.arraycopy(buffer, 0, b, offset, Math.min(length,
-        b.length - offset));
-    return b;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public ByteStringBuilder copyTo(ByteStringBuilder builder)
-  {
-    builder.append(buffer, 0, length);
-    return builder;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public OutputStream copyTo(OutputStream stream) throws IOException
-  {
-    stream.write(buffer, 0, length);
-    return stream;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int copyTo(WritableByteChannel channel) throws IOException
-  {
-    return channel.write(ByteBuffer.wrap(buffer, 0, length));
-  }
-
-
-
-  /**
-   * Ensures that the specified number of additional bytes will fit in
-   * this byte string builder and resizes it if necessary.
-   *
-   * @param size
-   *          The number of additional bytes.
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder ensureAdditionalCapacity(int size)
-  {
-    int newCount = length + size;
-    if (newCount > buffer.length)
-    {
-      byte[] newbuffer = new byte[Math.max(buffer.length << 1, newCount)];
-      System.arraycopy(buffer, 0, newbuffer, 0, length);
-      buffer = newbuffer;
-    }
-    return this;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean equals(byte[] b, int offset, int length)
-      throws IndexOutOfBoundsException
-  {
-    ByteString.checkArrayBounds(b, offset, length);
-    return ByteString.equals(this.buffer, 0, this.length,
-        b, offset, length);
-  }
-
-
-
-  /**
-   * Indicates whether the provided object is equal to this byte
-   * string builder. In order for it to be considered equal, the
-   * provided object must be a byte sequence containing the same bytes
-   * in the same order.
-   *
-   * @param o
-   *          The object for which to make the determination.
-   * @return {@code true} if the provided object is a byte sequence
-   *         whose content is equal to that of this byte string
-   *         builder, or {@code false} if not.
-   */
-  @Override
-  public boolean equals(Object o)
-  {
-    if (this == o)
-    {
-      return true;
-    }
-    else if (o instanceof ByteSequence)
-    {
-      ByteSequence other = (ByteSequence) o;
-      return other.equals(buffer, 0, length);
-    }
-    else
-    {
-      return false;
-    }
-  }
-
-
-
-  /**
-   * Returns the byte array that backs this byte string builder.
-   * Modifications to this byte string builder's content may cause the
-   * returned array's content to be modified, and vice versa.
-   * <p>
-   * Note that the length of the returned array is only guaranteed to
-   * be the same as the length of this byte string builder immediately
-   * after a call to {@link #trimToSize()}.
-   * <p>
-   * In addition, subsequent modifications to this byte string builder
-   * may cause the backing byte array to be reallocated thus
-   * decoupling the returned byte array from this byte string builder.
-   *
-   * @return The byte array that backs this byte string builder.
-   */
-  public byte[] getBackingArray()
-  {
-    return buffer;
-  }
-
-
-
-  /**
-   * Returns a hash code for this byte string builder. It will be the
-   * sum of all of the bytes contained in the byte string builder.
-   * <p>
-   * <b>NOTE:</b> subsequent changes to this byte string builder will
-   * invalidate the returned hash code.
-   *
-   * @return A hash code for this byte string builder.
-   */
-  @Override
-  public int hashCode()
-  {
-    return ByteString.hashCode(buffer, 0, length);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public int length()
-  {
-    return length;
-  }
-
-
-
-  /**
-   * Sets the byte value at the specified index.
-   * <p>
-   * An index ranges from zero to {@code length() - 1}. The first byte value of
-   * the sequence is at index zero, the next at index one, and so on, as for
-   * array indexing.
-   *
-   * @param index
-   *          The index of the byte to be set.
-   * @param b
-   *          The new byte value.
-   * @return This byte string builder.
-   * @throws IndexOutOfBoundsException
-   *           If the index argument is negative or not less than length().
-   */
-  public ByteStringBuilder setByteAt(int index, byte b)
-      throws IndexOutOfBoundsException
-  {
-    if (index >= length || index < 0)
-    {
-      throw new IndexOutOfBoundsException();
-    }
-    buffer[index] = b;
-    return this;
-  }
-
-
-
-  /**
-   * Returns a new byte sequence that is a subsequence of this byte
-   * sequence.
-   * <p>
-   * The subsequence starts with the byte value at the specified
-   * {@code start} index and ends with the byte value at index {@code
-   * end - 1}. The length (in bytes) of the returned sequence is
-   * {@code end - start}, so if {@code start == end} then an empty
-   * sequence is returned.
-   * <p>
-   * <b>NOTE:</b> the returned sub-sequence will be robust against all
-   * updates to the byte string builder except for invocations of the
-   * method {@link #clear()}. If a permanent immutable byte sequence
-   * is required then callers should invoke {@code toByteString()} on
-   * the returned byte sequence.
-   *
-   * @param start
-   *          The start index, inclusive.
-   * @param end
-   *          The end index, exclusive.
-   * @return The newly created byte subsequence.
-   * @throws IndexOutOfBoundsException
-   *           If {@code start} or {@code end} are negative, if
-   *           {@code end} is greater than {@code length()}, or if
-   *           {@code start} is greater than {@code end}.
-   */
-  public ByteSequence subSequence(int start, int end)
-      throws IndexOutOfBoundsException
-  {
-    if ((start < 0) || (start > end) || (end > length))
-    {
-      throw new IndexOutOfBoundsException();
-    }
-
-    return new SubSequence(start, end - start);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public byte[] toByteArray()
-  {
-    return copyTo(new byte[length]);
-  }
-
-
-
-  /**
-   * Returns the {@link ByteString} representation of this byte string
-   * builder. Subsequent changes to this byte string builder will not
-   * modify the returned {@link ByteString}.
-   *
-   * @return The {@link ByteString} representation of this byte
-   *         sequence.
-   */
-  public ByteString toByteString()
-  {
-    byte[] b = new byte[length];
-    System.arraycopy(buffer, 0, b, 0, length);
-    return ByteString.wrap(b);
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String toString()
-  {
-    return ByteString.toString(buffer, 0, length);
-  }
-
-
-
-  /**
-   * Attempts to reduce storage used for this byte string builder. If
-   * the buffer is larger than necessary to hold its current sequence
-   * of bytes, then it may be resized to become more space efficient.
-   *
-   * @return This byte string builder.
-   */
-  public ByteStringBuilder trimToSize()
-  {
-    if (buffer.length > length)
-    {
-      byte[] newBuffer = new byte[length];
-      System.arraycopy(buffer, 0, newBuffer, 0, length);
-      buffer = newBuffer;
-    }
-    return this;
-  }
-
-
-
-  /**
-   * Attempts to uncompress the data in this buffer into the given
-   * destination buffer. Note that if uncompression was not
-   * successful, then the destination buffer will remain unchanged.
-   *
-   * @param output
-   *          The destination buffer of compressed data.
-   * @param cryptoManager
-   *          The cryptoManager to use to compress the data.
-   * @param uncompressedSize
-   *          The uncompressed size of the data if known or 0
-   *          otherwise.
-   * @return <code>true</code> if decompression was successful or
-   *         <code>false</code> otherwise.
-   * @throws java.util.zip.DataFormatException
-   *           If a problem occurs while attempting to uncompress the
-   *           data.
-   */
-  public boolean uncompress(ByteStringBuilder output,
-      CryptoManager cryptoManager, int uncompressedSize)
-      throws DataFormatException
-  {
-    // Resize destination buffer if a uncompressed size was provided.
-    if (uncompressedSize > 0)
-      output.ensureAdditionalCapacity(uncompressedSize);
-
-    int decompressResult = cryptoManager.uncompress(buffer, 0, length,
-        output.buffer, output.length, output.buffer.length - output.length);
-
-    if (decompressResult < 0)
-    {
-      // The destination buffer wasn't big enough. Resize and retry.
-      output.ensureAdditionalCapacity(-(decompressResult));
-      decompressResult = cryptoManager.uncompress(buffer, 0, length,
-          output.buffer, output.length, output.buffer.length - output.length);
-    }
-
-    if (decompressResult >= 0)
-    {
-      // It was successful.
-      output.length += decompressResult;
-      return true;
-    }
-
-    // Still unsuccessful. Give up.
-    return false;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public ByteBuffer asByteBuffer()
-  {
-    return ByteBuffer.wrap(buffer, 0, length);
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReaderTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReaderTestCase.java
deleted file mode 100644
index 48cc414..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReaderTestCase.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- */
-package org.opends.server.protocols.asn1;
-
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.channels.Channels;
-import java.nio.channels.IllegalBlockingModeException;
-
-/**
- * Test class for ASN1ByteChannelReader
- */
-public class ASN1ByteChannelReaderTestCase extends ASN1ReaderTestCase
-{
-  @Override
-  ASN1Reader getReader(byte[] b, int maxElementSize) throws IOException
-  {
-    ByteArrayInputStream inStream = new ByteArrayInputStream(b);
-    ASN1ByteChannelReader reader =
-        new ASN1ByteChannelReader(Channels.newChannel(inStream),
-            b.length, maxElementSize);
-    reader.processChannelData();
-    return reader;
-  }
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsNull()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsNull();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsInteger()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsInteger();
-  }
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsEnumerated()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsEnumerated();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsBoolean()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsBoolean();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions  = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsOctetString()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsOctetString();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeShortArrayAsSequence()
-      throws Exception
-  {
-    super.testDecodeShortArrayAsSequence();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that has less bytes than indicated by the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeLengthMismatchArrayAsBoolean()
-      throws Exception
-  {
-    super.testDecodeLengthMismatchArrayAsBoolean();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a length mismatch.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeLengthMismatchArrayAsInteger()
-      throws Exception
-  {
-    super.testDecodeLengthMismatchArrayAsInteger();
-  }
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a length mismatch.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeLengthMismatchArrayAsEnumerated()
-      throws Exception
-  {
-    super.testDecodeLengthMismatchArrayAsEnumerated();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using an array whose actual length doesn't match with the decoded length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions  = { IllegalBlockingModeException.class })
-  public void testDecodeLengthMismatchArrayAsOctetString()
-      throws Exception
-  {
-    super.testDecodeLengthMismatchArrayAsOctetString();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that doesn't contain a full length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsBoolean()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsBoolean();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a truncated length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsInteger()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsInteger();
-  }
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a truncated length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsEnumerated()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsEnumerated();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an array with a truncated length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsNull()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsNull();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using an array that doesn't fully contain the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions  = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsOctetString()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsOctetString();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with an array that doesn't fully describe the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeTruncatedLengthArrayAsSequence()
-      throws Exception
-  {
-    super.testDecodeTruncatedLengthArrayAsSequence();
-  }
-
-  /**
-   * Tests to make sure a premature EOF while reading a sub sequence can be
-   * detected.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testDecodeSequencePrematureEof()
-      throws Exception
-  {
-    super.testDecodeSequencePrematureEof();
-  }
-
-  /**
-   * Tests the <CODE>skipElement</CODE> method.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Override
-  @Test(expectedExceptions = { IllegalBlockingModeException.class })
-  public void testSkipElementIncompleteRead()
-      throws Exception
-  {
-    super.testSkipElementIncompleteRead();
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReaderTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReaderTestCase.java
deleted file mode 100644
index 3d4889b..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReaderTestCase.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-import org.forgerock.opendj.ldap.ByteSequenceReader;
-import org.forgerock.opendj.ldap.ByteString;
-
-/**
- * Test class for ASN1ByteSequenceReaderTestCase
- */
-public class ASN1ByteSequenceReaderTestCase extends ASN1ReaderTestCase
-{
-  ASN1Reader getReader(byte[] b, int maxElementSize)
-  {
-    ByteSequenceReader reader = ByteString.wrap(b).asReader();
-    return new ASN1ByteSequenceReader(reader, maxElementSize);
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReaderTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReaderTestCase.java
deleted file mode 100644
index 4ead8e2..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReaderTestCase.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- */
-package org.opends.server.protocols.asn1;
-
-import java.io.ByteArrayInputStream;
-
-/**
- * Test class for ASN1InputStreamReader
- */
-public class ASN1InputStreamReaderTestCase extends ASN1ReaderTestCase
-{
-  ASN1Reader getReader(byte[] b, int maxElementSize)
-  {
-    ByteArrayInputStream inStream = new ByteArrayInputStream(b);
-    return new ASN1InputStreamReader(inStream, maxElementSize);
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriterTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriterTestCase.java
deleted file mode 100644
index 5b8eb13..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriterTestCase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
- */
-package org.opends.server.protocols.asn1;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-/**
- * Test class for ASN1OutputStreamWriter
- */
-public class ASN1OutputStreamWriterTestCase extends ASN1WriterTestCase
-{
-  private ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-  private ASN1Writer writer = ASN1.getWriter(outStream);
-
-  @Override
-  ASN1Writer getWriter()
-  {
-    outStream.reset();
-    return writer;
-  }
-
-  @Override
-  ASN1Reader getReader(byte[] encodedBytes)
-  {
-    ByteArrayInputStream inStream =
-        new ByteArrayInputStream(encodedBytes);
-    return new ASN1InputStreamReader(inStream, 0);
-  }
-
-  @Override
-  byte[] getEncodedBytes()
-  {
-    return outStream.toByteArray();
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ReaderTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ReaderTestCase.java
deleted file mode 100644
index ab370fb..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ReaderTestCase.java
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-
-import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
-import static org.testng.Assert.*;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.DirectoryServerTestCase;
-
-import java.io.IOException;
-
-/**
- * An abstract base class for all ASN1Reader test cases.
- */
-@Test(groups = { "precommit", "asn1" }, sequential = true)
-public abstract class ASN1ReaderTestCase extends DirectoryServerTestCase
-{
-
-  /**
-   * Retrieves the set of byte array values that may be used for testing.
-   *
-   * @return  The set of byte array values that may be used for testing.
-   */
-  @DataProvider(name = "byteValues")
-  public Object[][] getByteValues()
-  {
-    Object[][] array = new Object[256][1];
-    for (int i=0; i < 256; i++)
-    {
-      array[i] = new Object[] { new byte[] { (byte) (i & 0xFF) } };
-    }
-
-    return array;
-  }
-
-
-
-  /**
-   * Create byte arrays with encoded ASN.1 elements to test decoding them as
-   * octet strings.
-   *
-   * @return  A list of byte arrays with encoded ASN.1 elements that can be
-   *          decoded as octet strings.
-   */
-  @DataProvider(name = "elementArrays")
-  public Object[][] getElementArrays()
-  {
-    return new Object[][]
-        {
-            new Object[] { new byte[] { 0x04, 0x00 } },
-            new Object[] { new byte[] { (byte) 0x50, 0x00 } },
-            new Object[] { new byte[] { 0x04, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F } },
-            new Object[] { new byte[] { 0x01, 0x01, 0x00 } },
-            new Object[] { new byte[] { 0x01, 0x01, (byte) 0xFF } },
-            new Object[] { new byte[] { 0x0A, 0x01, 0x00 } },
-            new Object[] { new byte[] { 0x0A, 0x01, 0x01 } },
-            new Object[] { new byte[] { 0x0A, 0x01, 0x7F } },
-            new Object[] { new byte[] { 0x0A, 0x01, (byte) 0x80 } },
-            new Object[] { new byte[] { 0x0A, 0x01, (byte) 0xFF } },
-            new Object[] { new byte[] { 0x0A, 0x02, 0x01, 0x00 } },
-            new Object[] { new byte[] { 0x02, 0x01, 0x00 } },
-            new Object[] { new byte[] { 0x02, 0x01, 0x01 } },
-            new Object[] { new byte[] { 0x02, 0x01, 0x7F } },
-            new Object[] { new byte[] { 0x02, 0x02, 0x00, (byte) 0x80 } },
-            new Object[] { new byte[] { 0x02, 0x02, 0x00, (byte) 0xFF } },
-            new Object[] { new byte[] { 0x02, 0x02, 0x01, 0x00 } },
-            new Object[] { new byte[] { 0x05, 0x00 } },
-            new Object[] { new byte[] { 0x30, 0x00 } },
-            new Object[] { new byte[] { 0x31, 0x00 } },
-            new Object[] { new byte[] { 0x05, (byte) 0x81, 0x00 } },
-            new Object[] { new byte[] { 0x05, (byte) 0x82, 0x00, 0x00 } },
-            new Object[] { new byte[] { 0x05, (byte) 0x83, 0x00, 0x00, 0x00 } },
-            new Object[] { new byte[] { 0x05, (byte) 0x84, 0x00, 0x00, 0x00, 0x00 } },
-        };
-  }
-
-  /**
-   * Gets the reader to be use for the unit tests.
-   *
-   * @param b
-   *          The array of bytes to be read.
-   * @param maxElementSize
-   *          The max element size.
-   * @return The reader to be use for the unit tests.
-   * @throws IOException
-   *           In an unexpected IO exception occurred.
-   */
-  abstract ASN1Reader getReader(byte[] b, int maxElementSize)
-      throws IOException;
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[1];
-    getReader(b, 0).readNull();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an array with a long length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x05, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x00 };
-    getReader(b, 0).readNull();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an array with a truncated length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x05, (byte) 0x82, 0x00 };
-    getReader(b, 0).readNull();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an arry with a nonzero length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeNonZeroLengthArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x05, 0x01, 0x00 };
-    getReader(b, 0).readNull();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an arry with a zero length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test()
-  public void testDecodeZeroLengthArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x05, 0x00 };
-    getReader(b, 0).readNull();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsNull</CODE> method that takes a byte array argument
-   * with an arry with a zero length that takes multiple bytes to encode.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test()
-  public void testDecodeExtendedZeroLengthArrayAsNull()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x05, (byte) 0x81, 0x00 };
-    getReader(b, 0).readNull();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortArrayAsInteger()
-      throws Exception
-  {
-    byte[] b = new byte[0];
-    getReader(b, 0).readInteger();
-  }
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortArrayAsEnumerated()
-      throws Exception
-  {
-    byte[] b = new byte[0];
-    getReader(b, 0).readEnumerated();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a long length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsInteger()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 };
-    getReader(b, 0).readInteger();
-  }
-
-
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a long length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsEnumerated()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 };
-    getReader(b, 0).readEnumerated();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a truncated length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsInteger()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x82, 0x00 };
-    getReader(b, 0).readInteger();
-  }
-
-
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a truncated length array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsEnumerated()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x82, 0x00 };
-    getReader(b, 0).readEnumerated();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
-   * a length mismatch.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLengthMismatchArrayAsInteger()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x81, 0x01 };
-    getReader(b, 0).readInteger();
-  }
-
-  /**
-   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
-   * a length mismatch.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLengthMismatchArrayAsEnumerated()
-      throws Exception
-  {
-    byte[] b = { 0x02, (byte) 0x81, 0x01 };
-    getReader(b, 0).readEnumerated();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with valid arrays.
-   *
-   * @param  b  The byte array to use for the element values.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "byteValues")
-  public void testDecodeValidArrayAsBoolean(byte[] b)
-      throws Exception
-  {
-    // First, test with the standard Boolean type.
-    byte[] elementArray = new byte[] { 0x01, 0x01, b[0] };
-    assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00));
-
-
-    // Next, test with a nonstandard Boolean type.
-    elementArray[0] = (byte) 0x50;
-    assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00));
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with valid arrays using extended lengths.
-   *
-   * @param  b  The byte array to use for the element values.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "byteValues")
-  public void testDecodeValidExtendedArrayAsBoolean(byte[] b)
-      throws Exception
-  {
-    // First, test with the standard Boolean type.
-    byte[] elementArray = new byte[] { 0x01, (byte) 0x81, 0x01, b[0] };
-    assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00));
-
-
-    // Next, test with a nonstandard Boolean type.
-    elementArray[0] = (byte) 0x50;
-    assertEquals(getReader(elementArray, 0).readBoolean(), (b[0] != 0x00));
-  }
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = new byte[1];
-    getReader(b, 0).readBoolean();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that takes too many bytes to expressthe length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = { 0x01, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 };
-    getReader(b, 0).readBoolean();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that doesn't contain a full length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = { 0x01, (byte) 0x82, 0x00 };
-    getReader(b, 0).readBoolean();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that has less bytes than indicated by the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLengthMismatchArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = { 0x01, 0x01 };
-    getReader(b, 0).readBoolean();
-  }
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that has an invalid number of bytes in the value.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortValueArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = { 0x01, 0x00, 0x00, 0x00 };
-    getReader(b, 0).readBoolean();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
-   * argument with an array that has an invalid number of bytes in the value.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongValueArrayAsBoolean()
-      throws Exception
-  {
-    byte[] b = { 0x01, 0x02, 0x00, 0x00 };
-    getReader(b, 0).readBoolean();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using a valid array.
-   *
-   * @param  b  The byte array to decode.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "elementArrays")
-  public void testDecodeValidArrayAsOctetString(byte[] b)
-      throws Exception
-  {
-    ByteStringBuilder bsb = new ByteStringBuilder();
-    bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    bsb.appendBERLength(b.length);
-    bsb.append(b);
-
-    assertEquals(getReader(bsb.toByteArray(), 0).readOctetString(),
-        ByteString.wrap(b));
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetStringAsString</CODE> method that takes a
-   * byte array using a valid array.
-   *
-   * @param  b  The byte array to decode.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "elementArrays")
-  public void testDecodeValidArrayAsOctetStringAsString(byte[] b)
-      throws Exception
-  {
-    ByteStringBuilder bsb = new ByteStringBuilder();
-    bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    bsb.appendBERLength(b.length);
-    bsb.append(b);
-
-    assertEquals(getReader(bsb.toByteArray(), 0).readOctetStringAsString(),
-        new String(b, "UTF-8"));
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetStringAsString</CODE> method that takes a
-   * byte array using a valid array.
-   *
-   * @param  b  The byte array to decode.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "elementArrays")
-  public void testDecodeValidArrayAsOctetStringAsStringCharSet(byte[] b)
-      throws Exception
-  {
-    ByteStringBuilder bsb = new ByteStringBuilder();
-    bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    bsb.appendBERLength(b.length);
-    bsb.append(b);
-
-    assertEquals(
-        getReader(bsb.toByteArray(), 0).readOctetStringAsString("UTF-8"),
-        new String(b, "UTF-8"));
-  }
-
-  /**
-   * Tests the <CODE>decodeAsOctetStringBuilder</CODE> method that takes a
-   * byte array using a valid array.
-   *
-   * @param  b  The byte array to decode.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "elementArrays")
-  public void testDecodeValidArrayAsOctetStringBuilder(byte[] b)
-      throws Exception
-  {
-    ByteStringBuilder bsb = new ByteStringBuilder();
-    bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    bsb.appendBERLength(b.length);
-    bsb.append(b);
-
-    ByteStringBuilder bsb2 = new ByteStringBuilder();
-    getReader(bsb.toByteArray(), 0).readOctetString(bsb2);
-    assertEquals(bsb2.toByteString(), ByteString.wrap(b));
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions  = { ASN1Exception.class })
-  public void testDecodeShortArrayAsOctetString()
-      throws Exception
-  {
-    byte[] b = new byte[1];
-    getReader(b, 0).readOctetString();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using an array that indicates it takes more than four bytes to encode the
-   * length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions  = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsOctetString()
-      throws Exception
-  {
-    byte[] b = { 0x04, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x00 };
-    getReader(b, 0).readOctetString();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using an array that doesn't fully contain the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions  = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsOctetString()
-      throws Exception
-  {
-    byte[] b = { 0x04, (byte) 0x82, 0x00 };
-    getReader(b, 0).readOctetString();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsOctetString</CODE> method that takes a byte array
-   * using an array whose actual length doesn't match with the decoded length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions  = { ASN1Exception.class })
-  public void testDecodeLengthMismatchArrayAsOctetString()
-      throws Exception
-  {
-    byte[] b = { 0x04, 0x02, 0x00 };
-    getReader(b, 0).readOctetString();
-  }
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with valid arrays.
-   *
-   * @param  encodedElements  Byte arrays that may be used as valid values for
-   *                          encoded elements.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(dataProvider = "elementArrays")
-  public void testDecodeValidArrayAsSequence(byte[] encodedElements)
-      throws Exception
-  {
-    ByteStringBuilder bsb = new ByteStringBuilder();
-    bsb.append(ASN1Constants.UNIVERSAL_SEQUENCE_TYPE);
-    bsb.appendBERLength(encodedElements.length + 2);
-    bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    bsb.appendBERLength(encodedElements.length);
-    bsb.append(encodedElements);
-
-    ASN1Reader reader = getReader(bsb.toByteArray(), 0);
-    assertEquals(reader.peekLength(), encodedElements.length + 2);
-    reader.readStartSequence();
-    assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
-    assertEquals(reader.peekLength(), encodedElements.length);
-    reader.readOctetString().equals(ByteString.wrap(encodedElements));
-    reader.readEndSequence();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with a short array.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeShortArrayAsSequence()
-      throws Exception
-  {
-    byte[] b = new byte[1];
-    getReader(b, 0).readStartSequence();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with an array that takes too many bytes to encode the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeLongLengthArrayAsSequence()
-      throws Exception
-  {
-    byte[] b = { 0x30, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x00 };
-    getReader(b, 0).readStartSequence();
-  }
-
-
-
-  /**
-   * Tests the <CODE>decodeAsSequence</CODE> method that takes a byte array
-   * argument with an array that doesn't fully describe the length.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeTruncatedLengthArrayAsSequence()
-      throws Exception
-  {
-    byte[] b = { 0x30, (byte) 0x82, 0x00 };
-    getReader(b, 0).readStartSequence();
-  }
-
-
-
-  /**
-   * Tests the <CODE>readOctetString</CODE> method when the max element size
-   * is exceeded.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeOctetStringExceedMaxSize()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x04, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
-    getReader(b, 3).readOctetString();
-  }
-
-  /**
-   * Tests the <CODE>readOctetString</CODE> method when the max element size
-   * is exceeded.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeSequenceExceedMaxSize()
-      throws Exception
-  {
-    byte[] b = new byte[] { 0x30, 0x07, 0x04, 0x05, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
-    getReader(b, 3).readOctetString();
-  }
-
-  /**
-   * Tests to make sure a premature EOF while reading a sub sequence can be
-   * detected.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testDecodeSequencePrematureEof()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x09, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00 };
-    ASN1Reader reader = getReader(b, 0);
-    reader.readStartSequence();
-    while(reader.hasNextElement())
-    {
-      reader.readBoolean();
-    }
-    reader.readEndSequence();
-  }
-
-  /**
-   * Tests to make sure trailing components are ignored if not used.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test
-  public void testDecodeSequenceIncompleteRead()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 };
-    ASN1Reader reader = getReader(b, 0);
-    reader.readStartSequence();
-    reader.readEndSequence();
-    assertFalse(reader.readBoolean());
-  }
-
-  /**
-   * Tests the <CODE>skipElement</CODE> method.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testSkipElementIncompleteRead()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x09, 0x01, 0x01, 0x00, 0x01, 0x02 };
-    ASN1Reader reader = getReader(b, 0);
-    reader.readStartSequence();
-    reader.readBoolean();
-    reader.skipElement();
-    reader.readEndSequence();
-  }
-
-  /**
-   * Tests the <CODE>skipElement</CODE> method.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test
-  public void testSkipElement()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x09, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01,
-        0x02, 0x01, 0x02 };
-    ASN1Reader reader = getReader(b, 0);
-    reader.readStartSequence();
-    reader.readInteger();
-    reader.skipElement();
-    assertEquals(reader.readInteger(), 2);
-    reader.readEndSequence();
-  }
-
-  /**
-   * Tests the <CODE>elementAvailable</CODE> method.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test
-  public void testElementAvailable()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x06, 0x02, 0x01, 0x00, 0x02 };
-    ASN1Reader reader = getReader(b, 0);
-    assertFalse(reader.elementAvailable());
-
-    b = new byte[] { 0x30, 0x03, 0x02, 0x01, 0x00 };
-    reader = getReader(b, 0);
-    assertTrue(reader.elementAvailable());
-    reader.readStartSequence();
-    assertTrue(reader.elementAvailable());
-    reader.readInteger();
-    assertFalse(reader.elementAvailable());
-  }
-
-  /**
-   * Tests the <CODE>hasNextElement</CODE> method.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test
-  public void testHasNextElement()
-      throws Exception
-  {
-    // An ASN.1 sequence of booleans missing one boolean element at the end
-    byte[] b = new byte[] { 0x30, 0x06, 0x02, 0x01, 0x00, 0x02, 0x00, 0x03 };
-    ASN1Reader reader = getReader(b, 0);
-    assertTrue(reader.hasNextElement());
-    reader.readStartSequence();
-    assertTrue(reader.hasNextElement());
-    reader.readInteger();
-    assertTrue(reader.hasNextElement());
-
-    b = new byte[] { 0x30, 0x03, 0x02, 0x01, 0x00 };
-    reader = getReader(b, 0);
-    assertTrue(reader.hasNextElement());
-    reader.readStartSequence();
-    assertTrue(reader.hasNextElement());
-    reader.readInteger();
-    assertFalse(reader.hasNextElement());
-  }
-
-  /**
-   * Tests the <CODE>readEndSequence</CODE> method without first calling
-   * readStartSequence.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test(expectedExceptions = { ASN1Exception.class })
-  public void testReadEndSequenceNoStartSequence()
-      throws Exception
-  {
-    byte[] b = { 0x30, 0x01, 0x00 };
-    getReader(b, 0).readEndSequence();
-  }
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1WriterTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1WriterTestCase.java
deleted file mode 100644
index b72cd75..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1WriterTestCase.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.protocols.asn1;
-
-
-import org.opends.server.DirectoryServerTestCase;
-import static org.opends.server.protocols.asn1.ASN1Constants.*;
-import org.opends.server.util.StaticUtils;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
-
-import java.io.IOException;
-
-/**
- * An abstract base class for all ASN1Writer test cases.
- */
-@Test(groups = { "precommit", "asn1" }, sequential = true)
-public abstract class ASN1WriterTestCase extends DirectoryServerTestCase {
-
-  // Create an array with all of the valid single-byte types.  We don't
-  // support multi-byte types, so this should be a comprehensive data set.
-  private byte[] testTypes = new byte[0xFF];
-  {
-    for (int i=0x00; i < 0xFF; i++)
-    {
-      testTypes[i] = (byte) (i & 0xFF);
-    }
-  }
-
-
-  /**
-   * Retrieves the set of boolean values that may be used for testing.
-   *
-   * @return  The set of boolean values that may be used for testing.
-   */
-  @DataProvider(name = "booleanValues")
-  public Object[][] getBooleanValues()
-  {
-    return new Object[][]
-        {
-            new Object[] { false },
-            new Object[] { true }
-        };
-  }
-
-  /**
-   * Retrieves the set of int values that should be used for testing.
-   *
-   * @return  The set of int values that should be used for testing.
-   */
-  @DataProvider(name = "intValues")
-  public Object[][] getIntValues()
-  {
-    return new Object[][]
-        {
-            new Object[] { 0x00000000, 1 },
-            new Object[] { 0x00000001, 1 },
-            new Object[] { 0x0000000F, 1 },
-            new Object[] { 0x00000010, 1 },
-            new Object[] { 0x0000007F, 1 },
-            new Object[] { 0x00000080, 2 },
-            new Object[] { 0x000000FF, 2 },
-            new Object[] { 0x00000100, 2 },
-            new Object[] { 0x00000FFF, 2 },
-            new Object[] { 0x00001000, 2 },
-            new Object[] { 0x0000FFFF, 3 },
-            new Object[] { 0x00010000, 3 },
-            new Object[] { 0x000FFFFF, 3 },
-            new Object[] { 0x00100000, 3 },
-            new Object[] { 0x00FFFFFF, 4 },
-            new Object[] { 0x01000000, 4 },
-            new Object[] { 0x0FFFFFFF, 4 },
-            new Object[] { 0x10000000, 4 },
-            new Object[] { 0x7FFFFFFF, 4 },
-            new Object[] { -0x00000001, 1 },
-            new Object[] { -0x0000000F, 1 },
-            new Object[] { -0x00000010, 1 },
-            new Object[] { -0x0000007F, 1 },
-            new Object[] { -0x00000080, 1 },
-            new Object[] { -0x000000FF, 2 },
-            new Object[] { -0x00000100, 2 },
-            new Object[] { -0x00000FFF, 2 },
-            new Object[] { -0x00001000, 2 },
-            new Object[] { -0x0000FFFF, 3 },
-            new Object[] { -0x00010000, 3 },
-            new Object[] { -0x000FFFFF, 3 },
-            new Object[] { -0x00100000, 3 },
-            new Object[] { -0x00FFFFFF, 4 },
-            new Object[] { -0x01000000, 4 },
-            new Object[] { -0x0FFFFFFF, 4 },
-            new Object[] { -0x10000000, 4 },
-            new Object[] { -0x7FFFFFFF, 4 },
-            new Object[] { 0x80000000, 4 }
-        };
-  }
-
-  /**
-   * Retrieves the set of long values that should be used for testing.
-   *
-   * @return  The set of long values that should be used for testing.
-   */
-  @DataProvider(name = "longValues")
-  public Object[][] getLongValues()
-  {
-    return new Object[][]
-        {
-            new Object[] { 0x0000000000000000L, 1 },
-            new Object[] { 0x0000000000000001L, 1 },
-            new Object[] { 0x000000000000007FL, 1 },
-            new Object[] { 0x0000000000000080L, 2 },
-            new Object[] { 0x00000000000000FFL, 2 },
-            new Object[] { 0x0000000000000100L, 2 },
-            new Object[] { 0x000000000000FFFFL, 3 },
-            new Object[] { 0x0000000000010000L, 3 },
-            new Object[] { 0x0000000000FFFFFFL, 4 },
-            new Object[] { 0x0000000001000000L, 4 },
-            new Object[] { 0x00000000FFFFFFFFL, 5 },
-            new Object[] { 0x0000000100000000L, 5 },
-            new Object[] { 0x000000FFFFFFFFFFL, 6 },
-            new Object[] { 0x0000010000000000L, 6 },
-            new Object[] { 0x0000FFFFFFFFFFFFL, 7 },
-            new Object[] { 0x0001000000000000L, 7 },
-            new Object[] { 0x00FFFFFFFFFFFFFFL, 8 },
-            new Object[] { 0x0100000000000000L, 8 },
-            new Object[] { 0x7FFFFFFFFFFFFFFFL, 8 },
-            new Object[] { -0x0000000000000001L, 1 },
-            new Object[] { -0x000000000000007FL, 1 },
-            new Object[] { -0x0000000000000080L, 1 },
-            new Object[] { -0x00000000000000FFL, 2 },
-            new Object[] { -0x0000000000000100L, 2 },
-            new Object[] { -0x000000000000FFFFL, 3 },
-            new Object[] { -0x0000000000010000L, 3 },
-            new Object[] { -0x0000000000FFFFFFL, 4 },
-            new Object[] { -0x0000000001000000L, 4 },
-            new Object[] { -0x00000000FFFFFFFFL, 5 },
-            new Object[] { -0x0000000100000000L, 5 },
-            new Object[] { -0x000000FFFFFFFFFFL, 6 },
-            new Object[] { -0x0000010000000000L, 6 },
-            new Object[] { -0x0000FFFFFFFFFFFFL, 7 },
-            new Object[] { -0x0001000000000000L, 7 },
-            new Object[] { -0x00FFFFFFFFFFFFFFL, 8 },
-            new Object[] { -0x0100000000000000L, 8 },
-            new Object[] { -0x7FFFFFFFFFFFFFFFL, 8 },
-            new Object[] { 0x8000000000000000L, 8 }
-        };
-  }
-
-  /**
-   * Create byte arrays to use for element values.
-   *
-   * @return  A list of byte arrays that can be used as element values.
-   */
-  @DataProvider(name = "binaryValues")
-  public Object[][] getBinaryValues()
-  {
-    // NOTE -- Don't make these arrays too big since they consume memory.
-    return new Object[][]
-        {
-            new Object[] { new byte[0x00] },    // The zero-byte value
-            new Object[] { new byte[0x01] },    // The single-byte value
-            new Object[] { new byte[0x7F] },    // The largest 1-byte length encoding
-            new Object[] { new byte[0x80] },    // The smallest 2-byte length encoding
-            new Object[] { new byte[0xFF] },    // The largest 2-byte length encoding
-            new Object[] { new byte[0x0100] },  // The smallest 3-byte length encoding
-            new Object[] { new byte[0xFFFF] },  // The largest 3-byte length encoding
-            new Object[] { new byte[0x010000] } // The smallest 4-byte length encoding
-        };
-  }
-
-  /**
-   * Create strings to use for element values.
-   *
-   * @return  A list of strings that can be used as element values.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @DataProvider(name = "stringValues")
-  public Object[][] getStringValues()
-      throws Exception
-  {
-    return new Object[][]
-        {
-            new Object[] { null },
-            new Object[] { "" },
-            new Object[] { "\u0000" },
-            new Object[] { "\t" },
-            new Object[] { "\n" },
-            new Object[] { "\r\n" },
-            new Object[] { " " },
-            new Object[] { "a" },
-            new Object[] { "Test1\tTest2\tTest3" },
-            new Object[] { "Test1\nTest2\nTest3" },
-            new Object[] { "Test1\r\nTest2\r\nTest3" },
-            new Object[] { "The Quick Brown Fox Jumps Over The Lazy Dog" },
-            new Object[] { "\u00BFD\u00F3nde est\u00E1 el ba\u00F1o?" }
-        };
-  }
-
-  abstract ASN1Writer getWriter() throws IOException;
-
-  abstract ASN1Reader getReader(byte[] encodedBytes) throws ASN1Exception, IOException;
-
-  abstract byte[] getEncodedBytes() throws IOException, ASN1Exception;
-
-  /**
-   * Tests the <CODE>write/readBoolean</CODE> methods.
-   *
-   * @param  b  The boolean value to use in the test.
-   */
-  @Test(dataProvider = "booleanValues")
-  public void testEncodeDecodeBoolean(boolean b) throws Exception
-  {
-    getWriter().writeBoolean(b);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), 1);
-    assertEquals(r.peekType(), UNIVERSAL_BOOLEAN_TYPE);
-    assertEquals(r.readBoolean(), b);
-  }
-
-  /**
-   * Tests the <CODE>write/readBoolean</CODE> methods.
-   *
-   * @param  b  The boolean value to use in the test.
-   */
-  @Test(dataProvider = "booleanValues")
-  public void testEncodeDecodeBooleanType(boolean b) throws Exception
-  {
-    for(byte type : testTypes)
-    {
-      getWriter().writeBoolean(type, b);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), 1);
-      assertEquals(r.peekType(), type);
-      assertEquals(r.readBoolean(), b);
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readInteger</CODE> methods with Java ints.
-   *
-   * @param  i  The integer value to use for the test.
-   */
-  @Test(dataProvider = "intValues")
-  public void testEncodeDecodeEnuerated(int i, int length) throws Exception
-  {
-    getWriter().writeEnumerated(i);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), length);
-    assertEquals(r.peekType(), UNIVERSAL_ENUMERATED_TYPE);
-    assertEquals(r.readInteger(), i);
-  }
-
-  /**
-   * Tests that negative integers are encoded according
-   * to ASN.1 BER specification.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test()
-  public void testNegativeIntEncoding()
-         throws Exception
-  {
-    // Some negative integers of interest
-    // to test specific ranges/boundaries.
-    getWriter().writeInteger(-1);
-    byte[] value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-
-    getWriter().writeInteger(-2);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFE);
-
-    getWriter().writeInteger(-127);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x81);
-
-    getWriter().writeInteger(-128);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-
-    getWriter().writeInteger(-255);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x01);
-
-    getWriter().writeInteger(-256);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-
-    getWriter().writeInteger(-65535);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x01);
-
-    getWriter().writeInteger(-65536);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-
-    getWriter().writeInteger(-2147483647);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-    assertEquals(value[5], (byte) 0x01);
-
-    getWriter().writeInteger(-2147483648);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-    assertEquals(value[5], (byte) 0x00);
-  }
-
-  /**
-   * Tests that negative integers are encoded according
-   * to ASN.1 BER specification.
-   *
-   * @throws  Exception  If an unexpected problem occurs.
-   */
-  @Test()
-  public void testNegativeLongEncoding()
-         throws Exception
-  {
-    // Some negative integers of interest
-    // to test specific ranges/boundaries.
-    getWriter().writeInteger(-1L);
-    byte[] value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-
-    getWriter().writeInteger(-2L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFE);
-
-    getWriter().writeInteger(-127L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x81);
-
-    getWriter().writeInteger(-128L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-
-    getWriter().writeInteger(-255L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x01);
-
-    getWriter().writeInteger(-256L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-
-    getWriter().writeInteger(-65535L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x01);
-
-    getWriter().writeInteger(-65536L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0xFF);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-
-    getWriter().writeInteger(-2147483647L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-    assertEquals(value[5], (byte) 0x01);
-
-    getWriter().writeInteger(-2147483648L);
-    value = getEncodedBytes();
-    assertEquals(value[2], (byte) 0x80);
-    assertEquals(value[3], (byte) 0x00);
-    assertEquals(value[4], (byte) 0x00);
-    assertEquals(value[5], (byte) 0x00);
-  }
-
-
-  /**
-   * Tests the <CODE>write/readInteger</CODE> methods with Java ints.
-   *
-   * @param  i  The integer value to use for the test.
-   */
-  @Test(dataProvider = "intValues")
-  public void testEncodeDecodeInteger(int i, int length) throws Exception
-  {
-    getWriter().writeInteger(i);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), length);
-    assertEquals(r.peekType(), UNIVERSAL_INTEGER_TYPE);
-    assertEquals(r.readInteger(), i);
-  }
-
-  /**
-   * Tests the <CODE>write/readInteger</CODE> methods with Java ints.
-   *
-   * @param  i  The integer value to use for the test.
-   */
-  @Test(dataProvider = "intValues")
-  public void testEncodeDecodeIntegerType(int i, int length) throws Exception
-  {
-    for(byte type : testTypes)
-    {
-      getWriter().writeInteger(type, i);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), length);
-      assertEquals(r.peekType(), type);
-      assertEquals(r.readInteger(), i);
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readInteger</CODE> methods with Java longs.
-   *
-   * @param  l The long value to use for the test.
-   */
-  @Test(dataProvider = "longValues")
-  public void testEncodeDecodeInteger(long l, int length) throws Exception
-  {
-    getWriter().writeInteger(l);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), length);
-    assertEquals(r.peekType(), UNIVERSAL_INTEGER_TYPE);
-    assertEquals(r.readInteger(), l);
-  }
-
-  /**
-   * Tests the <CODE>write/readInteger</CODE> methods wiht JavaLongs.
-   *
-   * @param  l The long value to use for the test.
-   */
-  @Test(dataProvider = "longValues")
-  public void testEncodeDecodeIntegerType(long l, int length) throws Exception
-  {
-    for(byte type : testTypes)
-    {
-      getWriter().writeInteger(type, l);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), length);
-      assertEquals(r.peekType(), type);
-      assertEquals(r.readInteger(), l);
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readNull</CODE> methods.
-   */
-  @Test
-  public void testEncodeDecodeNull() throws Exception
-  {
-    getWriter().writeNull();
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), 0);
-    assertEquals(r.peekType(), UNIVERSAL_NULL_TYPE);
-    r.readNull();
-  }
-
-  /**
-   * Tests the <CODE>write/readNull</CODE> methods.
-   */
-  @Test
-  public void testEncodeDecodeNullType() throws Exception
-  {
-    for(byte type : testTypes)
-    {
-      getWriter().writeNull(type);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), 0);
-      assertEquals(r.peekType(), type);
-      r.readNull();
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readOctetString</CODE> methods.
-   */
-  @Test
-  public void testEncodeDecodeOctetStringOffLen() throws Exception
-  {
-    byte[] b = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
-
-    for(int i = 0; i < 5; i+=2)
-    {
-      byte[] bsb = new byte[3];
-      System.arraycopy(b, i, bsb, 0, 3);
-      ByteString bs = ByteString.wrap(bsb);
-      getWriter().writeOctetString(b, i, 3);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), 3);
-      assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
-      assertTrue(bs.equals(r.readOctetString()));
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readOctetString</CODE> methods.
-   */
-  @Test(dataProvider = "binaryValues")
-  public void testEncodeDecodeOctetString(byte[] b) throws Exception
-  {
-    ByteString bs = ByteString.wrap(b);
-
-    getWriter().writeOctetString(bs);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), b.length);
-    assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
-    assertTrue(bs.equals(r.readOctetString()));
-
-
-    getWriter().writeOctetString(b, 0, b.length);
-
-    r = getReader(getEncodedBytes());
-    assertEquals(r.peekLength(), b.length);
-    assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
-    assertTrue(bs.equals(r.readOctetString()));
-  }
-
-  /**
-   * Tests the <CODE>write/readOctetString</CODE> methods.
-   */
-  @Test(dataProvider = "binaryValues")
-  public void testEncodeDecodeOctetStringType(byte[] b) throws Exception
-  {
-    ByteString bs = ByteString.wrap(b);
-    ByteStringBuilder bsb = new ByteStringBuilder();
-
-    for(byte type : testTypes)
-    {
-      bsb.clear();
-      getWriter().writeOctetString(type, bs);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), b.length);
-      assertEquals(r.peekType(), type);
-      r.readOctetString(bsb);
-      assertTrue(bs.equals(bsb));
-
-      bsb.clear();
-      getWriter().writeOctetString(type, b, 0, b.length);
-
-      r = getReader(getEncodedBytes());
-      assertEquals(r.peekLength(), b.length);
-      assertEquals(r.peekType(), type);
-      r.readOctetString(bsb);
-      assertTrue(bs.equals(bsb));
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readOctetString</CODE> methods.
-   */
-  @Test(dataProvider = "stringValues")
-  public void testEncodeDecodeOctetString(String s) throws Exception
-  {
-    getWriter().writeOctetString(s);
-
-    ASN1Reader r = getReader(getEncodedBytes());
-    if(s == null)
-    {
-      assertEquals(r.peekLength(), 0);
-    }
-    else
-    {
-      assertEquals(r.peekLength(), StaticUtils.getBytes(s).length);
-    }
-    assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
-    if(s == null)
-    {
-      assertTrue(r.readOctetStringAsString("UTF-8").equals(""));
-    }
-    else
-    {
-      assertTrue(s.equals(r.readOctetStringAsString("UTF-8")));
-    }
-  }
-
-  /**
-   * Tests the <CODE>write/readOctetString</CODE> methods.
-   */
-  @Test(dataProvider = "stringValues")
-  public void testEncodeDecodeOctetStringType(String s) throws Exception
-  {
-    for(byte type : testTypes)
-    {
-      getWriter().writeOctetString(type, s);
-
-      ASN1Reader r = getReader(getEncodedBytes());
-      if(s == null)
-      {
-        assertEquals(r.peekLength(), 0);
-      }
-      else
-      {
-        assertEquals(r.peekLength(), StaticUtils.getBytes(s).length);
-      }
-      assertEquals(r.peekType(), type);
-      if(s == null)
-      {
-        assertTrue(r.readOctetStringAsString("UTF-8").equals(""));
-      }
-      else
-      {
-        assertTrue(s.equals(r.readOctetStringAsString("UTF-8")));
-      }
-    }
-  }
-
-  @Test
-  public void testEncodeDecodeSequence() throws Exception
-  {
-    ASN1Writer writer = getWriter();
-
-    writer.writeStartSequence();
-
-    writer.writeBoolean(true);
-    writer.writeBoolean(false);
-    writer.writeInteger(0);
-    writer.writeInteger(10L);
-    writer.writeNull();
-    writer.writeOctetString("test value");
-    writer.writeOctetString("skip value");
-
-    writer.writeStartSequence();
-    writer.writeOctetString("nested sequence");
-    writer.writeEndSequence();
-
-    writer.writeStartSet();
-    writer.writeOctetString("nested set");
-    writer.writeEndSet();
-
-    writer.writeEndSequence();
-
-    ASN1Reader reader = getReader(getEncodedBytes());
-    assertEquals(reader.peekType(), UNIVERSAL_SEQUENCE_TYPE);
-    assertEquals(reader.peekLength(), 71);
-
-    assertTrue(reader.hasNextElement());
-    reader.readStartSequence();
-    assertTrue(reader.hasNextElement());
-
-    assertEquals(true, reader.readBoolean());
-    assertEquals(false, reader.readBoolean());
-    assertEquals(0, reader.readInteger());
-    assertEquals(10, reader.readInteger());
-    reader.readNull();
-    assertEquals("test value", reader.readOctetStringAsString());
-    reader.skipElement();
-
-    assertEquals(reader.peekLength(), 17);
-    assertEquals(reader.peekType(), UNIVERSAL_SEQUENCE_TYPE);
-    reader.readStartSequence();
-    assertEquals("nested sequence", reader.readOctetStringAsString());
-    reader.readEndSequence();
-
-    assertEquals(reader.peekLength(), 12);
-    assertEquals(reader.peekType(), UNIVERSAL_SET_TYPE);
-    reader.readStartSequence();
-    assertEquals("nested set", reader.readOctetStringAsString());
-    reader.readEndSequence();
-
-    assertFalse(reader.hasNextElement());
-    reader.readEndSequence();
-    assertFalse(reader.elementAvailable());
-  }
-}

--
Gitblit v1.10.0