【问题标题】:Using xades4j for signature UBL2.1 Invoice使用 xades4j 签名 UBL2.1 发票
【发布时间】:2019-03-22 04:21:03
【问题描述】:

我尝试使用 xades4j 库对 UBL2.1 Invoice 进行数字签名。

UBL定义xpath转换为:

count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)

并引用 Tranform 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"));

我得到了 Excetion,在 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 库通过 using function here() 进行参考变换吗???

最好的问候, 约西普

【问题讨论】:

    标签: xpath xades4j


    【解决方案1】:

    学习规范后:

    ,我的结论是 xades4j 库有错误。

    但是当我再次尝试执行我的代码以查看生成了什么异常堆栈时,我发现一切正常。

    所以,我撤回这个问题。

    乔斯普

    【讨论】:

      【解决方案2】:

      作为参考,添加对 Xalan 的显式引用可以解决问题。更多信息在这里:https://github.com/luisgoncalves/xades4j/issues/177

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-03-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多