java - Add Reference to Resolver for a detached XAdES signature -
i've got create own xades signature project, , works fine except detached signatures. far understand, have add reference xml object point container original document stored. have tried both resolveranonymous , resolverlocalfilesystem.
xmlsignature sig = new xmlsignature(doctobesigned, "", sigalgorithm); element element = sig.getelement(); //adding signedinfo, keyinfo , xades properties in between resolverlocalfilesystem resolver = new resolverlocalfilesystem(); //resolveranonymous resolver = new resolveranonymous(documenttosign); sig.addresourceresolver(resolver); sig.adddocument("detachedobjectreference-1", null, esigutils.algorithmidtourn(hashalgorithmid), /* sends 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;
the error i'm getting follows:
original exception org.apache.xml.security.signature.referencenotinitializedexception: not find resolver uri detachedobjectreference-1 , base original exception org.apache.xml.security.signature.referencenotinitializedexception: not find resolver uri detachedobjectreference-1 , base original exception org.apache.xml.security.utils.resolver.resourceresolverexception: not find resolver uri detachedobjectreference-1 , base
could where's mistake?
thanks in advance!
alright, fixed it.
there id resolver apache xml security adds reference missing. next code snippet needs added signature work:
element objeto = doctobesigned.createelementns( constants.signaturespecns, "ds:object"); objeto.setattributens(null, constants._att_id, "detachedsignaturereference"); idresolver.registerelementbyid(objeto, "detachedsignaturereference");
instead of resolvers using.
Comments
Post a Comment