CXF WSPasswordCallback 的替代方案

Alternative to CXF WSPasswordCallback

对于 SOAP 客户端,我正在使用 CXF 安全性实现证书签名。

在所有提供的示例中,对 passwordCallback class 的引用是在 WSS4JOutInterceptor 属性中设置的。

 securityProperties.put(WSHandlerConstants.PW_CALLBACK_CLASS, UTPasswordCallback.class.getName());
client.getOutInterceptors().add(new WSS4JOutInterceptor(securityProperties));

是否有 WSPasswordCallback 的替代方法?可以直接设置密码吗?

您可以在加密属性文件中指定密钥库的私钥密码以及用于签名:http://ws.apache.org/wss4j/config.html

通过在requestContext中设置密码找到解决方案:

client.getRequestContext().put("password", "PASSWORD");