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

Matthew Swift
18.58.2012 fc11cb328f23d141ecfedd16d791e39fd4e1d299
Fix OPENDJ-595: Merge ASN1Constants into ASN1
1 files deleted
11 files modified
486 ■■■■■ changed files
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java 5 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java 13 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java 114 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java 41 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java 162 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java 58 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java 4 ●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java 20 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java 24 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java 6 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java 14 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java 25 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java
@@ -26,8 +26,6 @@
 */
package com.forgerock.opendj.ldap;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_FALSE;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_TRUE;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED;
import java.io.IOException;
@@ -35,6 +33,7 @@
import java.util.logging.Level;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.asn1.ASN1;
import org.forgerock.opendj.asn1.ASN1Writer;
import org.forgerock.opendj.asn1.AbstractASN1Writer;
import org.forgerock.opendj.ldap.ByteSequence;
@@ -229,7 +228,7 @@
    public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException {
        sequenceBuffer.writeByte(type);
        writeLength(sequenceBuffer, 1);
        sequenceBuffer.writeByte(booleanValue ? BOOLEAN_VALUE_TRUE : BOOLEAN_VALUE_FALSE);
        sequenceBuffer.writeByte(booleanValue ? ASN1.BOOLEAN_VALUE_TRUE : ASN1.BOOLEAN_VALUE_FALSE);
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format(
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java
@@ -22,14 +22,12 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 *      Portions copyright 2011-2012 ForgeRock AS
 */
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.*;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_BOOLEAN_TYPE;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_LDAP_MODIFICATION_DECODE_INVALID_MOD_TYPE;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_DEREF;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_SCOPE;
@@ -38,6 +36,7 @@
import java.util.logging.Level;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.asn1.ASN1;
import org.forgerock.opendj.asn1.ASN1Reader;
import org.forgerock.opendj.ldap.Attribute;
import org.forgerock.opendj.ldap.AttributeDescription;
@@ -521,10 +520,10 @@
            oid = reader.readOctetStringAsString();
            isCritical = false;
            value = null;
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE)) {
            if (reader.hasNextElement() && (reader.peekType() == ASN1.UNIVERSAL_BOOLEAN_TYPE)) {
                isCritical = reader.readBoolean();
            }
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE)) {
            if (reader.hasNextElement() && (reader.peekType() == ASN1.UNIVERSAL_OCTET_STRING_TYPE)) {
                value = reader.readOctetString();
            }
        } finally {
@@ -555,10 +554,10 @@
            oid = reader.readOctetStringAsString();
            isCritical = false;
            value = null;
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE)) {
            if (reader.hasNextElement() && (reader.peekType() == ASN1.UNIVERSAL_BOOLEAN_TYPE)) {
                isCritical = reader.readBoolean();
            }
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE)) {
            if (reader.hasNextElement() && (reader.peekType() == ASN1.UNIVERSAL_OCTET_STRING_TYPE)) {
                value = reader.readOctetString();
            }
        } finally {
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 */
package org.forgerock.opendj.asn1;
@@ -46,6 +47,119 @@
public final class ASN1 {
    /**
     * 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;
    /**
     * 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 enumerated type.
     */
    public static final byte UNIVERSAL_ENUMERATED_TYPE = 0x0A;
    /**
     * 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 null type.
     */
    public static final byte UNIVERSAL_NULL_TYPE = 0x05;
    /**
     * 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 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 ASN.1 element decoding state that indicates that the next byte read
     * should be additional bytes of a multi-byte length.
     */
    static final int ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES = 2;
    /**
     * The ASN.1 element decoding state that indicates that the next byte read
     * should be the first byte for the element length.
     */
    static final int ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE = 1;
    /**
     * The ASN.1 element decoding state that indicates that the next byte read
     * should be the BER type for a new element.
     */
    static final int ELEMENT_READ_STATE_NEED_TYPE = 0;
    /**
     * The ASN.1 element decoding state that indicates that the next byte read
     * should be applied to the value of the element.
     */
    static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES = 3;
    /**
     * The byte array that will be used for ASN.1 elements with no value.
     */
    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.
     */
    static final byte TYPE_MASK_ALL_BUT_CLASS = (byte) 0xC0;
    /**
     * The bitmask that can be ANDed with the BER type to zero out all bits
     * except the primitive/constructed bit.
     */
    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 in the application-specific class.
     */
    static final byte TYPE_MASK_APPLICATION = 0x40;
    /**
     * The bitmask that can be ANDed with the BER type to determine if the
     * element is constructed.
     */
    static final byte TYPE_MASK_CONSTRUCTED = 0x20;
    /**
     * The bitmask that can be ANDed with the BER type to determine if the
     * element is in the context-specific class.
     */
    static final byte TYPE_MASK_CONTEXT = (byte) 0x80;
    /**
     * The bitmask that can be ANDed with the BER type to determine if the
     * element is a primitive.
     */
    static final byte TYPE_MASK_PRIMITIVE = 0x00;
    /**
     * The bitmask that can be ANDed with the BER type to determine if the
     * element is in the private class.
     */
    static final byte TYPE_MASK_PRIVATE = (byte) 0xC0;
    /**
     * The bitmask that can be ANDed with the BER type to determine if the
     * element is in the universal class.
     */
    static final byte TYPE_MASK_UNIVERSAL = 0x00;
    /**
     * Returns an ASN.1 reader whose source is the provided byte array and
     * having an unlimited maximum BER element size.
     *
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java
@@ -27,9 +27,6 @@
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_TYPE;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
import static org.forgerock.opendj.ldap.CoreMessages.*;
import java.io.IOException;
@@ -49,7 +46,7 @@
 */
final class ASN1ByteSequenceReader extends AbstractASN1Reader implements ASN1Reader {
    private int state = ELEMENT_READ_STATE_NEED_TYPE;
    private int state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    private byte peekType = 0;
@@ -88,10 +85,10 @@
     * {@inheritDoc}
     */
    public boolean elementAvailable() throws IOException {
        if ((state == ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false)) {
        if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false)) {
            return false;
        }
        if ((state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
        if ((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
                && !needFirstLengthByteState(false)) {
            return false;
        }
@@ -103,7 +100,7 @@
     * {@inheritDoc}
     */
    public boolean hasNextElement() throws IOException {
        return (state != ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(false);
        return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(false);
    }
    /**
@@ -112,7 +109,7 @@
    public int peekLength() throws IOException {
        peekType();
        if (state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE) {
        if (state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE) {
            needFirstLengthByteState(true);
        }
@@ -123,7 +120,7 @@
     * {@inheritDoc}
     */
    public byte peekType() throws IOException {
        if (state == ELEMENT_READ_STATE_NEED_TYPE) {
        if (state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) {
            // Read just the type.
            if (reader.remaining() <= 0) {
                final LocalizableMessage message = ERR_ASN1_TRUCATED_TYPE_BYTE.get();
@@ -132,7 +129,7 @@
            final int type = reader.get();
            peekType = (byte) type;
            state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
            state = ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
        }
        return peekType;
@@ -156,7 +153,7 @@
        }
        final int readByte = reader.get();
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return readByte != 0x00;
    }
@@ -177,7 +174,7 @@
        reader = readerStack.removeFirst();
        // Reset the state
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -232,7 +229,7 @@
                longValue = (longValue << 8) | (readByte & 0xFF);
            }
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return longValue;
        } else {
            int intValue = 0;
@@ -244,7 +241,7 @@
                intValue = (intValue << 8) | (readByte & 0xFF);
            }
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return intValue;
        }
    }
@@ -262,7 +259,7 @@
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -278,7 +275,7 @@
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return reader.getByteString(peekLength);
    }
@@ -297,7 +294,7 @@
        }
        builder.append(reader, peekLength);
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return builder;
    }
@@ -314,7 +311,7 @@
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return reader.getString(peekLength);
    }
@@ -336,7 +333,7 @@
        reader = subByteString;
        // Reset the state
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -360,7 +357,7 @@
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        reader.skip(peekLength);
        return this;
    }
@@ -419,7 +416,7 @@
                            .get(peekLength, maxElementSize);
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        state = ASN1.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        return true;
    }
@@ -446,7 +443,7 @@
        final int type = reader.get();
        peekType = (byte) type;
        state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
        state = ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
        return true;
    }
}
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java
File was deleted
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java
@@ -27,10 +27,6 @@
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_TYPE;
import static org.forgerock.opendj.asn1.ASN1Constants.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
import static org.forgerock.opendj.ldap.CoreMessages.*;
import java.io.IOException;
@@ -50,7 +46,7 @@
 * An ASN1Reader that reads from an input stream.
 */
final class ASN1InputStreamReader extends AbstractASN1Reader implements ASN1Reader {
    private int state = ELEMENT_READ_STATE_NEED_TYPE;
    private int state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    private byte peekType = 0;
@@ -97,14 +93,14 @@
     * {@inheritDoc}
     */
    public boolean elementAvailable() throws IOException {
        if ((state == ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false, false)) {
        if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false, false)) {
            return false;
        }
        if ((state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
        if ((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
                && !needFirstLengthByteState(false, false)) {
            return false;
        }
        if ((state == ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES)
        if ((state == ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES)
                && !needAdditionalLengthBytesState(false, false)) {
            return false;
        }
@@ -124,7 +120,7 @@
            return (subSq.getSizeLimit() - subSq.getBytesRead() > 0);
        }
        return (state != ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true, false);
        return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true, false);
    }
    /**
@@ -134,11 +130,11 @@
        peekType();
        switch (state) {
        case ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE:
        case ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE:
            needFirstLengthByteState(true, true);
            break;
        case ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES:
        case ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES:
            needAdditionalLengthBytesState(true, true);
        }
@@ -149,7 +145,7 @@
     * {@inheritDoc}
     */
    public byte peekType() throws IOException {
        if (state == ELEMENT_READ_STATE_NEED_TYPE) {
        if (state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) {
            needTypeState(true, true);
        }
@@ -180,7 +176,7 @@
                    String.valueOf(readByte != 0x00)));
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return readByte != 0x00;
    }
@@ -212,7 +208,7 @@
        in = streamStack.removeFirst();
        // Reset the state
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -268,7 +264,7 @@
                longValue = (longValue << 8) | (readByte & 0xFF);
            }
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return longValue;
        } else {
            int intValue = 0;
@@ -291,7 +287,7 @@
                        intValue));
            }
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return intValue;
        }
    }
@@ -314,7 +310,7 @@
                    peekType, peekLength));
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -325,7 +321,7 @@
        peekLength();
        if (peekLength == 0) {
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return ByteString.empty();
        }
@@ -349,7 +345,7 @@
                    "READ ASN.1 OCTETSTRING(type=0x%x, length=%d)", peekType, peekLength));
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return ByteString.wrap(value);
    }
@@ -361,7 +357,7 @@
        peekLength();
        if (peekLength == 0) {
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return builder;
        }
@@ -383,7 +379,7 @@
                    "READ ASN.1 OCTETSTRING(type=0x%x, length=%d)", peekType, peekLength));
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return builder;
    }
@@ -395,7 +391,7 @@
        peekLength();
        if (peekLength == 0) {
            state = ELEMENT_READ_STATE_NEED_TYPE;
            state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
            return "";
        }
@@ -416,7 +412,7 @@
            bytesNeeded -= bytesRead;
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        String str;
        try {
@@ -457,7 +453,7 @@
        in = subStream;
        // Reset the state
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
    }
    /**
@@ -481,7 +477,7 @@
            final LocalizableMessage message = ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength);
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_TYPE;
        state = ASN1.ELEMENT_READ_STATE_NEED_TYPE;
        return this;
    }
@@ -509,7 +505,7 @@
        while (lengthBytesNeeded > 0) {
            readByte = in.read();
            if (readByte == -1) {
                state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
                state = ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
                if (throwEofException) {
                    final LocalizableMessage message =
                            ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
@@ -529,7 +525,7 @@
                            .get(peekLength, maxElementSize);
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        state = ASN1.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        return true;
    }
@@ -572,14 +568,14 @@
            peekLength = 0x00;
            if (!isBlocking && (in.available() < lengthBytesNeeded)) {
                state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
                state = ASN1.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;
                    state = ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
                    if (throwEofException) {
                        final LocalizableMessage message =
                                ERR_ASN1_TRUNCATED_LENGTH_BYTES.get(lengthBytesNeeded);
@@ -600,7 +596,7 @@
                            .get(peekLength, maxElementSize);
            throw DecodeException.fatalError(message);
        }
        state = ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        state = ASN1.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
        return true;
    }
@@ -635,7 +631,7 @@
        }
        peekType = (byte) type;
        state = ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
        state = ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
        return true;
    }
}
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java
@@ -26,8 +26,6 @@
 */
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_FALSE;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_TRUE;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED;
import java.io.IOException;
@@ -90,7 +88,7 @@
    public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException {
        out.write(type);
        writeLength(1);
        out.write(booleanValue ? BOOLEAN_VALUE_TRUE : BOOLEAN_VALUE_FALSE);
        out.write(booleanValue ? ASN1.BOOLEAN_VALUE_TRUE : ASN1.BOOLEAN_VALUE_FALSE);
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format(
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java
@@ -22,11 +22,11 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 */
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.*;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ASN1_UNEXPECTED_TAG;
import java.io.IOException;
@@ -53,7 +53,7 @@
     */
    public boolean readBoolean(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_BOOLEAN_TYPE;
            type = ASN1.UNIVERSAL_BOOLEAN_TYPE;
        }
        checkType(type);
        return readBoolean();
@@ -64,7 +64,7 @@
     */
    public int readEnumerated(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_ENUMERATED_TYPE;
            type = ASN1.UNIVERSAL_ENUMERATED_TYPE;
        }
        checkType(type);
        return readEnumerated();
@@ -75,7 +75,7 @@
     */
    public long readInteger(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_INTEGER_TYPE;
            type = ASN1.UNIVERSAL_INTEGER_TYPE;
        }
        checkType(type);
        return readInteger();
@@ -86,7 +86,7 @@
     */
    public void readNull(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_NULL_TYPE;
            type = ASN1.UNIVERSAL_NULL_TYPE;
        }
        checkType(type);
        readNull();
@@ -97,7 +97,7 @@
     */
    public ByteString readOctetString(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_OCTET_STRING_TYPE;
            type = ASN1.UNIVERSAL_OCTET_STRING_TYPE;
        }
        checkType(type);
        return readOctetString();
@@ -109,7 +109,7 @@
    public ByteStringBuilder readOctetString(byte type, final ByteStringBuilder builder)
            throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_OCTET_STRING_TYPE;
            type = ASN1.UNIVERSAL_OCTET_STRING_TYPE;
        }
        checkType(type);
        readOctetString(builder);
@@ -123,7 +123,7 @@
        // We could cache the UTF-8 CharSet if performance proves to be an
        // issue.
        if (type == 0x00) {
            type = UNIVERSAL_OCTET_STRING_TYPE;
            type = ASN1.UNIVERSAL_OCTET_STRING_TYPE;
        }
        checkType(type);
        return readOctetStringAsString();
@@ -134,7 +134,7 @@
     */
    public void readStartSequence(byte type) throws IOException {
        if (type == 0x00) {
            type = UNIVERSAL_SEQUENCE_TYPE;
            type = ASN1.UNIVERSAL_SEQUENCE_TYPE;
        }
        checkType(type);
        readStartSequence();
@@ -147,7 +147,7 @@
        // From an implementation point of view, a set is equivalent to a
        // sequence.
        if (type == 0x00) {
            type = UNIVERSAL_SET_TYPE;
            type = ASN1.UNIVERSAL_SET_TYPE;
        }
        checkType(type);
        readStartSet();
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java
@@ -22,12 +22,10 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 *      Portions copyright 2011-2012 ForgeRock AS
 */
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.*;
import java.io.IOException;
import org.forgerock.opendj.ldap.ByteSequence;
@@ -49,35 +47,35 @@
     * {@inheritDoc}
     */
    public ASN1Writer writeBoolean(final boolean value) throws IOException {
        return writeBoolean(UNIVERSAL_BOOLEAN_TYPE, value);
        return writeBoolean(ASN1.UNIVERSAL_BOOLEAN_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeEnumerated(final int value) throws IOException {
        return writeEnumerated(UNIVERSAL_ENUMERATED_TYPE, value);
        return writeEnumerated(ASN1.UNIVERSAL_ENUMERATED_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeInteger(final int value) throws IOException {
        return writeInteger(UNIVERSAL_INTEGER_TYPE, value);
        return writeInteger(ASN1.UNIVERSAL_INTEGER_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeInteger(final long value) throws IOException {
        return writeInteger(UNIVERSAL_INTEGER_TYPE, value);
        return writeInteger(ASN1.UNIVERSAL_INTEGER_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeNull() throws IOException {
        return writeNull(UNIVERSAL_NULL_TYPE);
        return writeNull(ASN1.UNIVERSAL_NULL_TYPE);
    }
    /**
@@ -99,35 +97,35 @@
     */
    public ASN1Writer writeOctetString(final byte[] value, final int offset, final int length)
            throws IOException {
        return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value, offset, length);
        return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value, offset, length);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeOctetString(final ByteSequence value) throws IOException {
        return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value);
        return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeOctetString(final String value) throws IOException {
        return writeOctetString(UNIVERSAL_OCTET_STRING_TYPE, value);
        return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeStartSequence() throws IOException {
        return writeStartSequence(UNIVERSAL_SEQUENCE_TYPE);
        return writeStartSequence(ASN1.UNIVERSAL_SEQUENCE_TYPE);
    }
    /**
     * {@inheritDoc}
     */
    public ASN1Writer writeStartSet() throws IOException {
        return writeStartSet(UNIVERSAL_SET_TYPE);
        return writeStartSet(ASN1.UNIVERSAL_SET_TYPE);
    }
}
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java
@@ -27,8 +27,6 @@
package org.forgerock.opendj.ldap.controls;
import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_INTEGER_TYPE;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE;
import static org.forgerock.opendj.ldap.CoreMessages.*;
import java.io.IOException;
@@ -121,7 +119,7 @@
                        }
                        if (reader.hasNextElement()
                                && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE)) {
                                && (reader.peekType() == ASN1.UNIVERSAL_OCTET_STRING_TYPE)) {
                            if (changeType != PersistentSearchChangeType.MODIFY_DN) {
                                final LocalizableMessage message =
                                        ERR_ECN_ILLEGAL_PREVIOUS_DN.get(String.valueOf(changeType));
@@ -131,7 +129,7 @@
                            previousDNString = reader.readOctetStringAsString();
                        }
                        if (reader.hasNextElement()
                                && (reader.peekType() == UNIVERSAL_INTEGER_TYPE)) {
                                && (reader.peekType() == ASN1.UNIVERSAL_INTEGER_TYPE)) {
                            changeNumber = reader.readInteger();
                        }
                    } catch (final IOException e) {
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java
@@ -528,7 +528,7 @@
    @Test(dataProvider = "elementArrays")
    public void testDecodeValidArrayAsOctetString(final byte[] b) throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.append(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.appendBERLength(b.length);
        bsb.append(b);
@@ -547,7 +547,7 @@
    @Test(dataProvider = "elementArrays")
    public void testDecodeValidArrayAsOctetStringAsString(final byte[] b) throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.append(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.appendBERLength(b.length);
        bsb.append(b);
@@ -567,7 +567,7 @@
    @Test(dataProvider = "elementArrays")
    public void testDecodeValidArrayAsOctetStringAsStringCharSet(final byte[] b) throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.append(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.appendBERLength(b.length);
        bsb.append(b);
@@ -587,7 +587,7 @@
    @Test(dataProvider = "elementArrays")
    public void testDecodeValidArrayAsOctetStringBuilder(final byte[] b) throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.append(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.appendBERLength(b.length);
        bsb.append(b);
@@ -609,16 +609,16 @@
    @Test(dataProvider = "elementArrays")
    public void testDecodeValidArrayAsSequence(final byte[] encodedElements) throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append(ASN1Constants.UNIVERSAL_SEQUENCE_TYPE);
        bsb.append(ASN1.UNIVERSAL_SEQUENCE_TYPE);
        bsb.appendBERLength(encodedElements.length + 2);
        bsb.append(ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.append(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        bsb.appendBERLength(encodedElements.length);
        bsb.append(encodedElements);
        final ASN1Reader reader = getReader(bsb.toByteArray(), 0);
        assertEquals(reader.peekLength(), encodedElements.length + 2);
        reader.readStartSequence();
        assertEquals(reader.peekType(), ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE);
        assertEquals(reader.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        assertEquals(reader.peekLength(), encodedElements.length);
        reader.readOctetString().equals(ByteString.wrap(encodedElements));
        reader.readEndSequence();
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java
@@ -26,7 +26,6 @@
 */
package org.forgerock.opendj.asn1;
import static org.forgerock.opendj.asn1.ASN1Constants.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -182,7 +181,7 @@
        final ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), 1);
        assertEquals(r.peekType(), UNIVERSAL_BOOLEAN_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_BOOLEAN_TYPE);
        assertEquals(r.readBoolean(), b);
    }
@@ -216,7 +215,7 @@
        final ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), length);
        assertEquals(r.peekType(), UNIVERSAL_ENUMERATED_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_ENUMERATED_TYPE);
        assertEquals(r.readInteger(), i);
    }
@@ -232,7 +231,7 @@
        final ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), length);
        assertEquals(r.peekType(), UNIVERSAL_INTEGER_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_INTEGER_TYPE);
        assertEquals(r.readInteger(), i);
    }
@@ -248,7 +247,7 @@
        final ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), length);
        assertEquals(r.peekType(), UNIVERSAL_INTEGER_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_INTEGER_TYPE);
        assertEquals(r.readInteger(), l);
    }
@@ -297,7 +296,7 @@
        final ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), 0);
        assertEquals(r.peekType(), UNIVERSAL_NULL_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_NULL_TYPE);
        r.readNull();
    }
@@ -327,14 +326,14 @@
        ASN1Reader r = getReader(getEncodedBytes());
        assertEquals(r.peekLength(), b.length);
        assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
        assertEquals(r.peekType(), ASN1.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);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        assertTrue(bs.equals(r.readOctetString()));
    }
@@ -351,7 +350,7 @@
        } else {
            assertEquals(r.peekLength(), StaticUtils.getBytes(s).length);
        }
        assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
        assertEquals(r.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE);
        if (s == null) {
            assertTrue(r.readOctetStringAsString().equals(""));
        } else {
@@ -374,7 +373,7 @@
            final ASN1Reader r = getReader(getEncodedBytes());
            assertEquals(r.peekLength(), 3);
            assertEquals(r.peekType(), UNIVERSAL_OCTET_STRING_TYPE);
            assertEquals(r.peekType(), ASN1.UNIVERSAL_OCTET_STRING_TYPE);
            assertTrue(bs.equals(r.readOctetString()));
        }
    }
@@ -456,7 +455,7 @@
        writer.writeEndSequence();
        final ASN1Reader reader = getReader(getEncodedBytes());
        assertEquals(reader.peekType(), UNIVERSAL_SEQUENCE_TYPE);
        assertEquals(reader.peekType(), ASN1.UNIVERSAL_SEQUENCE_TYPE);
        assertEquals(reader.peekLength(), 71);
        assertTrue(reader.hasNextElement());
@@ -472,13 +471,13 @@
        reader.skipElement();
        assertEquals(reader.peekLength(), 17);
        assertEquals(reader.peekType(), UNIVERSAL_SEQUENCE_TYPE);
        assertEquals(reader.peekType(), ASN1.UNIVERSAL_SEQUENCE_TYPE);
        reader.readStartSequence();
        assertEquals("nested sequence", reader.readOctetStringAsString());
        reader.readEndSequence();
        assertEquals(reader.peekLength(), 12);
        assertEquals(reader.peekType(), UNIVERSAL_SET_TYPE);
        assertEquals(reader.peekType(), ASN1.UNIVERSAL_SET_TYPE);
        reader.readStartSequence();
        assertEquals("nested set", reader.readOctetStringAsString());
        reader.readEndSequence();