org.pdfbox.encryption
Class DocumentEncryption

java.lang.Object
  extended by org.pdfbox.encryption.DocumentEncryption

public class DocumentEncryption
extends Object

This class will deal with encrypting/decrypting a document.

Version:
$Revision: 1.10 $
Author:
Ben Litchfield (ben@benlitchfield.com)

Constructor Summary
DocumentEncryption(COSDocument doc)
          Constructor.
DocumentEncryption(PDDocument doc)
          Constructor.
 
Method Summary
 void decryptDocument(String password)
          This will decrypt the document.
 void decryptStream(COSStream stream, long objNum, long genNum)
          This will decrypt a stream.
 void decryptString(COSString string, long objNum, long genNum)
          This will decrypt a string.
 void initForEncryption()
          This will encrypt the given document, given the owner password and user password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentEncryption

public DocumentEncryption(PDDocument doc)
Constructor.

Parameters:
doc - The document to decrypt.

DocumentEncryption

public DocumentEncryption(COSDocument doc)
Constructor.

Parameters:
doc - The document to decrypt.
Method Detail

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.
IOException - If there is an error accessing the data.

decryptDocument

public void decryptDocument(String password)
                     throws CryptographyException,
                            IOException,
                            InvalidPasswordException
This will decrypt the document.

Parameters:
password - The password for the document.
Throws:
CryptographyException - If there is an error decrypting the document.
IOException - If there is an error getting the stream data.
InvalidPasswordException - If the password is not a user or owner password.

decryptStream

public void decryptStream(COSStream stream,
                          long objNum,
                          long genNum)
                   throws CryptographyException,
                          IOException
This will decrypt a stream.

Parameters:
stream - The stream to decrypt.
objNum - The object number.
genNum - The object generation number.
Throws:
CryptographyException - If there is an error getting the stream.
IOException - If there is an error getting the stream data.

decryptString

public void decryptString(COSString string,
                          long objNum,
                          long genNum)
                   throws CryptographyException,
                          IOException
This will decrypt a string.

Parameters:
string - the string to decrypt.
objNum - The object number.
genNum - The object generation number.
Throws:
CryptographyException - If an error occurs during decryption.
IOException - If an error occurs writing the new string.


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.