ewe.io
Class BlockInputStream

java.lang.Object
  extended byewe.io.BlockIO
      extended byewe.io.BlockInputStream

public class BlockInputStream
extends BlockIO

A BlockInputStream is used to read in distinct blocks of data as sent by BlockOutputStream. The data sent by the BlockOutputStream may be Secure Documents as represented by ewe.security.SecureDocument and this BlockInputStream will then attempt to decode and validate them using the encryption parameters as provided by setPassword() and setKeys().


Field Summary
protected  InputStream in
           
 
Fields inherited from class ewe.io.BlockIO
intBuff, isOutput, secureDocument
 
Constructor Summary
BlockInputStream(InputStream in)
          Create a BlockInputStream using the provided InputStream for reading in data.
 
Method Summary
 void close()
          close this BlockInputStream and the underlying input stream.
 ByteArray readBlock()
          This is used to read the next block of incoming data.
 ByteArray readBlock(ByteArray dest)
          This is used to read the next block of incoming data.
 void setDecryptor(DataProcessor decryptor)
          Set the decryptor to be used explicitly.
 void setDecryptor(String password)
          Set the decryptor by creating a new Decryptor which uses the provided password.
 void setKeys(EncryptionKey myPrivateKey, EncryptionKey remotePublicKey)
          Set the Public/Private keys.
 
Methods inherited from class ewe.io.BlockIO
createSecureDocument, getSecureDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

in

protected InputStream in
Constructor Detail

BlockInputStream

public BlockInputStream(InputStream in)
Create a BlockInputStream using the provided InputStream for reading in data.

Method Detail

setDecryptor

public void setDecryptor(DataProcessor decryptor)
                  throws IOException
Set the decryptor to be used explicitly.

Throws:
IOException

setDecryptor

public void setDecryptor(String password)
                  throws IOException
Set the decryptor by creating a new Decryptor which uses the provided password.

Throws:
IOException

readBlock

public ByteArray readBlock(ByteArray dest)
                    throws IOException
This is used to read the next block of incoming data.

Parameters:
dest - an optional destination ByteArray. If this is null a new one is created. The destination ByteArray is always cleared before the new data is added.
Returns:
the destination ByteArray or a new ByteArray. On a clean end-of-stream this will return null.
Throws:
IOException - if an error occured reading or decoding or decrypting the data.

readBlock

public ByteArray readBlock()
                    throws IOException
This is used to read the next block of incoming data.

Returns:
A new ByteArray containing the data or null if the stream has closed cleanly.
Throws:
IOException - if an error occured reading or decoding or decrypting the data.

close

public void close()
           throws IOException
close this BlockInputStream and the underlying input stream.

Throws:
IOException - if an error occured closing the underlying stream.

setKeys

public void setKeys(EncryptionKey myPrivateKey,
                    EncryptionKey remotePublicKey)
Set the Public/Private keys.

Parameters:
myPrivateKey - This is used to decrypt the symmetric session key for each block of data.
remotePublicKey - The remotePublicKey is used to verify the signature of data signed by the sender. If it is null signatures will not be verified.