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 2007/04/17 14:47:16 UTC

svn commit: r529583 [1/5] - in /incubator/cxf/trunk: rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/...

Author: eglynn
Date: Tue Apr 17 05:47:13 2007
New Revision: 529583

URL: http://svn.apache.org/viewvc?view=rev&rev=529583
Log:
Applying patch for CXF-438 (Trust Decider callback for Conduit) on behalf of Polar Humenn

Added:
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/CachedOutputStream.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpBasicAuthSupplier.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpURLConnectionFactory.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpURLConnectionFactoryImpl.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpURLConnectionInfo.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/MessageTrustDecider.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionInfo.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/UntrustedURLConnectionIOException.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpBasicAuthSupplierBeanDefinitionParser.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/MessageTrustDeciderBeanDefinitionParser.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionInfo.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLConnectionTest.java   (with props)
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitURLEasyMockTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/GreeterImpl.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PushBack401.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/Server.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/TrustHandler.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Abost.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Bethal.cer   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Bethal.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Bethal.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Gordy.cer   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Gordy.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Gordy.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Http2HttpLoopRedirectFail.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Http2HttpRedirect.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Hurlon.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Morpit.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Mortimer.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Poltim.cer   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Poltim.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Poltim.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Rethwel.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Tarpin.cer   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Tarpin.cxf
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Tarpin.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/client1.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/genkeys.sh   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/greeting.wsdl   (with props)
Removed:
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionFactory.java
Modified:
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/HttpConduitBeanDefinitionParser.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/spring/NamespaceHandler.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLSocketFactoryWrapper.java
    incubator/cxf/trunk/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=529583&r1=529582&r2=529583
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Tue Apr 17 05:47:13 2007
@@ -177,8 +177,7 @@
     }
     
     protected void buildServiceFromWSDL(String url) {
-        LOG.info("Creating Service " + getServiceQName() + " from WSDL.");        
-        
+        LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url);
         WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName());
         setService(factory.create());
 

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java?view=diff&rev=529583&r1=529582&r2=529583
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java Tue Apr 17 05:47:13 2007
@@ -20,9 +20,6 @@
 package org.apache.cxf.transport.http;
 
 import java.io.IOException;
-import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -36,7 +33,6 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.configuration.security.SSLClientPolicy;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -53,33 +49,75 @@
 import org.apache.cxf.wsdl11.WSDLEndpointFactory;
 import org.xmlsoap.schemas.wsdl.http.AddressType;
 
+
+/**
+ * As a ConduitInitiator, this class sets up new HTTPConduits for particular
+ * endpoints.
+ *
+ * TODO: Document DestinationFactory
+ * TODO: Document WSDLEndpointFactory
+ *
+ */
 public abstract class AbstractHTTPTransportFactory 
     extends AbstractTransportFactory 
     implements ConduitInitiator, DestinationFactory, WSDLEndpointFactory {
 
+    /**
+     * This constant holds the prefixes served by this factory.
+     */
     private static final Set<String> URI_PREFIXES = new HashSet<String>();
     static {
         URI_PREFIXES.add("http://");
         URI_PREFIXES.add("https://");
     }
 
+    /**
+     * The CXF Bus which this HTTPTransportFactory
+     * is governed.
+     */
     private Bus bus;
+  
+    /**
+     * This collection contains "activationNamespaces" which is synominous
+     * with "transportId"s. TransportIds are already part of 
+     * AbstractTransportFactory.
+     * TODO: Change these to "transportIds"?
+     */
     private Collection<String> activationNamespaces;
 
+    /**
+     * This method is used by Spring to inject the bus.
+     * @param b The CXF bus.
+     */
     @Resource(name = "bus")
     public void setBus(Bus b) {
         bus = b;
     }
 
+    /**
+     * This method returns the CXF Bus under which this HTTPTransportFactory
+     * is governed.
+     */
     public Bus getBus() {
         return bus;
     }
 
+    /**
+     * This call is used by spring to "inject" the transport ids.
+     * TODO: Change this to "setTransportIds"?
+     * @param ans The transport ids.
+     */
     @Resource(name = "activationNamespaces")
     public void setActivationNamespaces(Collection<String> ans) {
         activationNamespaces = ans;
     }
 
+    /**
+     * This call gets called after this class is instantiated by Spring.
+     * It registers itself as a ConduitInitiator and DestinationFactory under
+     * the many names that are considered "transportIds" (which are currently
+     * named "activationNamespaces").
+     */
     @PostConstruct
     void registerWithBindingManager() {
         if (null == bus) {
@@ -101,21 +139,42 @@
         }
     }
 
+    /**
+     * This call creates a new HTTPConduit for the endpoint. It is equivalent
+     * to calling getConduit without an EndpointReferenceType.
+     */
     public Conduit getConduit(EndpointInfo endpointInfo) throws IOException {
         return getConduit(endpointInfo, null);
     }
 
-    public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target) throws IOException {
+    /**
+     * This call creates a new HTTP Conduit based on the EndpointInfo and
+     * EndpointReferenceType.
+     * TODO: What are the formal constraints on EndpointInfo and 
+     * EndpointReferenceType values?
+     */
+    public Conduit getConduit(
+            EndpointInfo endpointInfo,
+            EndpointReferenceType target
+    ) throws IOException {
         HTTPConduit conduit = target == null
-            ? new HTTPConduit(bus, endpointInfo) : new HTTPConduit(bus, endpointInfo, target);
+            ? new HTTPConduit(bus, endpointInfo)
+            : new HTTPConduit(bus, endpointInfo, target);
+        
+        // Spring configure the conduit.  
         configure(conduit);
-        conduit.retrieveConnectionFactory();
+        conduit.finalizeConfig();
         return conduit;
     }
 
     public abstract Destination getDestination(EndpointInfo endpointInfo) throws IOException;
 
-    public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, Port port) {
+
+    public EndpointInfo createEndpointInfo(
+        ServiceInfo serviceInfo, 
+        BindingInfo b, 
+        Port        port
+    ) {
         List ees = port.getExtensibilityElements();
         for (Iterator itr = ees.iterator(); itr.hasNext();) {
             Object extensor = itr.next();
@@ -123,13 +182,17 @@
             if (extensor instanceof HTTPAddress) {
                 HTTPAddress httpAdd = (HTTPAddress)extensor;
 
-                EndpointInfo info = new EndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
+                EndpointInfo info = 
+                    new EndpointInfo(serviceInfo, 
+                            "http://schemas.xmlsoap.org/wsdl/http/");
                 info.setAddress(httpAdd.getLocationURI());
                 return info;
             } else if (extensor instanceof AddressType) {
                 AddressType httpAdd = (AddressType)extensor;
 
-                EndpointInfo info = new EndpointInfo(serviceInfo, "http://schemas.xmlsoap.org/wsdl/http/");
+                EndpointInfo info = 
+                    new EndpointInfo(serviceInfo, 
+                            "http://schemas.xmlsoap.org/wsdl/http/");
                 info.setAddress(httpAdd.getLocation());
                 return info;
             }
@@ -146,6 +209,12 @@
         return URI_PREFIXES;
     }
 
+    /**
+     * This call uses the Configurer from the bus to configure
+     * a bean.
+     * 
+     * @param bean
+     */
     protected void configure(Object bean) {
         Configurer configurer = bus.getExtension(Configurer.class);
         if (null != configurer) {
@@ -153,18 +222,19 @@
         }
     }
 
-    protected static URLConnectionFactory getConnectionFactory(SSLClientPolicy policy) {
-        return policy == null
-               ? new URLConnectionFactory() {
-                       public URLConnection createConnection(Proxy proxy, URL u)
-                           throws IOException {
-                           return proxy != null 
-                                  ? u.openConnection(proxy)
-                                  : u.openConnection();
-                       }
-                   }
-               : new HttpsURLConnectionFactory(policy);
-    }
-    
+    /**
+     * This static call creates a connection factory based on
+     * the existence of the SSL (TLS) client side configuration. 
+     */
+    static HttpURLConnectionFactory getConnectionFactory(
+        HTTPConduit configuredConduit
+    ) {
+        if (configuredConduit.getSslClient() == null) {
+            return new HttpURLConnectionFactoryImpl();
+        } else {
+            return new HttpsURLConnectionFactory(
+                             configuredConduit.getSslClient());
+        }
+    }    
 
-}
\ No newline at end of file
+}

Added: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/CachedOutputStream.java?view=auto&rev=529583
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/CachedOutputStream.java (added)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/CachedOutputStream.java Tue Apr 17 05:47:13 2007
@@ -0,0 +1,70 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.cxf.io.AbstractCachedOutputStream;
+
+public class CachedOutputStream extends AbstractCachedOutputStream {
+
+    OutputStream flowThroughStream;
+    
+    public CachedOutputStream(OutputStream stream) {
+        super();
+        flowThroughStream = stream;
+    }
+
+    @Override
+    protected void doClose() throws IOException {
+        flowThroughStream.flush();
+        flowThroughStream.close();
+    }
+
+    @Override
+    protected void doFlush() throws IOException {
+        // does nothing
+
+    }
+
+    @Override
+    protected void onWrite() throws IOException {
+        // does nothing
+    }
+
+    @Override
+    public void write(int b) throws IOException {
+        flowThroughStream.write(b);
+        super.write(b);
+    }
+    
+    @Override
+    public void write(byte[] b, int off, int len) throws IOException {
+        flowThroughStream.write(b, off, len);
+        super.write(b, off, len);
+    }
+    
+    @Override
+    public void write(byte[] b) throws IOException {
+        flowThroughStream.write(b);
+        super.write(b);
+    }
+}

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