public class StandardSecurityHandler extends SecurityHandler
ICEpdf's standard security handler allows access permissions and up to two passwords to be specified for a document: an owner password and a user password. An application's decision to encrypt a document is based on whether the user creating the document specifies any passwords or access restrictions (for example, in a security settings dialog that the user can invoke before saving the PDF file); if so, the document is encrypted, and the permissions and information required to validate the passwords are stored in the encryption dictionary. (An application may also create an encrypted document without any user interaction, if it has some other source of information about what passwords and permissions to use.)
If a user attempts to open an encrypted document that has a user password, the viewer application should prompt for a password. Correctly supplying either password allows the user to open the document, decrypt it, and display it on the screen. If the document does not have a user password, no password is requested; the viewer application can simply open, decrypt, and display the document. Whether additional operations are allowed on a decrypted document depends on which password (if any) was supplied when the document was opened and on any access restrictions that were specified when the document was created:
Access permissions are specified in the form of flags corresponding to the various operations, and the set of operations to which they correspond, depends in turn on the security handler's revision number (also stored in the encryption dictionary). If the revision number is 2 or greater, the operations to which user access can be controlled are as follows:
If the security handler's revision number is 3 or greater, user access to the following operations can be controlled more selectively:
In addition, revision 3 enables the extraction of text and graphics (in support of accessibility to disabled users or for other purposes) to be controlled separately. Beginning with revision 4, the standard security handler supports crypt filters. The support is limited to the Identity crypt filter and crypt filters named StdCF whose dictionaries contain a CFM value of V2 and an AuthEvent value of DocOpen.
| Modifier and Type | Field and Description |
|---|---|
static Name |
IDENTITY_KEY |
static Name |
NAME_KEY |
encryptionDictionary, handlerName, permissions| Constructor and Description |
|---|
StandardSecurityHandler(EncryptionDictionary encryptionDictionary) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(Reference objectReference,
byte[] encryptionKey,
byte[] data)
Decrypt the PDF data bytestream or string.
|
void |
dispose()
Dispose of the security handler.
|
byte[] |
encrypt(Reference objectReference,
byte[] encryptionKey,
byte[] data)
Encrypt the PDF data bytestream or string.
|
byte[] |
getDecryptionKey()
Gets the encryption key used by the security handler for decryption data.
|
java.io.InputStream |
getEncryptionInputStream(Reference objectReference,
byte[] encryptionKey,
java.util.HashMap decodeParams,
java.io.InputStream input) |
byte[] |
getEncryptionKey()
Gets the encryption key used by the security handler for encrypting data.
|
java.lang.String |
getHandlerName()
Gets the name of the default security handler.
|
Permissions |
getPermissions()
Gets the PDF permissions object associated with this document's
security handler.
|
void |
init()
Initiate the security handler
|
boolean |
isAuthorized(java.lang.String password)
Determines whether the supplied password is authorized to view the
PDF document.
|
boolean |
isOwnerAuthorized(java.lang.String password)
Determines whether the supplied owner password is authorized to view the
PDF document.
|
boolean |
isUserAuthorized(java.lang.String password)
Determines whether the supplied user password is authorized to view the
PDF document.
|
public static final Name NAME_KEY
public static final Name IDENTITY_KEY
public StandardSecurityHandler(EncryptionDictionary encryptionDictionary)
public boolean isAuthorized(java.lang.String password)
SecurityHandlerInterfaceisAuthorized in interface SecurityHandlerInterfaceisAuthorized in class SecurityHandlerpassword - password to authorizepublic boolean isOwnerAuthorized(java.lang.String password)
SecurityHandlerInterfaceisOwnerAuthorized in interface SecurityHandlerInterfaceisOwnerAuthorized in class SecurityHandlerpassword - password to authorizepublic boolean isUserAuthorized(java.lang.String password)
SecurityHandlerInterfaceisUserAuthorized in interface SecurityHandlerInterfaceisUserAuthorized in class SecurityHandlerpassword - password to authorizepublic byte[] encrypt(Reference objectReference, byte[] encryptionKey, byte[] data)
SecurityHandlerInterfaceencrypt in interface SecurityHandlerInterfaceencrypt in class SecurityHandlerobjectReference - reference to PDF object being encrypted; this object
contains the PDF object number and revision.encryptionKey - encryption key used by encryption algorithm.data - byte data to be encrypted; either represents an object stream
or string value.public byte[] decrypt(Reference objectReference, byte[] encryptionKey, byte[] data)
SecurityHandlerInterfacedecrypt in interface SecurityHandlerInterfacedecrypt in class SecurityHandlerobjectReference - reference to PDF object being encrypted; this object
contains the PDF object number and revision.encryptionKey - encryption key used by decryption algorithm.data - byte data to be decrypted; either represents an object stream
or string value.public java.io.InputStream getEncryptionInputStream(Reference objectReference, byte[] encryptionKey, java.util.HashMap decodeParams, java.io.InputStream input)
getEncryptionInputStream in interface SecurityHandlerInterfacegetEncryptionInputStream in class SecurityHandlerpublic byte[] getEncryptionKey()
SecurityHandlerInterfacegetEncryptionKey in interface SecurityHandlerInterfacegetEncryptionKey in class SecurityHandlerpublic byte[] getDecryptionKey()
SecurityHandlerInterfacegetDecryptionKey in interface SecurityHandlerInterfacegetDecryptionKey in class SecurityHandlerpublic Permissions getPermissions()
SecurityHandlerInterfacegetPermissions in interface SecurityHandlerInterfacegetPermissions in class SecurityHandlerpublic java.lang.String getHandlerName()
SecurityHandlerInterfacegetHandlerName in interface SecurityHandlerInterfacegetHandlerName in class SecurityHandlerpublic void init()
SecurityHandlerInterfaceinit in interface SecurityHandlerInterfaceinit in class SecurityHandlerpublic void dispose()
SecurityHandlerInterfacedispose in interface SecurityHandlerInterfacedispose in class SecurityHandler