public abstract class SecurityHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
keyLength
The length of the secret key used to encrypt the document.
|
| Constructor and Description |
|---|
SecurityHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
decrypt(COSBase obj,
long objNum,
long genNum)
This will dispatch to the correct method.
|
protected void |
decryptDataRC4(byte[] finalKey,
byte[] input,
OutputStream output)
Encrypt or decrypt data with RC4.
|
protected void |
decryptDataRC4(byte[] finalKey,
InputStream input,
OutputStream output)
Encrypt or decrypt data with RC4.
|
void |
decryptStream(COSStream stream,
long objNum,
long genNum)
This will decrypt a stream.
|
AccessPermission |
getCurrentAccessPermission()
Returns the access permissions that were computed during document decryption.
|
byte[] |
getEncryptionKey() |
int |
getKeyLength()
Getter of the property keyLength.
|
abstract boolean |
hasProtectionPolicy()
Returns whether a protection policy has been set.
|
boolean |
isAES()
True if AES is used for encryption and decryption.
|
abstract void |
prepareForDecryption(PDEncryption encryption,
COSArray documentIDArray,
DecryptionMaterial decryptionMaterial)
Prepares everything to decrypt the document.
|
void |
setAES(boolean aesValue)
Set to true if AES for encryption and decryption should be used.
|
void |
setCurrentAccessPermission(AccessPermission currentAccessPermission)
Sets the access permissions.
|
protected void |
setDecryptMetadata(boolean decryptMetadata)
Set wether to decrypt meta data.
|
protected void |
setEncryptionKey(byte[] encryptionKey) |
void |
setKeyLength(int keyLen)
Setter of the property keyLength.
|
protected void |
setStreamFilterName(COSName streamFilterName)
Set the stream filter name.
|
protected void |
setStringFilterName(COSName stringFilterName)
Set the string filter name.
|
protected int keyLength
protected void setDecryptMetadata(boolean decryptMetadata)
decryptMetadata - true if meta data has to be decrypted.protected void setStringFilterName(COSName stringFilterName)
stringFilterName - the string filter name.protected void setStreamFilterName(COSName streamFilterName)
streamFilterName - the stream filter name.public abstract void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws IOException
encryption - encryption dictionary, can be retrieved via PDDocument.getEncryption()documentIDArray - document id which is returned via COSDocument.getDocumentID()decryptionMaterial - Information used to decrypt the document.IOException - If there is an error accessing data.protected void decryptDataRC4(byte[] finalKey,
InputStream input,
OutputStream output)
throws IOException
finalKey - The final key obtained with via calcFinalKey(long, long).input - The data to encrypt.output - The output to write the encrypted data to.IOException - If there is an error reading the data.protected void decryptDataRC4(byte[] finalKey,
byte[] input,
OutputStream output)
throws IOException
finalKey - The final key obtained with via calcFinalKey(long, long).input - The data to encrypt.output - The output to write the encrypted data to.IOException - If there is an error reading the data.public void decrypt(COSBase obj, long objNum, long genNum) throws IOException
obj - The object to decrypt.objNum - The object number.genNum - The object generation Number.IOException - If there is an error getting the stream data.public void decryptStream(COSStream stream, long objNum, long genNum) throws IOException
stream - The stream to decrypt.objNum - The object number.genNum - The object generation number.IOException - If there is an error getting the stream data.public int getKeyLength()
public void setKeyLength(int keyLen)
keyLen - The keyLength to set.public void setCurrentAccessPermission(AccessPermission currentAccessPermission)
currentAccessPermission - The access permissions to be set.public AccessPermission getCurrentAccessPermission()
public boolean isAES()
public void setAES(boolean aesValue)
aesValue - if true AES will be usedpublic byte[] getEncryptionKey()
protected void setEncryptionKey(byte[] encryptionKey)
public abstract boolean hasProtectionPolicy()
Copyright © 2020 sejda. All rights reserved.