new SecurityHandler()
Standard Security Handler is a standard password-based security handler.
Methods
-
<static> create(crypt_type)
-
create a Standard Security Handler.
Parameters:
Name Type Description crypt_type
number/enum PDFNet.SecurityHandler.AlgorithmType = { e_RC4_40 : 1 e_RC4_128 : 2 e_AES : 3 e_AES_256 : 4 }
The encryption algorithm identifier.
Returns:
A promise that resolves to an object of type: "SecurityHandler"
-
<static> createDefault()
-
Create a default Security Handler.
Returns:
{SecurityHandler} A promise that resolves to a SecurityHandler object.
-
<static> createFromEncCode(name, key_len, enc_code)
-
create a Standard Security Handler.
Parameters:
Name Type Description name
string The name of the Standard Security Handler.
key_len
number The bit length of the encryption key (40 or 128 bit).
enc_code
number 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.
- Default Value:
-
- values for key_len and enc_code are 128 and 2 respectively.
Returns:
A promise that resolves to an object of type: "SecurityHandler"
-
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:
Name Type Description p
number/enum PDFNet.SecurityHandler.Permission = { e_owner : 1 e_doc_open : 2 e_doc_modify : 3 e_print : 4 e_print_high : 5 e_extract_content : 6 e_mod_annot : 7 e_fill_forms : 8 e_access_support : 9 e_assemble_doc : 10 }
permission to authorize
Returns:
A promise that resolves to an unknown type
-
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)
-
Parameters:
Name Type Description password_buf
Array -
changeMasterPasswordNonAscii(password)
-
Set the new master password to a binary string
Parameters:
Name Type Description password
the new user password
-
changeMasterPasswordUString(password)
-
Sets the new master/owner password.
Parameters:
Name Type Description password
string The new master/owner password.
-
changeRevisionNumber(rev_num)
-
Change the revision number and the encryption algorithm of the standard security handler.
Parameters:
Name Type Description rev_num
number 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)
-
Parameters:
Name Type Description password_buf
Array -
changeUserPasswordNonAscii(password)
-
Set the new user password to a binary string
Parameters:
Name Type Description password
the new user password
-
changeUserPasswordUString(password)
-
Sets the new user password.
Parameters:
Name Type Description password
string The new user password.
-
clone()
-
Returns:
A promise that resolves to a new, cloned instance of SecurityHandler.
-
destroy()
-
Destructor
-
editSecurityData(doc)
-
Parameters:
Name Type Description doc
PDFNet.SDFDoc Returns:
A promise that resolves to an unknown type
-
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:
Name Type Description doc
PDFNet.SDFDoc The document to save.
Returns:
A promise that resolves to encrypt_dict
- Type
- PDFNet.Obj
-
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:
Name Type Description req_opr
number/enum PDFNet.SecurityHandler.Permission = { e_owner : 1 e_doc_open : 2 e_doc_modify : 3 e_print : 4 e_print_high : 5 e_extract_content : 6 e_mod_annot : 7 e_fill_forms : 8 e_access_support : 9 e_assemble_doc : 10 }
the permission for which authorization data is requested.
Returns:
A promise that resolves to false if the operation was canceled, true otherwise.
- Type
- boolean
-
getEncryptionAlgorithmID()
-
Returns:
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.
- Type
- number
-
getHandlerDocName()
-
Returns:
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.
- Type
- string
-
getKeyLength()
-
Returns:
A promise that resolves to the length of the encryption key in bytes.
- Type
- number
-
getPermission(p)
-
Parameters:
Name Type Description p
number/enum PDFNet.SecurityHandler.Permission = { e_owner : 1 e_doc_open : 2 e_doc_modify : 3 e_print : 4 e_print_high : 5 e_extract_content : 6 e_mod_annot : 7 e_fill_forms : 8 e_access_support : 9 e_assemble_doc : 10 }
A Permission to be granted.
Returns:
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.
- Type
- boolean
-
getRevisionNumber()
-
Returns:
A promise that resolves to the revision number of the standard security algorithm.
- Type
- number
-
initialize(doc, encrypt_dict, custom_data)
-
Parameters:
Name Type Description doc
PDFNet.SDFDoc encrypt_dict
PDFNet.Obj custom_data
-
initPassword(password)
-
the method can be called in GetAuthorizationData() callback to specify user supplied ASCII password.
Parameters:
Name Type Description password
user supplied ASCII password
-
initPasswordBuffer(password_buf)
-
Parameters:
Name Type Description password_buf
Array -
initPasswordNonAscii(password)
-
the method can be called in GetAuthorizationData() callback to specify user supplied non-ASCII password.
Parameters:
Name Type Description password
user supplied non-ASCII password
-
initPasswordUString(password)
-
Parameters:
Name Type Description password
string -
isAES()
-
Returns:
A promise that resolves to true is this security handler uses 128 bit AES (Advanced Encryption Standard) algorithm to encrypt strings or streams.
- Type
- boolean
-
isAESObj(stream)
-
The following function can be used to verify whether a given stream is encrypted using AES.
Parameters:
Name Type Description stream
PDFNet.Obj A pointer to an SDF::Stream object
Returns:
A promise that resolves to true if the given stream is encrypted using AES encryption.
- Type
- boolean
-
isMasterPasswordRequired()
-
Returns:
A promise that resolves to true if the SecurityHandler requires a master (owner) password.
- Type
- boolean
-
isModified()
-
Returns:
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.
- Type
- boolean
-
isRC4()
-
Returns:
A promise that resolves to true is this security handler uses RC4 algorithm to encrypt strings or streams.
- Type
- boolean
-
isUserPasswordRequired()
-
Returns:
A promise that resolves to true if the SecurityHandler requires a user password.
- Type
- boolean
-
setEncryptMetadata(encrypt_metadata)
-
Indicates whether the document-level metadata stream is to be encrypted.
Parameters:
Name Type Description encrypt_metadata
boolean 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:
Name Type Description is_modified
boolean Value to set the SecurityHandler's is modified flag to
-
setPermission(perm, value)
-
Set the permission setting of the StdSecurityHandler.
Parameters:
Name Type Description perm
number/enum PDFNet.SecurityHandler.Permission = { e_owner : 1 e_doc_open : 2 e_doc_modify : 3 e_print : 4 e_print_high : 5 e_extract_content : 6 e_mod_annot : 7 e_fill_forms : 8 e_access_support : 9 e_assemble_doc : 10 }
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.
value
boolean true if the permission/s should be granted, false otherwise.