Package com.oss.util

Class BERTool.BERReader

java.lang.Object
com.oss.util.BERTool.BERReader
Enclosing class:
BERTool

public static class BERTool.BERReader extends Object
Provides the readTLV() method to read a complete BER encoding from an input stream and return it as an array of bytes.

The class instance uses an internal byte buffer to acquire encoded bytes that are read from the input stream. The buffer is allocated with a default or specified size and is resized as needed to acquire the longest BER encoding across multiple invocations of the readTLV() method.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an instance with a default initial buffer size.
    BERReader(int size)
    Constructs an instance with a specified initial buffer size.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Reads a complete BER encoding from an input stream and returns it as an array of bytes.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BERReader

      public BERReader()
      Constructs an instance with a default initial buffer size.
    • BERReader

      public BERReader(int size)
      Constructs an instance with a specified initial buffer size.
      Parameters:
      size - the initial size of the internal buffer that is used to acquire a BER encoding.
  • Method Details

    • readTLV

      public byte[] readTLV(InputStream in) throws IOException
      Reads a complete BER encoding from an input stream and returns it as an array of bytes.
      Parameters:
      in - the input stream.
      Returns:
      the byte array containing a complete BER/DER/CER encoding.
      Throws:
      IOException - when an input error occurs.
      BERTool.BERException - when an error in the BER data is detected.