1

如何在 WS-Security usernameToken 警察中将用户名和密码设置为硬代码?

....
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
    <ramp:user>admin</ramp:user>
    <ramp:password......> ???
</ramp:RampartConfig>   
....
4

1 回答 1

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");
        }
    }
}

然后在壁垒配置中

<passwordCallbackClass>something.something.MyHardcodedPasswordHandler</passwordCallbackClass>
于 2013-02-18T11:41:06.683 回答