我正在尝试与 CXF 的 WS 安全实现(usernametoken)合作。我已经按照上面所说的做了一切http://cxf.apache.org/docs/ws-security.html http://cxf.apache.org/docs/ws-security.html。我的密码回调处理程序似乎工作正常,但困扰我的是一部分:
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");
}
as said
请注意,对于 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
答案(我已经尝试过)可以在此博客页面中找到:
http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html http://coheigea.blogspot.com/2011/06/custom-token-validation-in-apache-cxf.html
本质是创建org.apache.ws.security.validate.UsernameTokenValidator的子类,并重写verifyPlaintextPassword方法。在该方法中,传递 UsernameToken(提供 getName 和 getPassword)。如果它们无效,则抛出异常。
要在 spring 配置中安装自定义验证器,请添加例如
<jaxws:properties>
<entry key="ws-security.ut.validator">
<bean class="com.example.webservice.MyCustomUsernameTokenValidator" />
</entry>
</jaxws:properties>
进入 。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)