cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1021707 - in /cxf/trunk: rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
Date Tue, 12 Oct 2010 09:32:38 GMT
Author: ema
Date: Tue Oct 12 09:32:38 2010
New Revision: 1021707

URL: http://svn.apache.org/viewvc?rev=1021707&view=rev
Log:
[CXF-3060]:Made the AddressingFeature(true,true) work when the wsa policy is not enforced

Modified:
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=1021707&r1=1021706&r2=1021707&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Tue
Oct 12 09:32:38 2010
@@ -574,6 +574,38 @@ public class MAPAggregator extends Abstr
                 && !getWSAddressingFeature(message).isAddressingRequired()) {
                 assertAddressing(message);
             }
+            //CXF-3060 :If wsa policy is not enforced, AddressingProperties map is null and
+            // AddressingFeature.isRequired, requestor checks inbound message and throw exception
+            if (null == theMaps
+                && !ContextUtils.isOutbound(message) 
+                && ContextUtils.isRequestor(message)
+                && getWSAddressingFeature(message) != null
+                && getWSAddressingFeature(message).isAddressingRequired()) {
+                boolean missingWsaHeader = false;
+                AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+                if (aim == null || aim.size() == 0) {
+                    missingWsaHeader = true;
+                }
+                if (aim != null && aim.size() > 0) {
+                    missingWsaHeader = true;
+                    QName[] types = new QName[] {
+                        MetadataConstants.ADDRESSING_ASSERTION_QNAME,
+                        MetadataConstants.USING_ADDRESSING_2004_QNAME,
+                        MetadataConstants.USING_ADDRESSING_2005_QNAME,
+                        MetadataConstants.USING_ADDRESSING_2006_QNAME
+                    };
+                    for (QName type : types) {
+                        if (aim.containsKey(type) && aim.get(type).size() > 0)
{
+                            missingWsaHeader = false;
+                        }
+                    }
+                }
+                if (missingWsaHeader) {
+                    String reason = BUNDLE.getString("MISSING_ACTION_MESSAGE");
+                    throw new SoapFault(reason, new QName(Names.WSA_NAMESPACE_NAME,
+                                                          Names.HEADER_REQUIRED_NAME));
+                }
+            }
         }
         return continueProcessing;
     }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java?rev=1021707&r1=1021706&r2=1021707&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_disable/WSADisableTest.java
Tue Oct 12 09:32:38 2010
@@ -117,6 +117,25 @@ public class WSADisableTest extends Abst
             //expected
         }
     }
+    
+    //CXF-3060
+    @Test
+    public void testDisableServerEnableClientRequired() throws Exception {
+        AddNumbersPortType port = getService().getAddNumbersPort(new AddressingFeature(true,
true));
+
+        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                                                        "http://localhost:" + PORT + "/jaxws/add");
+        try {
+            port.addNumbers(1, 2);
+            fail("Expected missing WSA header exception");
+        } catch (Exception e) {
+            String expected = "A required header representing a Message Addressing"
+                              + " Property is not present";
+            assertTrue("Caught unexpected exception : " + e.getMessage(),
+                       e.getMessage().indexOf(expected) > -1);
+        }
+    }
+    
 
     private AddNumbersService getService() {
         URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");



Mime
View raw message