Topic: [求助]用java se6对xml进行Detached签名时,DOMSignContext的设置问题

  Print this page

1.[求助]用java se6对xml进行Detached签名时,DOMSignContext的设置问题 Copy to clipboard
Posted by: sunydudu
Posted on: 2007-09-03 22:11

请问用java se6对xml进行Detached签名时,DOMSignContext应该怎样设置阿
Document doc = dbf.newDocumentBuilder().newDocument();
DOMSignContext dsc =
new DOMSignContext(keyPair.getPrivate(), doc);
这样怎么不行啊,当执行signature.sign(dsc); 时,会抛出javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.URIReferenceException: com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException

如果将上面的代码改为
Document doc =
dbf.newDocumentBuilder().parse(new FileInputStream ("xmlForSign.xml"));
DOMSignContext dsc =
new DOMSignContext(keyPair.getPrivate(), doc.getDocumentElement());
会签名正确,但是却不是想要的Detached的分离签名,是
<SignedData>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
..............
</Signature>
</SignedData>

这样的enveloped的形式,

不知道怎么回事,哪位大侠帮帮忙啊,对于分离的签名,上下文信息应该怎样设置?还是有其他的方法?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923