Class Asn1


  • public final class Asn1
    extends Object
    This class contains various static factory methods for creating ASN.1 readers and writers.
    See Also:
    Asn1Reader, Asn1Writer
    • Field Detail

      • BOOLEAN_VALUE_FALSE

        public static final byte BOOLEAN_VALUE_FALSE
        The byte array containing the pre-encoded ASN.1 encoding for a boolean value of "false".
        See Also:
        Constant Field Values
      • BOOLEAN_VALUE_TRUE

        public static final byte BOOLEAN_VALUE_TRUE
        The byte array containing the pre-encoded ASN.1 encoding for a boolean value of "false".
        See Also:
        Constant Field Values
      • UNIVERSAL_BOOLEAN_TYPE

        public static final byte UNIVERSAL_BOOLEAN_TYPE
        The BER type that is assigned to the universal Boolean element.
        See Also:
        Constant Field Values
      • UNIVERSAL_INTEGER_TYPE

        public static final byte UNIVERSAL_INTEGER_TYPE
        The BER type that is assigned to the universal integer type.
        See Also:
        Constant Field Values
      • UNIVERSAL_BIT_STRING_TYPE

        public static final byte UNIVERSAL_BIT_STRING_TYPE
        The BER type that is assigned to the universal bit string type.
        See Also:
        Constant Field Values
      • UNIVERSAL_OCTET_STRING_TYPE

        public static final byte UNIVERSAL_OCTET_STRING_TYPE
        The BER type that is assigned to the universal octet string type.
        See Also:
        Constant Field Values
      • UNIVERSAL_NULL_TYPE

        public static final byte UNIVERSAL_NULL_TYPE
        The BER type that is assigned to the universal null type.
        See Also:
        Constant Field Values
      • OBJECT_IDENTIFIER

        public static final byte OBJECT_IDENTIFIER
        The BER type that is assigned to the object identifier type.
        See Also:
        Constant Field Values
      • UNIVERSAL_PRINTABLE_STRING_TYPE

        public static final byte UNIVERSAL_PRINTABLE_STRING_TYPE
        The BER type that is assigned to the universal Printable String type.
        See Also:
        Constant Field Values
      • UNIVERSAL_UTC_TIME_TYPE

        public static final byte UNIVERSAL_UTC_TIME_TYPE
        The BER type that is assigned to the utc time type.
        See Also:
        Constant Field Values
      • UNIVERSAL_GENERALIZED_TIME_TYPE

        public static final byte UNIVERSAL_GENERALIZED_TIME_TYPE
        The BER type that is assigned to the generalized time type.
        See Also:
        Constant Field Values
      • UNIVERSAL_ENUMERATED_TYPE

        public static final byte UNIVERSAL_ENUMERATED_TYPE
        The BER type that is assigned to the universal enumerated type.
        See Also:
        Constant Field Values
      • UNIVERSAL_SEQUENCE_TYPE

        public static final byte UNIVERSAL_SEQUENCE_TYPE
        The BER type that is assigned to the universal sequence type.
        See Also:
        Constant Field Values
      • UNIVERSAL_SET_TYPE

        public static final byte UNIVERSAL_SET_TYPE
        The BER type that is assigned to the universal set type.
        See Also:
        Constant Field Values
      • ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES

        public static final int ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES
        The ASN.1 element decoding state that indicates that the next byte read should be additional bytes of a multi-byte length.
        See Also:
        Constant Field Values
      • ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE

        public static final int ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE
        The ASN.1 element decoding state that indicates that the next byte read should be the first byte for the element length.
        See Also:
        Constant Field Values
      • ELEMENT_READ_STATE_NEED_TYPE

        public static final int ELEMENT_READ_STATE_NEED_TYPE
        The ASN.1 element decoding state that indicates that the next byte read should be the BER type for a new element.
        See Also:
        Constant Field Values
      • ELEMENT_READ_STATE_NEED_VALUE_BYTES

        public static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES
        The ASN.1 element decoding state that indicates that the next byte read should be applied to the value of the element.
        See Also:
        Constant Field Values
      • TYPE_MASK_CONSTRUCTED

        public static final byte TYPE_MASK_CONSTRUCTED
        The bitmask that can be ANDed with the BER type to determine if the element is constructed.
        See Also:
        Constant Field Values
      • TYPE_MASK_CONTEXT

        public static final byte TYPE_MASK_CONTEXT
        The bitmask that can be ANDed with the BER type to determine if the element is in the context-specific class.
        See Also:
        Constant Field Values
    • Method Detail

      • getReader

        public static Asn1Reader getReader​(byte[] array)
        Returns an ASN.1 reader whose source is the provided byte array and having an unlimited maximum BER element size.
        Parameters:
        array - The byte array to use.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(byte[] array,
                                           int maxElementSize)
        Returns an ASN.1 reader whose source is the provided byte array and having a user defined maximum BER element size.
        Parameters:
        array - The byte array to use.
        maxElementSize - The maximum BER element size, or 0 to indicate that there is no limit.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(ByteSequence sequence)
        Returns an ASN.1 reader whose source is the provided byte sequence and having an unlimited maximum BER element size.
        Parameters:
        sequence - The byte sequence to use.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(ByteSequence sequence,
                                           int maxElementSize)
        Returns an ASN.1 reader whose source is the provided byte sequence and having a user defined maximum BER element size.
        Parameters:
        sequence - The byte sequence to use.
        maxElementSize - The maximum BER element size, or 0 to indicate that there is no limit.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(ByteSequenceReader reader)
        Returns an ASN.1 reader whose source is the provided byte sequence reader and having an unlimited maximum BER element size.
        Parameters:
        reader - The byte sequence reader to use.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(ByteSequenceReader reader,
                                           int maxElementSize)
        Returns an ASN.1 reader whose source is the provided byte sequence reader and having a user defined maximum BER element size.
        Parameters:
        reader - The byte sequence reader to use.
        maxElementSize - The maximum BER element size, or 0 to indicate that there is no limit.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(InputStream stream)
        Returns an ASN.1 reader whose source is the provided input stream and having an unlimited maximum BER element size.
        Parameters:
        stream - The input stream to use.
        Returns:
        The new ASN.1 reader.
      • getReader

        public static Asn1Reader getReader​(InputStream stream,
                                           int maxElementSize)
        Returns an ASN.1 reader whose source is the provided input stream and having a user defined maximum BER element size.
        Parameters:
        stream - The input stream to use.
        maxElementSize - The maximum BER element size, or 0 to indicate that there is no limit.
        Returns:
        The new ASN.1 reader.
      • getWriter

        public static Asn1Writer getWriter​(ByteStringBuilder builder)
        Returns an ASN.1 writer whose destination is the provided byte string builder.
        Parameters:
        builder - The byte string builder to use.
        Returns:
        The new ASN.1 writer.
      • getWriter

        public static Asn1Writer getWriter​(ByteStringBuilder builder,
                                           int maxBufferSize)
        Returns an ASN.1 writer whose destination is the provided byte string builder.
        Parameters:
        builder - The output stream to use.
        maxBufferSize - The threshold capacity beyond which internal cached buffers used for encoding and decoding ASN1 will be trimmed after use.
        Returns:
        The new ASN.1 writer.
      • getWriter

        public static Asn1Writer getWriter​(OutputStream stream)
        Returns an ASN.1 writer whose destination is the provided output stream.
        Parameters:
        stream - The output stream to use.
        Returns:
        The new ASN.1 writer.
      • getWriter

        public static Asn1Writer getWriter​(OutputStream stream,
                                           int maxBufferSize)
        Returns an ASN.1 writer whose destination is the provided output stream.
        Parameters:
        stream - The output stream to use.
        maxBufferSize - The threshold capacity beyond which internal cached buffers used for encoding and decoding ASN1 will be trimmed after use.
        Returns:
        The new ASN.1 writer.