org.pdfbox.pdmodel.encryption
Class SecurityHandler
java.lang.Object
org.pdfbox.pdmodel.encryption.SecurityHandler
public abstract class SecurityHandler
extends java.lang.Object
This class represents a security handler as described in the PDF specifications.
A security handler is responsible of documents protection.
protected AccessPermission | currentAccessPermission - The access permission granted to the current user for the document.
|
protected PDDocument | document - The document whose security is handled by this security handler.
|
protected byte[] | encryptionKey - The encryption key that will used to encrypt / decrypt.
|
protected int | keyLength - The length of the secret key used to encrypt the document.
|
protected ARCFour | rc4 - The RC4 implementation used for cryptographic functions.
|
protected int | version - The value of V field of the Encryption dictionary.
|
currentAccessPermission
protected AccessPermission currentAccessPermission
The access permission granted to the current user for the document. These
permissions are computed during decryption and are in read only mode.
document
protected PDDocument document
The document whose security is handled by this security handler.
encryptionKey
protected byte[] encryptionKey
The encryption key that will used to encrypt / decrypt.
keyLength
protected int keyLength
The length of the secret key used to encrypt the document.
rc4
protected ARCFour rc4
The RC4 implementation used for cryptographic functions.
version
protected int version
The value of V field of the Encryption dictionary.
decryptDocument
public abstract void decryptDocument(PDDocument doc,
DecryptionMaterial mat)
throws CryptographyException,
IOException
Prepare the document for decryption.
doc
- The document to decrypt.mat
- Information required to decrypt the document.
decryptStream
public void decryptStream(COSStream stream,
long objNum,
long genNum)
throws CryptographyException,
IOException
This will decrypt a stream.
stream
- The stream to decrypt.objNum
- The object number.genNum
- The object generation number.
decryptString
public void decryptString(COSString string,
long objNum,
long genNum)
throws CryptographyException,
IOException
This will decrypt a string.
string
- the string to decrypt.objNum
- The object number.genNum
- The object generation number.
encryptData
public void encryptData(long objectNumber,
long genNumber,
InputStream data,
OutputStream output)
throws CryptographyException,
IOException
Encrypt a set of data.
objectNumber
- The data object number.genNumber
- The data generation number.data
- The data to encrypt.output
- The output to write the encrypted data to.
getCurrentAccessPermission
public AccessPermission getCurrentAccessPermission()
Returns the access permissions that were computed during document decryption.
The returned object is in read only mode.
- the access permissions or null if the document was not decrypted.
getKeyLength
public int getKeyLength()
Getter of the property keyLength.
prepareDocumentForEncryption
public abstract void prepareDocumentForEncryption(PDDocument doc)
throws CryptographyException,
IOException
Prepare the document for encryption.
doc
- The document that will be encrypted.
proceedDecryption
protected void proceedDecryption()
throws IOException,
CryptographyException
This method must be called by an implementation of this class to really proceed
to decryption.
setKeyLength
public void setKeyLength(int keyLen)
Setter of the property keyLength.
keyLen
- The keyLength to set.