Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: code comments added

...

Code Block
java
java
Map<String,Object> inProps= new HashMap<String,Object>();
... // how to configure the properties is outlined below;

WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
cxfEndpoint.getInInterceptors().add(wssIn);
cxfEndpoint.getInInterceptors().add(new SAAJInInterceptor()); // 2.0.x only; not needed in 2.1+

Map<String,Object> outProps = new HashMap<String,Object>();
... // how to configure the properties is outlined below;

WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
cxfEndpoint.getOutInterceptors().add(new SAAJOutInterceptor()); // 2.0.x only; not needed in 2.1+

Spring XML Configuration

If you're using Spring to build endpoints, you can easily integrate accomplish the above in your bean definitions as well.

Code Block
xml
xml
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath*:META-INF/cxf/cxf-extension-*.xml" />

<jaxws:endpoint id="myService"
  implementor="com.acme.MyServiceImpl"
  address="http://localhost:9001/MyService">
  <jaxws:inInterceptors>
     <!-- SAAJ Interceptor explicitly needed only for 2.0.x --> 
     <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
     <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
       <constructor-arg>
         <map>
           <entry key="action" value="..."/>
           <entry key="signaturePropFile" value="..."/>
           <entry key="user" value="..."/>
           ...
         </map>
       </constructor-arg>
     </bean>
  </jaxws:inInterceptors>
</jaxws:endpoint>

...