net.handle.hdllib
Class SignedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.handle.hdllib.SignedInputStream
All Implemented Interfaces:
java.io.Closeable

public class SignedInputStream
extends java.io.InputStream

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 system specification. This class and the format of the stream it reads will almost definitely change with future versions of the handle system. A possible improvement is to use digest or MAC-based verification rather than full public/private key signatures for each block.


Field Summary
static int STREAM_TYPE_PK
           
 
Constructor Summary
SignedInputStream(java.security.PublicKey sourceKey, java.io.InputStream in)
          Create a stream that can verify the data read from the stream in blocks.
 
Method Summary
 int read()
          Read a byte from the stream.
 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.InputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STREAM_TYPE_PK

public static final int STREAM_TYPE_PK
See Also:
Constant Field Values
Constructor Detail

SignedInputStream

public SignedInputStream(java.security.PublicKey sourceKey,
                         java.io.InputStream in)
                  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

read

public int read()
         throws java.io.IOException
Read a byte from the stream.

Specified by:
read in class java.io.InputStream
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