xpath - 使用 xades4j 签名 UBL2.1 发票
问题描述
我尝试使用 xades4j 库对 UBL2.1 Invoice 进行数字签名。
UBL 将 xpath 转换定义为:
count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)
并引用Transform ALgorithm XPath 1.0: http ://www.w3.org/TR/1999/REC-xpath-19991116
当我用 xades4j 定义引用时,它看起来像这样:
DataObjectDesc ref1 = new DataObjectReference("")
.withTransform(new XPathTransform(xpathValue).withNamespace(xpathNamespacePrefix, xpathNamespace))
.withDataObjectFormat(new DataObjectFormatProperty("application/xml", "UTF-8").withDescription("xml dokumenta"));
我得到了在 xpath 中使用的函数 here() 未知的异常。Xpath 1.0 中未定义函数 here()。但是在示例 od UBL 签名的 xml 文件中,有:
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
<ds:XPath xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2">
count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)
</ds:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>nLVnpwiT7Va0bsPgf14kso83NS8l+/usrd/a5l5ybeY=</ds:DigestValue>
</ds:Reference>
函数 here() 在 XML-Signature XPath Filter 2.0 中定义:https ://www.w3.org/TR/xmldsig-filter2/
我可以使用 xades4j 库使用函数 here() 进行参考变换吗???
最好的问候,约瑟普
解决方案
学习规范后:
- http://docs.oasis-open.org/ubl/prd2-UBL-2.1/doc/dsig/cd11-UBL-DSig-1.0.html
- https://www.w3.org/TR/xmldsig-core1/
- https://www.w3.org/TR/1999/REC-xpath-19991116/
- https://www.w3.org/TR/xmldsig-filter2/
,我断定xades4j库有bug。
但是当我再次尝试执行我的代码以查看生成了什么异常堆栈时,我认为一切正常。
所以,我撤回这个问题。
约瑟普
推荐阅读
- javascript - 如何修改 Loopback 4 中的错误信息?
- json - 熊猫的嵌套列表列表
- maven - 将自定义属性添加到 pom.properties
- python - 错误消息 Filedialog tkinter / FIFinderSyncExtensionHost 在两者中都实现
- r - system("timedatectl") "查询服务器失败:连接超时"
- javascript - 如果 JSON 数据不存在,如何隐藏 div
- java - 如何在团队城市插件开发jsp中处理表单提交
- php - php-amqplib:如何防止无限加载网页?
- java - Java 多环境最佳实践问题
- javascript - 是否可以在 Zapier Code 中启动服务器