如何在WS-Security usernameToken警察中将用户名和密码设置为硬编码?
....
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:user>admin</ramp:user>
<ramp:password......> ???
</ramp:RampartConfig>
....
答案 0 :(得分:1)
您必须使用<passwordCallbackClass>
如果您想对密码进行硬编码,请定义一个类似的类。
public class MyHardcodedPasswordHandler implements CallbackHandler {
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (Callback callback : callbacks) {
WSPasswordCallback pwcb = (WSPasswordCallback)callback;
pwcb.setPassword("myPassword");
}
}
}
然后在rampart配置
<passwordCallbackClass>something.something.MyHardcodedPasswordHandler</passwordCallbackClass>