org.apache.pdfbox.pdmodel.encryption
Class PublicKeySecurityHandler

java.lang.Object
  extended by org.apache.pdfbox.pdmodel.encryption.SecurityHandler
      extended by org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler

public class PublicKeySecurityHandler
extends SecurityHandler

This class implements the public key security handler described in the PDF specification.

Version:
$Revision: 1.3 $
Author:
Benoit Guillon ([email protected])
See Also:
Spec 1.6 p104, to see how to protect document with this security handler.

Field Summary
static String FILTER
          The filter name.
 
Fields inherited from class org.apache.pdfbox.pdmodel.encryption.SecurityHandler
currentAccessPermission, document, encryptionKey, keyLength, rc4, version
 
Constructor Summary
PublicKeySecurityHandler()
          Constructor.
PublicKeySecurityHandler(PublicKeyProtectionPolicy p)
          Constructor used for encryption.
 
Method Summary
 void decryptDocument(PDDocument doc, DecryptionMaterial decryptionMaterial)
          Decrypt the document.
 void prepareDocumentForEncryption(PDDocument doc)
          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
decryptStream, decryptString, encryptData, encryptData, encryptStream, getCurrentAccessPermission, getKeyLength, isAES, proceedDecryption, setAES, setKeyLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILTER

public static final String FILTER
The filter name.

See Also:
Constant Field Values
Constructor Detail

PublicKeySecurityHandler

public PublicKeySecurityHandler()
Constructor.


PublicKeySecurityHandler

public PublicKeySecurityHandler(PublicKeyProtectionPolicy p)
Constructor used for encryption.

Parameters:
p - The protection policy.
Method Detail

decryptDocument

public void decryptDocument(PDDocument doc,
                            DecryptionMaterial decryptionMaterial)
                     throws CryptographyException,
                            IOException
Decrypt the document.

Specified by:
decryptDocument in class SecurityHandler
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. If decryptDocument(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 class SecurityHandler
Parameters:
encDictionary - encryption dictionary, can be retrieved via PDDocument.getEncryptionDictionary()
documentIDArray - document id which is returned via COSDocument#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

public void prepareDocumentForEncryption(PDDocument doc)
                                  throws CryptographyException
Prepare the document for encryption.

Specified by:
prepareDocumentForEncryption in class SecurityHandler
Parameters:
doc - The document that will be encrypted.
Throws:
CryptographyException - If there is an error while encrypting.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.