Soap UI 使用肥皂信封中的什么来创建 XMLDsig 签名?或相反的问题,如何验证 Soap XMLDsig 响应的签名?我之所以问,是因为我只设法使用 Soap UI 获得了正确的响应。
假设我们在 SoapUI 中生成了这个请愿书:
<soapenv:Envelope xmlns:dat="..." xmlns:pet="..." xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-...">{BinarySecurityToken}</wsse:BinarySecurityToken>
<ds:Signature Id="SIG-..." xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="dat pet soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-...">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="dat pet" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>{Sha1Diest encoded base 64}</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
{Signature encoded base 64}
</ds:SignatureValue>
<ds:KeyInfo Id="KI-...">
<wsse:SecurityTokenReference wsu:Id="STR-...">
<wsse:Reference URI="#X509-..." ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</soapenv:Header>
<soapenv:Body wsu:Id="id-..." xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<pet:Petition>
...data...
</pet:Petition>
</soapenv:Body>
</soapenv:Envelope>
我有这个java代码来生成二进制安全令牌(它与soapui生成的匹配,因为相同的证书),但是使用相同的信封我得到不同的签名和摘要值:
Java 代码:https ://pastebin.com/06NUwkLW
那么,我应该使用什么String plaintext
来获得正确的签名和摘要值?
我已经尝试过使用 cxf3.4 和 axis2 客户端(使用 wsdl2java),但是添加 WS-Security 非常复杂,我只找到用户名/密码验证,这不是我需要的。