Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
FoxitPDFSDKPython2.SignatureCallback Class Reference

Inherits FoxitPDFSDKPython2._object.

## Public Member Functions
def | CheckCertificateValidity (cert_path, cert_password, client_data)
| A callback function used to check the validity of a certificate. More...
def | ContinueCalcDigest (client_data, pause)
| A callback function used to continue the custom digest calculation process. More...
def | GetDigest (client_data)
| A callback function used to get the digest after the calculation process is finished. More...
def | IsNeedPadData ()
| A callback function used to check whether to return all contents with padding zero or not, when callback function FoxitPDFSDKPython2.SignatureCallback.VerifySigState is called. More...
def | Release ()
| A callback function used to release current callback object itself. More...
def | Sign (digest, digest_length, cert_file_stream, cert_password, digest_algorithm, client_data)
| A callback function used to do signing and return the signed data. More...
def | Sign (digest, digest_length, cert_path, cert_password, digest_algorithm, client_data)
| A callback function used to do signing and return the signed data. More...
def | StartCalcDigest (file, byte_range_array, size_of_array, signature, client_data)
| A callback function used to start a custom digest calculation, mainly to initialize the calculation process. More...
def | VerifySigState (digest, digest_length, signed_data, signed_data_len, client_data)
| A callback function used to verify the integrity of a signature and return the verify state. More...

## Static Public Attributes
| e_CertCannotGetPrivateKey = _fsdk.SignatureCallback_e_CertCannotGetPrivateKey
| Certificate's private key cannot be gotten.
| e_CertDataError = _fsdk.SignatureCallback_e_CertDataError
| Certificate's data is error.
| e_CertExpired = _fsdk.SignatureCallback_e_CertExpired
| Certificate is expired.
| e_CertInvalidPassword = _fsdk.SignatureCallback_e_CertInvalidPassword
| Certificate's password is wrong.
| e_CertInvalidPath = _fsdk.SignatureCallback_e_CertInvalidPath
| Certificate's path is wrong.
| e_CertNotSet = _fsdk.SignatureCallback_e_CertNotSet
| Certificate is not set to sign a signature.
| e_CertUnsupportType = _fsdk.SignatureCallback_e_CertUnsupportType
| Certificate is unsupport type.
| e_CertValid = _fsdk.SignatureCallback_e_CertValid
| Certificate is valid.

## Detailed Description

This class represent a callback object to sign or verify signature. All the pure virtual functions in this class are used as callback functions and should be implemented by user, in order to sign or verify signature in a customized way.
User can set register customized signature callback object to Foxit PDF SDK by function FoxitPDFSDKPython2.Library.RegisterSignatureCallback with filter and sub filter as the callback name.

See also
  FoxitPDFSDKPython2.Library

## Member Function Documentation

## ◆ CheckCertificateValidity()

def FoxitPDFSDKPython2.SignatureCallback.CheckCertificateValidity | ( |  | cert_path,
|  |  | cert_password,
|  |  | client_data
| ) |  |

A callback function used to check the validity of a certificate.

This callback function will be triggered when function FoxitPDFSDKPython2.Signature.StartSign is called. If no need to check the certificate, value FoxitPDFSDKPython2.SignatureCallback.e_CertValid can be returned directly.

Parameters

  [in] | cert_path | A full path of a certificate file (including file name and extension), which will be used for signing. This is passed by user from function FoxitPDFSDKPython2.Signature.StartSign .
  [in] | cert_password | A password string used to open the cert file. If this is an empty string, that means no password is required.This is passed by user from function FoxitPDFSDKPython2.Signature.StartSign .
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign .

Returns
  Certificate validity. Please refer to values starting from FoxitPDFSDKPython2.SignatureCallback.e_CertValid and it should be one of these values.

## ◆ ContinueCalcDigest()

def FoxitPDFSDKPython2.SignatureCallback.ContinueCalcDigest | ( |  | client_data,
|  |  | pause
| ) |  |

A callback function used to continue the custom digest calculation process.

Parameters

  [in] | pause | Pause object which decides if the calculation process needs to be paused. If this is null, it means not to pause during the calculation process. If this is not null, please check the the return value of function NeedToPauseNow() of this input parameter and decide when to pause the calculation process.
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign or FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  FoxitPDFSDKPython2.Progressive.e_Finished means the calculation process has finished successfully.
  FoxitPDFSDKPython2.Progressive.e_ToBeContinued means the calculation process is not finished yet and callback function FoxitPDFSDKPython2.SignatureCallback.ContinueCalcDigest would be triggered again to continue the process.
  FoxitPDFSDKPython2.Progressive.e_Error means any error occurs.

## ◆ GetDigest()

def FoxitPDFSDKPython2.SignatureCallback.GetDigest | ( |  | client_data | ) |

A callback function used to get the digest after the calculation process is finished.

This callback function will be triggered when the calculation process is finished successfully.

Parameters

  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign or FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  The digest string. If there is any error, please return an empty string.

## ◆ IsNeedPadData()

def FoxitPDFSDKPython2.SignatureCallback.IsNeedPadData | ( |  | ) |

A callback function used to check whether to return all contents with padding zero or not, when callback function FoxitPDFSDKPython2.SignatureCallback.VerifySigState is called.

Returns
  true means to return all data in contents steam (including padding zero), while false means to return contents data without padding zero in stream end.

## ◆ Release()

def FoxitPDFSDKPython2.SignatureCallback.Release | ( |  | ) |

A callback function used to release current callback object itself.

Returns
  None.

## ◆ Sign() [1/2]

def FoxitPDFSDKPython2.SignatureCallback.Sign | ( |  | digest,
|  |  | digest_length,
|  |  | cert_file_stream,
|  |  | cert_password,
|  |  | digest_algorithm,
|  |  | client_data
| ) |  |

A callback function used to do signing and return the signed data.

Host application provides this callback function for custom sign mechanism. This callback function would be triggered during the signature signing process.

Parameters

  [in] | digest | The digest data buffer, for source file buffer to be signed.
  [in] | digest_length | The size of digest data buffer.
  [in] | cert_file_stream | A FoxitPDFSDKPython2.StreamCallback object which is implemented by user to access content of a certificate file which will be used for signing.
  [in] | cert_password | The password string, used to open the cert file. If this is an empty string, that means no password is required.
  [in] | digest_algorithm | The algorithm of message digest for signed data. Please refer to values starting from FoxitPDFSDKPython2.Signature.e_DigestSHA1 and this would be one of these values.
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign or FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  Signed data. If there is any error, please return an empty string.
  The length of returned signed data should be within the default length of signature contents which is 7942 by default or specified by fucntion FoxitPDFSDKPython2.Signature.SetDefaultContentsLength before signing the unsigned signature.

## ◆ Sign() [2/2]

def FoxitPDFSDKPython2.SignatureCallback.Sign | ( |  | digest,
|  |  | digest_length,
|  |  | cert_path,
|  |  | cert_password,
|  |  | digest_algorithm,
|  |  | client_data
| ) |  |

A callback function used to do signing and return the signed data.

Host application provides this callback function for custom sign mechanism. This callback function would be triggered during the signature signing process.

Parameters

  [in] | digest | The digest data buffer, for source file buffer to be signed.
  [in] | digest_length | The size of digest data buffer.
  [in] | cert_path | The certificate file path, which will be used for signing.
  [in] | cert_password | The password string, used to open the cert file. If this is an empty string, that means no password is required.
  [in] | digest_algorithm | The algorithm of message digest for signed data. Please refer to values starting from FoxitPDFSDKPython2.Signature.e_DigestSHA1 and this would be one of these values.
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign or FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  Signed data. If there is any error, please return an empty string.
  The length of returned signed data should be within the default length of signature contents which is 7942 by default or specified by fucntion FoxitPDFSDKPython2.Signature.SetDefaultContentsLength before signing the unsigned signature.

## ◆ StartCalcDigest()

def FoxitPDFSDKPython2.SignatureCallback.StartCalcDigest | ( |  | file,
|  |  | byte_range_array,
|  |  | size_of_array,
|  |  | signature,
|  |  | client_data
| ) |  |

A callback function used to start a custom digest calculation, mainly to initialize the calculation process.

Parameters

  [in] | file | When signing a signature, this represents the source file object to be signed. When verifying a signature field, this represents the source file object to be verified.
  [in] | byte_range_array | A byte range array of the signed document(not the source document). Elements in this array always be in pairs of offset-size values in order of: offset,size,offset,size...
  [in] | size_of_array | Count of elements in the byte range array byte_range_array.
  [in] | signature | A signature object.
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign , FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  true means the calculation process is successfully started and then FoxitPDFSDKPython2.SignatureCallback.ContinueCalcDigest will be triggered to continue the calculation process. false means fail to start a calculation process.

## ◆ VerifySigState()

def FoxitPDFSDKPython2.SignatureCallback.VerifySigState | ( |  | digest,
|  |  | digest_length,
|  |  | signed_data,
|  |  | signed_data_len,
|  |  | client_data
| ) |  |

A callback function used to verify the integrity of a signature and return the verify state.

Host application provides this callback function for custom sign mechanism. This callback function would be triggered during the signature verifying process.
From 7.0, this callback function is only used to verify the intergrity of a signature. Please check the comment about return value for more details.

Parameters

  [in] | digest | The digest data buffer, for source file buffer to be verified.
  [in] | digest_length | The size of digest data buffer.
  [in] | signed_data | The signed data buffer.
  [in] | signed_data_len | The size of signed data buffer.
  [in] | client_data | A user-defined object, which is passed by user from function FoxitPDFSDKPython2.Signature.StartSign or FoxitPDFSDKPython2.Signature.StartVerify .

Returns
  Verify state:
  - Please return FoxitPDFSDKPython2.Signature.e_StateVerifyNoChange alone to indicate that the document has not been changed within the scope of the signature.
  - Otherwise, please return FoxitPDFSDKPython2.Signature.e_StateVerifyChange alone or combined with other error state value.