我正在嘗試向我的ws客戶端添加UsernameToken wss標頭。 的客戶端實現javax.xml.ws.Service和由於WSDL包含必須添加CXF UsernameToken問題
<wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" wsu:Id="UsernameTokenPolicy">
<sp:UsernameToken>
<wsp:Policy>
<sp:WssUsernameToken10/>
<sp:HashPassword/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
UsernameToken的報頭已經通過WSDL2Java的CFX 3.1.4
生成。搜索了一下,我發現,這是簡單的
((BindingProvider)soapClient).getRequestContext().put("ws-security.username", usr);
((BindingProvider)soapClient).getRequestContext().put("ws-security.password", psw);
通過時,我試圖執行一個電話,我得到下面的錯誤方式:
These policy alternatives can not be satisfied:
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}UsernameToken: Password hashing policy not enforced
有什麼建議? 謝謝。
P.S.我已經檢查了類似的帖子在堆棧溢出,但如果我嘗試像一個differente方法建議here我得到一個不同的錯誤:
Interceptor for XXXX has thrown exception, unwinding now
org.apache.cxf.ws.policy.PolicyException: No username available