You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2006/08/07 09:27:22 UTC

svn commit: r429264 - in /webservices/axis2/trunk/java/modules: addressing/src/META-INF/module.xml addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java core/src/org/apache/axis2/addressing/AddressingConstants.java

Author: davidillsley
Date: Mon Aug  7 00:27:21 2006
New Revision: 429264

URL: http://svn.apache.org/viewvc?rev=429264&view=rev
Log:
Core changes for AXIS2-948 - Validates the ReplyTo+FaultTo EPRs against the wsaw:Anonymous value

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml?rev=429264&r1=429263&r2=429264&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml Mon Aug  7 00:27:21 2006
@@ -32,8 +32,6 @@
         <handler name="AddressingSubmissionInHandler" class="org.apache.axis2.handlers.addressing.AddressingSubmissionInHandler">
             <order phase="PreDispatch"/>
         </handler>
-        <handler name="AddressingWSDLValidationHandler" class="org.apache.axis2.handlers.addressing.AddressingWSDLValidationHandler">
-            <order phase="Dispatch" after="InstanceDispatcher" />
-        </handler>
+        <!-- AddressingWSDLValidationHandler not present on the INfaultflow so that we don't get faults bouncing around forever -->
     </INfaultflow>
 </module>

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java?rev=429264&r1=429263&r2=429264&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java Mon Aug  7 00:27:21 2006
@@ -17,9 +17,12 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingHelper;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -27,17 +30,20 @@
 
     private static final Log log = LogFactory.getLog(AddressingWSDLValidationHandler.class);
     
+    /* (non-Javadoc)
+     * @see org.apache.axis2.engine.Handler#invoke(org.apache.axis2.context.MessageContext)
+     */
     public void invoke(MessageContext msgContext) throws AxisFault {
         // Check that if wsaddressing=required that addressing headers were found inbound
         checkUsingAddressing(msgContext);
         // Check that if anonymous flag is in effect that the replyto and faultto are valid
-            // Not yet implemented
+        checkAnonymous(msgContext);
         // If no AxisOperation has been found at the end of the dispatch phase and addressing
         // is in use we should throw and ActionNotSupported Fault
-            // Not yet implemented
+        checkAction(msgContext);
     }
     
-    /*
+    /**
      * Check that if the wsaddressing="required" attribute exists on the service
      * definition or <wsaw:UsingAddressing wsdl:required="true" /> was found in the
      * WSDL that WS-Addressing headers were found on the inbound message
@@ -53,6 +59,50 @@
                 log.trace("checkUsingAddressing: WS_ADDRESSING_VERSION=" + flag);
             if (flag == null) {
                 FinalFaults.triggerMessageAddressingRequiredFault(msgContext,AddressingConstants.WSA_ACTION);
+            }
+        }
+    }
+    
+    /**
+     * Check that if a wsaw:Anonymous value was set on the AxisOperation that the values in the
+     * ReplyTo+FaultTo are valid and fault if not.
+     */
+    private void checkAnonymous(MessageContext msgContext) throws AxisFault {
+        String anonymous = Utils.getParameterValue(msgContext.getAxisOperation().getParameter(AddressingConstants.WSAW_ANONYMOUS_PARAMETER_NAME));
+        if (log.isTraceEnabled())
+            log.trace("checkAnonymous: Anonymous=" + anonymous);
+        if("required".equals(anonymous)){
+            if(AddressingHelper.isReplyRedirected(msgContext)){
+                EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+                msgContext.setReplyTo(anonEPR);
+                msgContext.setFaultTo(anonEPR);
+                FinalFaults.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
+            }
+            if(AddressingHelper.isFaultRedirected(msgContext)){
+                EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+                msgContext.setReplyTo(anonEPR);
+                msgContext.setFaultTo(anonEPR);
+                FinalFaults.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
+            }
+        }else if("prohibited".equals(anonymous)){
+            if(!AddressingHelper.isReplyRedirected(msgContext)){
+                FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
+            }
+            if(!AddressingHelper.isFaultRedirected(msgContext)){
+                FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
+            }
+        }
+    }
+    
+    /**
+     * If addressing was found and the dispatch failed we SHOULD (and hence will) return a
+     * WS-Addressing ActionNotSupported fault. This will make more sense once the AddressingBasedDsipatcher
+     * is moved into the addressing module
+     */
+    private void checkAction(MessageContext msgContext) throws AxisFault{
+        if(msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION)!=null){
+            if((msgContext.getAxisService() == null) || (msgContext.getAxisOperation() == null)){
+                FinalFaults.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=429264&r1=429263&r2=429264&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java Mon Aug  7 00:27:21 2006
@@ -69,6 +69,8 @@
     // So you will not see Addressing Headers in the OUT path.
     public static final String DISABLE_ADDRESSING_FOR_OUT_MESSAGES = "disableAddressingForOutMessages";
 
+    public static final String WSAW_ANONYMOUS_PARAMETER_NAME = "wsawAnonymous";
+    
     public interface Final {
 
         // ====================== Addressing 1.0 Final Version Constants ====================



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org