Package com.itextpdf.kernel.pdf
Class EncryptionProperties
- java.lang.Object
-
- com.itextpdf.kernel.pdf.EncryptionProperties
-
public class EncryptionProperties extends java.lang.ObjectAllows configuration of output PDF encryption.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static MacPropertiesDEFAULT_MAC_PROPERTIESprotected intencryptionAlgorithmprotected MacPropertiesmacPropertiesMacPropertiesclass to configure MAC integrity protection properties.protected byte[]ownerPasswordprotected java.security.cert.Certificate[]publicCertificatesprotected int[]publicKeyEncryptPermissionsprotected intstandardEncryptPermissionsprotected byte[]userPassword
-
Constructor Summary
Constructors Constructor Description EncryptionProperties()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearEncryption()(package private) booleanisPublicKeyEncryptionUsed()(package private) booleanisStandardEncryptionUsed()private static voidrandomBytes(byte[] bytes)EncryptionPropertiessetPublicKeyEncryption(java.security.cert.Certificate[] certs, int[] permissions, int encryptionAlgorithm, MacProperties macProperties)Sets the certificate encryption options for the document.EncryptionPropertiessetStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)Sets the encryption options for the document.EncryptionPropertiessetStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm, MacProperties macProperties)Sets the encryption options for the document.
-
-
-
Field Detail
-
encryptionAlgorithm
protected int encryptionAlgorithm
-
userPassword
protected byte[] userPassword
-
ownerPassword
protected byte[] ownerPassword
-
standardEncryptPermissions
protected int standardEncryptPermissions
-
publicCertificates
protected java.security.cert.Certificate[] publicCertificates
-
publicKeyEncryptPermissions
protected int[] publicKeyEncryptPermissions
-
macProperties
protected MacProperties macProperties
MacPropertiesclass to configure MAC integrity protection properties.
-
DEFAULT_MAC_PROPERTIES
static final MacProperties DEFAULT_MAC_PROPERTIES
-
-
Method Detail
-
setStandardEncryption
public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)
Sets the encryption options for the document.- Parameters:
userPassword- the user password. Can be null or of zero length, which is equal to omitting the user passwordownerPassword- the owner password. If it's null or empty, iText will generate a random string to be used as the owner passwordpermissions- the user permissions. The open permissions for the document can beEncryptionConstants.ALLOW_PRINTING,EncryptionConstants.ALLOW_MODIFY_CONTENTS,EncryptionConstants.ALLOW_COPY,EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS,EncryptionConstants.ALLOW_FILL_IN,EncryptionConstants.ALLOW_SCREENREADERS,EncryptionConstants.ALLOW_ASSEMBLYandEncryptionConstants.ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing themencryptionAlgorithm- the type of encryption. It can be one ofEncryptionConstants.STANDARD_ENCRYPTION_40,EncryptionConstants.STANDARD_ENCRYPTION_128,EncryptionConstants.ENCRYPTION_AES_128,EncryptionConstants.ENCRYPTION_AES_256orEncryptionConstants.ENCRYPTION_AES_GCM. OptionallyEncryptionConstants.DO_NOT_ENCRYPT_METADATAcan be OEed to output the metadata in cleartext.EncryptionConstants.EMBEDDED_FILES_ONLYcan be ORed as well. Please be aware that the passed encryption types may override permissions:EncryptionConstants.STANDARD_ENCRYPTION_40implicitly setsEncryptionConstants.DO_NOT_ENCRYPT_METADATAandEncryptionConstants.EMBEDDED_FILES_ONLYas false;EncryptionConstants.STANDARD_ENCRYPTION_128implicitly setsEncryptionConstants.EMBEDDED_FILES_ONLYas false;- Returns:
- this
EncryptionProperties
-
setStandardEncryption
public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm, MacProperties macProperties)
Sets the encryption options for the document.- Parameters:
userPassword- the user password. Can be null or of zero length, which is equal to omitting the user passwordownerPassword- the owner password. If it's null or empty, iText will generate a random string to be used as the owner passwordpermissions- the user permissions. The open permissions for the document can beEncryptionConstants.ALLOW_PRINTING,EncryptionConstants.ALLOW_MODIFY_CONTENTS,EncryptionConstants.ALLOW_COPY,EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS,EncryptionConstants.ALLOW_FILL_IN,EncryptionConstants.ALLOW_SCREENREADERS,EncryptionConstants.ALLOW_ASSEMBLYandEncryptionConstants.ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing themencryptionAlgorithm- the type of encryption. It can be one ofEncryptionConstants.STANDARD_ENCRYPTION_40,EncryptionConstants.STANDARD_ENCRYPTION_128,EncryptionConstants.ENCRYPTION_AES_128,EncryptionConstants.ENCRYPTION_AES_256orEncryptionConstants.ENCRYPTION_AES_GCM. OptionallyEncryptionConstants.DO_NOT_ENCRYPT_METADATAcan be OEed to output the metadata in cleartext.EncryptionConstants.EMBEDDED_FILES_ONLYcan be ORed as well. Please be aware that the passed encryption types may override permissions:EncryptionConstants.STANDARD_ENCRYPTION_40implicitly setsEncryptionConstants.DO_NOT_ENCRYPT_METADATAandEncryptionConstants.EMBEDDED_FILES_ONLYas false;EncryptionConstants.STANDARD_ENCRYPTION_128implicitly setsEncryptionConstants.EMBEDDED_FILES_ONLYas false;macProperties-MacPropertiesclass to configure MAC integrity protection properties. Passnullif you want to disable MAC protection for any reason- Returns:
- this
EncryptionProperties
-
setPublicKeyEncryption
public EncryptionProperties setPublicKeyEncryption(java.security.cert.Certificate[] certs, int[] permissions, int encryptionAlgorithm, MacProperties macProperties)
Sets the certificate encryption options for the document.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.
- Parameters:
certs- the public certificates to be used for the encryptionpermissions- the user permissions for each of the certificates The open permissions for the document can beEncryptionConstants.ALLOW_PRINTING,EncryptionConstants.ALLOW_MODIFY_CONTENTS,EncryptionConstants.ALLOW_COPY,EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS,EncryptionConstants.ALLOW_FILL_IN,EncryptionConstants.ALLOW_SCREENREADERS,EncryptionConstants.ALLOW_ASSEMBLYandEncryptionConstants.ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing themencryptionAlgorithm- the type of encryption. It can be one ofEncryptionConstants.STANDARD_ENCRYPTION_40,EncryptionConstants.STANDARD_ENCRYPTION_128,EncryptionConstants.ENCRYPTION_AES_128,EncryptionConstants.ENCRYPTION_AES_256orEncryptionConstants.ENCRYPTION_AES_GCM. OptionallyEncryptionConstants.DO_NOT_ENCRYPT_METADATAcan be ORed to output the metadata in cleartext.EncryptionConstants.EMBEDDED_FILES_ONLYcan be ORed as well. Please be aware that the passed encryption types may override permissions:EncryptionConstants.STANDARD_ENCRYPTION_40implicitly setsEncryptionConstants.DO_NOT_ENCRYPT_METADATAandEncryptionConstants.EMBEDDED_FILES_ONLYas false;EncryptionConstants.STANDARD_ENCRYPTION_128implicitly setsEncryptionConstants.EMBEDDED_FILES_ONLYas false;macProperties-MacPropertiesclass to configure MAC integrity protection properties. Passnullif you want to disable MAC protection for any reason- Returns:
- this
EncryptionProperties
-
isStandardEncryptionUsed
boolean isStandardEncryptionUsed()
-
isPublicKeyEncryptionUsed
boolean isPublicKeyEncryptionUsed()
-
clearEncryption
private void clearEncryption()
-
randomBytes
private static void randomBytes(byte[] bytes)
-
-