xades4j

Is there an example of how to do a XAdES-BES enveloped signature with the XAdES4j library?


I'm trying to use the XAdES4j library to sign xml with an enveloped signature. From everything I've read it looks like it is possible to do exactly what I'd like to do, but I've not been able to find a simple example to help me to understand the workflow better. The library is found here:

https://github.com/luisgoncalves/xades4j

It includes a wiki, but the wiki does not give a clear example. It refers you to the unit tests in the code. However, in the code for the unit tests, there are numerous methods that do not exist in the main code stream. I'm looking for a simple example for a XAdES-BES enveloping signature to be added to xml given these variables:

The path to my xml file: /path/to/xml/myXmlFile.xml

The root element in my xml file: invoice

The path to my cert: /path/to/cert/myCert.p12

Password to my cert: "myPassword"

Can anybody help me out with a clear example?

Thanks so much in advance :)


Solution

  • Here's a full example provided by another user within an issue in GitHub. It illustrates both XAdES-BES and XAdES-T.

    On the project's wiki you have detail instructions on which classes need to be used and pointers to more detailed information.

    Regarding the unit tests, there are some common/helper methods on the base classes that can be useful in other scenarios, namely on SignatureServicesTestBase and SignerTestBase

    Hope this helps.