public interface SecurityHandler
SecurityHandler performs the main actions required to decrypt or encrypt a PDF document.
In the case of decryption, the SecurityHandler authenticates the right to decrypt
the document. For example, password-based SecurityHandler validitates
the password in the process of authentication.
SecurityHandler also delivers (on decryption) or determines (on encryption) encryption
permissions. For the password-based security handlers, this is the content of the
/P entry in the Encrypt dictionary;
the public-key-based security handlers get the encryption permissions from the proper PKCS#7
object in the Recipients array in the Encrypt dictionary. Other security
handlers implementations may get/set encryption permissions as they deem appropriate.
Therefore the SecurityHandler interface contains the method that returns
PermissionsProvider that handles encryption permissions.
SecurityHandler declares the interfaces for a specific security
handler in a PDFDocument.
The security handler provides the following functionality:
The PDF Java ToolKit provides the following password-based security handler.
The names for other security handlers can be registered by using the procedure described in the PDF Reference, Appendix E.
| Modifier and Type | Method and Description |
|---|---|
boolean |
authenticate(Map params,
byte[] docID)
Authenticates the right to decrypt and access the document.
|
boolean |
authenticate(Map params,
byte[] docID,
DecryptedState decryptedState)
Authenticates the right to decrypt and access the document by plugging in
the decrypted state of the document.
|
DecryptedState |
getDecryptedState()
Returns decrypted state of the document.
|
EncryptionHandler |
getEncryptionHandler(String cryptName,
Map encryptParams,
byte[] docId)
Instantiates an encryption handler that performs the actual
encryption/decryption operations with the base encryption key
calculated by this security handler.
|
Map |
getEncryptParameters()
Get the encryption parameters specified by this Security Handler
This can be either the original Encryption Parameters Map that were
passed in the
getEncryptionHandler(String, Map, byte[])
call with some entries possibly changed. |
PermissionProvider |
getPermissionProvider()
Fetch the permission provider that specifies encryption permissions associated with this security handler.
|
EncryptionHandler getEncryptionHandler(String cryptName, Map encryptParams, byte[] docId) throws PDFSecurityAuthorizationException, PDFSecurityConfigurationException
cryptName - the name of the Crypt FilterencryptParams - the Encryption Parameters Map containing encryption
parameters for encryption. Depending on the implementation it may or may
not be the same Encryption Parameters Map used in decryption.
SecurityHandler may cache or discard it.docId - the first Document ID string in the PDF documents trailer.EncryptionHandler encryption handler that performs encryption/decryption for this
security handler. This handler may be cached by the Security Handler
for reuse as required.PDFSecurityAuthorizationExceptionPDFSecurityConfigurationExceptionauthenticate(Map, byte[])Map getEncryptParameters()
getEncryptionHandler(String, Map, byte[])
call with some entries possibly changed.
It could also be a completely new Map created in the SecurityHandler and
used to encrypt content.
Security Handler should not change Encryption Parameters Map used to decrypt
the content
In instances of the Security Handler for decryption this method may return
null because no encryption parameters were saved.
boolean authenticate(Map params, byte[] docID) throws PDFSecurityAuthorizationException, PDFSecurityConfigurationException
This method is usually called for the default Security Handler
by the Security Support implementation to ensure the ability to
process PDF document. Because particular streams
may use different Security Handlers for encryption (or decryption),
the authentication of these Security Handlers
may happen, depending on the implementation, in the
getEncryptionHandler(String, Map, byte[]) call.
params - the Encryption Parameters Map containing encryption
parameters for encryption. Depending on the implementation it may or may
not be the same Encryption Parameters Map used in decryption.
SecurityHandler may cache or discard the parameters map.
docID - the first Document ID string in the PDF documents trailer.PDFSecurityAuthorizationExceptionPDFSecurityConfigurationExceptionPermissionProvider getPermissionProvider()
boolean authenticate(Map params, byte[] docID, DecryptedState decryptedState) throws PDFSecurityConfigurationException, PDFSecurityAuthorizationException
params - the Encryption Parameters Map containing encryption
parameters for encryption. Depending on the implementation it may or may
not be the same Encryption Parameters Map used in decryption.
SecurityHandler may cache or discard the parameters map.
docID - the first Document ID string in the PDF documents trailer.decryptedState - Decrypted state of the documentPDFSecurityAuthorizationExceptionPDFSecurityConfigurationExceptionDecryptedState getDecryptedState()
Copyright © 2010 - 2020 Adobe. All Rights Reserved