XSLT transform in xmlsignature form, a part of xmldocument?

陌路散爱 提交于 2019-12-09 07:59:27

问题


I have a HTML page(A Form) where user will enter his details. Details to enter are
Name
age
salary
state
City
Now when user enters all details and click Button then I will create xml file containing the user details like

<root>
<name>abc</name>
<age>40</age>
<salary>20000</age>
<state>xyz</state>
<city>abc</city>
</root>


After this I want to sign this xml file using XMLSignature. I want to sign only two elements of document i.e name and salary element using XSLT transform and some digest and signature method.

My question is how to use the XSLT transform in our xmlsignature's transform element. What is the best way to achieve this?

One more issue when the user presses Another Button in HTML page, He should be shown the elements which are signed i.e name and salary should be displayed to user. How can I achieve that. Will XSLT transform plays a role here also?

Note: I am using Java libraries for XMLSignature


回答1:


Making reference to http://www.w3.org/TR/xmldsig-filter2/#sec-Examples, you might try an approach similar to the following:

<dsig:Transforms>
  <dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
    <dsig-xpath:XPath Filter="union"> /root/name </dsig-xpath:XPath>
    <dsig-xpath:XPath Filter="union"> /root/salary </dsig-xpath:XPath>
  </dsig:Transform>
</dsig:Transforms>


来源:https://stackoverflow.com/questions/10680590/xslt-transform-in-xmlsignature-form-a-part-of-xmldocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!