我尝试使用xades4j库对UBL2.1发票进行数字签名。
UBL将xpath转换定义为:
count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)和引用Tranform 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"));我得到Excetion,在xpath中使用函数here()是未知的。函数here()在Xpath 1.0中没有定义。但在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()进行引用转换吗?
致以最好的问候,Josip
发布于 2018-10-19 15:34:13
在研究了规范之后:
,我得出的结论是xades4j库有错误。
但是,当我再次尝试执行代码以查看生成了什么异常堆栈时,我认为一切都正常。
因此,我撤回这项质询。
Josip
发布于 2018-11-08 20:21:28
对于引用,向Xalan添加显式引用可以解决这个问题。更多信息在这里:https://github.com/luisgoncalves/xades4j/issues/177。
https://stackoverflow.com/questions/52855697
复制相似问题