public class SecureBlockOutputStream extends BlockOutputStream
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 |
---|---|
protected SecureDocument |
secureDocument |
maximumOutputBlockSize, out
Constructor and Description |
---|
SecureBlockOutputStream(OutputStream out)
Create a BlockOutputStream using the provided OutputStream for writing
out data.
|
Modifier and Type | Method and Description |
---|---|
void |
changeEncryption()
This forces the output stream to change its encryption.
|
protected SecureDocument |
createSecureDocument() |
protected boolean |
encrypt(byte[] source,
int offset,
int length,
ByteArray dest)
This is called during the writeBlock() method.
|
protected SecureDocument |
getSecureDocument() |
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.
|
blockWrite, close, writeBlock, writeBlock, writeDirect
protected SecureDocument secureDocument
public SecureBlockOutputStream(OutputStream out)
protected SecureDocument getSecureDocument()
protected SecureDocument createSecureDocument()
public void setDontUseCompression(boolean dontUseCompression)
public void setEncryptor(DataProcessor encryptor) throws IOException
IOException
public void setEncryptor(String password) throws IOException
IOException
public void changeEncryption() throws IOException
IOException
protected boolean encrypt(byte[] source, int offset, int length, ByteArray dest) throws IOException
encrypt
in class BlockOutputStream
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 setKeys(EncryptionKey remotePublicKey, EncryptionKey myPrivateKey)
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.