简体   繁体   English

如何添加UsernameTokenInterceptor cxf拦截器

[英]how to add UsernameTokenInterceptor cxf interceptor

I'm looking for a way to add security header to my soap request. 我正在寻找一种向我的soap请求添加安全标头的方法。

I've found the interceptor, which will solve my problem: UsernameTokenInterceptor Could someone suggest me how to create with my arguments (password, username) this bean and correctly insert it into my jaxws client 我找到了拦截​​器,它将解决我的问题: UsernameTokenInterceptor有人可以建议我如何使用我的参数(密码,用户名)创建此bean并将其正确插入到我的jaxws客户端中

<jaxws:client id="***" name="***" endpointName="***" serviceName="***" address="***" serviceClass="***" xmlns:tns="***">
<jaxws:outInterceptors>
    <ref bean="myInterceptor" />
</jaxws:outInterceptors>

The UsernameTokenInterceptor is a policy-aware interceptor that gets automatically created if your WSDL has a security policy that matches a sp:UsernameToken (with no other security binding. If so, then a different interceptor is used. UsernameTokenInterceptor is just to insert the UsernameToken). UsernameTokenInterceptor是一个策略感知型拦截器,如果您的WSDL具有与sp:UsernameToken匹配的安全策略(没有其他安全绑定,则将自动创建)。如果是,则使用其他拦截器。UsernameTokenInterceptor仅用于插入UsernameToken。 。 So you only need to specify the username + password as JAX-WS properties and you're done. 因此,您只需要指定用户名+密码作为JAX-WS属性即可。

If you don't have a security policy, then you want to use the WSS4JOutInterceptor instead, to manually insert a UsernameToken in the outbound security header. 如果没有安全策略,则想改用WSS4JOutInterceptor在出站安全标头中手动插入UsernameToken。

For an example of a policy which will trigger the UsernameTokenInterceptor, see the policy called "DoubleItPlaintextPolicy" here: 有关将触发UsernameTokenInterceptor的策略的示例,请参见此处的名为“ DoubleItPlaintextPolicy”的策略:

https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/ut/DoubleItUt.wsdl;h=c76294cb0f5900e363c0731e358449c93f925fe8;hb=HEAD https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/ws-security-examples/src/test/resources/org/apache/cxf/ systest / wssec /示例/ UT / DoubleItUt.wsdl; H = c76294cb0f5900e363c0731e358449c93f925fe8; HB = HEAD

If you want to use the manual approach, there is an example in the CXF docs: 如果要使用手动方法,则CXF文档中有一个示例:

http://cxf.apache.org/docs/ws-security.html http://cxf.apache.org/docs/ws-security.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM