我想使用 CXF 在 WSSE 安全标头中注入 Nonce 和 Created 元素。
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-6">
<wsse:Username>==Username==</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">==Password==</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">===EncodeString===</wsse:Nonce>
<wsu:Created>2016-05-20T10:51:24.795Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
我正在使用 org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor 类来填充 CXF 标头。但这仅填充wsse:Username和wsse:Password。我想要wsse:Nonce和wsse:Created在我的标题中。我应该采用哪种方法来填充安全标头中的上述元素?
下面是我用来填充它的代码,
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, "UsernameToken");
properties.put(WSHandlerConstants.USER, "userName-Text");
properties.put(WSHandlerConstants.PASSWORD_TYPE, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
properties.put(WSHandlerConstants.MUST_UNDERSTAND, "true");
properties.put(WSHandlerConstants.PW_CALLBACK_REF, new CustomWSPasswordCallback(passwordText));
WSS4JOutInterceptor wss4jOutInterceptor = new WSS4JOutInterceptor();
wss4jOutInterceptor.setProperties(properties);
我感谢您的帮助。
谢谢,阿什米什拉