cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r713594 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/configuration/spring/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/transports/http/src/main/java/...
Date Thu, 13 Nov 2008 00:59:57 GMT
Author: dkulp
Date: Wed Nov 12 16:59:56 2008
New Revision: 713594

URL: http://svn.apache.org/viewvc?rev=713594&view=rev
Log:
Merged revisions 713584 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r713584 | dkulp | 2008-11-12 19:49:27 -0500 (Wed, 12 Nov 2008) | 4 lines
  
  Install a real HostnameVerifier that should work (need to make this more configurable)
  Make the Configuration wildcarding actually use regex wildcards.
  Update to HttpConduits to configure based on the address URL as well as endpoint name.
........

Added:
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/CertificateHostnameVerifier.java
      - copied unchanged from r713584, cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/CertificateHostnameVerifier.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec-url.xml
      - copied unchanged from r713584, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/resources/resource-key-spec-url.xml
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ServiceDelegateAccessor.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 12 16:59:56 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708417,708550,708554,709353-709354,709425,710076,710150,710154,71138
 8,711410,711490,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708417,708550,708554,709353-709354,709425,710076,710150,710154,71138
 8,711410,711490,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
Wed Nov 12 16:59:56 2008
@@ -24,6 +24,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -32,6 +33,8 @@
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
 
 /**
@@ -70,7 +73,17 @@
                     ConduitInitiator conduitInitiator =
                         conduitInitiatorMgr.getConduitInitiator(transportID);
                     if (conduitInitiator != null) {
-                        selectedConduit = conduitInitiator.getConduit(ei);
+                        String add = (String)message.get(Message.ENDPOINT_ADDRESS);
+                        if (StringUtils.isEmpty(add)
+                            || add.equals(ei.getAddress())) {
+                            selectedConduit = conduitInitiator.getConduit(ei);
+                        } else {
+                            EndpointReferenceType epr = new EndpointReferenceType();
+                            AttributedURIType ad = new AttributedURIType();
+                            ad.setValue(add);
+                            epr.setAddress(ad);
+                            selectedConduit = conduitInitiator.getConduit(ei, epr);
+                        }
                         MessageObserver observer = 
                             exchange.get(MessageObserver.class);
                         if (observer != null) {

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Wed Nov 12 16:59:56 2008
@@ -20,12 +20,16 @@
 package org.apache.cxf.configuration.spring;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.Configurable;
@@ -47,7 +51,17 @@
     private static final Logger LOG = LogUtils.getL7dLogger(ConfigurerImpl.class);
 
     private Set<ApplicationContext> appContexts;
-    private final Map<String, String> wildCardBeanDefinitions = new HashMap<String,
String>();
+    private final Map<String, List<MatcherHolder>> wildCardBeanDefinitions
+        = new HashMap<String, List<MatcherHolder>>();
+    
+    static class MatcherHolder {
+        Matcher matcher;
+        String wildCardId;
+        public MatcherHolder(String orig, Matcher matcher) {
+            wildCardId = orig;
+            this.matcher = matcher;
+        }
+    }
     
     public ConfigurerImpl() {
         // complete
@@ -67,14 +81,19 @@
                         BeanDefinition bd = bdr.getBeanDefinition(n);
                         String className = bd.getBeanClassName();
                         if (null != className) {
-                            if (!wildCardBeanDefinitions.containsKey(className)) {
-                                wildCardBeanDefinitions.put(className, n);
-                            } else {
-                                LogUtils.log(LOG, Level.WARNING, "ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG",

-                                             new String[]{wildCardBeanDefinitions.get(className),
-                                                          className,
-                                                          n});   
+                            String orig = n;
+                            if (n.charAt(0) == '*') {
+                                //old wildcard
+                                n = "." + n.replaceAll("\\.", "\\."); 
                             }
+                            Matcher matcher = Pattern.compile(n).matcher("");
+                            List<MatcherHolder> m = wildCardBeanDefinitions.get(className);
+                            if (m == null) {
+                                m = new ArrayList<MatcherHolder>();
+                                wildCardBeanDefinitions.put(className, m);
+                            }
+                            MatcherHolder holder = new MatcherHolder(orig, matcher);
+                            m.add(holder);
                         } else {
                             LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG",
n); 
                         }
@@ -138,21 +157,24 @@
     private void configureWithWildCard(String bn, Object beanInstance) {
         if (!wildCardBeanDefinitions.isEmpty() && !isWildcardBeanName(bn)) {
             String className = beanInstance.getClass().getName();
-            if (wildCardBeanDefinitions.containsKey(className)) {
-                String wildCardBeanId = wildCardBeanDefinitions.get(className);
-                if (bn.endsWith(stripStar(wildCardBeanId))) {
-                    configureBean(wildCardBeanId, beanInstance);
-                }       
+            List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
+            if (matchers != null) {
+                for (MatcherHolder m : matchers) {
+                    synchronized (m.matcher) {
+                        m.matcher.reset(bn);
+                        if (m.matcher.matches()) {
+                            configureBean(m.wildCardId, beanInstance);
+                            return;
+                        }
+                    }
+                }
             }
         }
     }
 
     private boolean isWildcardBeanName(String bn) {
-        return bn.charAt(0) == '*';
-    }
-
-    private String stripStar(String wildCardBeanId) {
-        return wildCardBeanId.substring(1);
+        return bn.indexOf('*') != -1 || bn.indexOf('?') != -1
+            || (bn.indexOf('(') != -1 && bn.indexOf(')') != -1);
     }
 
     protected String getBeanName(Object beanInstance) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ServiceDelegateAccessor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ServiceDelegateAccessor.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ServiceDelegateAccessor.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ServiceDelegateAccessor.java
Wed Nov 12 16:59:56 2008
@@ -39,6 +39,7 @@
     private static final Logger LOG = LogUtils.getL7dLogger(ServiceDelegateAccessor.class);
 
     private static final String DELEGATE_FIELD_NAME = "delegate";
+    private static final String DELEGATE_FIELD_NAME2 = "_delegate";
 
     private ServiceDelegateAccessor() {        
     }
@@ -59,11 +60,18 @@
             delegateField.setAccessible(true);
             delegate = (ServiceImpl)delegateField.get(service);
         } catch (Exception e) {
-            WebServiceException wse = new WebServiceException("Failed to access Field named
"
-                                                              + DELEGATE_FIELD_NAME + " of
Service instance "
-                                                              + service, e);
-            LOG.log(Level.SEVERE, e.getMessage(), e);
-            throw wse;
+            try {
+                Field delegateField = Service.class.getDeclaredField(DELEGATE_FIELD_NAME2);
+                delegateField.setAccessible(true);
+                delegate = (ServiceImpl)delegateField.get(service);
+            } catch (Exception e2) {
+                WebServiceException wse = new WebServiceException("Failed to access Field
named "
+                                                                  + DELEGATE_FIELD_NAME 
+                                                                  + " of Service instance
"
+                                                                  + service, e);
+                LOG.log(Level.SEVERE, e.getMessage(), e);
+                throw wse;                
+            }
         }
         return delegate;
     }

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
Wed Nov 12 16:59:56 2008
@@ -158,9 +158,8 @@
         HTTPConduit conduit = target == null
             ? new HTTPConduit(bus, endpointInfo)
             : new HTTPConduit(bus, endpointInfo, target);
-        
         // Spring configure the conduit.  
-        configure(conduit);
+        configure(conduit, conduit.getAddress());
         conduit.finalizeConfig();
         return conduit;
     }
@@ -218,9 +217,15 @@
      * @param bean
      */
     protected void configure(Object bean) {
+        configure(bean, null);
+    }
+    protected void configure(Object bean, String extraName) {
         Configurer configurer = bus.getExtension(Configurer.class);
         if (null != configurer) {
             configurer.configureBean(bean);
+            if (extraName != null) {
+                configurer.configureBean(extraName, bean);
+            }
         }
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Wed Nov 12 16:59:56 2008
@@ -679,8 +679,10 @@
         String pathInfo = (String)message.get(Message.PATH_INFO);
         String queryString = (String)message.get(Message.QUERY_STRING);
         if (result == null) {
+            if (pathInfo == null && queryString == null) {
+                return getURL();
+            }
             result = getURL().toString();
-            
         }
         
         // REVISIT: is this really correct?

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/https/HttpsURLConnectionFactory.java
Wed Nov 12 16:59:56 2008
@@ -30,10 +30,8 @@
 import java.util.logging.Logger;
 
 import javax.imageio.IIOException;
-import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.cxf.common.logging.LogUtils;
@@ -60,8 +58,6 @@
     private static final Logger LOG =
         LogUtils.getL7dLogger(HttpsURLConnectionFactory.class);
     
-    private static final HostnameVerifier DISABLE_HOSTNAME_VERIFIER = new AlwaysTrueHostnameVerifier();
-    
     /*
      *  For development and testing only
      */
@@ -151,25 +147,6 @@
 
         return connection;
     }
-
-    /**
-     * This "accept all" hostname verifier is activated when the 
-     * disableCNCheck TLS client configuration parameter is set to 
-     * true (not recommended for production use).  The default of
-     * false makes sure the Common Name (CN) on the server 
-     * certificate equals that of the https:// URL provided by
-     * the SOAP client.
-     */
-    private static class AlwaysTrueHostnameVerifier implements HostnameVerifier {
-
-        public boolean verify(
-            String      hostname,
-            SSLSession  sslSession
-        ) {
-            return true;
-        }
-
-    }
     
     /**
      * This method assigns the various TLS parameters on the HttpsURLConnection
@@ -209,7 +186,9 @@
                                                         tlsClientParameters.getSecureSocketProtocol());
         }
         if (tlsClientParameters.isDisableCNCheck()) {
-            connection.setHostnameVerifier(DISABLE_HOSTNAME_VERIFIER);
+            connection.setHostnameVerifier(CertificateHostnameVerifier.ALLOW_ALL);
+        } else {
+            connection.setHostnameVerifier(CertificateHostnameVerifier.DEFAULT);
         }
         connection.setSSLSocketFactory(socketFactory);
     }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
Wed Nov 12 16:59:56 2008
@@ -82,7 +82,6 @@
         startServers();
         SOAPService service = new SOAPService();
         assertNotNull("Service is null", service);   
-        
         final Greeter port = service.getHttpsPort();
         assertNotNull("Port is null", port);
         
@@ -118,4 +117,9 @@
         testSuccessfulCall("resources/resource-key-spec.xml",
                            "https://localhost:9004/SoapContext/HttpsPort");
     }
+    @Test
+    public final void testResourceKeySpecEndpointURL() throws Exception {
+        testSuccessfulCall("resources/resource-key-spec-url.xml",
+                           "https://localhost:9005/SoapContext/HttpsPort");
+    }
 }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=713594&r1=713593&r2=713594&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Wed Nov 12 16:59:56 2008
@@ -831,6 +831,15 @@
         String realAddress = "http://localhost:9015/SoapContext/SoapPort";
         SOAPServiceBogusAddressTest service = new SOAPServiceBogusAddressTest();
         Greeter greeter = service.getSoapPort();
+        try {
+            greeter.greetMe("test");
+            fail("Should fail");
+        } catch (WebServiceException f) {
+            // expected
+        }
+
+        
+        
         BindingProvider bp = (BindingProvider)greeter;
         bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                    realAddress);



Mime
View raw message