Foxit PDF SDK
 All Classes Namespaces Functions Enumerations Enumerator Properties Pages
foxit.pdf.SignatureCallback Class Reference

Inherits SystemIDisposable.

Public Types

enum  CertValidity {
  CertValidity.e_CertValid = 0, CertValidity.e_CertExpired = 1, CertValidity.e_CertUnsupportType = 2, CertValidity.e_CertDataError = 3,
  CertValidity.e_CertInvalidPassword = 4, CertValidity.e_CertInvalidPath = 5, CertValidity.e_CertNotSet = 6, CertValidity.e_CertCannotGetPrivateKey = 7
}
 Enumeration for certificate validity. More...
 

Public Member Functions

virtual
SignatureCallback.CertValidity 
CheckCertificateValidity (string cert_path, byte[] cert_password, global::System.IntPtr client_data)
 A callback function used to check the validity of a certificate. More...
 
virtual Progressive.State ContinueCalcDigest (global::System.IntPtr client_data, PauseCallback pause)
 A callback function used to continue the custom digest calculation process. More...
 
virtual byte[] GetDigest (global::System.IntPtr client_data)
 A callback function used to get the digest after the calculation process is finished. More...
 
virtual bool IsNeedPadData ()
 A callback function used to check whether to return all contents with padding zero or not, when callback function SignatureCallback.VerifySigState is called. More...
 
virtual void Release ()
 A callback function used to release current callback object itself. More...
 
virtual byte[] Sign (global::System.IntPtr digest, int digest_length, string cert_path, byte[] cert_password, Signature.DigestAlgorithm digest_algorithm, global::System.IntPtr client_data)
 A callback function used to do signing and return the signed data. More...
 
virtual byte[] Sign (global::System.IntPtr digest, int digest_length, StreamCallback cert_file_stream, byte[] cert_password, Signature.DigestAlgorithm digest_algorithm, global::System.IntPtr client_data)
 A callback function used to do signing and return the signed data. More...
 
virtual bool StartCalcDigest (FileReaderCallback file, System.IntPtr byte_range_array, int size_of_array, Signature signature, global::System.IntPtr client_data)
 A callback function used to start a custom digest calculation, mainly to initialize the calculation process. More...
 
virtual uint VerifySigState (global::System.IntPtr digest, int digest_length, global::System.IntPtr signed_data, int signed_data_len, global::System.IntPtr client_data)
 A callback function used to verify the integrity of a signature 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 common.Library.RegisterSignatureCallback with filter and sub filter as the callback name.

See Also
foxit.common.Library

Member Enumeration Documentation

Enumeration for certificate validity.

Values of this enumeration should be used alone.

Enumerator
e_CertValid 

Certificate is valid.

e_CertExpired 

Certificate is expired.

e_CertUnsupportType 

Certificate is unsupport type.

e_CertDataError 

Certificate's data is error.

e_CertInvalidPassword 

Certificate's password is wrong.

e_CertInvalidPath 

Certificate's path is wrong.

e_CertNotSet 

Certificate is not set to sign a signature.

e_CertCannotGetPrivateKey 

Certificate's private key cannot be gotten.

Member Function Documentation

SignatureCallback.CertValidity foxit.pdf.SignatureCallback.CheckCertificateValidity ( string  cert_path,
byte[]  cert_password,
global::System.IntPtr  client_data 
)
inlinevirtual

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 foxit.pdf.SignatureCallback.CertValidity.e_CertValid can be returned directly.

Parameters
[in]cert_pathA full path of a 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
Certificate validity. Please refer to values starting from foxit.pdf.SignatureCallback.CertValidity.e_CertValid and it should be one of these values.
Progressive.State foxit.pdf.SignatureCallback.ContinueCalcDigest ( global::System.IntPtr  client_data,
PauseCallback  pause 
)
inlinevirtual

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 the return value of function NeedToPauseNow() of this input parameter and decide when to pause the calculation process.
[in]client_dataA user-defined object, which is passed by user from function Signature.StartSign or Signature.StartVerify .
Returns
foxit.common.Progressive.State.e_Finished means the rendering is finished successfully.
foxit.common.Progressive.State.e_ToBeContinued means the calculation process is not finished yet and callback function SignatureCallback.ContinueCalcDigest would be triggered again to continue the process.
foxit.common.Progressive.State.e_Error means any error occurs.
byte[] foxit.pdf.SignatureCallback.GetDigest ( global::System.IntPtr  client_data)
inlinevirtual

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_dataA user-defined object, which is passed by user from function Signature.StartSign or Signature.StartVerify .
Returns
The digest string. If there is any error, please return an empty string.
bool foxit.pdf.SignatureCallback.IsNeedPadData ( )
inlinevirtual

A callback function used to check whether to return all contents with padding zero or not, when callback function 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.
void foxit.pdf.SignatureCallback.Release ( )
inlinevirtual

A callback function used to release current callback object itself.

Returns
None.
byte[] foxit.pdf.SignatureCallback.Sign ( global::System.IntPtr  digest,
int  digest_length,
string  cert_path,
byte[]  cert_password,
Signature.DigestAlgorithm  digest_algorithm,
global::System.IntPtr  client_data 
)
inlinevirtual

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]digest_lengthThe size of digest data buffer.
[in]cert_pathThe certificate file path, 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 foxit.pdf.Signature.DigestAlgorithm.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.
byte[] foxit.pdf.SignatureCallback.Sign ( global::System.IntPtr  digest,
int  digest_length,
StreamCallback  cert_file_stream,
byte[]  cert_password,
Signature.DigestAlgorithm  digest_algorithm,
global::System.IntPtr  client_data 
)
inlinevirtual

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]digest_lengthThe size of digest data buffer.
[in]cert_file_streamA foxit.common.fxcrt.StreamCallback object which is implemented by user to access content of a certificate file 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 foxit.pdf.Signature.DigestAlgorithm.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.
bool foxit.pdf.SignatureCallback.StartCalcDigest ( FileReaderCallback  file,
System.IntPtr  byte_range_array,
int  size_of_array,
Signature  signature,
global::System.IntPtr  client_data 
)
inlinevirtual

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]byte_range_arrayA 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_arrayCount of elements in the byte range array byte_range_array.
[in]signatureA signature object.
[in]client_dataA user-defined object, which is passed by user from function Signature.StartSign , Signature.StartVerify .
Returns
true means the calculation process is successfully started and then SignatureCallback.ContinueCalcDigest will be triggered to continue the calculation process. false means fail to start a calculation process.
uint foxit.pdf.SignatureCallback.VerifySigState ( global::System.IntPtr  digest,
int  digest_length,
global::System.IntPtr  signed_data,
int  signed_data_len,
global::System.IntPtr  client_data 
)
inlinevirtual

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]digestThe digest data buffer, for source file buffer to be verified.
[in]digest_lengthThe size of digest data buffer.
[in]signed_dataThe signed data buffer.
[in]signed_data_lenThe size of signed data buffer.
[in]client_dataA user-defined object, which is passed by user from function Signature.StartSign or Signature.StartVerify .
Returns
Verify state: