| This class holds necessary information to decrypt a PDF document
protected by the public key security handler.
To decrypt such a document, we need:
- a valid X509 certificate which correspond to one of the recipient of the document
- the private key corresponding to this certificate
- the password to decrypt the private key if necessary
Objects of this class can be used with the openProtection method of PDDocument .
The following example shows how to decrypt a document using a PKCS#12 certificate
(typically files with a pfx extension).
PDDocument doc = PDDocument.load(document_path);
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(new FileInputStream(certificate_path), password.toCharArray());
PublicKeyDecryptionMaterial dm = new PublicKeyDecryptionMaterial(ks, null, password);
doc.openProtection(dm);
In this code sample certificate_path contains the path to the PKCS#12 certificate.
See Also: org.pdfbox.pdmodel.PDDocument.openProtection(DecryptionMaterial) author: Benoit Guillon (benoit.guillon@snv.jussieu.fr) version: $Revision: 1.2 $ |