net.handle.hdllib
Class SignedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.handle.hdllib.SignedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SignedOutputStream
extends java.io.OutputStream

Objects of this class can be used to sign the contents of a stream that can be verified by a SignedInputStream class. Note: This is not a part of the official handle system specification. This class and the format of the stream it creates 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.


Constructor Summary
SignedOutputStream(java.security.PrivateKey sourceKey, java.io.OutputStream out)
          Create a stream that can verify the data read from the stream in blocks.
 
Method Summary
 void flush()
           
 void signBlock()
          Signs the bytes written since the last signature on the stream.
 void write(int b)
          Write a byte to the stream.
 
Methods inherited from class java.io.OutputStream
close, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignedOutputStream

public SignedOutputStream(java.security.PrivateKey sourceKey,
                          java.io.OutputStream out)
                   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

write

public void write(int b)
           throws java.io.IOException
Write a byte to the stream.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

signBlock

public void signBlock()
               throws java.io.IOException,
                      java.security.SignatureException
Signs the bytes written since the last signature on the stream. This should be called at the exact same point in the stream as the verifyBlock method in the SignedInputStream class.

Throws:
java.io.IOException
java.security.SignatureException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException