From fc11cb328f23d141ecfedd16d791e39fd4e1d299 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 18 Sep 2012 07:58:15 +0000
Subject: [PATCH] Fix OPENDJ-595: Merge ASN1Constants into ASN1
---
/dev/null | 162 ------------------
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java | 20 +-
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java | 25 +-
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java | 4
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java | 5
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java | 114 ++++++++++++
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java | 6
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java | 14
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java | 41 ++--
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java | 24 +-
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java | 13
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java | 58 +++---
12 files changed, 211 insertions(+), 275 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java
index bf62813..5651f84 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java
+++ b/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(
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java
index e2ee7f3..74d6b9b 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java
+++ b/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 {
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java
index 3063245..e3e7a91 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java
+++ b/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.
*
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java
index 6eeb6bd..0592ff8 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java
+++ b/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;
}
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java
deleted file mode 100644
index 41d4967..0000000
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java
+++ /dev/null
@@ -1,162 +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.
- */
-package org.forgerock.opendj.asn1;
-
-/**
- * This class defines a number of constants that may be used when interacting
- * with ASN.1 elements.
- */
-public final class ASN1Constants {
-
- /**
- * 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 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 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 applied to the value of the element.
- */
- static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES = 3;
-
- /**
- * 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 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.
- */
- 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 determine if the
- * element is in the universal class.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- 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.
- */
- static final byte TYPE_MASK_PRIMITIVE = 0x00;
-
- /**
- * 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 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;
-
- // Prevent instantiation.
- private ASN1Constants() {
- // Nothing to do.
- }
-}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java
index b88c07f..8ce39e2 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java
+++ b/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;
}
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java
index 2245810..d1132f2 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java
+++ b/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(
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java
index 36fa325..d46ae43 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java
+++ b/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();
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java
index 7d113de..caa3c27 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java
+++ b/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);
}
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java
index 1a9eda3..a3b7011 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java
+++ b/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) {
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java
index 2cbfdcb..cb4379a 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java
+++ b/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();
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java
index 07cddf9..7dbf562 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java
+++ b/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();
--
Gitblit v1.10.0