public class SecurityManager
extends java.lang.Object
The Security Manager class manages the encryption of encrypted PDF documents. The class is initiated by the Document class if a Crypt key is found in the document's trailer. The singleton pattern is implemented so that it can be called from anywhere with the PDF object structure.
There is currently only support for Adobe Standard encryption which is supported by the StandardSecurityHandler. Additional support for custom security handlers, public-key handlers and crypt filters is currently under development.
The Security Manager needs tobe compliant with Sun Java JCE 1.2.1 implementation. The security manager assumes that org.bouncycastle.jce.provider.BouncyCastleProvider can be found on the class path and will try to load the class accordingly. However, if you have another crypto API that you would like to use, the system property org.icepdf.core.pobjects.security.provider can be set to the provider's class path.
| Constructor and Description |
|---|
SecurityManager(Library library,
java.util.HashMap<java.lang.Object,java.lang.Object> encryptionDictionary,
java.util.List fileID)
Creates new instance of SecurityManager object.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(Reference objectReference,
byte[] encryptionKey,
byte[] data)
Decrypt the
data using the encryptionKey and
objectReference of the PDF stream or String object. |
void |
dispose()
Disposes of the security handler instance.
|
byte[] |
encrypt(Reference objectReference,
byte[] encryptionKey,
byte[] data)
Encrypt the
data using the encryptionKey and
objectReference of the PDF stream or String object. |
byte[] |
getDecryptionKey()
Gets the decrypt key used by the security handler when decrypting data.
|
EncryptionDictionary |
getEncryptionDictionary()
Gets the encryption dictionary associated with the document encryption
handler.
|
java.io.InputStream |
getEncryptionInputStream(Reference objectReference,
byte[] encryptionKey,
java.util.HashMap decodeParams,
java.io.InputStream input,
boolean returnInputIfNullResult)
Return a new InputStream, from which read operations will return
data, read and decrypt from the InputStream parameter
objectReference of the PDF stream or String object. |
byte[] |
getEncryptionKey()
Gets the encryption key used by the security handler when encrypting data.
|
Permissions |
getPermissions()
Gets the permission associated with the document's encryption handler.
|
SecurityHandler |
getSecurityHandler()
Gets the SecurityHandler associated with this Security Manager.
|
boolean |
isAuthorized(java.lang.String password)
Determines whether the supplied password is authorized to view the
PDF document.
|
public SecurityManager(Library library, java.util.HashMap<java.lang.Object,java.lang.Object> encryptionDictionary, java.util.List fileID) throws PDFSecurityException
library - library of documents PDF objectsencryptionDictionary - encryption dictionary key valuesfileID - fileID of PDF documentPDFSecurityException - if the security provider could not be foundpublic void dispose()
public Permissions getPermissions()
public SecurityHandler getSecurityHandler()
public EncryptionDictionary getEncryptionDictionary()
public byte[] getEncryptionKey()
public byte[] getDecryptionKey()
public byte[] encrypt(Reference objectReference, byte[] encryptionKey, byte[] data)
data using the encryptionKey and
objectReference of the PDF stream or String object.objectReference - PDF objects number and revision numberencryptionKey - encryption key used to encrypt the datadata - byte data of a PDF Stream or String objectpublic byte[] decrypt(Reference objectReference, byte[] encryptionKey, byte[] data)
data using the encryptionKey and
objectReference of the PDF stream or String object.objectReference - PDF objects number and revision numberencryptionKey - encryption key used to decrypt the datadata - byte data of a PDF Stream or String objectpublic java.io.InputStream getEncryptionInputStream(Reference objectReference, byte[] encryptionKey, java.util.HashMap decodeParams, java.io.InputStream input, boolean returnInputIfNullResult)
objectReference of the PDF stream or String object.objectReference - PDF objects number and revision numberencryptionKey - encryption key used to decrypt the datainput - InputStream giving access to encrypted datadecodeParams - crypt filter optional parameters, can be null.returnInputIfNullResult - If results end up being null, then return input instead of nullpublic boolean isAuthorized(java.lang.String password)
password - password to authorize