Class ASN1ObjectIdentifier

  • All Implemented Interfaces:
    java.io.Serializable

    @NotMutable
    @ThreadSafety(level=COMPLETELY_THREADSAFE)
    public final class ASN1ObjectIdentifier
    extends ASN1Element
    This class provides an ASN.1 object identifier element, whose value represents a numeric OID. Note that ASN.1 object identifier elements must strictly conform to the numeric OID specification, which has the following requirements:
    • All valid OIDs must contain at least two components.
    • The value of the first component must be 0, 1, or 2.
    • If the value of the first component is 0 or 1, then the value of the second component must not be greater than 39.
    See Also:
    Serialized Form
    • Constructor Detail

      • ASN1ObjectIdentifier

        public ASN1ObjectIdentifier​(@NotNull
                                    OID oid)
                             throws ASN1Exception
        Creates a new ASN.1 object identifier element with the default BER type and the provided OID.
        Parameters:
        oid - The OID to represent with this element. It must not be null, and it must represent a valid OID.
        Throws:
        ASN1Exception - If the provided OID does not strictly adhere to the numeric OID format.
      • ASN1ObjectIdentifier

        public ASN1ObjectIdentifier​(byte type,
                                    @NotNull
                                    OID oid)
                             throws ASN1Exception
        Creates a new ASN.1 object identifier element with the specified BER type and the provided OID.
        Parameters:
        type - The BER type for this element.
        oid - The OID to represent with this element. It must not be null, and it must represent a valid OID.
        Throws:
        ASN1Exception - If the provided OID does not strictly adhere to the numeric OID format.
      • ASN1ObjectIdentifier

        public ASN1ObjectIdentifier​(@NotNull
                                    java.lang.String oidString)
                             throws ASN1Exception
        Creates a new ASN.1 object identifier element with the default BER type and the provided OID.
        Parameters:
        oidString - The string representation of the OID to represent with this element. It must not be null, and it must represent a valid OID.
        Throws:
        ASN1Exception - If the provided OID does not strictly adhere to the numeric OID format.
      • ASN1ObjectIdentifier

        public ASN1ObjectIdentifier​(byte type,
                                    @NotNull
                                    java.lang.String oidString)
                             throws ASN1Exception
        Creates a new ASN.1 object identifier element with the specified BER type and the provided OID.
        Parameters:
        type - The BER type for this element.
        oidString - The string representation of the OID to represent with this element. It must not be null, and it must represent a valid OID.
        Throws:
        ASN1Exception - If the provided OID does not strictly adhere to the numeric OID format.
    • Method Detail

      • getOID

        @NotNull
        public OID getOID()
        Retrieves the OID represented by this object identifier element.
        Returns:
        The OID represented by this object identifier element.
      • decodeAsObjectIdentifier

        @NotNull
        public static ASN1ObjectIdentifier decodeAsObjectIdentifier​(@NotNull
                                                                    byte[] elementBytes)
                                                             throws ASN1Exception
        Decodes the contents of the provided byte array as an object identifier element.
        Parameters:
        elementBytes - The byte array to decode as an ASN.1 object identifier element.
        Returns:
        The decoded ASN.1 object identifier element.
        Throws:
        ASN1Exception - If the provided array cannot be decoded as an object identifier element.
      • toString

        public void toString​(@NotNull
                             java.lang.StringBuilder buffer)
        Appends a string representation of the value for this ASN.1 element to the provided buffer.
        Overrides:
        toString in class ASN1Element
        Parameters:
        buffer - The buffer to which to append the information.