Sir,
I am trying to apply digital signature on the xml file generated through xforms document.
I want to develop the code that will develop a button on xforms document and after clicking on the button it will digitally sign the xml file generated throug xforms.
The code that i have written is as follows , kindly reply if there is any need for modification of the code,
The code is..
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:dsxp="http://www.w3.org/2002/06/xmldsig-filter2"
xmlns:sigmeta="http://www.ibm.com/xmlns/prod/forms/signature/metadata/1.0"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.6">
<head>
<xforms:model>
<xforms:instance id="GeneratedInstance" xmlns="">
<generated>
<test/>
<PAGE1>
<BUTTON1>
<ds:Signature>
<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>
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
<dsxp:XPath Filter="subtract">/xfdl:XFDL/xfdl:globalpage/xfdl:global/xfdl:xformsmodels/xforms:model/xforms:instance[@id="GeneratedInstance"]/generated/PAGE1/BUTTON1/ds:Signature</dsxp:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
</ds:DigestMethod>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
<dsxp:XPath Filter="intersect">here()/ancestor::ds:Signature[1]/ds:Object[sigmeta:metadata]</dsxp:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue></ds:SignatureValue>
<ds:Object>
<sigmeta:metadata>
<sigmeta:timestamp>
<sigmeta:signtime></sigmeta:signtime>
<sigmeta:dst></sigmeta:dst>
<sigmeta:date></sigmeta:date>
</sigmeta:timestamp>
<sigmeta:signformat>
application/signature+xml;
engine="GenericRSA"
</sigmeta:signformat>
</sigmeta:metadata>
</ds:Object>
</ds:Signature>
</BUTTON1>
</PAGE1>
</generated>
</xforms:instance>
<xforms:submission id="saveDoc" action="data.xml" replace="none" method="put" />
<xforms:submission id="loadDoc" action="data.xml" replace="instance" method="get"/>
<xforms:signature ref="ds:Signature" id="X">
<xforms:action ev:event="signature-create">
Actions to prepare dsig:Signature
</xforms:action>
<xforms:action ev:event="signature-create-done">
Actions to post-process success
</xforms:action>
<xforms:action ev:event="signature-create-error">
Actions that respond to failure
</xforms:action>
</xforms:signature>
</xforms:model>
</head>
<body>
<p>name</p>
<xforms:input ref="test"/>
<xforms:button sid="BUTTON1">
<xforms:trigger
ref="instance('GeneratedInstance')/PAGE1/
BUTTON1/ds:Signature/ds:SignatureValue">
<xforms:label>Click to Sign</xforms:label>
</xforms:trigger>
<xforms:itemlocation>
<below>FIELD3</below>
<width>246</width>
</xforms:itemlocation>
<xforms:value compute="signer == 'INVALID' ? invalid() : signer">
</xforms:value>
<xforms:type>signature</xforms:type>
<xforms:signer></xforms:signer>
<signformat>application/signature+xml;engine="GenericRSA"</signformat>
</xforms:button>
<xforms:submit submission="saveDoc">
<xforms:label>Save Doc</xforms:label>
</xforms:submit>
<xforms:submit submission="loadDoc">
<xforms:label>Load Doc</xforms:label>
</xforms:submit>
</body>
</html>
Please reply me ..
Thanks and Regads,
Deepak Tewani
Programmer
NIC