|
Onk!
The
signature is part of the XML while your payload is not, nevertheless, the
signature-relevant digest on this payload was/is part of the signature you
generated (in the "Reference" elements). Signature is generated over any
"Reference" content you add and is then validated (on receipt) the same way. How
you provide the XML signature input, is on you. The XMLDS is allowing to
register "external" resource resolvers on references.
Therefore both questions should be answered by creating an own
(clever but simple) resource resolver class (org.apache.xml.security.utils.resolver.ResourceResolverSpi) using org.apache.xml.security.signature.XMLSignature.addResourceResolver(new
YourResolverclass()) to let it be used. Once you created a resource
resolver, you need to add it to the list of resource resolvers and you need to
register on which references this resource resolver should be invoked. Once the
reference matches, your classes "engineCanResolve" is called and if you return
true your "engineResolve", if you only need to add a file content to be added
your engineResolve would look like this (despite the issue of identifying the
file which is actually to link here:-):
/* (non-Javadoc) { //else (how easy this could be), set the file source: FileInputStream inputStream = new FileInputStream("/data/myfiles/thetestsource.txt"); XMLSignatureInput result = new XMLSignatureInput(inputStream); result.setSourceURI("/data/myfiles/thetestsource.txt"); //that's it: return result; }//engineResolve I did something similar to what you describe to include attachments in an XMLDS signature. To solve that I created a "LocalFileLinkResolver" extending ResourceResolverSpi finding the local copy of the signed file and returning a FileInputStream on it. e.g.
aXMLSignature.addDocument( sURI,
transforms,Constants.ALGO_ID_DIGEST_SHA1)); lfResolver.register("myPrivateURL", "e:\\_test\\ebxml\\payload\\example_00_product.xml1"); lfResolver.register("blubberBla", "somewhere"); // aXMLSignature.addResourceResolver(new ResolverLocalFilesystem()); aXMLSignature.addResourceResolver(new MIMEAttachmentResolver()); aXMLSignature.addResourceResolver(lfResolver); hth
Tot
ziens
Atlana
|
