public class BlockOutputStream extends Object implements IBlockOutput
You can also provide an Encryptor for the Stream in which case the receiving BlockInputStream must also have a matching Decryptor.
Modifier and Type | Field and Description |
---|---|
static int |
maximumOutputBlockSize
By default this is 5 MB.
|
protected OutputStream |
out |
Constructor and Description |
---|
BlockOutputStream(OutputStream out)
Create a BlockOutputStream using the provided OutputStream for writing
out data.
|
Modifier and Type | Method and Description |
---|---|
void |
blockWrite(byte[] src,
int offset,
int length)
Set the Public/Private keys.
|
void |
close()
Close this BlockOutputStream and the underlying OutputStream.
|
protected boolean |
encrypt(byte[] source,
int offset,
int length,
ByteArray dest)
This is called during the writeBlock() method.
|
void |
writeBlock(byte[] source,
int offset,
int length)
Write out a block of data, encrypting if necessary.
|
void |
writeBlock(ByteArray data)
Write out a block of data.
|
protected void |
writeDirect(byte[] source,
int offset,
int length) |
protected OutputStream out
public static int maximumOutputBlockSize
public BlockOutputStream(OutputStream out)
public void writeBlock(ByteArray data) throws IOException
IOException
protected void writeDirect(byte[] source, int offset, int length) throws IOException
IOException
protected boolean encrypt(byte[] source, int offset, int length, ByteArray dest) throws IOException
source
- the source data.offset
- the offset of the source data bytes.length
- the number of bytes to be sent.dest
- a destination ByteArray that will not be null and will be cleared
before being passed.IOException
- if there was an error encrypting the data.public void writeBlock(byte[] source, int offset, int length) throws IOException
IOException
public void close() throws IOException
close
in interface IBlockOutput
IOException
- if an error occurs closing the underlying OutputStream.public void blockWrite(byte[] src, int offset, int length) throws IOException
blockWrite
in interface IBlockOutput
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.IOException