You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2011/04/25 04:54:47 UTC

svn commit: r1096399 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/ camel-http/src/test/java/org/apache/camel/component/http/ camel-http4/src/main/java/org/apache/camel/component/http4/ camel-http4/src/test/java...

Author: ningjiang
Date: Mon Apr 25 02:54:47 2011
New Revision: 1096399

URL: http://svn.apache.org/viewvc?rev=1096399&view=rev
Log:
CAMEL-3750 applied patch for camel-http,camel-http4 and camel-jetty

Added:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java   (with props)
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java   (with props)
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java   (with props)
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java   (with props)
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java   (with props)
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java   (with props)
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java   (with props)
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java   (with props)
Modified:
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,86 @@
+package org.apache.camel.component.http;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+
+/**
+ * A {@code SecureProtocolSocketFactory} implementation to allow configuration
+ * of Commons HTTP SSL/TLS options based on a {@link #JSSEClientParameters}
+ * instance or a provided {@code SSLSocketFactory} instance.
+ */
+public class SSLContextParametersSecureProtocolSocketFactory implements SecureProtocolSocketFactory {
+    
+    protected SSLSocketFactory factory = null;
+    
+    protected SSLContext context = null;
+    
+    /**
+     * Creates a new instance using the provided factory.
+     *
+     * @param factory the factory to use
+     */
+    public SSLContextParametersSecureProtocolSocketFactory(SSLSocketFactory factory) {
+        this.factory = factory;
+    } 
+    
+    /**
+     * Creates a new instance using a factory created by the provided client configuration
+     * parameters.
+     *
+     * @param params the configuration parameters to use when creating the socket factory
+     */
+    public SSLContextParametersSecureProtocolSocketFactory(SSLContextParameters params) {
+
+        try {
+            this.context = params.createSSLContext();
+            this.factory = this.context.getSocketFactory();
+        } catch (Exception e) {
+            throw new RuntimeCamelException("Error creating the SSLContext.", e);
+        }
+    }    
+
+    @Override
+    public Socket createSocket(String host, int port, 
+                               InetAddress localAddress, int localPort) throws IOException, UnknownHostException {
+        return this.factory.createSocket(host, port, localAddress, localPort);
+    }
+
+    @Override
+    public Socket createSocket(String host, int port, 
+                               InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException,
+        ConnectTimeoutException {
+        
+        if (params == null) {
+            throw new IllegalArgumentException("Parameters may not be null");
+        }
+        int timeout = params.getConnectionTimeout();
+        if (timeout == 0) {
+            return createSocket(host, port, localAddress, localPort);
+        } else {
+            return ControllerThreadSocketFactory.createSocket(
+                    this, host, port, localAddress, localPort, timeout);
+        }
+    }
+
+    @Override
+    public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
+        return this.factory.createSocket(host, port);
+    }
+
+    @Override
+    public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
+        return this.factory.createSocket(socket, host, port, autoClose);
+    }
+}

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.camel.component.http;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+
+public class HttpsSslContextParametersGetTest extends HttpsGetTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {                
+                SSLContextParameters params = new SSLContextParameters();
+                
+                ProtocolSocketFactory factory = 
+                    new SSLContextParametersSecureProtocolSocketFactory(params);
+                
+                Protocol.registerProtocol("https",
+                        new Protocol(
+                                "https",
+                                factory,
+                                443));
+                
+                from("direct:start")
+                    .to("https://mail.google.com/mail/").to("mock:results");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsSslContextParametersGetTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1096399&r1=1096398&r2=1096399&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java Mon Apr 25 02:54:47 2011
@@ -17,7 +17,6 @@
 package org.apache.camel.component.http4;
 
 import java.net.URI;
-import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,6 +26,7 @@ import org.apache.camel.impl.HeaderFilte
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.apache.http.auth.params.AuthParamBean;
 import org.apache.http.client.params.ClientParamBean;
 import org.apache.http.conn.ClientConnectionManager;
@@ -48,7 +48,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Defines the <a href="http://camel.apache.org/http.html">HTTP
+ * Defines the <a href="http://camel.apache.org/http4.html">HTTP4
  * Component</a>
  *
  * @version 
@@ -59,6 +59,7 @@ public class HttpComponent extends Heade
     protected HttpClientConfigurer httpClientConfigurer;
     protected ClientConnectionManager clientConnectionManager;
     protected HttpBinding httpBinding;
+    protected SSLContextParameters sslContextParameters;
     protected X509HostnameVerifier x509HostnameVerifier = new BrowserCompatHostnameVerifier();
 
     // options to the default created http connection manager
@@ -173,6 +174,11 @@ public class HttpComponent extends Heade
             x509HostnameVerifier = this.x509HostnameVerifier;
         }
         
+        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
+        if (sslContextParameters == null) {
+            sslContextParameters = this.sslContextParameters;
+        }
+        
         // create the configurer to use for this endpoint
         HttpClientConfigurer configurer = createHttpClientConfigurer(parameters);
         URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(httpClientParameters));
@@ -192,7 +198,7 @@ public class HttpComponent extends Heade
         // register port on schema registry
         boolean secure = isSecureConnection(uri);
         int port = getPort(httpUri);
-        registerPort(secure, x509HostnameVerifier, port);
+        registerPort(secure, x509HostnameVerifier, port, sslContextParameters);
         
         // create the endpoint
         HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, httpUri, clientParams, clientConnectionManager, configurer);
@@ -222,18 +228,22 @@ public class HttpComponent extends Heade
         }
         return port;
     }
-
-    protected void registerPort(boolean secure, X509HostnameVerifier x509HostnameVerifier, int port) throws NoSuchAlgorithmException {
+    
+    protected void registerPort(boolean secure, X509HostnameVerifier x509HostnameVerifier, int port, SSLContextParameters sslContextParams) throws Exception {
         SchemeRegistry registry = clientConnectionManager.getSchemeRegistry();
         if (secure) {
-            // must register both https and https4
-            SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
+            SSLSocketFactory socketFactory = null;
+            if (sslContextParams == null) {
+                socketFactory = SSLSocketFactory.getSocketFactory();
+            } else {
+                socketFactory = new SSLSocketFactory(sslContextParams.createSSLContext());
+            }
+            
             socketFactory.setHostnameVerifier(x509HostnameVerifier);
+            // must register both https and https4
             registry.register(new Scheme("https", port, socketFactory));
             LOG.info("Registering SSL scheme https on port " + port);
             
-            socketFactory = SSLSocketFactory.getSocketFactory();
-            socketFactory.setHostnameVerifier(x509HostnameVerifier);
             registry.register(new Scheme("https4", port, socketFactory));
             LOG.info("Registering SSL scheme https4 on port " + port);
         } else {
@@ -319,6 +329,14 @@ public class HttpComponent extends Heade
     public void setHttpBinding(HttpBinding httpBinding) {
         this.httpBinding = httpBinding;
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 
     public int getMaxTotalConnections() {
         return maxTotalConnections;

Added: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java (added)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,48 @@
+/**
+ * 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.camel.component.http4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.junit.Test;
+
+public class HttpsSslContextParametersGetTest extends HttpsGetTest {
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("sslContextParameters", new SSLContextParameters());
+
+        return registry;
+    }
+
+    @Test
+    public void httpsGet() throws Exception {
+        localServer.register("/mail/", new BasicValidationHandler("GET", null, null, getExpectedContent()));
+
+        Exchange exchange = template.request("https4://127.0.0.1:" + getPort() + "/mail/?x509HostnameVerifier=x509HostnameVerifier&sslContextParametersRef=sslContextParameters", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+            }
+        });
+
+        assertExchange(exchange);
+    }
+
+}

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsSslContextParametersGetTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java (added)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,39 @@
+/**
+ * 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.camel.component.jetty;
+
+import javax.net.ssl.SSLContext;
+
+import org.eclipse.jetty.client.HttpClient;
+
+public class CamelHttpClient extends HttpClient {
+    
+    private SSLContext context;
+
+    @Override
+    protected SSLContext getSSLContext() {
+        if (context == null) {
+            this.context = super.getSSLContext();
+        }
+        
+        return this.context;
+    }
+
+    public void setSSLContext(SSLContext context) {
+        this.context = context;
+    }
+}

Propchange: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=1096399&r1=1096398&r2=1096399&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java (original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java Mon Apr 25 02:54:47 2011
@@ -39,8 +39,10 @@ import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.eclipse.jetty.client.Address;
 import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.http.ssl.SslContextFactory;
 import org.eclipse.jetty.jmx.MBeanContainer;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
@@ -96,6 +98,8 @@ public class JettyHttpComponent extends 
     protected JettyHttpBinding jettyHttpBinding;
     protected Long continuationTimeout;
     protected boolean useContinuation = true;
+    protected SSLContextParameters sslContextParameters;
+    protected boolean isExplicitHttpClient;
 
     class ConnectorRef {
         Server server;
@@ -142,17 +146,45 @@ public class JettyHttpComponent extends 
         Filter multipartFilter = resolveAndRemoveReferenceParameter(parameters, "multipartFilterRef", Filter.class);
         Long continuationTimeout = getAndRemoveParameter(parameters, "continuationTimeout", Long.class);
         Boolean useContinuation = getAndRemoveParameter(parameters, "useContinuation", Boolean.class);
-
+        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
+        
+        
         // configure http client if we have url configuration for it
         // http client is only used for jetty http producer (hence not very commonly used)
         HttpClient client = null;
-        if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
-            // set additional parameters on http client
-            // only create client when needed
+        if (IntrospectionSupport.hasProperties(parameters, "httpClient.") || sslContextParameters != null) {
+            client = getNewHttpClient();
+            
+            if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
+                if (isExplicitHttpClient) {
+                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
+                             + "but this endpoint provides HttpClient configuration.  Are you sure that "
+                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
+                             + "to avoid altering existing HttpClient instances.");
+                }
+            
+                // set additional parameters on http client
+                IntrospectionSupport.setProperties(client, parameters, "httpClient.");
+                // validate that we could resolve all httpClient. parameters as this component is lenient
+                validateParameters(uri, parameters, "httpClient.");
+            }
+            
+            // Note that the component level instance is already configured in getNewHttpClient.
+            // We replace it here for endpoint level config.
+            if (sslContextParameters != null) {
+                if (isExplicitHttpClient) {
+                    LOG.warn("The user explicitly set an HttpClient instance on the component, "
+                             + "but this endpoint provides SSLContextParameters configuration.  Are you sure that "
+                             + "this is what was intended?  Applying endpoint configuration to a new HttpClient instance "
+                             + "to avoid altering existing HttpClient instances.");
+                }
+                
+                ((CamelHttpClient) client).setSSLContext(sslContextParameters.createSSLContext());
+            }
+        } else {
+            // Either we use the default one created by the component or we are using
+            // one explicitly set by the end user, either way, we just use it as is.
             client = getHttpClient();
-            IntrospectionSupport.setProperties(client, parameters, "httpClient.");
-            // validate that we could resolve all httpClient. parameters as this component is lenient
-            validateParameters(uri, parameters, "httpClient.");
         }
         // keep the configure parameters for the http client
         for (String key : parameters.keySet()) {
@@ -224,6 +256,11 @@ public class JettyHttpComponent extends 
         if (useContinuation != null) {
             endpoint.setUseContinuation(useContinuation);
         }
+        
+        if (sslContextParameters == null) {
+            sslContextParameters = this.sslContextParameters;
+        }
+        endpoint.setSslContextParameters(sslContextParameters);
 
         setProperties(endpoint, parameters);
         return endpoint;
@@ -243,7 +280,7 @@ public class JettyHttpComponent extends 
             if (connectorRef == null) {
                 Connector connector;
                 if ("https".equals(endpoint.getProtocol())) {
-                    connector = getSslSocketConnector(endpoint.getPort());
+                    connector = getSslSocketConnector(endpoint);
                 } else {
                     connector = getSocketConnector(endpoint.getPort());
                 }
@@ -400,44 +437,81 @@ public class JettyHttpComponent extends 
         return sslKeystore;
     }
 
-    protected SslSelectChannelConnector getSslSocketConnector(int port) throws Exception {
+    protected SslSelectChannelConnector getSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
         SslSelectChannelConnector answer = null;
         if (sslSocketConnectors != null) {
-            answer = sslSocketConnectors.get(port);
+            answer = sslSocketConnectors.get(endpoint.getPort());
         }
         if (answer == null) {
-            answer = createSslSocketConnector();
+            answer = createSslSocketConnector(endpoint);
         }
         return answer;
     }
     
-    protected SslSelectChannelConnector createSslSocketConnector() throws Exception {
-        SslSelectChannelConnector answer = new SslSelectChannelConnector();
-        // with default null values, jetty ssl system properties
-        // and console will be read by jetty implementation
-
-        String keystoreProperty = System.getProperty(JETTY_SSL_KEYSTORE);
-        if (keystoreProperty != null) {
-            answer.getSslContextFactory().setKeyStore(keystoreProperty);
-        } else if (sslKeystore != null) {
-            answer.getSslContextFactory().setKeyStore(sslKeystore);
-        }
-
-        String keystorePassword = System.getProperty(JETTY_SSL_KEYPASSWORD);
-        if (keystorePassword != null) {
-            answer.getSslContextFactory().setKeyManagerPassword(keystorePassword);
-        } else if (sslKeyPassword != null) {
-            answer.getSslContextFactory().setKeyManagerPassword(sslKeyPassword);
-        }
-
-        String password = System.getProperty(JETTY_SSL_PASSWORD);
-        if (password != null) {
-            answer.getSslContextFactory().setKeyStorePassword(password);
-        } else if (sslPassword != null) {
-            answer.getSslContextFactory().setKeyStorePassword(sslPassword);
+    protected SslSelectChannelConnector createSslSocketConnector(JettyHttpEndpoint endpoint) throws Exception {
+        SslSelectChannelConnector answer = null;
+        
+        // Note that this was set on the endpoint when it was constructed.  It was
+        // either explicitly set at the component or on the endpoint, but either way,
+        // the value is already set.  We therefore do not need to look at the component
+        // level SSLContextParameters again in this method.
+        SSLContextParameters endpointSslContextParameters = endpoint.getSslContextParameters();
+        
+        if (endpointSslContextParameters != null) {
+            SslContextFactory contextFact = new SslContextFactory() {
+                /**
+                 * We are going to provide the context so none of the configuration options
+                 * matter in the factory.  This method does not account for this scenario so
+                 * we short-circuit it here to just let things go when the context is already
+                 * provided.
+                 */
+                @Override
+                public boolean checkConfig() {
+                    if (getSslContext() == null) {
+                        return super.checkConfig();
+                    } else {
+                        return true;
+                    }
+                }
+                
+            };
+            contextFact.setSslContext(endpointSslContextParameters.createSSLContext());
+            answer = new SslSelectChannelConnector(contextFact);
+        } else {
+            answer = new SslSelectChannelConnector();
+            // with default null values, jetty ssl system properties
+            // and console will be read by jetty implementation
+    
+            String keystoreProperty = System.getProperty(JETTY_SSL_KEYSTORE);
+            if (keystoreProperty != null) {
+                answer.getSslContextFactory().setKeyStore(keystoreProperty);
+            } else if (sslKeystore != null) {
+                answer.getSslContextFactory().setKeyStore(sslKeystore);
+            }
+    
+            String keystorePassword = System.getProperty(JETTY_SSL_KEYPASSWORD);
+            if (keystorePassword != null) {
+                answer.getSslContextFactory().setKeyManagerPassword(keystorePassword);
+            } else if (sslKeyPassword != null) {
+                answer.getSslContextFactory().setKeyManagerPassword(sslKeyPassword);
+            }
+    
+            String password = System.getProperty(JETTY_SSL_PASSWORD);
+            if (password != null) {
+                answer.getSslContextFactory().setKeyStorePassword(password);
+            } else if (sslPassword != null) {
+                answer.getSslContextFactory().setKeyStorePassword(sslPassword);
+            }
         }
-
+        
         if (getSslSocketConnectorProperties() != null) {
+            if (endpointSslContextParameters != null) {
+                LOG.warn("An SSLContextParameters instance is configured "
+                         + "in addition to SslSocketConnectorProperties.  Any SslSocketConnector properties"
+                         + "related to the SSLContext will be ignored in favor of the settings provided through"
+                         + "SSLContextParameters.");
+            }
+            
             // must copy the map otherwise it will be deleted
             Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
             IntrospectionSupport.setProperties(answer, properties);
@@ -490,43 +564,58 @@ public class JettyHttpComponent extends 
         this.socketConnectors = socketConnectors;
     }
 
-    public synchronized HttpClient getHttpClient() {
+    public synchronized HttpClient getHttpClient() throws Exception {
         if (httpClient == null) {
-            httpClient = new HttpClient();
-            httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-
-            if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) {
-                String host = System.getProperty("http.proxyHost");
-                int port = Integer.parseInt(System.getProperty("http.proxyPort"));
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Java System Property http.proxyHost and http.proxyPort detected. Using http proxy host: "
-                            + host + " port: " + port);
-                }
-                httpClient.setProxy(new Address(host, port));
+            httpClient = this.getNewHttpClient();
+        }
+        return httpClient;
+    }
+    
+    public CamelHttpClient getNewHttpClient() throws Exception {
+        CamelHttpClient httpClient = new CamelHttpClient();
+        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+
+        if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) {
+            String host = System.getProperty("http.proxyHost");
+            int port = Integer.parseInt(System.getProperty("http.proxyPort"));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Java System Property http.proxyHost and http.proxyPort detected. Using http proxy host: "
+                        + host + " port: " + port);
             }
+            httpClient.setProxy(new Address(host, port));
+        }
 
-            // use QueueThreadPool as the default bounded is deprecated (see SMXCOMP-157)
-            if (getHttpClientThreadPool() == null) {
-                QueuedThreadPool qtp = new QueuedThreadPool();
-                if (httpClientMinThreads != null) {
-                    qtp.setMinThreads(httpClientMinThreads.intValue());
-                }
-                if (httpClientMaxThreads != null) {
-                    qtp.setMaxThreads(httpClientMaxThreads.intValue());
-                }
-                try {
-                    qtp.start();
-                } catch (Exception e) {
-                    throw new RuntimeCamelException("Error starting JettyHttpClient thread pool: " + qtp, e);
-                }
-                setHttpClientThreadPool(qtp);
+        // use QueueThreadPool as the default bounded is deprecated (see SMXCOMP-157)
+        if (getHttpClientThreadPool() == null) {
+            QueuedThreadPool qtp = new QueuedThreadPool();
+            if (httpClientMinThreads != null) {
+                qtp.setMinThreads(httpClientMinThreads.intValue());
+            }
+            if (httpClientMaxThreads != null) {
+                qtp.setMaxThreads(httpClientMaxThreads.intValue());
             }
-            httpClient.setThreadPool(getHttpClientThreadPool());
+            try {
+                qtp.start();
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Error starting JettyHttpClient thread pool: " + qtp, e);
+            }
+            setHttpClientThreadPool(qtp);
         }
+        httpClient.setThreadPool(getHttpClientThreadPool());
+        
+        if (this.sslContextParameters != null) {
+            ((CamelHttpClient) httpClient).setSSLContext(this.sslContextParameters.createSSLContext());
+        }
+        
         return httpClient;
     }
 
     public void setHttpClient(HttpClient httpClient) {
+        if (httpClient != null) {
+            this.isExplicitHttpClient = true;
+        } else {
+            this.isExplicitHttpClient = false;
+        }
         this.httpClient = httpClient;
     }
 
@@ -665,6 +754,14 @@ public class JettyHttpComponent extends 
     public void setUseContinuation(boolean useContinuation) {
         this.useContinuation = useContinuation;
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 
     // Implementation methods
     // -------------------------------------------------------------------------

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java?rev=1096399&r1=1096398&r2=1096399&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java (original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java Mon Apr 25 02:54:47 2011
@@ -28,6 +28,7 @@ import org.apache.camel.Producer;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.impl.SynchronousDelegateProducer;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.server.Handler;
 
@@ -45,6 +46,7 @@ public class JettyHttpEndpoint extends H
     private Filter multipartFilter;
     private Long continuationTimeout;
     private Boolean useContinuation;
+    private SSLContextParameters sslContextParameters;
 
     public JettyHttpEndpoint(JettyHttpComponent component, String uri, URI httpURL) throws URISyntaxException {
         super(uri, component, httpURL);
@@ -87,7 +89,7 @@ public class JettyHttpEndpoint extends H
         this.handlers = handlers;
     }
 
-    public HttpClient getClient() {
+    public HttpClient getClient() throws Exception {
         if (client == null) {
             return getComponent().getHttpClient();
         }
@@ -151,4 +153,12 @@ public class JettyHttpEndpoint extends H
     public void setUseContinuation(Boolean useContinuation) {
         this.useContinuation = useContinuation;
     }
+
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 }

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=1096399&r1=1096398&r2=1096399&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java (original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java Mon Apr 25 02:54:47 2011
@@ -67,9 +67,10 @@ public class JettyHttpProducer extends D
     }
 
     public boolean process(Exchange exchange, final AsyncCallback callback) {
-        HttpClient client = getEndpoint().getClient();
-
         try {
+            // TODO - Why does this use the endpoint client and not the one we were handed during construction?
+            HttpClient client = getEndpoint().getClient();
+            
             JettyContentExchange httpExchange = createHttpExchange(exchange, callback);
             doSendExchange(client, httpExchange);
         } catch (Exception e) {

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,88 @@
+/**
+ * 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.camel.component.jetty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
+
+public class ExplicitHttpsSslContextParametersRouteTest extends HttpsRouteTest {
+
+    // START SNIPPET: e2
+    private SslSelectChannelConnector createSslSocketConnector(CamelContext context) throws Exception {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+        ksp.setPassword(pwd);
+        
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword(pwd);
+        kmp.setKeyStore(ksp);
+        
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+        
+        // From Camel 2.5.0 Camel-Jetty is using SslSelectChannelConnector instead of SslSocketConnector
+        SslSelectChannelConnector sslSocketConnector = new SslSelectChannelConnector();
+        sslSocketConnector.setSslContext(sslContextParameters.createSSLContext());
+        
+        return sslSocketConnector;
+    }
+    // END SNIPPET: e2
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                // START SNIPPET: e1
+                // create SSL select channel connectors for port 9080 and 9090
+                Map<Integer, SslSelectChannelConnector> connectors = new HashMap<Integer, SslSelectChannelConnector>();
+                connectors.put(port1, createSslSocketConnector(getContext()));
+                connectors.put(port2, createSslSocketConnector(getContext()));
+
+                // create jetty component
+                JettyHttpComponent jetty = new JettyHttpComponent();
+                // add connectors
+                jetty.setSslSocketConnectors(connectors);
+                // add jetty to camel context
+                context.addComponent("jetty", jetty);
+                // END SNIPPET: e1
+
+                from("jetty:https://localhost:" + port1 + "/test").to("mock:a");
+
+                Processor proc = new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody("<b>Hello World</b>");
+                    }
+                };
+                from("jetty:https://localhost:" + port1 + "/hello").process(proc);
+                
+                from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,74 @@
+/**
+ * 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.camel.component.jetty;
+
+import java.net.URISyntaxException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+public class HttpsRouteSslContextParametersInComponentTest extends HttpsRouteTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws URISyntaxException {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                // create jetty component
+                JettyHttpComponent jetty = new JettyHttpComponent();
+                
+                KeyStoreParameters ksp = new KeyStoreParameters();
+                ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+                ksp.setPassword(pwd);
+                
+                KeyManagersParameters kmp = new KeyManagersParameters();
+                kmp.setKeyPassword(pwd);
+                kmp.setKeyStore(ksp);
+                
+                SSLContextParameters sslContextParameters = new SSLContextParameters();
+                sslContextParameters.setKeyManagers(kmp);
+                jetty.setSslContextParameters(sslContextParameters);
+                
+                // NOTE: These are here to check that they are properly ignored.
+                jetty.addSslSocketConnectorProperty("keyPassword", "sadfasdfasdfas");
+                jetty.addSslSocketConnectorProperty("password", "asdfasdfasdfdasfs");
+                jetty.addSslSocketConnectorProperty("keystore", "");
+                jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
+
+                // add jetty to camel context
+                context.addComponent("jetty", jetty);
+
+                from("jetty:https://localhost:" + port1 + "/test").to("mock:a");
+
+                Processor proc = new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody("<b>Hello World</b>");
+                    }
+                };
+                from("jetty:https://localhost:" + port1 + "/hello").process(proc);
+
+                from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,82 @@
+/**
+ * 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.camel.component.jetty;
+
+import java.net.URISyntaxException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+public class HttpsRouteSslContextParametersInUriTest extends HttpsRouteTest {
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+        ksp.setPassword(pwd);
+
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword(pwd);
+        kmp.setKeyStore(ksp);
+
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("sslContextParameters", sslContextParameters);
+
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws URISyntaxException {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                // create jetty component
+                JettyHttpComponent jetty = new JettyHttpComponent();
+                
+                // NOTE: These are here to check that they are properly ignored.
+                jetty.addSslSocketConnectorProperty("keyPassword", "sadfasdfasdfas");
+                jetty.addSslSocketConnectorProperty("password", "asdfasdfasdfdasfs");
+                jetty.addSslSocketConnectorProperty("keystore", "");
+                jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
+
+                // add jetty to camel context
+                context.addComponent("jetty", jetty);
+
+                from("jetty:https://localhost:" + port1 + "/test?sslContextParametersRef=sslContextParameters").to("mock:a");
+
+                Processor proc = new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody("<b>Hello World</b>");
+                    }
+                };
+                from("jetty:https://localhost:" + port1 + "/hello?sslContextParametersRef=sslContextParameters").process(proc);
+
+                from("jetty:https://localhost:" + port2 + "/test?sslContextParametersRef=sslContextParameters").to("mock:b");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java?rev=1096399&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java Mon Apr 25 02:54:47 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.camel.component.jetty.jettyproducer;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jetty.JettyHttpComponent;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
+
+public class JettyHttpsProducerSslContextInUriTest extends JettyProducerHttpsRouteTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+        ksp.setPassword(pwd);
+
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword(pwd);
+        kmp.setKeyStore(ksp);
+
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setKeyStore(ksp);
+
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+        sslContextParameters.setTrustManagers(tmp);
+
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("sslContextParameters", sslContextParameters);
+
+        return registry;
+    }
+    
+    protected void invokeHttpEndpoint() throws IOException {
+        template.sendBodyAndHeader(getHttpProducerScheme() + "localhost:" + port1 + "/test?sslContextParametersRef=sslContextParameters", expectedBody, "Content-Type",
+                                   "application/xml");
+        template.sendBodyAndHeader(getHttpProducerScheme() + "localhost:" + port2 + "/test?sslContextParametersRef=sslContextParameters", expectedBody, "Content-Type",
+                                   "application/xml");
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        
+        return new RouteBuilder() {
+            public void configure() throws URISyntaxException {
+                port1 = getPort();
+                port2 = getNextPort();
+                
+                JettyHttpComponent componentJetty = (JettyHttpComponent) context.getComponent("jetty");
+                componentJetty.setSslPassword(pwd);
+                componentJetty.setSslKeyPassword(pwd);
+                URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
+                componentJetty.setKeystore(keyStoreUrl.toURI().getPath());
+                
+                from("jetty:https://localhost:" + port1 + "/test?sslContextParametersRef=sslContextParameters").to("mock:a");
+
+                Processor proc = new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getOut().setBody("<b>Hello World</b>");
+                    }
+                };
+                from("jetty:https://localhost:" + port1 + "/hello?sslContextParametersRef=sslContextParameters").process(proc);
+                
+                from("jetty:https://localhost:" + port2 + "/test?sslContextParametersRef=sslContextParameters").to("mock:b");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpsProducerSslContextInUriTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date