Top Description Inners Fields Constructors Methods
org.bouncycastle.asn1

public Class ASN1ObjectIdentifier

extends ASN1Primitive
Class Inheritance
Known Direct Subclasses
org.bouncycastle.asn1.x509.PolicyQualifierId
Imports
java.io.ByteArrayOutputStream, .IOException, java.math.BigInteger, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.bouncycastle.util.Arrays

Class representing the ASN.1 OBJECT IDENTIFIER type.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final byte[]
private String
private static final long
private static final int
MAX_CONTENTS_LENGTH

Implementation limit on the length of the contents octets for an Object Identifier.

private static final int
private static final ConcurrentMap<ASN1ObjectIdentifier.OidHandle, ASN1ObjectIdentifier>
pack-priv static final ASN1UniversalType

Constructor Summary

AccessConstructor and Description
public
ASN1ObjectIdentifier(String
a string representation of an OID.
identifier
)

Create an OID based on the passed in String.

private
ASN1ObjectIdentifier(byte[] contents, String identifier)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
asn1Equals(ASN1Primitive other)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.

public ASN1ObjectIdentifier

Returns:

the OID for the new created branch.
branch
(String
node numbers for the new branch.
branchID
)

Return an OID that creates a branch under the current one.

pack-priv static void
checkContentsLength(int contentsLength)

pack-priv static void
checkIdentifier(String identifier)

pack-priv static ASN1ObjectIdentifier
createPrimitive(byte[] contents, boolean clone)

pack-priv void
encode(ASN1OutputStream out, boolean withTag)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encode.

pack-priv boolean
encodeConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.

pack-priv int
public static ASN1ObjectIdentifier
fromContents(byte[] contents)

public synchronized String

Returns:

the string representation of the OID carried by this object.
getId
()

Return the OID as a string.

public static ASN1ObjectIdentifier

Returns:

an ASN1ObjectIdentifier instance, or null.
getInstance
(Object
an ASN1ObjectIdentifier or an object that can be converted into one.
obj
)

Return an OID from the passed in object

public static ASN1ObjectIdentifier

Returns:

an ASN1ObjectIdentifier instance, or null.
getInstance
(ASN1TaggedObject
the tagged object holding the object we want
taggedObject
,
boolean
true if the object is meant to be explicitly tagged false otherwise.
explicit
)

Return an OBJECT IDENTIFIER from a tagged object.

public int
hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.hashCode.

Returns a hash code value for this object.

public ASN1ObjectIdentifier

Returns:

a reference to the identifier in the pool.
intern
()

Intern will return a reference to a pooled version of this object, unless it is not present in which case intern will add it.

private static boolean
public boolean

Returns:

true if the branch is on the passed in stem, false otherwise.
on
(ASN1ObjectIdentifier
the arc or branch that is a possible parent.
stem
)

Return true if this oid is an extension of the passed in branch - stem.

private static String
parseContents(byte[] contents)

private static byte[]
parseIdentifier(String identifier)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public static ASN1ObjectIdentifier
tryFromID(String identifier)

Inherited from org.bouncycastle.asn1.ASN1Primitive:
encodeToencodeToequalsequalsequalsfromByteArraytoASN1PrimitivetoDERObjecttoDLObject

Field Detail

contentsback to summary
private final byte[] contents
identifierback to summary
private String identifier
LONG_LIMITback to summary
private static final long LONG_LIMIT
MAX_CONTENTS_LENGTHback to summary
private static final int MAX_CONTENTS_LENGTH

Implementation limit on the length of the contents octets for an Object Identifier.

We adopt the same value used by OpenJDK. In theory there is no limit on the length of the contents, or the number of subidentifiers, or the length of individual subidentifiers. In practice, supporting arbitrary lengths can lead to issues, e.g. denial-of-service attacks when attempting to convert a parsed value to its (decimal) string form.

MAX_IDENTIFIER_LENGTHback to summary
private static final int MAX_IDENTIFIER_LENGTH
poolback to summary
private static final ConcurrentMap<ASN1ObjectIdentifier.OidHandle, ASN1ObjectIdentifier> pool
TYPEback to summary
pack-priv static final ASN1UniversalType TYPE

Constructor Detail

ASN1ObjectIdentifierback to summary
public ASN1ObjectIdentifier(String identifier)

Create an OID based on the passed in String.

Parameters
identifier:String

a string representation of an OID.

ASN1ObjectIdentifierback to summary
private ASN1ObjectIdentifier(byte[] contents, String identifier)

Method Detail

asn1Equalsback to summary
pack-priv boolean asn1Equals(ASN1Primitive other)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Doc from org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.

branchback to summary
public ASN1ObjectIdentifier branch(String branchID)

Return an OID that creates a branch under the current one.

Parameters
branchID:String

node numbers for the new branch.

Returns:ASN1ObjectIdentifier

the OID for the new created branch.

checkContentsLengthback to summary
pack-priv static void checkContentsLength(int contentsLength)
checkIdentifierback to summary
pack-priv static void checkIdentifier(String identifier)
createPrimitiveback to summary
pack-priv static ASN1ObjectIdentifier createPrimitive(byte[] contents, boolean clone)
encodeback to summary
pack-priv void encode(ASN1OutputStream out, boolean withTag) throws IOException

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encode.

encodeConstructedback to summary
pack-priv boolean encodeConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Doc from org.bouncycastle.asn1.ASN1Primitive.encodeConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.

Returns:boolean

true if CONSTRUCTED bit set on object's tag, false otherwise.

encodedLengthback to summary
pack-priv int encodedLength(boolean withTag)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodedLength.

fromContentsback to summary
public static ASN1ObjectIdentifier fromContents(byte[] contents)
getIdback to summary
public synchronized String getId()

Return the OID as a string.

Returns:String

the string representation of the OID carried by this object.

getInstanceback to summary
public static ASN1ObjectIdentifier getInstance(Object obj)

Return an OID from the passed in object

Parameters
obj:Object

an ASN1ObjectIdentifier or an object that can be converted into one.

Returns:ASN1ObjectIdentifier

an ASN1ObjectIdentifier instance, or null.

Exceptions
IllegalArgumentException:
if the object cannot be converted.
getInstanceback to summary
public static ASN1ObjectIdentifier getInstance(ASN1TaggedObject taggedObject, boolean explicit)

Return an OBJECT IDENTIFIER from a tagged object.

Parameters
taggedObject:ASN1TaggedObject

the tagged object holding the object we want

explicit:boolean

true if the object is meant to be explicitly tagged false otherwise.

Returns:ASN1ObjectIdentifier

an ASN1ObjectIdentifier instance, or null.

Exceptions
IllegalArgumentException:
if the tagged object cannot be converted.
hashCodeback to summary
public int hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.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.
Returns:int

a hash code value for this object

internback to summary
public ASN1ObjectIdentifier intern()

Intern will return a reference to a pooled version of this object, unless it is not present in which case intern will add it.

The pool is also used by the ASN.1 parsers to limit the number of duplicated OID objects in circulation.

Returns:ASN1ObjectIdentifier

a reference to the identifier in the pool.

isValidIdentifierback to summary
private static boolean isValidIdentifier(String identifier)
onback to summary
public boolean on(ASN1ObjectIdentifier stem)

Return true if this oid is an extension of the passed in branch - stem.

Parameters
stem:ASN1ObjectIdentifier

the arc or branch that is a possible parent.

Returns:boolean

true if the branch is on the passed in stem, false otherwise.

parseContentsback to summary
private static String parseContents(byte[] contents)
parseIdentifierback to summary
private static byte[] parseIdentifier(String identifier)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

tryFromIDback to summary
public static ASN1ObjectIdentifier tryFromID(String identifier)
org.bouncycastle.asn1 back to summary

pack-priv Class ASN1ObjectIdentifier.OidHandle

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
OidHandle(byte[] contents)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

contentsback to summary
private final byte[] contents
keyback to summary
private final int key

Constructor Detail

OidHandleback to summary
pack-priv OidHandle(byte[] contents)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

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.
Returns:int

a hash code value for this object