foxit::pdf::CustomSecurityCallback Class Referenceabstract
Inheritance diagram for foxit::pdf::CustomSecurityCallback:
foxit::pdf::SecurityCallback foxit::pdf::RMSSecurityCallback

Public Member Functions

virtual void * CreateContext (const char *filter, const char *sub_filter, const char *encrypt_info)=0
 A callback function used to create context for encryption and decryption. More...
 
virtual String DecryptData (const void *decryptor, const void *encrypted_data, uint32 encrypted_data_len)=0
 A callback function used to decrypt the encrypted data. More...
 
virtual bool EncryptData (const void *context, int obj_num, int gen_num, const void *src_data, uint32 src_data_len, void *out_dst_buffer, uint32 *out_dst_buffer_len)=0
 A callback function used to get encrypted data. More...
 
virtual String FinishDecryptor (void *decryptor)=0
 A callback function used to finish the decryption. More...
 
virtual SecurityHandler::CipherType GetCipher (const void *context)=0
 A callback function used to get the cipher type. More...
 
virtual uint32 GetDecryptedSize (const void *context, uint32 src_data_size)=0
 A callback function used to get the estimated decrypted data size. More...
 
virtual uint32 GetEncryptedSize (const void *context, int obj_num, int gen_num, const void *src_data, uint32 src_data_len)=0
 A callback function used to get the estimated encrypted size. More...
 
virtual String GetEncryptKey (const void *context)=0
 A callback function used to get the encryption key. More...
 
virtual PDFDoc::EncryptType GetSecurityType ()
 Get the encryption type of security callback. More...
 
virtual uint32 GetUserPermissions (const void *context, uint32 user_permission)=0
 A callback function used to get the user permissions. More...
 
virtual bool IsOwner (const void *context)=0
 A callback function used to check if current user is the owner of the PDF document. More...
 
virtual bool ReleaseContext (void *context)=0
 A callback function used to release the context for encryption and decryption. More...
 
virtual void * StartDecryptor (const void *context, int obj_num, int gen_num)=0
 A callback function used to start a decryption. More...
 
- Public Member Functions inherited from foxit::pdf::SecurityCallback
virtual void Release ()=0
 A callback function used to release current security callback object itself. More...
 

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 common::Library::RegisterSecurityCallback with with any custom filter name (following the PDF name conventions). Function common::Library::UnregisterSecurityCallback can be called to unregister the security callback object with the registered filter name.

Member Function Documentation

◆ CreateContext()

virtual void* foxit::pdf::CustomSecurityCallback::CreateContext ( const char *  filter,
const char *  sub_filter,
const char *  encrypt_info 
)
pure virtual

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

Parameters
[in]filterThe encryption filter of the PDF document.
[in]sub_filterThe sub filter of the PDF document.
[in]encrypt_infoThe encryption information of the PDF document.
Note
User should implement this callback function.
Returns
The encryption context.

◆ DecryptData()

virtual String foxit::pdf::CustomSecurityCallback::DecryptData ( const void *  decryptor,
const void *  encrypted_data,
uint32  encrypted_data_len 
)
pure virtual

A callback function used to decrypt the encrypted data.

Parameters
[in]decryptorThe decryptor implemented and created by user, returned by callback function CustomSecurityCallback::StartDecryptor.
[in]encrypted_dataThe buffer which stores the encrypted data.
[in]encrypted_data_lenThe length of encrypted data, in bytes.
Note
User should implement this callback function.
Returns
The decrypted data content.

◆ EncryptData()

virtual bool foxit::pdf::CustomSecurityCallback::EncryptData ( const void *  context,
int  obj_num,
int  gen_num,
const void *  src_data,
uint32  src_data_len,
void *  out_dst_buffer,
uint32 out_dst_buffer_len 
)
pure virtual

A callback function used to get encrypted data.

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
[in]obj_numThe object number for a PDF object.
[in]gen_numThe generation number for a PDF object.
[in]src_dataThe buffer which stores the plain text to be encrypted.
[in]src_data_lenThe length of the buffer.
[out]out_dst_bufferOutput parameter that receives the encrypted content.
[out]out_dst_buffer_lenOutput parameter that receives the length of the encrypted data.
Note
User should implement this callback function.
Returns
true means success, while false means failure.

◆ FinishDecryptor()

virtual String foxit::pdf::CustomSecurityCallback::FinishDecryptor ( void *  decryptor)
pure virtual

A callback function used to finish the decryption.

Parameters
[in]decryptorThe decryptor implemented and created by user, returned by callback function CustomSecurityCallback::StartDecryptor.
Note
User should implement this callback function.
Returns
The decrypted data content.

◆ GetCipher()

virtual SecurityHandler::CipherType foxit::pdf::CustomSecurityCallback::GetCipher ( const void *  context)
pure virtual

A callback function used to get the cipher type.

Parameters
[in]contextThe 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.

◆ GetDecryptedSize()

virtual uint32 foxit::pdf::CustomSecurityCallback::GetDecryptedSize ( const void *  context,
uint32  src_data_size 
)
pure virtual

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

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
[in]src_data_sizeSize of source data which is to be decrypted.
Note
User should implement this callback function.
Returns
The estimated decrypted data size.

◆ GetEncryptedSize()

virtual uint32 foxit::pdf::CustomSecurityCallback::GetEncryptedSize ( const void *  context,
int  obj_num,
int  gen_num,
const void *  src_data,
uint32  src_data_len 
)
pure virtual

A callback function used to get the estimated encrypted size.

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
[in]obj_numThe object number for a PDF object.
[in]gen_numThe generation number for a PDF object.
[in]src_dataThe buffer which stores the plain text to be encrypted.
[in]src_data_lenThe length of the buffer.
Note
User should implement this callback function.
Returns
The estimated encrypted size.

◆ GetEncryptKey()

virtual String foxit::pdf::CustomSecurityCallback::GetEncryptKey ( const void *  context)
pure virtual

A callback function used to get the encryption key.

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
Note
User should implement this callback function.
Returns
The encryption key.

◆ GetSecurityType()

virtual PDFDoc::EncryptType foxit::pdf::CustomSecurityCallback::GetSecurityType ( )
inlinevirtual

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_EncryptCustom.

Reimplemented from foxit::pdf::SecurityCallback.

Reimplemented in foxit::pdf::RMSSecurityCallback.

◆ GetUserPermissions()

virtual uint32 foxit::pdf::CustomSecurityCallback::GetUserPermissions ( const void *  context,
uint32  user_permission 
)
pure virtual

A callback function used to get the user permissions.

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
[in]user_permissionOriginal 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.

◆ IsOwner()

virtual bool foxit::pdf::CustomSecurityCallback::IsOwner ( const void *  context)
pure virtual

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

Parameters
[in]contextThe 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.

◆ ReleaseContext()

virtual bool foxit::pdf::CustomSecurityCallback::ReleaseContext ( void *  context)
pure virtual

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

Parameters
[in]contextThe 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.

◆ StartDecryptor()

virtual void* foxit::pdf::CustomSecurityCallback::StartDecryptor ( const void *  context,
int  obj_num,
int  gen_num 
)
pure virtual

A callback function used to start a decryption.

Parameters
[in]contextThe context for encryption and decryption, returned by callback function CustomSecurityCallback::CreateContext.
[in]obj_numThe object number for a PDF object.
[in]gen_numThe generation number for a PDF object.
Note
User should implement this callback function.
Returns
A decryptor implemented and created by user.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.