I am trying to extract an XML node from a URI reference. This URI reference is generated by an XAdES4j signer, and could reference a node within the same XML file, or in the same folder.
I was hoping that loading the reference would be as simple as
XMLSignatureInput referencedXML = ResourceResolver.resolveStatic(referenceNode.getAttributeNode("URI"), referenceDoc.getBaseURI());
However this just gives me a NullPointerException with no useful message. Both arguments are non-null, and in a simple case the URI attribute was "data.xml" and the referenceDoc base URI was "/Users/ryan/.../test-files/signature.xml. data.xml resides in the same test-files directory.
The URI could point to an element within a file, so I'm hoping there is a reference loader which deals with that complexity for me. What have I missed?!
edit:
The reference I am trying to load is:
<ds:Reference Id="xmldsig-c6050e36-d9e7-46d9-ac5f-447d1bbb405f-ref0" URI="lote.xml" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
Total stab in the dark (you really need to paste stacktraces...), but here goes.
I took a quick look at the source of ResourceResolver at: http://java2s.com/Open-Source/Java-Document/XML/xml-security-1.4.3/org/apache/xml/security/utils/resolver/ResourceResolver.java.htm
I can see there is going to be a NullPointerException due to a non initialised _resolverVector field in the ResourceResolver, unless the static init() method has already been called on ResourceResolver. Above the init() method, there is a comment:
The init() function is called by org.apache.xml.security.Init.init()
The ResourceResolver itself does not appear to trigger that call - do you do it ? If not you should try it, prior to using any of the org.apache.xml.security stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With