CreaSign enables you to create a signature based on a template file. The template file should contain the following:
The following is an example of a template XML file. It contains three orders and a template signature node with references to the second and the third node:
<orders>
<order Id="first">
<customer>
<name>Karl the Great</name>
<phone_number>123-342-353</phone_number>
</customer>
<item>
<number>908784375</number>
<description>royal crown</description>
<price>123421</price>
</item>
<date_of_purchase>2002-10-23</date_of_purchase>
<date_of_delivery>2002-11-03</date_of_delivery>
</order>
<order Id="second">
<customer>
<name>Karl the small</name>
<phone_number>123-342-353</phone_number>
</customer>
<item>
<number>3496875</number>
<description>yellow hat</description>
<price>12123</price>
</item>
<date_of_purchase>2002-10-27</date_of_purchase>
<date_of_delivery>2002-11-07</date_of_delivery>
</order>
<!-- This is a signature template. CreaSign will calculate the signature based on the references provided here -->
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="MySignature">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>
<ds:Reference URI="#second">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#third">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
</ds:Signature>
<order Id="third">
<customer>
<name>Karl the strong</name>
<phone_number>83245-1234</phone_number>
</customer>
<item>
<number>123</number>
<description>ten-gram weight</description>
<price>992</price>
</item>
<date_of_purchase>2002-10-27</date_of_purchase>
<date_of_delivery>2002-11-07</date_of_delivery>
</order>
</orders>
To create a signature based on a template XML, follow these steps:
' The following certificate will be used for signing
signingCert="CERT_FIND_SUBJECT_STR=CREA_TESTUSER_1"
' Load a template xml from file. It already contains all the references
set doc=CreateObject("Msxml2.FreeThreadedDOMDocument.4.0")
doc.preserveWhiteSpace=true
doc.load "files\orders sign template.xml"
' Create a signature object
set cs = CreateObject("CreaSignClientIE.XmlSignature")
' Attach it to the existing signature node
cs.XmlNode=doc.selectSingleNode("//*[@Id='MySignature']")
' Create a signature
cs.CreateSignature signingCert,0
' Save the result to a file
saveTo="files/signedTemplate.xml"
if WScript.Arguments.Count>0 then saveTo=WScript.Arguments(0)
doc.save saveTo
WScript.Echo "Result saved to: " & saveTo
(c) Crea 2002-2006