Package com.lowagie.text.pdf
Class PdfEncryption
- java.lang.Object
-
- com.lowagie.text.pdf.PdfEncryption
-
public class PdfEncryption extends Object
- Author:
- Paulo Soares (psoares@consiste.pt), Kazuya Ujihara
-
-
Field Summary
Fields Modifier and Type Field Description static intAES_128static intAES_256_V3protected PdfPublicKeySecurityHandlerpublicKeyHandlerThe public key security handler for certificate encryptionstatic intSTANDARD_ENCRYPTION_128static intSTANDARD_ENCRYPTION_40
-
Constructor Summary
Constructors Constructor Description PdfEncryption()PdfEncryption(PdfEncryption enc)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecipient(Certificate cert, int permission)intcalculateStreamSize(int n)byte[]computeUserPassword(byte[] ownerPassword)static byte[]createDocumentId()static PdfObjectcreateInfoId(byte[] id)static PdfObjectcreateInfoId(byte[] idPartOne, byte[] idPartTwo)booleandecryptAndCheckPerms(byte[] permsValue)implements step f of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3byte[]decryptByteArray(byte[] b)byte[]encryptByteArray(byte[] b)intgetCryptoMode()StandardDecryptiongetDecryptor()PdfDictionarygetEncryptionDictionary()OutputStreamEncryptiongetEncryptionStream(OutputStream os)PdfObjectgetFileID()booleanisEmbeddedFilesOnly()Indicates if only the embedded files have to be encrypted.booleanisMetadataEncrypted()voidsetCryptoMode(int mode, int kl)voidsetHashKey(int number, int generation)voidsetupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions)voidsetupByEncryptionKey(byte[] key, int keylength)voidsetupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions)implements step d of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3voidsetupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions)voidsetupByUserPassword(byte[] documentID, byte[] userPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions)implements step e of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3voidsetupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions)
-
-
-
Field Detail
-
STANDARD_ENCRYPTION_40
public static final int STANDARD_ENCRYPTION_40
- See Also:
- Constant Field Values
-
STANDARD_ENCRYPTION_128
public static final int STANDARD_ENCRYPTION_128
- See Also:
- Constant Field Values
-
AES_128
public static final int AES_128
- See Also:
- Constant Field Values
-
AES_256_V3
public static final int AES_256_V3
- See Also:
- Constant Field Values
-
publicKeyHandler
protected PdfPublicKeySecurityHandler publicKeyHandler
The public key security handler for certificate encryption
-
-
Constructor Detail
-
PdfEncryption
public PdfEncryption()
-
PdfEncryption
public PdfEncryption(PdfEncryption enc)
-
-
Method Detail
-
setCryptoMode
public void setCryptoMode(int mode, int kl)
-
getCryptoMode
public int getCryptoMode()
-
isMetadataEncrypted
public boolean isMetadataEncrypted()
-
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)
-
createDocumentId
public static byte[] createDocumentId()
-
setupByUserPassword
public void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions)- Parameters:
documentID- byte array of document iduserPassword- byte array of user passwordownerKey- byte array of owner keypermissions- permissions
-
setupByOwnerPassword
public void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions)- Parameters:
documentID- byte array of document idownerPassword- byte array of owner passworduserKey- byte array of user keyownerKey- byte array of owner keypermissions- permissions
-
setupByEncryptionKey
public void setupByEncryptionKey(byte[] key, int keylength)
-
setHashKey
public void setHashKey(int number, int generation)
-
createInfoId
public static PdfObject createInfoId(byte[] id)
-
createInfoId
public static PdfObject createInfoId(byte[] idPartOne, byte[] idPartTwo)
-
getEncryptionDictionary
public PdfDictionary getEncryptionDictionary()
-
getFileID
public PdfObject getFileID()
-
getEncryptionStream
public OutputStreamEncryption getEncryptionStream(OutputStream os)
-
calculateStreamSize
public int calculateStreamSize(int n)
-
encryptByteArray
public byte[] encryptByteArray(byte[] b)
-
getDecryptor
public StandardDecryption getDecryptor()
-
decryptByteArray
public byte[] decryptByteArray(byte[] b)
-
addRecipient
public void addRecipient(Certificate cert, int permission)
-
computeUserPassword
public byte[] computeUserPassword(byte[] ownerPassword)
-
setupByOwnerPassword
public void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions) throws GeneralSecurityExceptionimplements step d of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3- Throws:
GeneralSecurityException
-
setupByUserPassword
public void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions) throws GeneralSecurityExceptionimplements step e of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3- Throws:
GeneralSecurityException
-
decryptAndCheckPerms
public boolean decryptAndCheckPerms(byte[] permsValue) throws GeneralSecurityExceptionimplements step f of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3- Throws:
GeneralSecurityException
-
-