Foxit PDF RDK

Public Member Functions | List of all members
CustomSecurityCallback Class Reference
Inheritance diagram for CustomSecurityCallback:

## Public Member Functions
| CreateContext (filter, sub_filter, encrypt_info)
| A callback function used to create context for encryption and decryption. More...
| DecryptData (decryptor, encrypted_data, encrypted_data_len)
| A callback function used to decrypt the encrypted data. More...
| EncryptData (context, obj_num, gen_num, src_data, src_data_len)
| A callback function used to get encrypted data. More...
| FinishDecryptor (decryptor)
| A callback function used to finish the decryption. More...
| GetCipher (context)
| A callback function used to get the cipher type. More...
| GetDecryptedSize (context, src_data_size)
| A callback function used to get the estimated decrypted data size. More...
| GetEncryptedSize (context, obj_num, gen_num, src_data, src_data_len)
| A callback function used to get the estimated encrypted size. More...
| GetEncryptKey (context)
| A callback function used to get the encryption key. More...
| GetSecurityType ()
| Get the encryption type of security callback. More...
| GetUserPermissions (context, user_permission)
| A callback function used to get the user permissions. More...
| IsOwner (context)
| A callback function used to check if current user is the owner of the PDF document. More...
| ReleaseContext (context)
| A callback function used to release the context for encryption and decryption. More...
| StartDecryptor (context, obj_num, gen_num)
| A callback function used to start a decryption. More...
| UseStandardCryptoMethod (context)
| A callback function to check if to use standard crypto method or custom crypto method. More...
Public Member Functions inherited from NativeObjectWrapper
| constructor (r)
| GetPointerAsNumber ()

## Detailed Description

This class represents a callback object for custom decryption and encryption. If user wants to use custom security callback, user should inherit this callback class and implement the pure virtual functions (as callback functions), and then register the custom security callback object to Foxit PDF SDK by function Library.RegisterSecurityCallback with with any custom filter name (following the PDF name conventions). Function Library.UnregisterSecurityCallback can be called to unregister the security callback object with the registered filter name.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## Member Function Documentation

## ◆ CreateContext()

CustomSecurityCallback.CreateContext | ( | filter | ,
|  | sub_filter | ,
|  | encrypt_info |
| ) |  |

A callback function used to create context for encryption and decryption.

Parameters

  [in] | filter | The filter name of the custom security callback object.
  [in] | sub_filter | The sub filter name that specifies the syntax of the encryption dictionary contents.
  [in] | encrypt_info | The encryption information of the PDF document.

Note
  User should implement this callback function.

Returns
  The encryption context.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ DecryptData()

CustomSecurityCallback.DecryptData | ( | decryptor | ,
|  | encrypted_data | ,
|  | encrypted_data_len |
| ) |  |

A callback function used to decrypt the encrypted data.

Parameters

  [in] | decryptor | The decryptor implemented and created by user, returned by callback function CustomSecurityCallback.StartDecryptor.
  [in] | encrypted_data | The buffer which stores the encrypted data.
  [in] | encrypted_data_len | The length of encrypted data, in bytes.

Note
  User should implement this callback function.

Returns
  The decrypted data content.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ EncryptData()

CustomSecurityCallback.EncryptData | ( | context | ,
|  | obj_num | ,
|  | gen_num | ,
|  | src_data | ,
|  | src_data_len |
| ) |  |

A callback function used to get encrypted data.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.
  [in] | obj_num | The object number for a PDF object.
  [in] | gen_num | The generation number for a PDF object.
  [in] | src_data | The buffer which stores the plain text to be encrypted.
  [in] | src_data_len | The length of the buffer.

Note
  User should implement this callback function.

Returns
  true means success, while false means failure.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ FinishDecryptor()

CustomSecurityCallback.FinishDecryptor | ( | decryptor |  | ) |

A callback function used to finish the decryption.

Parameters

  [in] | decryptor | The decryptor implemented and created by user, returned by callback function CustomSecurityCallback.StartDecryptor.

Note
  User should implement this callback function.

Returns
  The decrypted data content.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetCipher()

CustomSecurityCallback.GetCipher | ( | context |  | ) |

A callback function used to get the cipher type.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.

Note
  User should implement this callback function.

Returns
  The cipher type. Please refer to values starting from SecurityHandler.e_CipherNone and this should be one of these values.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetDecryptedSize()

CustomSecurityCallback.GetDecryptedSize | ( | context | ,
|  | src_data_size |
| ) |  |

A callback function used to get the estimated decrypted data size.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.
  [in] | src_data_size | Size of source data which is to be decrypted.

Note
  User should implement this callback function.

Returns
  The estimated decrypted data size.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetEncryptedSize()

CustomSecurityCallback.GetEncryptedSize | ( | context | ,
|  | obj_num | ,
|  | gen_num | ,
|  | src_data | ,
|  | src_data_len |
| ) |  |

A callback function used to get the estimated encrypted size.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.
  [in] | obj_num | The object number for a PDF object.
  [in] | gen_num | The generation number for a PDF object.
  [in] | src_data | The buffer which stores the plain text to be encrypted.
  [in] | src_data_len | The length of the buffer.

Note
  User should implement this callback function.

Returns
  The estimated encrypted size.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetEncryptKey()

CustomSecurityCallback.GetEncryptKey | ( | context |  | ) |

A callback function used to get the encryption key.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.

Note
  User should implement this callback function.

Returns
  The encryption key.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetSecurityType()

CustomSecurityCallback.GetSecurityType | ( |  | ) |

Get the encryption type of security callback.

Note
  User should not override this function, otherwise there will be unexpected behavior.

Returns
  The encryption type. It would always be PDFDoc.e_EncryptFoxitDRM.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ GetUserPermissions()

CustomSecurityCallback.GetUserPermissions | ( | context | ,
|  | user_permission |
| ) |  |

A callback function used to get the user permissions.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.
  [in] | user_permission | Original permission settings of the document. Please refer to values starting from PDFDoc.e_PermPrint and this would be one or combination of these values.

Note
  User should implement this callback function.

Returns
  The new user permissions. Please refer to values starting from PDFDoc.e_PermPrint and this should be one or combination of these values.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ IsOwner()

CustomSecurityCallback.IsOwner | ( | context |  | ) |

A callback function used to check if current user is the owner of the PDF document.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.

Note
  User should implement this callback function.

Returns
  true means current user is the owner, and false means current user is not the owner.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ ReleaseContext()

CustomSecurityCallback.ReleaseContext | ( | context |  | ) |

A callback function used to release the context for encryption and decryption.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.

Note
  User should implement this callback function.

Returns
  true means success, while false means failure.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ StartDecryptor()

CustomSecurityCallback.StartDecryptor | ( | context | ,
|  | obj_num | ,
|  | gen_num |
| ) |  |

A callback function used to start a decryption.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.
  [in] | obj_num | The object number for a PDF object.
  [in] | gen_num | The generation number for a PDF object.

Note
  User should implement this callback function.

Returns
  A decryptor implemented and created by user.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.

## ◆ UseStandardCryptoMethod()

CustomSecurityCallback.UseStandardCryptoMethod | ( | context |  | ) |

A callback function to check if to use standard crypto method or custom crypto method.

Parameters

  [in] | context | The context for encryption and decryption, returned by callback function CustomSecurityCallback.CreateContext.

Returns
  - true means to use standard crypto method. In this case, callback functions CustomSecurityCallback.GetDecryptedSize, CustomSecurityCallback.StartDecryptor, CustomSecurityCallback.DecryptData, CustomSecurityCallback.FinishDecryptor, CustomSecurityCallback.GetEncryptedSize, and CustomSecurityCallback.EncryptData will be uselss and user can just use empty implementation for them.
  - false means use custom crypto method. In this case, please ensure callback functions mentioned above have all been implemented.

Examples
  /Users/ec2-user/gitlab-runner/builds/E-xKdhDo/0/foxit/sdk/mobile/gsdk-doc-auto-build/harmony_nodejs/input/Index.js.