Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.encryption » [javadoc | source]
public class: PublicKeyProtectionPolicy [javadoc | source]
This class represents the protection policy to use to protect a document with the public key security handler as described in the PDF specification 1.6 p104. PDF documents are encrypted so that they can be decrypted by one or more recipients. Each recipient have its own access permission. The following code sample shows how to protect a document using the public key security handler. In this code sample, doc is a PDDocument object.
PublicKeyProtectionPolicy policy = new PublicKeyProtectionPolicy();
PublicKeyRecipient recip = new PublicKeyRecipient();
AccessPermission ap = new AccessPermission();

// load the recipient's certificate
InputStream inStream = new FileInputStream(certificate_path);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate)cf.generateCertificate(inStream);

recip.setX509(certificate); // set the recipient's certificate
policy.setEncryptionKeyLength(128); // the document will be encrypted with 128 bits secret key
 public PublicKeyProtectionPolicy() 
Method from org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy Summary:
addRecipient,   getDecryptionCertificate,   getRecipientsIterator,   getRecipientsNumber,   removeRecipient,   setDecryptionCertificate
Methods from org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy:
getEncryptionKeyLength,   setEncryptionKeyLength
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy Detail:
 public  void addRecipient(PublicKeyRecipient r) 
    Adds a new recipient to the recipients list.
 public X509Certificate getDecryptionCertificate() 
    Getter of the property decryptionCertificate.
 public Iterator getRecipientsIterator() 
    Returns an iterator to browse the list of recipients. Object found in this iterator are PublicKeyRecipient.
 public int getRecipientsNumber() 
    Returns the number of recipients.
 public boolean removeRecipient(PublicKeyRecipient r) 
    Removes a recipient from the recipients list.
 public  void setDecryptionCertificate(X509Certificate aDecryptionCertificate) 
    Setter of the property decryptionCertificate.