You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/05/02 19:54:28 UTC

svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java

Author: ruchithf
Date: Tue May  2 10:54:26 2006
New Revision: 398988

URL: http://svn.apache.org/viewcvs?rev=398988&view=rev
Log:
Added a workaround to avoide an OM bug
Added support to set the addressing information if available on a fault within the receiver handler


Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java?rev=398988&r1=398987&r2=398988&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java Tue May  2 10:54:26 2006
@@ -16,12 +16,15 @@
 
 package org.apache.axis2.security;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.security.handler.WSDoAllHandler;
@@ -43,6 +46,7 @@
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.CallbackHandler;
+import javax.xml.namespace.QName;
 
 import java.security.cert.X509Certificate;
 import java.util.Iterator;
@@ -328,8 +332,10 @@
             }
             
         } catch (WSSecurityException wssEx) {
+            setAddressingInformationOnFault(msgContext);
             throw new AxisFault(wssEx);
         } catch (AxisFault axisFault) {
+            setAddressingInformationOnFault(msgContext);
             throw axisFault;
         } finally {
             if(reqData != null) {
@@ -345,6 +351,21 @@
             DocumentBuilderFactoryImpl.setDOOMRequired(false);
         }
         
+    }
+
+    private void setAddressingInformationOnFault(MessageContext msgContext) {
+        SOAPEnvelope env = msgContext.getEnvelope();
+        SOAPHeader header = env.getHeader();
+        
+        if(header != null) {
+            OMElement msgIdElem = header.getFirstChildWithName(new QName(AddressingConstants.Final.WSA_NAMESPACE,AddressingConstants.WSA_MESSAGE_ID));
+            if(msgIdElem != null) {
+                msgIdElem = header.getFirstChildWithName(new QName(AddressingConstants.Submission.WSA_NAMESPACE,AddressingConstants.WSA_MESSAGE_ID));
+            }
+            if(msgIdElem != null && msgIdElem.getText() != null) {
+                msgContext.getOptions().setMessageId(msgIdElem.getText());
+            }
+        }
     }
     
     

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java?rev=398988&r1=398987&r2=398988&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java Tue May  2 10:54:26 2006
@@ -20,10 +20,10 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
 import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -39,7 +39,6 @@
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 
 import java.io.ByteArrayInputStream;
@@ -89,6 +88,13 @@
             
             if(!disableDoom) {
     			env.build();
+                
+                //Workaround to prevent a bug in AXIOM where 
+                //there can be an incomplete OMElement as the first child body 
+                OMElement firstElement = env.getBody().getFirstElement();
+                if(firstElement != null) {
+                    firstElement.build();
+                }
     			
     			//Check the namespace and find SOAP version and factory
     			String nsURI = null;



Re: svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java

Posted by Ruchith Fernando <ru...@gmail.com>.
Yes !! This is just a temp workaround to prevent hitting the bug.
Lets fix it post 1.0 please

Thanks,
Ruchith

On 5/3/06, Sanjiva Weerawarana <sa...@opensource.lk> wrote:
> On Tue, 2006-05-02 at 17:54 +0000, ruchithf@apache.org wrote:
> > +
> > +                //Workaround to prevent a bug in AXIOM where
> > +                //there can be an incomplete OMElement as the first child body
> > +                OMElement firstElement = env.getBody().getFirstElement();
> > +                if(firstElement != null) {
> > +                    firstElement.build();
> > +                }
>
> Um if this is a bug in Axiom shouldn't we fix it there? I guess its post
> 1.0 now .. maybe that's what u mean.
>
> Sanjiva.
>
>

Re: svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java

Posted by Ruchith Fernando <ru...@gmail.com>.
Yes !! This is just a temp workaround to prevent hitting the bug.
Lets fix it post 1.0 please

Thanks,
Ruchith

On 5/3/06, Sanjiva Weerawarana <sa...@opensource.lk> wrote:
> On Tue, 2006-05-02 at 17:54 +0000, ruchithf@apache.org wrote:
> > +
> > +                //Workaround to prevent a bug in AXIOM where
> > +                //there can be an incomplete OMElement as the first child body
> > +                OMElement firstElement = env.getBody().getFirstElement();
> > +                if(firstElement != null) {
> > +                    firstElement.build();
> > +                }
>
> Um if this is a bug in Axiom shouldn't we fix it there? I guess its post
> 1.0 now .. maybe that's what u mean.
>
> Sanjiva.
>
>

Re: svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Tue, 2006-05-02 at 17:54 +0000, ruchithf@apache.org wrote:
> +                
> +                //Workaround to prevent a bug in AXIOM where 
> +                //there can be an incomplete OMElement as the first child body 
> +                OMElement firstElement = env.getBody().getFirstElement();
> +                if(firstElement != null) {
> +                    firstElement.build();
> +                }

Um if this is a bug in Axiom shouldn't we fix it there? I guess its post
1.0 now .. maybe that's what u mean.

Sanjiva.


Re: svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Tue, 2006-05-02 at 17:54 +0000, ruchithf@apache.org wrote:
> +                
> +                //Workaround to prevent a bug in AXIOM where 
> +                //there can be an incomplete OMElement as the first child body 
> +                OMElement firstElement = env.getBody().getFirstElement();
> +                if(firstElement != null) {
> +                    firstElement.build();
> +                }

Um if this is a bug in Axiom shouldn't we fix it there? I guess its post
1.0 now .. maybe that's what u mean.

Sanjiva.