Foxit PDF SDK  9.1
<FSSignatureCallback> Protocol Reference
Inheritance diagram for <FSSignatureCallback>:

Instance Methods

(FSSignatureCallbackCertValidity) - CheckCertificateValidity:certPassword:clientData:
 A callback function used to check the validity of a certificate. More...
 
(FSProgressiveState- continueCalcDigest:clientData:
 A callback function used to continue the custom digest calculation process. More...
 
(NSData *) - getDigest:
 A callback function used to get the digest after the calculation process is finished. More...
 
(BOOL) - isNeedPadData
 Whether return all contents all hex string include padding zero when call Verify function. More...
 
(NSData *) - sign:certPath:certPassword:digestAlgorithm:clientData:
 A callback function used to do signing and return the signed data. More...
 
(NSData *) - sign:certStream:certPassword:digestAlgorithm:clientData:
 A callback function used to do signing and return the signed data. More...
 
(BOOL) - startCalcDigest:byteRangeArray:signature:clientData:
 A callback function used to start a custom digest calculation, mainly to initialize the calculation process. More...
 
(FSSignatureStates- verifySigState:signedData:clientData:
 A callback function used to do verifying and return the verify state. More...
 

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 FSLibrary::registerSignatureCallback:sub_filter:signature_callback: with filter and sub filter as the callback name.

See also
FSLibrary

Method Documentation

◆ CheckCertificateValidity:certPassword:clientData:

- (FSSignatureCallbackCertValidity) CheckCertificateValidity: (NSString *)  certPath
certPassword: (NSString *)  certPassword
clientData: (void *)  clientData 
required

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

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

Parameters
[in]cert_pathA full path of a PFX certificate file (including file name and extension), which will be used for signing. This is passed by user from function Signature::StartSign.
[in]cert_passwordA 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 Signature::StartSign.
[in]client_dataA user-defined object, which is passed by user from function Signature::StartSign.
Returns
true means the ceritificate is valid, while false means invalid.

◆ continueCalcDigest:clientData:

- (FSProgressiveState) continueCalcDigest: (id< FSPauseCallback >)  pause
clientData: (void *)  clientData 
required

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

Parameters
[in]pausePause 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 returned value of function PauseCallback::NeedToPauseNow and decide when to pause the calculation process.
[in]clientDataPointer to a user-defined object, which is passed by user from function FSSignature::startSign:cert_password:digest_algorithm:save_path:client_data:pause: or FSSignature::startVerify:pause:.
Returns
FSProgressiveFinished means the rendering is finished successfully.
FSProgressiveToBeContinued means the calculation process is not finished yet and callback function FSSignatureCallback::continueCalcDigest:client_data: would be triggered again to continue the process.
FSProgressiveError means any error occurs.

◆ getDigest:

- (NSData *) getDigest: (void *)  clientData
required

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]clientDataPointer to a user-defined object, which is passed by user from function FSSignature::startSign:cert_password:digest_algorithm:save_path:client_data:pause: or FSSignature::startVerify:pause:.
Returns
The digest string. If there is any error, please return an empty string.

◆ isNeedPadData

- (BOOL) isNeedPadData
required

Whether return all contents all hex string include padding zero when call Verify function.

Returns
TRUE means return all data in contents steam. FALSE return contents data doesn't include zero in stream end.

◆ sign:certPath:certPassword:digestAlgorithm:clientData:

- (NSData *) sign: (NSData *)  digest
certPath: (NSString *)  certPath
certPassword: (NSString *)  certPassword
digestAlgorithm: (FSSignatureDigestAlgorithm digestAlgorithm
clientData: (void *)  clientData 
required

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]digestThe digest data buffer, for source file buffer to be signed.
[in]certPathThe certificate file path, which will be used for signing.
[in]certPasswordThe password string, used to open the cert file. If this is an empty string, that means no password is required.
[in]digestAlgorithmThe algorithm of message digest for signed data. Please refer to values starting from FSSignatureDigestSHA1 and this would be one of these values.
[in]clientDataPointer to a user-defined object, which is passed by user from function FSSignature::startSign:cert_password:digest_algorithm:save_path:client_data:pause: or FSSignature::startVerify:pause:.
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 FSSignature::setDefaultContentsLength: before signing the unsigned signature.

◆ sign:certStream:certPassword:digestAlgorithm:clientData:

- (NSData *) sign: (NSData *)  digest
certStream: (id< FSStreamCallback >)  certStream
certPassword: (NSString *)  certPassword
digestAlgorithm: (FSSignatureDigestAlgorithm digestAlgorithm
clientData: (void *)  clientData 
required

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]digestThe digest data buffer, for source file buffer to be signed.
[in]cert_file_streamThe certificate file stream, which will be used for signing.
[in]cert_passwordThe password string, used to open the cert file. If this is an empty string, that means no password is required.
[in]digest_algorithmThe algorithm of message digest for signed data. Please refer to values starting from Signature::e_DigestSHA1 and this would be one of these values.
[in]client_dataA user-defined object, which is passed by user from function Signature::StartSign or 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 Signature::SetDefaultContentsLength before signing the unsigned signature.

◆ startCalcDigest:byteRangeArray:signature:clientData:

- (BOOL) startCalcDigest: (id< FSFileReaderCallback >)  file
byteRangeArray: (NSArray< NSNumber * > *)  byteRangeArray
signature: (FSSignature *)  signature
clientData: (void *)  clientData 
required

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

Parameters
[in]fileWhen 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]byteRangeArrayA 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]signatureA signature object.
[in]clientDataPointer to a user-defined object, which is passed by user from function FSSignature::startSign:cert_password:digest_algorithm:save_path:client_data:pause: or FSSignature::startVerify:pause:.
Returns
YES means the calculation process is successfully started and then FSSignatureCallback::continueCalcDigest:client_data: will be triggered to continue the calculation process. NO means fail to start a calculation process.

◆ verifySigState:signedData:clientData:

- (FSSignatureStates) verifySigState: (NSData *)  digest
signedData: (NSData *)  signedData
clientData: (void *)  clientData 
required

A callback function used to do verifying 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.

Parameters
[in]digestThe digest data buffer, for source file buffer to be verified.
[in]signedDataThe signed data buffer.
[in]clientDataPointer to a user-defined object, which is passed by user from function FSSignature::startSign:cert_password:digest_algorithm:save_path:client_data:pause: or FSSignature::startVerify:pause:.
Returns
Verify state. Please refer to values starting from FSSignatureStateVerifyValid and this should be one or a combination of them.