我正在尝试与 CXF 的 WS-security implementation(usernametoken) 结合在一起。我已经完成了http://cxf.apache.org/docs/ws-security.html中所说的一切。我的 PasswordCallbackHandler 似乎正在工作,但困扰我的是一部分:
if (pc.getIdentifier().equals("joe")) {
// set the password on the callback. This will be compared to the
// password which was sent from the client.
pc.setPassword("password");
}
如前所述
请注意,对于 CXF 2.3.x 及之前的版本,纯文本密码(或任何其他未知密码类型)的特殊情况的密码验证委托给回调类,请参阅 org.apache.ws.security。 WSS4J 项目的processor.UsernameTokenProcessor#handleUsernameToken() 方法javadoc。在这种情况下,ServerPasswordCallback 应该类似于以下内容:
所以直到 cxf 2.3.x 都是这样完成的
if (pc.getIdentifer().equals("joe") {
if (!pc.getPassword().equals("password")) {
throw new IOException("wrong password");
}
}
我的问题是:我不想 pc.setPassword("plainTextPassword") 因为我想将它存储在任何资源中。这种高达 2.3.x 的设计允许我这样做,因为我可以手动加密它。有没有办法在回调中设置加密密码或对存储的加密密码进行 usernametoken 身份验证?
我正在使用 cxf 2.5.x