
Adobe Acrobat SDK
Working with Document Security
Developing Plug-ins and Applications
Saving a secured file 158
3. If Acrobat finds no match, indicating that the necessary handler could not be found, it does not open
the document. If it finds a matching security handler, it invokes that handler’s
P
DCryptNewSecurityDataProc
callback to extract and decrypt information from the PDF file’s
encryption dictionary.
4. Acrobat invokes the security handler’s authorize callback (
PDCryptAuthorizeExProc
) with NULL
authorization data, and with the requested permissions set to
PDPermReqOprOpen
or
pdPermOpen
(requesting that the user be allowed to open the file). This allows support for authorization schemes
that do not need authorization data.
5. If authorization succeeds, the handler’s authorization callback must return the
PDPermReqStatus
(when the callback is
PDCryptAuthorizeExProc
) or
pdPermOpen
(when the callback is
PDCryptAuthorizeProc
) indicating that the user is permitted to open the file.
6. If authorization fails, the authorization procedure passed in the call to open the
PDDoc
is called.
7. If authorization still fails, the file is not opened.
8. If authorization succeeds, Acrobat calls the security handler’s
PDCryptNewCryptDataProc
callback
to create the decryption key that is used to decrypt the file. The
PDCryptNewCryptDataProc
callback can construct the decryption key in any way it chooses, but generally performs some
calculation based on the contents of the security data structure filled previously by the handler’s
PDCryptNewSecurityDataProc
callback.
Saving a secured file
When saving a file, it is important to remember the following information:
●
When a user selects document encryption for the first time or has selected a different security handler
for an already encrypted file, the newly-selected handler does not take effect until the document is
saved.
●
To be allowed to save a file, the user must have
PDPermReqOprModify
or either
pdPermEdit
or
pdPermEditNotes
permission.
●
In Acrobat 5.0, a save operation forces a complete encrypted copy of the file to be written.
The following information is applicable to when a secured file is saved:
●
If the file is being saved in an encrypted form for the first time or if a different security handler is
selected, Acrobat calls the new security handler’s
PDCryptNewSecurityDataProc
callback. This
action creates a new copy of the new security handler’s security data structure.
●
If the file is saved in an encrypted form for the first time or if a different security handler is selected,
Acrobat calls the new security handlerfs
PDCryptUpdateSecurityDataProc
callback. This
presents whatever user interface the security handler has for enabling the user to set permissions.
●
Acrobat invokes the new security handler’s
PDCryptFillEncryptDictProc
callback to encrypt and
write into the PDF file’s encryption dictionary whatever data the security handler wants to save in the
PDF file.
●
Acrobat writes out the encrypted file.
●
Acrobat sets the new security handler as the document’s current security handler.