Class ASN1InputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, DERTags

    public class ASN1InputStream
    extends java.io.FilterInputStream
    implements DERTags
    a general purpose ASN.1 decoder - note: this class differs from the others in that it returns null after it has read the last object in the stream. If an ASN.1 NULL is encountered a DER/BER Null object is returned.
    • Field Detail

      • END_OF_STREAM

        private static final DERObject END_OF_STREAM
      • eofFound

        boolean eofFound
      • limit

        int limit
    • Constructor Detail

      • ASN1InputStream

        public ASN1InputStream​(java.io.InputStream is)
      • ASN1InputStream

        public ASN1InputStream​(byte[] input)
        Create an ASN1InputStream based on the input byte array. The length of DER objects in the stream is automatically limited to the length of the input array.
        Parameters:
        input - array containing ASN.1 encoded data.
      • ASN1InputStream

        public ASN1InputStream​(java.io.InputStream input,
                               int limit)
        Create an ASN1InputStream where no DER object will be longer than limit.
        Parameters:
        input - stream containing ASN.1 encoded data.
        limit - maximum size of a DER encoded object.
    • Method Detail

      • readLength

        protected int readLength()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readFully

        protected void readFully​(byte[] bytes)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • buildObject

        protected DERObject buildObject​(int tag,
                                        int tagNo,
                                        int length)
                                 throws java.io.IOException
        build an object given its tag and the number of bytes to construct it from.
        Throws:
        java.io.IOException
      • readDefiniteLengthFully

        private byte[] readDefiniteLengthFully​(int length)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readIndefiniteLengthFully

        private byte[] readIndefiniteLengthFully()
                                          throws java.io.IOException
        read a string of bytes representing an indefinite length object.
        Throws:
        java.io.IOException
      • buildConstructedOctetString

        private BERConstructedOctetString buildConstructedOctetString​(DERObject sentinel)
                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • buildDerConstructedOctetString

        private BERConstructedOctetString buildDerConstructedOctetString​(int length)
                                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • buildEncodableVector

        private ASN1EncodableVector buildEncodableVector​(DERObject sentinel)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • buildDerEncodableVector

        private ASN1EncodableVector buildDerEncodableVector​(int length)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readObject

        public DERObject readObject()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readTagNumber

        private int readTagNumber​(int tag)
                           throws java.io.IOException
        Throws:
        java.io.IOException