Class Asn1

java.lang.Object
org.forgerock.opendj.io.Asn1

public final class Asn1 extends Object
This class contains various static factory methods for creating ASN.1 readers and writers.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    static Asn1Reader
    Returns an ASN.1 reader whose source is the provided input stream and having an unlimited maximum BER element size.
    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.
    static Asn1Reader
    Returns an ASN.1 reader whose source is the provided byte string and having an unlimited maximum BER element size.
    static Asn1Reader
    getReader(ByteString bytes, int maxElementSize)
    Returns an ASN.1 reader whose source is the provided byte string and having a user defined maximum BER element size.
    static Asn1Reader
    Returns an ASN.1 reader whose source is the provided byte string reader and having an unlimited maximum BER element size.
    static Asn1Reader
    getReader(ByteStringReader reader, int maxElementSize)
    Returns an ASN.1 reader whose source is the provided byte string reader and having a user defined maximum BER element size.
    static Asn1Writer
    Returns an ASN.1 writer with an initial capacity of 32 bytes.
    static Asn1Writer
    getWriter(int initialCapacity)
    Returns an ASN.1 writer with the provided initial capacity.
    static ByteString
    Writes an ASN.1 sequence using the provided Consumer and returns the encoded bytes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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(ByteString bytes)
      Returns an ASN.1 reader whose source is the provided byte string and having an unlimited maximum BER element size.
      Parameters:
      bytes - The byte string to use.
      Returns:
      The new ASN.1 reader.
    • getReader

      public static Asn1Reader getReader(ByteString bytes, int maxElementSize)
      Returns an ASN.1 reader whose source is the provided byte string and having a user defined maximum BER element size.
      Parameters:
      bytes - The byte string 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(ByteStringReader reader)
      Returns an ASN.1 reader whose source is the provided byte string reader and having an unlimited maximum BER element size.
      Parameters:
      reader - The byte string reader to use.
      Returns:
      The new ASN.1 reader.
    • getReader

      public static Asn1Reader getReader(ByteStringReader reader, int maxElementSize)
      Returns an ASN.1 reader whose source is the provided byte string reader and having a user defined maximum BER element size.
      Parameters:
      reader - The byte string 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()
      Returns an ASN.1 writer with an initial capacity of 32 bytes.
      Returns:
      The new ASN.1 writer.
    • getWriter

      public static Asn1Writer getWriter(int initialCapacity)
      Returns an ASN.1 writer with the provided initial capacity.
      Parameters:
      initialCapacity - The initial capacity of the internal byte buffer.
      Returns:
      The new ASN.1 writer.
    • writeAsn1Sequence

      public static ByteString writeAsn1Sequence(Consumer<Asn1Writer> sequenceWriter)
      Writes an ASN.1 sequence using the provided Consumer and returns the encoded bytes.
      Parameters:
      sequenceWriter - A consumer which is responsible for writing the contents of the sequence to the provided ASN.1 writer. Any IOExceptions thrown by the consumer will be treated as runtime errors.
      Returns:
      The encoded ASN.1 sequence.