org.pdfbox.encryption

Class DocumentEncryption


public class DocumentEncryption
extends java.lang.Object

This class will deal with encrypting/decrypting a document.
Version:
$Revision: 1.13 $
Author:
Ben Litchfield
See Also:
StandardSecurityHandler

Constructor Summary

DocumentEncryption(COSDocument doc)
Constructor.
DocumentEncryption(PDDocument doc)
Constructor.

Method Summary

void
decrypt(Object obj, long objNum, long genNum)
This will dispatch to the correct method.
void
decryptDocument(String password)
This will decrypt the document.
void
initForEncryption()
This will encrypt the given document, given the owner password and user password.

Constructor Details

DocumentEncryption

public DocumentEncryption(COSDocument doc)
Constructor.
Parameters:
doc - The document to decrypt.

DocumentEncryption

public DocumentEncryption(PDDocument doc)
Constructor.
Parameters:
doc - The document to decrypt.

Method Details

decrypt

public void decrypt(Object obj,
                    long objNum,
                    long genNum)
            throws CryptographyException,
                   IOException
This will dispatch to the correct method.
Parameters:
obj - The object to decrypt.
objNum - The object number.
genNum - The object generation Number.
Throws:
CryptographyException - If there is an error decrypting the stream.

decryptDocument

public void decryptDocument(String password)
            throws CryptographyException,
                   IOException,
                   InvalidPasswordException
This will decrypt the document.
Parameters:
password - The password for the document.
Throws:
InvalidPasswordException - If the password is not a user or owner password.

initForEncryption

public void initForEncryption()
            throws CryptographyException,
                   IOException
This will encrypt the given document, given the owner password and user password. The encryption method used is the standard filter.
Throws:
CryptographyException - If an error occurs during encryption.