SignEvent Object

Microsoft Office InfoPath

Show All Show All

SignEvent Object

An event object that is used during the OnSign event.

Remarks

Note  This object model member is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Service Pack 1 or later is not installed. Any form that implements this object model member in its code will generate an error message if it is opened in InfoPath when service pack features are disabled or unavailable.

Using the SignEvent object

Use the SignedDataBlock property of the SignEventObject object to determine which signed data block is triggering the OnSign event. The OnSign event is raised for a fully trusted form template only.

Example

In the following example, the SignEvent object is used to add a signature and timestamp to a SignedDataBlock object:

    [InfoPathEventHandler(EventType=InfoPathEventType.OnSign)]
public void OnSign(SignEvent e)
{
    Signature signature = e.SignedDataBlock.Signatures.Create();
	   signature.Sign();

	   // Countersign the signature with a trusted timestamp.

	   // Get the XML node storing the signature block.
	   IXMLDOMNode oNodeSig = signature.SignatureBlockXmlNode;
	   IXMLDOMNode oNodeSigValue = oNodeSig.selectSingleNode(".//*[local-name(.)=’signatureValue’]");
	   // Get time stamp from timestamp service (fictitious).
	   MyTrustedTimeStampingService s = new MyTrustedTimeStampingService();
	   string strVerifiedTimeStamp = s.AddTimeStamp(oNodeSigValue.text);
	
	   //Add the value returned from the timestamping service to the 
	   //unsigned part of the signature block.
   	IXMLDOMNode oNodeObj = oNodeSig.selectSingleNode(".//*[local-name(.)=’Object’]");
	   IXMLDOMNode oNode = oNodeObj.cloneNode(false);
	   oNode.text = strVerifiedTimeStamp;
	   oNodeObj.parentNode.appendChild(oNode);

	   e.ReturnStatus = true;
}