Class AbstractAsn1Reader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Asn1Reader

    public abstract class AbstractAsn1Reader
    extends Object
    implements Asn1Reader
    An abstract ASN1Reader which can be used as the basis for implementing new ASN1 reader implementations.
    • Constructor Detail

      • AbstractAsn1Reader

        protected AbstractAsn1Reader()
        Creates a new abstract ASN.1 reader.
    • Method Detail

      • readBoolean

        public boolean readBoolean​(byte type)
                            throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as a boolean having the provided type tag.
        Specified by:
        readBoolean in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Returns:
        The decoded boolean value.
        Throws:
        DecodeException - If the element cannot be decoded as a boolean.
        IOException - If an unexpected IO error occurred.
      • readEnumerated

        public int readEnumerated​(byte type)
                           throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as an enumerated having the provided type tag.
        Specified by:
        readEnumerated in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Returns:
        The decoded enumerated value.
        Throws:
        DecodeException - If the element cannot be decoded as an enumerated value.
        IOException - If an unexpected IO error occurred.
      • readInteger

        public long readInteger​(byte type)
                         throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as an integer having the provided type tag.
        Specified by:
        readInteger in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Returns:
        The decoded integer value.
        Throws:
        DecodeException - If the element cannot be decoded as an integer.
        IOException - If an unexpected IO error occurred.
      • readNull

        public void readNull​(byte type)
                      throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as a null element having the provided type tag.
        Specified by:
        readNull in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Throws:
        DecodeException - If the element cannot be decoded as a null element.
        IOException - If an unexpected IO error occurred.
      • readOctetString

        public ByteString readOctetString​(byte type)
                                   throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as an octet string having the provided type tag.
        Specified by:
        readOctetString in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Returns:
        The decoded octet string represented using a ByteString.
        Throws:
        DecodeException - If the element cannot be decoded as an octet string.
        IOException - If an unexpected IO error occurred.
      • readOctetStringAsString

        public String readOctetStringAsString​(byte type)
                                       throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as an octet string having the provided type tag and decodes the value as a UTF-8 encoded string.
        Specified by:
        readOctetStringAsString in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Returns:
        The decoded octet string as a UTF-8 encoded string.
        Throws:
        DecodeException - If the element cannot be decoded as an octet string.
        IOException - If an unexpected IO error occurred.
      • readAsn1Element

        public ByteString readAsn1Element()
                                   throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element and returns its full encoding, which includes tag and length bytes.
        Specified by:
        readAsn1Element in interface Asn1Reader
        Returns:
        The full encoding of the next element.
        Throws:
        IOException - If an unexpected IO error occurred.
      • readStartExplicitTag

        public void readStartExplicitTag​(byte type)
                                  throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as an explicit tag having the provided tag type. All further reads will read the elements in the explicit tag until Asn1Reader.readEndExplicitTag() is called.
        Specified by:
        readStartExplicitTag in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Throws:
        DecodeException - If the element cannot be decoded as an explicit tag.
        IOException - If an unexpected IO error occurred.
      • readStartSequence

        public void readStartSequence​(byte type)
                               throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as a sequence having the provided type tag. All further reads will read the elements in the sequence until Asn1Reader.readEndSequence() is called.
        Specified by:
        readStartSequence in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Throws:
        DecodeException - If the element cannot be decoded as a sequence.
        IOException - If an unexpected IO error occurred.
      • readStartSet

        public void readStartSet​(byte type)
                          throws IOException
        Description copied from interface: Asn1Reader
        Reads the next element as a set having the provided type tag. All further reads will read the elements in the set until Asn1Reader.readEndSet() is called.
        Specified by:
        readStartSet in interface Asn1Reader
        Parameters:
        type - The expected type tag of the element.
        Throws:
        DecodeException - If the element cannot be decoded as a set.
        IOException - If an unexpected IO error occurred.
      • skipElement

        public Asn1Reader skipElement​(byte expectedType)
                               throws IOException
        Description copied from interface: Asn1Reader
        Skips the next element having the provided type tag without decoding it.
        Specified by:
        skipElement in interface Asn1Reader
        Parameters:
        expectedType - The expected type tag of the element.
        Returns:
        A reference to this ASN.1 reader.
        Throws:
        DecodeException - If the next element does not have the provided type tag.
        IOException - If an unexpected IO error occurred.