Class PdfEncryption
java.lang.Object
com.itextpdf.text.pdf.PdfEncryption
- Author:
- Paulo Soares, Kazuya Ujihara
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intprotected PdfPublicKeySecurityHandlerThe public key security handler for certificate encryptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecipient(Certificate cert, int permission) intcalculateStreamSize(int n) byte[]computeUserPassword(byte[] ownerPassword) Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 algorithm (Revision 2 - 4).static byte[]static PdfObjectcreateInfoId(byte[] id, boolean modified) byte[]decryptByteArray(byte[] b) byte[]encryptByteArray(byte[] b) intgetFileID(boolean modified) longbooleanIndicates if only the embedded files have to be encrypted.booleanbooleanreadKey(PdfDictionary enc, byte[] password) voidsetCryptoMode(int mode, int kl) voidsetHashKey(int number, int generation) voidsetKey(byte[] key) voidsetupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions) voidsetupByEncryptionKey(byte[] key, int keylength) voidsetupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, long permissions) voidsetupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, long permissions)
-
Field Details
-
STANDARD_ENCRYPTION_40
public static final int STANDARD_ENCRYPTION_40- See Also:
-
STANDARD_ENCRYPTION_128
public static final int STANDARD_ENCRYPTION_128- See Also:
-
AES_128
public static final int AES_128- See Also:
-
AES_256
public static final int AES_256- See Also:
-
publicKeyHandler
The public key security handler for certificate encryption
-
-
Constructor Details
-
PdfEncryption
public PdfEncryption() -
PdfEncryption
-
-
Method Details
-
setCryptoMode
public void setCryptoMode(int mode, int kl) -
getCryptoMode
public int getCryptoMode() -
isMetadataEncrypted
public boolean isMetadataEncrypted() -
getPermissions
public long getPermissions() -
isEmbeddedFilesOnly
public boolean isEmbeddedFilesOnly()Indicates if only the embedded files have to be encrypted.- Returns:
- if true only the embedded files will be encrypted
- Since:
- 2.1.3
-
setupAllKeys
public void setupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions) -
readKey
- Throws:
BadPasswordException
-
createDocumentId
public static byte[] createDocumentId() -
setupByUserPassword
public void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, long permissions) -
setupByOwnerPassword
public void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, long permissions) -
setKey
public void setKey(byte[] key) -
setupByEncryptionKey
public void setupByEncryptionKey(byte[] key, int keylength) -
setHashKey
public void setHashKey(int number, int generation) -
createInfoId
- Throws:
IOException
-
getEncryptionDictionary
-
getFileID
- Throws:
IOException
-
getEncryptionStream
-
calculateStreamSize
public int calculateStreamSize(int n) -
encryptByteArray
public byte[] encryptByteArray(byte[] b) -
getDecryptor
-
decryptByteArray
public byte[] decryptByteArray(byte[] b) -
addRecipient
-
computeUserPassword
public byte[] computeUserPassword(byte[] ownerPassword) Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 algorithm (Revision 2 - 4).- Parameters:
ownerPassword- owner password of the encrypted document.- Returns:
- user password, or null if revision 5 (AES256) or greater of standard encryption handler was used.
-