public class ArchiveCreator
extends java.lang.Object
Due to the format of an Entrust Archive, it is not possible to stream them during creation. This means that all the data in the file must be buffered internally, making this format not well suited for encrypting or signing large files.
Use of this class is not recommended. The Entrust Archive format is a proprietary format used by older Entrust products, and is not interoperable. PKCS7 or SMIME should be used instead for interoperability purposes.
ArchiveInputStream| Constructor and Description |
|---|
ArchiveCreator(User user,
java.io.File toProtect,
PemOptions pemOptions,
LargeFileOptions largeFileOptions,
java.io.OutputStream outStream)
This constructor provides support for protection of large files (larger
than available memory) with Entrust Archive format.
|
ArchiveCreator(User user,
java.io.File toProtect,
PemOptions options,
java.io.OutputStream outStream)
This constructor only supports protection of small files (smaller than
available memory) with Entrust Archive format.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort the operation of protecting data.
|
X509Certificate[] |
addRecipients(X509Certificate[] recipients)
Adds each certificate in the given array as a message recipient.
|
void |
addTrustedRecipients(X509Certificate[] recipients)
Adds each certificate in the given array as a message recipient.
|
int |
process()
This method should be called repeatedly to read data from the input file,
and protect the data.
|
void |
useOAEP(boolean useOAEP)
Indicate whether or not OAEP padding should be used when encrypting
the message.
|
public ArchiveCreator(User user, java.io.File toProtect, PemOptions options, java.io.OutputStream outStream) throws ArchiveException, UserNotLoggedInException, java.io.FileNotFoundException
During archive creation, all data will be buffered to memory. When used
with large files, an OutOfMemoryError can occur.
user - The user creating the ArchivetoProtect - The File to protectoptions - The options used to protect the file.outStream - A stream to write the protected file to. This stream will be closed
once processing is finished.UserNotLoggedInException - if the given user is not logged in.ArchiveException - if the given parameters are not valid, or there is an error initializing
the cryptographic operations.java.io.FileNotFoundException - if the file to protect cannot be foundpublic ArchiveCreator(User user, java.io.File toProtect, PemOptions pemOptions, LargeFileOptions largeFileOptions, java.io.OutputStream outStream) throws ArchiveException, UserNotLoggedInException, java.io.FileNotFoundException
During archive creation, all data will be buffered to a combination of
memory and temporary files. For details on large file support, refer
to LargeFileOptions.
user - The user creating the ArchivetoProtect - The File to protectpemOptions - PEM related options used to protect the filelargeFileOptions - options related to the protection of large filesoutStream - A stream to write the protected file to. This stream will be closed
once processing is finished.UserNotLoggedInException - if the given user is not logged in.ArchiveException - if the given parameters are not valid, or there is an error initializing
the cryptographic operations.java.io.FileNotFoundException - if the file to protect cannot be foundpublic X509Certificate[] addRecipients(X509Certificate[] recipients)
For each certificate, this method makes sure the key usage is appropriate for encryption, and that the certificate is valid. It does not ensure the uniqueness of recipients.
recipients - the encryption certificates of the intended message recipientspublic void addTrustedRecipients(X509Certificate[] recipients) throws ArchiveException
This method does not validate certificates, only that the key usage is appropriate for encryption. It does not ensure the uniqueness of recipients. Certificates that are not appropriate for encryption are ignored.
recipients - the encryption certificates of the intended message recipientsArchiveException - if the user is not allowed to trust arbitrary certificates. This is
equivalent to saying the user is not permitted to use a personal address
book.ClientSettings.getPermitPAB()public void useOAEP(boolean useOAEP)
useOAEP - whether or not OAEP padding should be usedpublic int process()
throws java.io.IOException,
ArchiveException
-1.
After it returns -1, the OutputStream where the
Archive was being written to is closed.-1
if all the data has been processed.java.io.IOException - if an error occurs reading from the file being protected, or writing
to the output stream.ArchiveException - if the processing was aborted by abort(), or if
any other error, such as signature calculation, occurs.public void abort()