首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用xades4j签名UBL2.1发票

使用xades4j签名UBL2.1发票
EN

Stack Overflow用户
提问于 2018-10-17 21:09:57
回答 2查看 788关注 0票数 0

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

UBL将xpath转换定义为:

代码语言:javascript
运行
复制
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定义引用时,它看起来像这样:

代码语言:javascript
运行
复制
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文件的示例中,有:

代码语言:javascript
运行
复制
<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

EN

回答 2

Stack Overflow用户

发布于 2018-10-19 15:34:13

在研究了规范之后:

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

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

因此,我撤回这项质询。

Josip

票数 0
EN

Stack Overflow用户

发布于 2018-11-08 20:21:28

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52855697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档