public class EncryptionProperties extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected int |
encryptionAlgorithm |
protected byte[] |
ownerPassword |
protected Certificate[] |
publicCertificates |
protected int[] |
publicKeyEncryptPermissions |
protected int |
standardEncryptPermissions |
protected byte[] |
userPassword |
Constructor and Description |
---|
EncryptionProperties() |
Modifier and Type | Method and Description |
---|---|
EncryptionProperties |
setPublicKeyEncryption(Certificate[] certs, int[] permissions, int encryptionAlgorithm)
Sets the certificate encryption options for the document.
|
EncryptionProperties |
setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)
Sets the encryption options for the document.
|
protected int encryptionAlgorithm
protected byte[] userPassword
protected byte[] ownerPassword
protected int standardEncryptPermissions
protected Certificate[] publicCertificates
protected int[] publicKeyEncryptPermissions
public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)
userPassword
- the user password. Can be null or of zero length, which is equal to omitting the user password
ownerPassword
- the owner password. If it's null or empty, iText will generate a random string to be used as the owner password
permissions
- the user permissions. The open permissions for the document can be EncryptionConstants.ALLOW_PRINTING
, EncryptionConstants.ALLOW_MODIFY_CONTENTS
, EncryptionConstants.ALLOW_COPY
, EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS
, EncryptionConstants.ALLOW_FILL_IN
, EncryptionConstants.ALLOW_SCREENREADERS
, EncryptionConstants.ALLOW_ASSEMBLY
and EncryptionConstants.ALLOW_DEGRADED_PRINTING
. The permissions can be combined by ORing them
encryptionAlgorithm
- the type of encryption. It can be one of EncryptionConstants.STANDARD_ENCRYPTION_40
, EncryptionConstants.STANDARD_ENCRYPTION_128
, EncryptionConstants.ENCRYPTION_AES_128
or EncryptionConstants.ENCRYPTION_AES_256
. Optionally EncryptionConstants.DO_NOT_ENCRYPT_METADATA
can be OEed to output the metadata in cleartext. EncryptionConstants.EMBEDDED_FILES_ONLY
can be ORed as well. Please be aware that the passed encryption types may override permissions: EncryptionConstants.STANDARD_ENCRYPTION_40
implicitly sets EncryptionConstants.DO_NOT_ENCRYPT_METADATA
and EncryptionConstants.EMBEDDED_FILES_ONLY
as false; EncryptionConstants.STANDARD_ENCRYPTION_128
implicitly sets EncryptionConstants.EMBEDDED_FILES_ONLY
as false;
EncryptionProperties
public EncryptionProperties setPublicKeyEncryption(Certificate[] certs, int[] permissions, int encryptionAlgorithm)
An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate.
certs
- the public certificates to be used for the encryption
permissions
- the user permissions for each of the certificates The open permissions for the document can be EncryptionConstants.ALLOW_PRINTING
, EncryptionConstants.ALLOW_MODIFY_CONTENTS
, EncryptionConstants.ALLOW_COPY
, EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS
, EncryptionConstants.ALLOW_FILL_IN
, EncryptionConstants.ALLOW_SCREENREADERS
, EncryptionConstants.ALLOW_ASSEMBLY
and EncryptionConstants.ALLOW_DEGRADED_PRINTING
. The permissions can be combined by ORing them
encryptionAlgorithm
- the type of encryption. It can be one of EncryptionConstants.STANDARD_ENCRYPTION_40
, EncryptionConstants.STANDARD_ENCRYPTION_128
, EncryptionConstants.ENCRYPTION_AES_128
or EncryptionConstants.ENCRYPTION_AES_256
. Optionally EncryptionConstants.DO_NOT_ENCRYPT_METADATA
can be ORed to output the metadata in cleartext. EncryptionConstants.EMBEDDED_FILES_ONLY
can be ORed as well. Please be aware that the passed encryption types may override permissions: EncryptionConstants.STANDARD_ENCRYPTION_40
implicitly sets EncryptionConstants.DO_NOT_ENCRYPT_METADATA
and EncryptionConstants.EMBEDDED_FILES_ONLY
as false; EncryptionConstants.STANDARD_ENCRYPTION_128
implicitly sets EncryptionConstants.EMBEDDED_FILES_ONLY
as false;
EncryptionProperties
Copyright © 1998–2021 iText Group NV. All rights reserved.