Class SignedInputStream

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

    public class SignedInputStream
    extends java.io.FilterInputStream
    Objects of this class can be used to verify the contents of a stream generated by a SignedOutputStream class. Note: This is not a part of the official handle protocol specification. This was introduced by CNRI solely for replication in the Handle.net software.
    • Constructor Summary

      Constructors 
      Constructor Description
      SignedInputStream​(java.security.PublicKey sourceKey, java.io.InputStream in, java.net.Socket socket)
      Create a stream that can verify the data read from the stream in blocks.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isSecure()  
      int read()
      Read a byte from the stream.
      int read​(byte[] b)  
      int read​(byte[] b, int off, int len)  
      boolean verifyBlock()
      Reads a signature from the stream and verifies the bytes read since the last verification based on that signature.
      • Methods inherited from class java.io.FilterInputStream

        available, close, mark, markSupported, reset, skip
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SignedInputStream

        public SignedInputStream​(java.security.PublicKey sourceKey,
                                 java.io.InputStream in,
                                 java.net.Socket socket)
                          throws java.lang.Exception
        Create a stream that can verify the data read from the stream in blocks. The caller should call the verifyBlock method at the end of every block of data that needs to be verified. verifyBlock must be called at the same position in the stream that signBlock was called in the parallel SignedOutputStream object that generated the stream.
        Throws:
        java.lang.Exception
    • Method Detail

      • isSecure

        public boolean isSecure()
      • read

        public int read()
                 throws java.io.IOException
        Read a byte from the stream.
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • verifyBlock

        public boolean verifyBlock()
                            throws java.io.IOException,
                                   java.security.SignatureException
        Reads a signature from the stream and verifies the bytes read since the last verification based on that signature. This should be called at the exact same point in the stream as the signBlock() in the SignedOutpuStream class.
        Throws:
        java.io.IOException
        java.security.SignatureException