Class: SecurityHandler

PDFNet. SecurityHandler


new SecurityHandler()

Standard Security Handler is a standard password-based security handler.

Extends

Members


<static> AlgorithmType

Type:
  • number
Properties:
Name Type Description
e_RC4_40 number
e_RC4_128 number
e_AES number
e_AES_256 number

<static> Permission

Type:
  • number
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>

changeMasterPasswordBuffer(password_buf)

Sets the new master/owner password.
Parameters:
Name Type Description
password_buf ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray The new master/owner password.
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)

Sets the new user password.
Parameters:
Name Type Description
password_buf ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray The new user password.
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>

destroy()

Destructor
Inherited From:
Returns:
Type
Promise.<void>

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. Note: The returned key length is given 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. Note: in order to check for permission the method will repeatedly (up to three times) attempt to GetAuthorizationData() and Authorize() permission. If the permission is not granted AuthorizeFailed() callback will be called. This callback method allows derived class to provide UI feedback for failed authorization.
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)

This method can be called in GetAuthorizationData() callback to specify user supplied password.
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)

This method can be called in GetAuthorizationData() callback to specify user supplied 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. Note: EncryptMetadata flag affects only Crypt filters available in PDF 1.5 (Acrobat 6) and later. By default, metadata stream will be encrypted.
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