1

I try to use xades4j library for digital signature of UBL2.1 Invoice.

UBL define xpath transformation as:

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

and referencing Tranform ALgorithm XPath 1.0: http://www.w3.org/TR/1999/REC-xpath-19991116

When I define reference with xades4j it look like this:

DataObjectDesc ref1 = new DataObjectReference("")
                                    .withTransform(new XPathTransform(xpathValue).withNamespace(xpathNamespacePrefix, xpathNamespace))
                                    .withDataObjectFormat(new DataObjectFormatProperty("application/xml", "UTF-8").withDescription("xml dokumenta"));

I got Excetion that used function here() in xpath is unknown. Function here() is not defined in Xpath 1.0. But in examples od UBL signed xml files, there is:

<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>

Function here() is defined in XML-Signature XPath Filter 2.0: https://www.w3.org/TR/xmldsig-filter2/

Can I use xades4j library make reference transform with using function here()???

Best regards, Josip

Josip V.
  • 31
  • 6

2 Answers2

0

After studying specifications:

, I concluded that xades4j library has bug.

But when I tried to execute my code again to see what exception stack is generated, I figured that everything works OK.

So, I withdraw this question.

Josip

Josip V.
  • 31
  • 6
0

For reference, adding an explicit reference to Xalan solves the problem. More info here: https://github.com/luisgoncalves/xades4j/issues/177.

lgoncalves
  • 2,040
  • 1
  • 14
  • 12