4

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

rjj
  • 53
  • 1
  • 5

1 Answers1

6

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.

lgoncalves
  • 2,040
  • 1
  • 14
  • 12
  • What should keyStorage folder contain? – Jacek Kaczmarek Jan 16 '22 at 23:06
  • In the example linked above KeyStorage doesn't seem to be a folder. It seems to be the name of a JKS keystore in the file-system, which contains the trust anchors for certificate validation (it is used with PKIXCertificateValidationProvider). – lgoncalves Jan 17 '22 at 08:25