Class PublicKeySecurityHandler
java.lang.Object
org.apache.pdfbox.pdmodel.encryption.SecurityHandler
org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler
This class implements the public key security handler
described in the PDF specification.
[PDF Spec 1.6 p104]
- Version:
- $Revision: 1.3 $
- Author:
- Benoit Guillon (benoit.guillon@snv.jussieu.fr)
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.pdfbox.pdmodel.encryption.SecurityHandler
currentAccessPermission, decryptMetadata, document, encryptionKey, keyLength, rc4, version
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Constructor used for encryption. -
Method Summary
Modifier and TypeMethodDescriptionvoid
decryptDocument
(PDDocument doc, DecryptionMaterial decryptionMaterial) Decrypt the document.boolean
Returns whether a protection policy has been set.void
Prepare the document for encryption.void
prepareForDecryption
(PDEncryptionDictionary encDictionary, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) Prepares everything to decrypt the document.Methods inherited from class org.apache.pdfbox.pdmodel.encryption.SecurityHandler
decryptArray, decryptStream, decryptString, encryptData, encryptData, encryptStream, encryptString, getCurrentAccessPermission, getKeyLength, isAES, proceedDecryption, setAES, setKeyLength
-
Field Details
-
FILTER
The filter name.- See Also:
-
-
Constructor Details
-
PublicKeySecurityHandler
public PublicKeySecurityHandler()Constructor. -
PublicKeySecurityHandler
Constructor used for encryption.- Parameters:
p
- The protection policy.
-
-
Method Details
-
decryptDocument
public void decryptDocument(PDDocument doc, DecryptionMaterial decryptionMaterial) throws CryptographyException, IOException Decrypt the document.- Specified by:
decryptDocument
in classSecurityHandler
- Parameters:
doc
- The document to decrypt.decryptionMaterial
- The data used to decrypt the document.- Throws:
CryptographyException
- If there is an error during decryption.IOException
- If there is an error accessing data.
-
prepareForDecryption
public void prepareForDecryption(PDEncryptionDictionary encDictionary, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws CryptographyException, IOException Prepares everything to decrypt the document. IfdecryptDocument(PDDocument, DecryptionMaterial)
is used, this method is called from there. Only if decryption of single objects is needed this should be called instead.- Specified by:
prepareForDecryption
in classSecurityHandler
- Parameters:
encDictionary
- encryption dictionary, can be retrieved viaPDDocument.getEncryptionDictionary()
documentIDArray
- document id which is returned viaCOSDocument.getDocumentID()
(not used by this handler)decryptionMaterial
- Information used to decrypt the document.- Throws:
IOException
- If there is an error accessing data.CryptographyException
- If there is an error with decryption.
-
prepareDocumentForEncryption
Prepare the document for encryption.- Specified by:
prepareDocumentForEncryption
in classSecurityHandler
- Parameters:
doc
- The document that will be encrypted.- Throws:
CryptographyException
- If there is an error while encrypting.
-
hasProtectionPolicy
public boolean hasProtectionPolicy()Returns whether a protection policy has been set.- Specified by:
hasProtectionPolicy
in classSecurityHandler
- Returns:
- true if a protection policy has been set.
-