ewe.io
Class BlockOutputStream

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

public class BlockOutputStream
extends BlockIO

A BlockOutputStream is used to write out a block of data that is received by a BlockInputStream as a single block.

You can also provide an Encryptor for the Stream in which case the receiving BlockInputStream must also have a matching Decryptor.


Field Summary
protected  OutputStream out
           
 
Fields inherited from class ewe.io.BlockIO
intBuff, isOutput, secureDocument
 
Constructor Summary
BlockOutputStream(OutputStream out)
          Create a BlockOutputStream using the provided OutputStream for writing out data.
 
Method Summary
 void changeEncryption()
          This forces the output stream to change its encryption.
 void close()
          Close this BlockOutputStream and the underlying OutputStream.
 void setDontUseCompression(boolean dontUseCompression)
          This is used to set the dontUseCompression option for data encryption.
 void setEncryptor(DataProcessor encryptor)
          Explicitly set the encryptor to use.
 void setEncryptor(String password)
          Set the encryptor to be a new Encryptor using the specified password.
 void setKeys(EncryptionKey remotePublicKey, EncryptionKey myPrivateKey)
          Set the Public/Private keys.
 void writeBlock(byte[] source, int offset, int length)
          Write out a block of data, encrypting it as necessary.
 void writeBlock(ByteArray data)
          Write out a block of data.
 
Methods inherited from class ewe.io.BlockIO
createSecureDocument, getSecureDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

out

protected OutputStream out
Constructor Detail

BlockOutputStream

public BlockOutputStream(OutputStream out)
Create a BlockOutputStream using the provided OutputStream for writing out data.

Method Detail

setDontUseCompression

public void setDontUseCompression(boolean dontUseCompression)
This is used to set the dontUseCompression option for data encryption.


setEncryptor

public void setEncryptor(DataProcessor encryptor)
                  throws IOException
Explicitly set the encryptor to use.

Throws:
IOException

setEncryptor

public void setEncryptor(String password)
                  throws IOException
Set the encryptor to be a new Encryptor using the specified password.

Throws:
IOException

changeEncryption

public void changeEncryption()
                      throws IOException
This forces the output stream to change its encryption. This is only used when a remote Public Key is available. The new encryption key is encrypted using the receiver's Public Key and then sent along with the data encrypted using that new key.

Throws:
IOException

writeBlock

public void writeBlock(ByteArray data)
                throws IOException
Write out a block of data.

Throws:
IOException

writeBlock

public void writeBlock(byte[] source,
                       int offset,
                       int length)
                throws IOException
Write out a block of data, encrypting it as necessary.

Throws:
IOException

close

public void close()
           throws IOException
Close this BlockOutputStream and the underlying OutputStream.

Throws:
IOException - if an error occurs closing the underlying OutputStream.

setKeys

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

Parameters:
remotePublicKey - This is the public key of the receiver and the symmetric key used to encrypt each block of data will be encrypted using this key.
myPrivateKey - if this is not null it will be used to sign data being transmitted. If you do not want to sign outgoing data, you can leave this null.