Details
Description
I have followed the instructions found in page http://xfire.codehaus.org/WS-Security to sign my messages from client to service and from service to client, and it works fine ! But when an exception is thrown by the service, the message is not signed, and the following stack trace is displayed by the client :
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: WSS4JInHandler: Request does not contain required Security header
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:92)
org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
$Proxy12.rechercherPatrimoine(Unknown Source)
net.gicm.astral.test.XfireTest.test(XfireTest.java:65)
org.apache.jsp.index_jsp._jspService(index_jsp.java:48)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
You can find client code + service.xml in attachment.
I have tried to add a <faultHandlers> in service.xml, but it doesn't work. Below what i have added in service.xml, but without success :
<faultHandlers>
<handler handlerClass="org.codehaus.xfire.util.dom.DOMOutHandler" />
<bean class="org.codehaus.xfire.security.wss4j.WSS4JOutHandler" xmlns="">
<property name="properties">
<props>
<prop key="action">Signature</prop>
<prop key="signaturePropFile">service.properties</prop>
<prop key="signatureKeyIdentifier">DirectReference</prop>
<prop key="passwordCallbackClass">net.gicm.astral.handler.PasswordHandler</prop>
<prop key="user">Service</prop>
</props>
</property>
</bean>
</faultHandlers>
It is the same problem that is described in http://www.nabble.com/ws-security--exception-fault-handling-tf2241051.html#a6215424.
There is still a problem with XFIRE 1.2.6. Here's the stack trace :
18:12:22 ERROR - [DefaultFaultHandler.sendFault] Could not send fault.
java.lang.NullPointerException
at org.apache.ws.security.util.WSSecurityUtil.findElement(WSSecurityUtil.java:198)
at org.apache.ws.security.message.WSSecSignature.addReferencesToSign(WSSecSignature.java:534)
at org.apache.ws.security.message.WSSecSignature.build(WSSecSignature.java:716)
at org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:54)
at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:192)
at org.codehaus.xfire.security.wss4j.WSS4JOutHandler.invoke(WSS4JOutHandler.java:158)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.handler.DefaultFaultHandler.sendFault(DefaultFaultHandler.java:88)
at org.codehaus.xfire.handler.DefaultFaultHandler.invoke(DefaultFaultHandler.java:51)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:99)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:134)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:109)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
I use
XFIRE-1.2.6 (through maven2) that use WSS4J 1.5.1.My configuration is :
<property name="faultHandlers">
<list>
<bean class="org.codehaus.xfire.util.dom.DOMOutHandler"/>
<bean class="org.codehaus.xfire.security.wss4j.WSS4JOutHandler">
<property name="properties">
<props>
<prop key="action">UsernameToken Timestamp Signature</prop>
<prop key="user">serveralias</prop>
<prop key="passwordCallbackClass">com.sofinco.soffwk.security.PasswordHandler</prop>
<prop key="signaturePropFile">/outsecurity_sign.properties</prop>
<prop key="signatureKeyIdentifier">IssuerSerial</prop>
</props>
</property>
</bean>
</list>
</property>
XFIRE-1.2.6 (through maven2) that use WSS4J 1.5.1. My configuration is : <property name="faultHandlers"> <list> <bean class="org.codehaus.xfire.util.dom.DOMOutHandler"/> <bean class="org.codehaus.xfire.security.wss4j.WSS4JOutHandler"> <property name="properties"> <props> <prop key="action">UsernameToken Timestamp Signature</prop> <prop key="user">serveralias</prop> <prop key="passwordCallbackClass">com.sofinco.soffwk.security.PasswordHandler</prop> <prop key="signaturePropFile">/outsecurity_sign.properties</prop> <prop key="signatureKeyIdentifier">IssuerSerial</prop> </props> </property> </bean> </list> </property>