Hello,
I'm trying to upgrade my libraries that leverage Apache Santuario and I'm
getting failures in my test cases. Has something changed in resolving
reference URIs? I can't seem to find what actually causes this to happen
in the specification, but it's likely that I'm missing something.
Consider this example:
<comments>
<comment ID="1">
<text>This is the first comment.</text>
</comment>
<comment ID="2">
<text>This is the second comment.</text>
</comment>
</comments>
I'm trying to individually sign the first "comment" element:
final XMLSignature signature = new XMLSignature(ownerDoc, baseURI,
sigAlgorithm);
final Transforms transforms = new Transforms(ownerDoc);
// "singleComment" is the Node representing the first "comment" element.
I'm placing the signature inside the "comment" element.
singleComment.appendChild(signature.getElement());
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
signature.addDocument("#1", transforms, Constants.ALGO_ID_DIGEST_SHA1);
signature.addKeyInfo(certificate);
signature.addKeyInfo(certificate.getPublicKey());
signature.sign(privateKey);
This is the error I'm receiving:
java.lang.AssertionError:
org.apache.xml.security.signature.MissingResourceFailureException: The
Reference for URI #1 has no XMLSignatureInput
Original Exception was
org.apache.xml.security.signature.ReferenceNotInitializedException: Cannot
resolve element with ID 1
Original Exception was
org.apache.xml.security.signature.ReferenceNotInitializedException: Cannot
resolve element with ID 1
Original Exception was
org.apache.xml.security.signature.ReferenceNotInitializedException: Cannot
resolve element with ID 1
Original Exception was
org.apache.xml.security.utils.resolver.ResourceResolverException: Cannot
resolve element with ID 1
Which leads me to believe that it can't find the ID reference supplied by
the ID attribute in each "comment" element. This works perfectly in
1.4.4. What do I need to change in order to upgrade?
Thanks,
Michael Bishop