You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2008/05/26 19:01:22 UTC

svn commit: r660230 - in /cxf/trunk: rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/ rt/transports/http/src/main/resources/META-INF/cxf/ systests/src/test/java/org/apache/cxf/systest/ws/policy/

Author: eglynn
Date: Mon May 26 10:01:16 2008
New Revision: 660230

URL: http://svn.apache.org/viewvc?rev=660230&view=rev
Log:
Added a no-op PolicyInterceptorProvider so as to prevent the policy enforcement logic making it impossible to assert the HTTPClientPolicy upfront before the HTTPConduit becomes invoved (e.g. via a WSPolicyFeature applied to the <jawx:client> bean).

Added:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java   (with props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl   (with props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml   (with props)
Modified:
    cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-extension-http.xml
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java?rev=660230&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java Mon May 26 10:01:16 2008
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.transport.http.policy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.ws.policy.AbstractPolicyInterceptorProvider;
+
+/**
+ * This no-op PolicyInterceptorProvider prevents the policy enforcement
+ * logic making it impossible to assert the HTTPClientPolicy upfront
+ * before the HTTPConduit becomes invoved (e.g. via a WSPolicyFeature
+ * applied to the <jawx:client> bean).
+ */
+public class NoOpPolicyInterceptorProvider
+    extends AbstractPolicyInterceptorProvider {
+
+    private static final Collection<QName> ASSERTION_TYPES;
+    private static final QName HTTP_CONF_NAME =
+        new QName("http://cxf.apache.org/transports/http/configuration", "client");
+    
+    static {
+        Collection<QName> types = new ArrayList<QName>();
+        types.add(HTTP_CONF_NAME);
+        ASSERTION_TYPES = types;
+    }
+    
+    public NoOpPolicyInterceptorProvider() {
+        super(ASSERTION_TYPES);
+    }
+}

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/NoOpPolicyInterceptorProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-extension-http.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-extension-http.xml?rev=660230&r1=660229&r2=660230&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-extension-http.xml (original)
+++ cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-extension-http.xml Mon May 26 10:01:16 2008
@@ -27,6 +27,9 @@
 	  id="org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder"/>
     <bean class="org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder"
 	  id="org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder"/>
+    <bean class="org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider"
+          id="org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider"/>
+ 
     
     
     <bean class="org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory"

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?rev=660230&r1=660229&r2=660230&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Mon May 26 10:01:16 2008
@@ -31,6 +31,7 @@
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.greeter_control.BasicGreeterService;
 import org.apache.cxf.greeter_control.Greeter;
 import org.apache.cxf.greeter_control.PingMeFault;
@@ -38,6 +39,7 @@
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.junit.BeforeClass;
@@ -57,7 +59,13 @@
 public class HTTPClientPolicyTest extends AbstractBusClientServerTestBase {
 
     private static final Logger LOG = LogUtils.getLogger(HTTPClientPolicyTest.class);
-
+    private static final String POLICY_ENGINE_ENABLED_CFG =
+        "org/apache/cxf/systest/ws/policy/http.xml";
+    private static final String POLICY_VIA_FEATURE_CFG =
+        "org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml";
+    private static final QName GREETER_QNAME =
+        new QName("http://cxf.apache.org/greeter_control", "BasicGreeterService");
+    
     public static class Server extends AbstractBusTestServerBase {
    
         protected void run()  {            
@@ -100,7 +108,7 @@
     @Test
     public void testUsingHTTPClientPolicies() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
-        bus = bf.createBus("org/apache/cxf/systest/ws/policy/http.xml");
+        bus = bf.createBus(POLICY_ENGINE_ENABLED_CFG);
         BusFactory.setDefaultBus(bus);
         
         PolicyTestUtils.setPolicyConstants(bus, 
@@ -117,8 +125,7 @@
         
         URL url = HTTPClientPolicyTest.class.getResource("http_client_greeter.wsdl");
         
-        BasicGreeterService gs = new BasicGreeterService(url, 
-            new QName("http://cxf.apache.org/greeter_control", "BasicGreeterService"));
+        BasicGreeterService gs = new BasicGreeterService(url, GREETER_QNAME);
         final Greeter greeter = gs.getGreeterPort();
         LOG.fine("Created greeter client.");
         
@@ -159,4 +166,32 @@
         } 
 
     }
+    
+    @Test
+    public void testHTTPClientPolicyViaFeature() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = bf.createBus(POLICY_VIA_FEATURE_CFG);
+        BusFactory.setDefaultBus(bus);
+        
+        // use a WSDL sanitized of any policy assertions, instead
+        // the HTTPClientPolicy is applied via a feature set on the
+        // <jaxws:client> bean
+        //
+        URL url = HTTPClientPolicyTest.class.getResource("bare_greeter.wsdl");
+        
+        BasicGreeterService gs = new BasicGreeterService(url, GREETER_QNAME);
+        final Greeter greeter = gs.getGreeterPort();
+        LOG.fine("Created greeter client.");
+        
+        greeter.greetMeOneWay("CXF");
+        
+        HTTPConduit c = 
+            (HTTPConduit)(ClientProxy.getClient(greeter).getConduit());
+        assertNotNull("expected HTTPConduit", c);
+        assertNotNull("expected DecoupledEndpoint", 
+                      c.getClient().getDecoupledEndpoint());
+        assertEquals("unexpected DecoupledEndpoint", 
+                     "http://localhost:9990/decoupled_endpoint",
+                     c.getClient().getDecoupledEndpoint());
+    }
 }

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl?rev=660230&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl Mon May 26 10:01:16 2008
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:tns="http://cxf.apache.org/greeter_control"
+    xmlns:x1="http://cxf.apache.org/greeter_control/types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://cxf.apache.org/greeter_control" name="HelloWorld">
+    <wsdl:types>
+        <schema targetNamespace="http://cxf.apache.org/greeter_control/types" 
+            xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+            <element name="sayHi">
+                <complexType/>
+            </element>
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMe">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeOneWay">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="pingMe">
+                <complexType/>
+            </element>
+            <element name="pingMeResponse">
+                <complexType/>
+            </element>
+            <element name="faultDetail">
+                <complexType>
+                    <sequence>
+                        <element name="minor" type="xsd:short"/>
+                        <element name="major" type="xsd:short"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+
+   
+   <wsdl:message name="sayHiRequest">
+        <wsdl:part element="x1:sayHi" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part element="x1:sayHiResponse" name="out"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeRequest">
+        <wsdl:part element="x1:greetMe" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+        <wsdl:part element="x1:greetMeResponse" name="out"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeOneWayRequest">
+        <wsdl:part element="x1:greetMeOneWay" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="pingMeRequest">
+    <wsdl:part name="in" element="x1:pingMe"/>
+    </wsdl:message>
+    <wsdl:message name="pingMeResponse">
+        <wsdl:part name="out" element="x1:pingMeResponse"/>
+    </wsdl:message>        
+    <wsdl:message name="pingMeFault">
+        <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+    </wsdl:message> 
+    
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMe">
+            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMeOneWay">
+            <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+        </wsdl:operation>
+
+        <wsdl:operation name="pingMe">
+            <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+            <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+            <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>            
+        </wsdl:operation> 
+    </wsdl:portType>
+
+    <wsdl:binding name="GreeterSOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        
+        <wsdl:operation name="sayHi">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="sayHiRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="sayHiResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMe">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="greetMeResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        
+        <wsdl:operation name="greetMeOneWay">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeOneWayRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+
+            <wsdl:operation name="pingMe">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="pingMeFault">
+                <soap:fault name="pingMeFault" use="literal"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        
+    </wsdl:binding>
+   
+    <wsdl:service name="BasicGreeterService">
+        <wsdl:port binding="tns:GreeterSOAPBinding" name="GreeterPort">
+            <soap:address location="http://localhost:9020/SoapContext/GreeterPort"/>
+        </wsdl:port>
+    </wsdl:service>
+
+</wsdl:definitions>
+

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/bare_greeter.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml?rev=660230&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml Mon May 26 10:01:16 2008
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:cxf="http://cxf.apache.org/core"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xmlns:p="http://cxf.apache.org/policy"
+       xmlns:jaxws="http://cxf.apache.org/jaxws"
+       xmlns:wsp="http://www.w3.org/ns/ws-policy"
+       xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+http://www.w3.org/ns/ws-policy http://www.w3.org/2007/02/ws-policy.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+   <jaxws:client name="{http://cxf.apache.org/greeter_control}GreeterPort"
+                 createdFromAPI="true">
+        <jaxws:features>
+            <p:policies>
+                <wsp:PolicyReference URI="#DecoupledPolicy"/>
+            </p:policies>
+        </jaxws:features>
+   </jaxws:client>
+    
+    <wsp:Policy wsu:Id="DecoupledPolicy">
+        <wsp:ExactlyOne>
+            <http:client DecoupledEndpoint="http://localhost:9990/decoupled_endpoint"/>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+
+</beans>

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http_client_policy_feature.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml