Spring XML Configuration
If you're using Spring to build endpoints (e.g., web services running on a servlet container such as Tomcat), you can easily accomplish the above using your bean definitions instead.
<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">
<bean id="myPasswordCallback"
class="com.mycompany.webservice.ServerPasswordCallback"/>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordDigest"/>
<entry key="signaturePropFile" value="..."/>
<entry key="passwordCallbackRef">
<ref bean="myPasswordCallback"/>
</entry>
...
</map>
</constructor-arg>
</bean>
</jaxws:inInterceptors>
</jaxws:endpoint>
The entry keys and values given in the constructor-arg element above (action, signaturePropFile, etc.) map to the text strings in WSS4J's WSHandlerConstants and WSConstants classes for the corresponding WSHandlerConstants.XXXXX and WSConstants.XXXX constants you see in the section below. So by viewing WSHandlerConstants, for example, you can see that the WSHandlerConstants.USERNAME_TOKEN value given below would need to be "UsernameToken" instead when doing Spring configuration.
If you want to avoid looking up the text keys for the WSHandlerConstants.XXXXX and WSConstants.XXXX constants, you can also use the Spring util namespace to reference static constants in your Spring context as shown below.
<beans
...
xmlns:util="http://www.springframework.org/schema/util"
...
xsi:schemaLocation="
...
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
...
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry value="UsernameToken">
<key>
<util:constant static-field=
"org.apache.ws.security.handler.WSHandlerConstants.ACTION"/>
</key>
</entry>
...
</map>
</constructor-arg>
</bean>
...
</beans>