我必须为一个项目创建我自己的 XAdES 签名,除了分离的签名外,一切正常。据我了解,我必须添加对 XML 对象的引用,该对象将指向存储原始文档的容器。我已经尝试过使用 ResolverAnonymous 和 ResolverLocalFileSystem。
XMLSignature sig = new XMLSignature(docToBeSigned, "", sigAlgorithm);
Element element = sig.getElement();
//adding signedinfo, keyinfo and xades properties in between
ResolverLocalFilesystem resolver = new ResolverLocalFilesystem();
//ResolverAnonymous resolver = new ResolverAnonymous(documentToSign);
sig.addResourceResolver(resolver);
sig.addDocument("DetachedObjectReference-1", null,
ESIGUtils.algorithmIDtoURN(hashAlgorithmID), /* it sends the corresponding SHA-1 URL */
SignedDataObject-Reference", null);
Element objeto = docToBeSigned.createElement("ds:Object");
objeto.setAttribute("Id", "Object-1");
element.appendChild(objeto);
sig.sign(privateKey);
return docToBeSigned;
我得到的错误如下:
Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Could not find a resolver for URI DetachedObjectReference-1 and Base
Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Could not find a resolver for URI DetachedObjectReference-1 and Base
Original Exception was org.apache.xml.security.utils.resolver.ResourceResolverException: Could not find a resolver for URI DetachedObjectReference-1 and Base
谁能说我的错误在哪里?
提前致谢!