APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.util

public final Class ObjectIdentifier

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.*, java.math.BigInteger, java.util.Arrays, java.util.concurrent.ConcurrentHashMap

Represent an ISO Object Identifier.

Object Identifiers are arbitrary length hierarchical identifiers. The individual components are numbers, and they define paths from the root of an ISO-managed identifier space. You will sometimes see a string name used instead of (or in addition to) the numerical id. These are synonyms for the numerical IDs, but are not widely used since most sites do not know all the requisite strings, while all sites can parse the numeric forms.

So for example, JavaSoft has the sole authority to assign the meaning to identifiers below the 1.3.6.1.4.1.42.2.17 node in the hierarchy, and other organizations can easily acquire the ability to assign such unique identifiers.

Authors
David Brownell, Amit Kapoor, Hemma Prafullchandra

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private int
private Object
components

Changed to Object

private transient boolean
private byte[]
encoding

We use the DER value (no tag, no length) as the internal format

private static final int
private static final ConcurrentHashMap<String, ObjectIdentifier>
private static final long
private transient volatile String

Constructor Summary

AccessConstructor and Description
private
ObjectIdentifier(String oid)

Constructs, from a string.

pack-priv
ObjectIdentifier(byte[] encoding)

public
ObjectIdentifier(DerInputStream
the input stream
in
)

Reads an ObjectIdentifier from a DerInputStream.

Method Summary

Modifier and TypeMethod and Description
private static void
check(byte[] encoding)

Check the DER encoding.

private static void
checkCount(int count)

private static void
private static void
private static void
checkOidSize(int oidLength)

private static void
checkOtherComponent(int i, int num)

private static void
private static void
checkSecondComponent(int first, int second)

private static void
checkSecondComponent(int first, BigInteger second)

pack-priv void
public boolean

Returns:

true iff the names are identical.
equals
(Object obj)

Overrides java.lang.Object.equals.

Compares this identifier with another, for equality.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private void
init(int[] components, int length)

public static ObjectIdentifier
of(String oidStr)

Returns an ObjectIdentifier instance for the specific String.

public static ObjectIdentifier
of(KnownOIDs o)

Returns an ObjectIdentifier instance for the specific KnownOIDs.

private static byte[]

Returns:

the repacked bytes
pack
(byte[]
the input byte array
in
,
int
start point inside in
ioffset
,
int
number of bytes to repack
ilength
,
int
NUB for input
iw
,
int
NUB for output
ow
)

Repack all bits from input to output.

private static int

Returns:

the number of bytes pasted
pack7Oid
(byte[] in, int ioffset, int ilength, byte[]
the existing array to be pasted into
out
,
int
the starting position to paste
ooffset
)

Repack from NUB 8 to a NUB 7 OID sub-identifier, remove all unnecessary 0 headings, set the first bit of all non-tail output bytes to 1 (as ITU-T Rec.

private static int
pack7Oid(int input, byte[] out, int ooffset)

Pack the int into a OID sub-identifier DER encoding

private static int
pack7Oid(BigInteger input, byte[] out, int ooffset)

Pack the BigInteger into a OID subidentifier DER encoding

private static int

Returns:

the number of bytes pasted
pack8
(byte[] in, int ioffset, int ilength, byte[]
the existing array to be pasted into
out
,
int
the starting position to paste
ooffset
)

Repack from NUB 7 to NUB 8, remove all unnecessary 0 headings, and paste it into an existing byte array.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
is
)

Restores the state of this object from the stream.

private int[]

Returns:

components in an int array, if all the components are less than Integer.MAX_VALUE. Otherwise, null.
toIntArray
()

Private helper method for serialization.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string form of the object ID. The format is the conventional "dot" notation for such IDs, without any user-friendly descriptive strings, since those strings will not be understood everywhere.

private void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

componentLenback to summary
private int componentLen
componentsback to summary
private Object components

Changed to Object

Annotations
@SuppressWarnings:serial
componentsCalculatedback to summary
private transient boolean componentsCalculated
encodingback to summary
private byte[] encoding

We use the DER value (no tag, no length) as the internal format

MAXIMUM_OID_SIZEback to summary
private static final int MAXIMUM_OID_SIZE
oidTableback to summary
private static final ConcurrentHashMap<String, ObjectIdentifier> oidTable
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial
stringFormback to summary
private transient volatile String stringForm

Constructor Detail

ObjectIdentifierback to summary
private ObjectIdentifier(String oid) throws IOException

Constructs, from a string. This string should be of the form 1.23.56. Validity check included.

ObjectIdentifierback to summary
pack-priv ObjectIdentifier(byte[] encoding) throws IOException
ObjectIdentifierback to summary
public ObjectIdentifier(DerInputStream in) throws IOException

Reads an ObjectIdentifier from a DerInputStream.

Parameters
in:DerInputStream

the input stream

Exceptions
IOException:
if there is an encoding error

Method Detail

checkback to summary
private static void check(byte[] encoding) throws IOException

Check the DER encoding. Since DER encoding defines that the integer bits are unsigned, so there's no need to check the MSB.

checkCountback to summary
private static void checkCount(int count) throws IOException
checkFirstComponentback to summary
private static void checkFirstComponent(int first) throws IOException
checkFirstComponentback to summary
private static void checkFirstComponent(BigInteger first) throws IOException
checkOidSizeback to summary
private static void checkOidSize(int oidLength) throws IOException
checkOtherComponentback to summary
private static void checkOtherComponent(int i, int num) throws IOException
checkOtherComponentback to summary
private static void checkOtherComponent(int i, BigInteger num) throws IOException
checkSecondComponentback to summary
private static void checkSecondComponent(int first, int second) throws IOException
checkSecondComponentback to summary
private static void checkSecondComponent(int first, BigInteger second) throws IOException
encodeback to summary
pack-priv void encode(DerOutputStream out)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this identifier with another, for equality.

Returns:boolean

true iff the names are identical.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
initback to summary
private void init(int[] components, int length) throws IOException
ofback to summary
public static ObjectIdentifier of(String oidStr) throws IOException

Returns an ObjectIdentifier instance for the specific String. If the String is not a valid OID string, an IOException is thrown.

ofback to summary
public static ObjectIdentifier of(KnownOIDs o)

Returns an ObjectIdentifier instance for the specific KnownOIDs.

packback to summary
private static byte[] pack(byte[] in, int ioffset, int ilength, int iw, int ow)

Repack all bits from input to output. On the both sides, only a portion (from the least significant bit) of the 8 bits in a byte is used. This number is defined as the number of useful bits (NUB) for the array. All used bits from the input byte array and repacked into the output in the exactly same order. The output bits are aligned so that the final bit of the input (the least significant bit in the last byte), when repacked as the final bit of the output, is still at the least significant position. Zeroes will be padded on the left side of the first output byte if necessary. All unused bits in the output are also zeroed. For example: if the input is 01001100 with NUB 8, the output which has a NUB 6 will look like: 00000001 00001100 The first 2 bits of the output bytes are unused bits. The other bits turn out to be 000001 001100. While the 8 bits on the right are from the input, the left 4 zeroes are padded to fill the 6 bits space.

Parameters
in:byte[]

the input byte array

ioffset:int

start point inside in

ilength:int

number of bytes to repack

iw:int

NUB for input

ow:int

NUB for output

Returns:byte[]

the repacked bytes

pack7Oidback to summary
private static int pack7Oid(byte[] in, int ioffset, int ilength, byte[] out, int ooffset)

Repack from NUB 8 to a NUB 7 OID sub-identifier, remove all unnecessary 0 headings, set the first bit of all non-tail output bytes to 1 (as ITU-T Rec. X.690 8.19.2 says), and paste it into an existing byte array.

Parameters
out:byte[]

the existing array to be pasted into

ooffset:int

the starting position to paste

Returns:int

the number of bytes pasted

pack7Oidback to summary
private static int pack7Oid(int input, byte[] out, int ooffset)

Pack the int into a OID sub-identifier DER encoding

pack7Oidback to summary
private static int pack7Oid(BigInteger input, byte[] out, int ooffset)

Pack the BigInteger into a OID subidentifier DER encoding

pack8back to summary
private static int pack8(byte[] in, int ioffset, int ilength, byte[] out, int ooffset)

Repack from NUB 7 to NUB 8, remove all unnecessary 0 headings, and paste it into an existing byte array.

Parameters
out:byte[]

the existing array to be pasted into

ooffset:int

the starting position to paste

Returns:int

the number of bytes pasted

readObjectback to summary
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
is:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toIntArrayback to summary
private int[] toIntArray()

Private helper method for serialization. To be compatible with old versions of JDK.

Returns:int[]

components in an int array, if all the components are less than Integer.MAX_VALUE. Otherwise, null.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string form of the object ID. The format is the conventional "dot" notation for such IDs, without any user-friendly descriptive strings, since those strings will not be understood everywhere.

Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream os) throws IOException
Annotations
@Serial
sun.security.util back to summary

pack-priv Class ObjectIdentifier.HugeOidNotSupportedByOldJDK

extends Object
implements Serializable
Class Inheritance
  • java.lang.Object
  • sun.security.util.ObjectIdentifier.HugeOidNotSupportedByOldJDK
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private static final long
pack-priv static ObjectIdentifier.HugeOidNotSupportedByOldJDK

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial
theOneback to summary
pack-priv static ObjectIdentifier.HugeOidNotSupportedByOldJDK theOne

Constructor Detail

HugeOidNotSupportedByOldJDKback to summary
pack-priv HugeOidNotSupportedByOldJDK()