Class PDFNet.SecurityHandler
PDFNet.SecurityHandler
Constructor Attributes | Constructor Name and Description |
---|---|
Standard Security Handler is a standard password-based security handler.
|
Method Attributes | Method Name and Description |
---|---|
authorize(p)
The method is called when a user tries to set security for an encrypted
document and when a user tries to open a file.
|
|
A callback method indicating repeated failed authorization.
|
|
changeMasterPasswordBuffer(password_buf)
[Documentation Not Yet Added]
|
|
changeMasterPasswordNonAscii(password)
Set the new master password to a binary string
|
|
changeMasterPasswordUString(password)
Sets the new master/owner password.
|
|
changeRevisionNumber(rev_num)
Change the revision number and the encryption algorithm of the
standard security handler.
|
|
changeUserPasswordBuffer(password_buf)
[Documentation Not Yet Added]
|
|
changeUserPasswordNonAscii(password)
Set the new user password to a binary string
|
|
changeUserPasswordUString(password)
Sets the new user password.
|
|
clone()
|
|
<static> |
PDFNet.SecurityHandler.create(crypt_type)
create a Standard Security Handler.
|
<static> |
PDFNet.SecurityHandler.createDefault()
[Documentation Not Yet Added]
|
<static> |
PDFNet.SecurityHandler.createFromEncCode(name, key_len, enc_code)
create a Standard Security Handler.
|
destroy()
Destructor
|
|
editSecurityData(doc)
Called when the security handler should activate a dialog box
with the current security settings that may be modified.
|
|
fillEncryptDict(doc)
Called when an encrypted document is saved.
|
|
getAuthorizationData(req_opr)
This method is invoked in case Authorize() failed.
|
|
initialize(doc, encrypt_dict, custom_data)
[Documentation Not Yet Added]
|
|
initPassword(password)
the method can be called in GetAuthorizationData() callback to
specify user supplied ASCII password.
|
|
initPasswordBuffer(password_buf)
[Documentation Not Yet Added]
|
|
initPasswordNonAscii(password)
the method can be called in GetAuthorizationData() callback to
specify user supplied non-ASCII password.
|
|
initPasswordUString(password)
this method can be called in GetAuthorizationData() callback to
specify user supplied password.
|
|
isAES()
|
|
isAESObj(stream)
The following function can be used to verify whether a given stream is
encrypted using AES.
|
|
isRC4()
|
|
setEncryptMetadata(encrypt_metadata)
Indicates whether the document-level metadata stream is to
be encrypted.
|
|
setModified(is_modified)
The method allows derived classes to set SecurityHandler is modified flag.
|
|
setPermission(perm, value)
Set the permission setting of the StdSecurityHandler.
|
Class Detail
PDFNet.SecurityHandler(id)
Standard Security Handler is a standard password-based security handler.
- Parameters:
- id
Method Detail
{[ERROR]}
authorize(p)
The method is called when a user tries to set security for an encrypted
document and when a user tries to open a file. It must decide, based on
the contents of the authorization data structure, whether or not the
user is permitted to open the file, and what permissions the user has
for this file.
- Parameters:
- {number} p
- permission to authorize
- Returns:
- {[ERROR]} A promise that resolves to an unknown type (generated documentation)
authorizeFailed()
A callback method indicating repeated failed authorization.
Override this callback in order to provide a UI feedback for failed
authorization. Default implementation returns immediately.
changeMasterPasswordBuffer(password_buf)
[Documentation Not Yet Added]
- Parameters:
- {Array} password_buf
- (generated documentation)
changeMasterPasswordNonAscii(password)
Set the new master password to a binary string
- Parameters:
- password
- the new user password
changeMasterPasswordUString(password)
Sets the new master/owner password.
- Parameters:
- {string} password
- The new master/owner password.
changeRevisionNumber(rev_num)
Change the revision number and the encryption algorithm of the
standard security handler.
- Parameters:
- {number} rev_num
- the new revision number of the standard security algorithm. Currently allowed values for the revision number are (see Table 3.18 in PDF Reference Manual v1.6 for more details): 2 : Encryption using 40-bit RC4 algorithm. 3 : Encryption using 128-bit RC4 algorithm. Available in PDF 1.4 and above. 4 : Encryption using Crypt filters and 128-bit AES (Advanced Encryption Standard) algorithm. Available in PDF 1.6 and above.
changeUserPasswordBuffer(password_buf)
[Documentation Not Yet Added]
- Parameters:
- {Array} password_buf
- (generated documentation)
changeUserPasswordNonAscii(password)
Set the new user password to a binary string
- Parameters:
- password
- the new user password
changeUserPasswordUString(password)
Sets the new user password.
- Parameters:
- {string} password
- The new user password.
{SecurityHandler}
clone()
- Returns:
- {SecurityHandler} A promise that resolves to a new, cloned instance of SecurityHandler.
<static>
{SecurityHandler}
PDFNet.SecurityHandler.create(crypt_type)
create a Standard Security Handler.
- Parameters:
- {number} crypt_type
- The encryption algorithm identifier.
- Returns:
- {SecurityHandler} A promise that resolves to an object of type: "SecurityHandler" (generated documentation)
<static>
{SecurityHandler}
PDFNet.SecurityHandler.createDefault()
[Documentation Not Yet Added]
- Returns:
- {SecurityHandler} A promise that resolves to an object of type: "SecurityHandler" (generated documentation)
<static>
{SecurityHandler}
PDFNet.SecurityHandler.createFromEncCode(name, key_len, enc_code)
create a Standard Security Handler.
- Parameters:
- {string} name
- The name of the Standard Security Handler.
- {number} key_len
- The bit length of the encryption key (40 or 128 bit).
- {number} enc_code
- The encryption algorithm identifier. The number corresponds to the V entry in encryption dictionary. Currently allowed values are (see Table 3.18 in PDF Reference Manual v1.6 for more details): 1 : Encryption using 40-bit RC4 algorithm. 2 : Encryption using 128-bit RC4 algorithm. Available in PDF 1.4 and above. 3 : This algorithm was deprecated by PDF standard and is not supported. 4 : Encryption using Crypt filters and 128-bit AES (Advanced Encryption Standard) algorithm. Available in PDF 1.6 and above.
- Returns:
- {SecurityHandler} A promise that resolves to an object of type: "SecurityHandler" (generated documentation)
destroy()
Destructor
{boolean}
editSecurityData(doc)
Called when the security handler should activate a dialog box
with the current security settings that may be modified.
- Parameters:
- {SDFDoc} doc
- (generated documentation)
- Returns:
- {boolean} A promise that resolves to true if the operation was successful false otherwise.
{Obj}
fillEncryptDict(doc)
Called when an encrypted document is saved. Fills the document's Encryption
dictionary with whatever information the security handler wants to store in
the document.
The sequence of events during creation of the encrypt_dict is as follows:
encrypt_dict is created (if it does not exist)
Filter attribute is added to the dictionary
call this method to allow the security handler to add its own attributes
call the GetCryptKey to get the algorithm version, key, and key length
checks if the V attribute has been added to the dictionary and, if not,
then sets V to the algorithm version
set the Length attribute if V is 2 or greater
add the encrypt_dict to the document
- Parameters:
- {SDFDoc} doc
- The document to save.
- Returns:
- {Obj} A promise that resolves to encrypt_dict
{boolean}
getAuthorizationData(req_opr)
This method is invoked in case Authorize() failed. The callback must
determine the user's authorization properties for the document by
obtaining authorization data (e.g. a password through a GUI dialog).
The authorization data is subsequently used by the security handler's Authorize()
to determine whether or not the user is authorized to open the file.
- Parameters:
- {number} req_opr
- the permission for which authorization data is requested.
- Returns:
- {boolean} A promise that resolves to false if the operation was canceled, true otherwise.
{number}
getEncryptionAlgorithmID()
- Returns:
- {number} A promise that resolves to the encryption algorithm identifier. A code specifying the algorithm to be used in encrypting and decrypting the document. Returned number corresponds to V entry in encryption dictionary. Currently allowed values are from 0-4. See PDF Reference Manual for more details.
{string}
getHandlerDocName()
- Returns:
- {string} A promise that resolves to the name of the security handler as it appears in the serialized file as the value of /Filter key in /Encrypt dictionary.
{number}
getKeyLength()
- Returns:
- {number} A promise that resolves to the length of the encryption key in bytes.
{boolean}
getPermission(p)
- Parameters:
- {number} p
- A Permission to be granted.
- Returns:
- {boolean} A promise that resolves to true if the SecurityHandler permits the specified action (Permission p) on the document, or false if the permission was not granted.
{number}
getRevisionNumber()
- Returns:
- {number} A promise that resolves to the revision number of the standard security algorithm.
initialize(doc, encrypt_dict, custom_data)
[Documentation Not Yet Added]
- Parameters:
- {SDFDoc} doc
- (generated documentation)
- {Obj} encrypt_dict
- (generated documentation)
- custom_data
- (generated documentation [X])
initPassword(password)
the method can be called in GetAuthorizationData() callback to
specify user supplied ASCII password.
- Parameters:
- password
- user supplied ASCII password
initPasswordBuffer(password_buf)
[Documentation Not Yet Added]
- Parameters:
- {Array} password_buf
- (generated documentation)
initPasswordNonAscii(password)
the method can be called in GetAuthorizationData() callback to
specify user supplied non-ASCII password.
- Parameters:
- password
- user supplied non-ASCII password
initPasswordUString(password)
this method can be called in GetAuthorizationData() callback to
specify user supplied password.
- Parameters:
- {string} password
- (generated documentation)
{boolean}
isAES()
- Returns:
- {boolean} A promise that resolves to true is this security handler uses 128 bit AES (Advanced Encryption Standard) algorithm to encrypt strings or streams.
{boolean}
isAESObj(stream)
The following function can be used to verify whether a given stream is
encrypted using AES.
- Parameters:
- {Obj} stream
- A pointer to an SDF::Stream object
- Returns:
- {boolean} A promise that resolves to true if the given stream is encrypted using AES encryption.
{boolean}
isMasterPasswordRequired()
- Returns:
- {boolean} A promise that resolves to true if the SecurityHandler requires a master (owner) password.
{boolean}
isModified()
- Returns:
- {boolean} A promise that resolves to true if the SecurityHandler was modified (by calling SetModified()) or false otherwise. If the user changes SecurityHandler's settings (e.g. by changing a password), IsModified() should return true.
{boolean}
isRC4()
- Returns:
- {boolean} A promise that resolves to true is this security handler uses RC4 algorithm to encrypt strings or streams.
{boolean}
isUserPasswordRequired()
- Returns:
- {boolean} A promise that resolves to true if the SecurityHandler requires a user password.
setEncryptMetadata(encrypt_metadata)
Indicates whether the document-level metadata stream is to
be encrypted.
- Parameters:
- {boolean} encrypt_metadata
- true if metadata stream should be encrypted, false otherwise.
setModified(is_modified)
The method allows derived classes to set SecurityHandler is modified flag.
This method should be called whenever there are changes (e.g. a password change)
to the SecurityHandler
- Parameters:
- {boolean} is_modified
- Value to set the SecurityHandler's is modified flag to
setPermission(perm, value)
Set the permission setting of the StdSecurityHandler.
- Parameters:
- {number} perm
- indicates a permission to set or clear. It can be any of the following values: e_print // print the document. e_doc_modify // edit the document more than adding or modifying text notes. e_extract_content // enable content extraction e_mod_annot // allow modifications to annotations e_fill_forms // allow changes to fill in forms e_access_support // content access for the visually impaired. e_assemble_doc // allow document assembly e_print_high // high resolution print.
- {boolean} value
- true if the permission/s should be granted, false otherwise.