new SecurityHandler()
Standard Security Handler is a standard password-based security handler.
Extends
Members
-
<static> AlgorithmType
-
Properties:
Name Type Description e_RC4_40
number e_RC4_128
number e_AES
number e_AES_256
number -
<static> Permission
-
Properties:
Name Type Description e_owner
number e_doc_open
number e_doc_modify
number e_print
number e_print_high
number e_extract_content
number e_mod_annot
number e_fill_forms
number e_access_support
number e_assemble_doc
number
Methods
-
<static> create(crypt_type)
-
create a Standard Security Handler.
Parameters:
Name Type Description crypt_type
number 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: "PDFNet.SecurityHandler"- Type
- Promise.<PDFNet.SecurityHandler>
-
<static> createDefault()
-
Create a default Security Handler.
Returns:
A promise that resolves to a SecurityHandler object.- Type
- Promise.<PDFNet.SecurityHandler>
-
<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: "PDFNet.SecurityHandler"- Type
- Promise.<PDFNet.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 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 authorizeReturns:
A promise that resolves to an object of type: "boolean"- Type
- Promise.<boolean>
-
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.
Returns:
- Type
- Promise.<void>
-
changeMasterPasswordBuffer(password_buf)
-
Parameters:
Name Type Description password_buf
ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray Returns:
- Type
- Promise.<void>
-
changeMasterPasswordNonAscii(password)
-
Set the new master password to a binary string
Parameters:
Name Type Description password
string the new user password Returns:
- Type
- Promise.<void>
-
changeMasterPasswordUString(password)
-
Sets the new master/owner password.
Parameters:
Name Type Description password
string The new master/owner password. Returns:
- Type
- Promise.<void>
-
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. Returns:
- Type
- Promise.<void>
-
changeUserPasswordBuffer(password_buf)
-
Parameters:
Name Type Description password_buf
ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray Returns:
- Type
- Promise.<void>
-
changeUserPasswordNonAscii(password)
-
Set the new user password to a binary string
Parameters:
Name Type Description password
string the new user password Returns:
- Type
- Promise.<void>
-
changeUserPasswordUString(password)
-
Sets the new user password.
Parameters:
Name Type Description password
string The new user password. Returns:
- Type
- Promise.<void>
-
clone()
-
Returns:
A promise that resolves to a new, cloned instance of SecurityHandler.- Type
- Promise.<PDFNet.SecurityHandler>
-
destroy()
-
Destructor
- Inherited From:
Returns:
- Type
- Promise.<void>
-
editSecurityData(doc)
-
Parameters:
Name Type Description doc
PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc Returns:
A promise that resolves to an object of type: "boolean"- Type
- Promise.<boolean>
-
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.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document to save. Returns:
A promise that resolves to encrypt_dict- Type
- Promise.<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 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
- Promise.<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
- Promise.<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
- Promise.<string>
-
getKeyLength()
-
Returns:
A promise that resolves to the length of the encryption key in bytes.- Type
- Promise.<number>
-
getPermission(p)
-
Parameters:
Name Type Description p
number 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
- Promise.<boolean>
-
getRevisionNumber()
-
Returns:
A promise that resolves to the revision number of the standard security algorithm.- Type
- Promise.<number>
-
initPassword(password)
-
the method can be called in GetAuthorizationData() callback to specify user supplied ASCII password.
Parameters:
Name Type Description password
string user supplied ASCII password Returns:
- Type
- Promise.<void>
-
initPasswordBuffer(password_buf)
-
Parameters:
Name Type Description password_buf
ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray Returns:
- Type
- Promise.<void>
-
initPasswordNonAscii(password)
-
the method can be called in GetAuthorizationData() callback to specify user supplied non-ASCII password.
Parameters:
Name Type Description password
string user supplied non-ASCII password Returns:
- Type
- Promise.<void>
-
initPasswordUString(password)
-
Parameters:
Name Type Description password
string Returns:
- Type
- Promise.<void>
-
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
- Promise.<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
- Promise.<boolean>
-
isMasterPasswordRequired()
-
Returns:
A promise that resolves to true if the SecurityHandler requires a master (owner) password.- Type
- Promise.<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
- Promise.<boolean>
-
isRC4()
-
Returns:
A promise that resolves to true is this security handler uses RC4 algorithm to encrypt strings or streams.- Type
- Promise.<boolean>
-
isUserPasswordRequired()
-
Returns:
A promise that resolves to true if the SecurityHandler requires a user password.- Type
- Promise.<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. Returns:
- Type
- Promise.<void>
-
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 Argument Description is_modified
boolean <optional>
Value to set the SecurityHandler's is modified flag to Returns:
- Type
- Promise.<void>
-
setPermission(perm, value)
-
Set the permission setting of the StdSecurityHandler.
Parameters:
Name Type Description perm
number 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. Returns:
- Type
- Promise.<void>
-
takeOwnership()
-
Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
- Inherited From:
Returns:
- Type
- void