使用 WSSVerification API 的签名验证方法
可以通过将 WSS API 用于使用者绑定来验证签名或签名信息。签名和规范算法方法用于生成器绑定。com.ibm.websphere.wssecurity.wssapi.verification 包中提供了 WSSVerification API。
要配置使用者签名信息以保护消息完整性,必须首先进行数字签名,然后验证 SOAP 消息的签名。完整性是指数字签名,而机密性是指加密。保证完整性可降低数据在网络中传输时被修改的风险。
方法
可以使用下列方法来验证签名:
- 签名方法
- 设置签名算法方法。
- 规范方法
- 设置规范算法方法。
为请求生成者配置指定的算法必须与为响应使用者配置指定的算法相匹配。
签名算法
签名算法指定用来为证书签名的签名验证算法。签名算法指定签名验证方法的统一资源标识 (URI)。WebSphere® Application Server 支持以下预先配置的算法:
算法 | 描述 |
---|---|
WSSVerification.HMAC_SHA1 | 签名算法的 URI,HMAC:http://www.w3.org/2000/09/xmldsig#hmac-sha1 |
WSSVerification.RSA_SHA1(缺省值) | 签名算法的 URI,RSA:http://www.w3.org/2000/09/xmldsig#rsa-sha1 |
WebSphere Application Server 不支持 DSA-SHA1 的算法:http://www.w3.org/2000/09/xmldsig#dsa-sha1
规范算法
规范算法指定规范方法的统一资源标识 (URI)。WebSphere Application Server 支持以下预先配置的算法:
算法 | 描述 |
---|---|
WSSVerification.C14N | 包含规范算法的 URI,C14N:http://www.w3.org/2001/10/xml-c14n# |
WSSVerification.EXC_C14N(缺省值) | 排除规范算法的 URI,EXC_C14N:http://www.w3.org/2001/10/xml-exc-c14n# |
以下示例提供了用于指定签名验证的 X.509 令牌安全性令牌的样本 WSS API 代码:
WSSFactory factory = WSSFactory.getInstance();
WSSConsumingContext concont = factory.newWSSConsumingContext();
// X509ConsumeCallbackHandler
X509ConsumeCallbackHandler callbackHandler = new
X509ConsumeCallbackHandler("dsig-receiver.ks",
"jks",
"server".toCharArray(),
certList,
java.security.Security.getProvider("IBMCertPath")46 );
// Set the verification component
// DEFAULT verification parts: Body, WS-Addressing header, and Timestamp
// DEFAULT data encryption algorithm: RSA-SHA1
// DEFAULT digest algorithm: SHA1
// DEFAULT canonicalization algorithm: exc-c14n
WSSVerification ver = factory.newWSSVerification(X509Token.class,
callbackhandler);
concont.add(ver);
// Validate the WS-Security header
concont.validate(msgctx);