You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/29 06:34:20 UTC

camel git commit: CAMEL-9046: Implement Camel SSL-Context for cxfrs

Repository: camel
Updated Branches:
  refs/heads/master 7c3beb5dc -> 3cc803a1a


CAMEL-9046: Implement Camel SSL-Context for cxfrs


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3cc803a1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3cc803a1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3cc803a1

Branch: refs/heads/master
Commit: 3cc803a1a9d26caacec07059c3ecd0e7e7a0e626
Parents: 7c3beb5
Author: Arno Noordover <an...@users.noreply.github.com>
Authored: Sat May 28 22:33:51 2016 +0200
Committer: Arno Noordover <an...@users.noreply.github.com>
Committed: Sat May 28 22:33:51 2016 +0200

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfEndpoint.java |  11 +-
 .../HostnameVerifierCxfEndpointConfigurer.java  |  19 +---
 .../component/cxf/SslCxfEndpointConfigurer.java |  33 +-----
 ...tractHostnameVerifierEndpointConfigurer.java |  36 +++++++
 .../common/AbstractSslEndpointConfigurer.java   |  51 +++++++++
 .../AbstractTLSClientParameterConfigurer.java   |  30 ++++++
 .../jaxrs/ChainedCxfRsEndpointConfigurer.java   |  77 ++++++++++++++
 .../component/cxf/jaxrs/CxfRsEndpoint.java      |  59 +++++++++++
 .../cxf/jaxrs/CxfRsEndpointConfigurer.java      |  48 +++++++++
 .../component/cxf/jaxrs/CxfRsProducer.java      |   1 +
 ...HostnameVerifierCxfRsEndpointConfigurer.java |  54 ++++++++++
 .../cxf/jaxrs/SslCxfRsEndpointConfigurer.java   |  56 ++++++++++
 .../camel/component/cxf/CXFTestSupport.java     |   4 +
 .../cxf/jaxrs/CxfRsSslProducerTest.java         | 105 +++++++++++++++++++
 .../cxf/jaxrs/CxfRsSpringSslProducer.xml        |  96 +++++++++++++++++
 15 files changed, 629 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index 88f32ae..853a6e2 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -378,9 +378,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
 
         sfb.setBus(getBus());
         sfb.setStart(false);
-        if (getCxfEndpointConfigurer() != null) {
-            getCxfEndpointConfigurer().configure(sfb);
-        }
+        getNullSafeCxfEndpointConfigurer().configure(sfb);
     }
 
     /**
@@ -575,9 +573,8 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
         }
 
         factoryBean.setBus(getBus());
-        if (getCxfEndpointConfigurer() != null) {
-            getCxfEndpointConfigurer().configure(factoryBean);
-        }
+
+        getNullSafeCxfEndpointConfigurer().configure(factoryBean);
     }
 
     // Package private methods
@@ -1234,7 +1231,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
                 if (nd instanceof Document) {
                     nd = ((Document)nd).getDocumentElement();
                 }
-                return ((Element)nd).getLocalName();
+                return nd.getLocalName();
             } else if (source instanceof StaxSource) {
                 StaxSource s = (StaxSource)source;
                 r = s.getXMLStreamReader();

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
index 913ce59..bf13c72 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
@@ -18,18 +18,16 @@ package org.apache.camel.component.cxf;
 
 import javax.net.ssl.HostnameVerifier;
 
-import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.camel.component.cxf.common.AbstractHostnameVerifierEndpointConfigurer;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
 import org.apache.cxf.transport.http.HTTPConduit;
 
-public final class HostnameVerifierCxfEndpointConfigurer implements CxfEndpointConfigurer {
-
-    private final HostnameVerifier hostnameVerifier;
+public final class HostnameVerifierCxfEndpointConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfEndpointConfigurer {
 
     private HostnameVerifierCxfEndpointConfigurer(HostnameVerifier hostnameVerifier) {
-        this.hostnameVerifier = hostnameVerifier;
+        super(hostnameVerifier);
     }
 
     public static CxfEndpointConfigurer create(HostnameVerifier hostnameVerifier) {
@@ -46,16 +44,7 @@ public final class HostnameVerifierCxfEndpointConfigurer implements CxfEndpointC
     @Override
     public void configureClient(Client client) {
         HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
-        TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
-        tlsClientParameters.setHostnameVerifier(hostnameVerifier);
-        httpConduit.setTlsClientParameters(tlsClientParameters);
-    }
-
-    private TLSClientParameters tryToGetTLSClientParametersFromConduit(HTTPConduit httpConduit) {
-        if (httpConduit.getTlsClientParameters() != null) {
-            return httpConduit.getTlsClientParameters();
-        }
-        return new TLSClientParameters();
+        setupHttpConduit(httpConduit);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
index 2c19dcf..d16e139 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
@@ -16,26 +16,19 @@
  */
 package org.apache.camel.component.cxf;
 
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import javax.net.ssl.SSLSocketFactory;
-
 import org.apache.camel.CamelContext;
+import org.apache.camel.component.cxf.common.AbstractSslEndpointConfigurer;
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
 import org.apache.cxf.transport.http.HTTPConduit;
 
-public final class SslCxfEndpointConfigurer implements CxfEndpointConfigurer {
-    private final SSLContextParameters sslContextParameters;
-    private final CamelContext camelContext;
+public final class SslCxfEndpointConfigurer extends AbstractSslEndpointConfigurer implements CxfEndpointConfigurer {
 
     private SslCxfEndpointConfigurer(SSLContextParameters sslContextParameters,
                                      CamelContext camelContext) {
-        this.camelContext = camelContext;
-        this.sslContextParameters = sslContextParameters;
+        super(sslContextParameters, camelContext);
     }
 
     public static CxfEndpointConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) {
@@ -53,25 +46,7 @@ public final class SslCxfEndpointConfigurer implements CxfEndpointConfigurer {
     @Override
     public void configureClient(Client client) {
         HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
-        TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
-        tlsClientParameters.setSSLSocketFactory(tryToGetSSLSocketFactory());
-        httpConduit.setTlsClientParameters(tlsClientParameters);
-    }
-
-    private TLSClientParameters tryToGetTLSClientParametersFromConduit(HTTPConduit httpConduit) {
-        if (httpConduit.getTlsClientParameters() != null) {
-            return httpConduit.getTlsClientParameters();
-        }
-        return new TLSClientParameters();
-    }
-
-    private SSLSocketFactory tryToGetSSLSocketFactory() {
-        try {
-            return sslContextParameters.createSSLContext(camelContext)
-                    .getSocketFactory();
-        } catch (GeneralSecurityException | IOException e) {
-            throw new RuntimeException("Setting SSL failed", e);
-        }
+        setupHttpConduit(httpConduit);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractHostnameVerifierEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractHostnameVerifierEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractHostnameVerifierEndpointConfigurer.java
new file mode 100644
index 0000000..bbb9b30
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractHostnameVerifierEndpointConfigurer.java
@@ -0,0 +1,36 @@
+/**
+ * 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.cxf.common;
+
+import javax.net.ssl.HostnameVerifier;
+
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public class AbstractHostnameVerifierEndpointConfigurer extends AbstractTLSClientParameterConfigurer {
+    protected final HostnameVerifier hostnameVerifier;
+
+    public AbstractHostnameVerifierEndpointConfigurer(HostnameVerifier hostnameVerifier) {
+        this.hostnameVerifier = hostnameVerifier;
+    }
+
+    protected void setupHttpConduit(HTTPConduit httpConduit) {
+        TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
+        tlsClientParameters.setHostnameVerifier(hostnameVerifier);
+        httpConduit.setTlsClientParameters(tlsClientParameters);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractSslEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractSslEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractSslEndpointConfigurer.java
new file mode 100644
index 0000000..b4dfb91
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractSslEndpointConfigurer.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.common;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public class AbstractSslEndpointConfigurer extends AbstractTLSClientParameterConfigurer {
+    protected final SSLContextParameters sslContextParameters;
+    protected final CamelContext camelContext;
+
+    public AbstractSslEndpointConfigurer(SSLContextParameters sslContextParameters, CamelContext camelContext) {
+        this.sslContextParameters = sslContextParameters;
+        this.camelContext = camelContext;
+    }
+
+    protected void setupHttpConduit(HTTPConduit httpConduit) {
+        TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
+        tlsClientParameters.setSSLSocketFactory(tryToGetSSLSocketFactory());
+        httpConduit.setTlsClientParameters(tlsClientParameters);
+    }
+
+    private SSLSocketFactory tryToGetSSLSocketFactory() {
+        try {
+            return sslContextParameters.createSSLContext(camelContext)
+                    .getSocketFactory();
+        } catch (GeneralSecurityException | IOException e) {
+            throw new RuntimeException("Setting SSL failed", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractTLSClientParameterConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractTLSClientParameterConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractTLSClientParameterConfigurer.java
new file mode 100644
index 0000000..6957961
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/common/AbstractTLSClientParameterConfigurer.java
@@ -0,0 +1,30 @@
+/**
+ * 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.cxf.common;
+
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public class AbstractTLSClientParameterConfigurer {
+
+    protected TLSClientParameters tryToGetTLSClientParametersFromConduit(HTTPConduit httpConduit) {
+        if (httpConduit.getTlsClientParameters() != null) {
+            return httpConduit.getTlsClientParameters();
+        }
+        return new TLSClientParameters();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java
new file mode 100644
index 0000000..a9aeaf5
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java
@@ -0,0 +1,77 @@
+/**
+ * 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.cxf.jaxrs;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+
+public final class ChainedCxfRsEndpointConfigurer implements CxfRsEndpointConfigurer {
+    private CxfRsEndpointConfigurer parent;
+    private CxfRsEndpointConfigurer child;
+
+    private ChainedCxfRsEndpointConfigurer() {
+    }
+
+    public static ChainedCxfRsEndpointConfigurer create(CxfRsEndpointConfigurer parent,
+                                                        CxfRsEndpointConfigurer child) {
+        ChainedCxfRsEndpointConfigurer result = new ChainedCxfRsEndpointConfigurer();
+        result.parent = parent;
+        result.child = child;
+        return result;
+    }
+
+    public ChainedCxfRsEndpointConfigurer addChild(CxfRsEndpointConfigurer cxfEndpointConfigurer) {
+        ChainedCxfRsEndpointConfigurer result = new ChainedCxfRsEndpointConfigurer();
+        result.parent = this;
+        result.child = cxfEndpointConfigurer;
+        return result;
+    }
+
+    @Override
+    public void configure(AbstractJAXRSFactoryBean factoryBean) {
+        parent.configure(factoryBean);
+        child.configure(factoryBean);
+    }
+
+    @Override
+    public void configureClient(Client client) {
+        parent.configureClient(client);
+        child.configureClient(client);
+    }
+
+    @Override
+    public void configureServer(Server server) {
+        parent.configureServer(server);
+        child.configureServer(server);
+    }
+
+    public static class NullCxfRsEndpointConfigurer implements CxfRsEndpointConfigurer {
+
+        @Override
+        public void configure(AbstractJAXRSFactoryBean factoryBean) {
+        }
+
+        @Override
+        public void configureClient(Client client) {
+        }
+
+        @Override
+        public void configureServer(Server server) {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index 96885ba..cb5dff4 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
@@ -39,6 +40,7 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
@@ -102,6 +104,10 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
     private boolean throwExceptionOnFailure = true;
     @UriParam(label = "producer,advanced", defaultValue = "10")
     private int maxClientCacheSize = 10;
+    @UriParam(label = "producer")
+    private SSLContextParameters sslContextParameters;
+    @UriParam(label = "producer")
+    private HostnameVerifier hostnameVerifier;
     @UriParam
     private boolean loggingFeatureEnabled;
     @UriParam
@@ -116,6 +122,8 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
     private boolean performInvocation;
     @UriParam(label = "advanced")
     private boolean propagateContexts;
+    @UriParam(label = "advanced")
+    private CxfRsEndpointConfigurer cxfRsEndpointConfigurer;
 
     public CxfRsEndpoint() {
     }
@@ -204,6 +212,12 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
         return skipFaultLogging;
     }
 
+    public CxfRsEndpointConfigurer getChainedCxfRsEndpointConfigurer() {
+        return ChainedCxfRsEndpointConfigurer
+                .create(getNullSafeCxfRsEndpointConfigurer(),
+                        SslCxfRsEndpointConfigurer.create(sslContextParameters, getCamelContext()))
+                .addChild(HostnameVerifierCxfRsEndpointConfigurer.create(hostnameVerifier));
+    }
     /**
      * This option controls whether the PhaseInterceptorChain skips logging the Fault that it catches.
      */
@@ -237,6 +251,14 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
         }
         setupCommonFactoryProperties(sfb);
         sfb.setStart(false);
+        getNullSafeCxfRsEndpointConfigurer().configure(sfb);
+    }
+
+    private CxfRsEndpointConfigurer getNullSafeCxfRsEndpointConfigurer() {
+        if (cxfRsEndpointConfigurer == null) {
+            return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer();
+        }
+        return cxfRsEndpointConfigurer;
     }
 
     private void processResourceModel(JAXRSServerFactoryBean sfb) {
@@ -283,6 +305,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
         }
         setupCommonFactoryProperties(cfb);
         cfb.setThreadSafe(true);
+        getNullSafeCxfRsEndpointConfigurer().configure(cfb);
     }
 
     protected void setupCommonFactoryProperties(AbstractJAXRSFactoryBean factory) {
@@ -724,4 +747,40 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
     private static class InterceptorHolder extends AbstractBasicInterceptorProvider {
     }
 
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    /**
+     * The Camel SSL setting reference. Use the # notation to reference the SSL Context.
+     */
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+
+    public HostnameVerifier getHostnameVerifier() {
+        return hostnameVerifier;
+    }
+
+    /**
+     * The hostname verifier to be used. Use the # notation to reference a HostnameVerifier
+     * from the registry.
+     */
+    public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+        this.hostnameVerifier = hostnameVerifier;
+    }
+
+    public CxfRsEndpointConfigurer getCxfRsEndpointConfigurer() {
+        return cxfRsEndpointConfigurer;
+    }
+
+    /**
+     * This option could apply the implementation of org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer which supports to configure the CXF endpoint
+     * in  programmatic way. User can configure the CXF server and client by implementing configure{Server/Client} method of CxfEndpointConfigurer.
+     */
+    public void setCxfRsEndpointConfigurer(CxfRsEndpointConfigurer configurer) {
+        this.cxfRsEndpointConfigurer = configurer;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java
new file mode 100644
index 0000000..bfa9929
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java
@@ -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.cxf.jaxrs;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+
+/**
+ * A pluggable strategy for configuring the cxfRsEndpoint by using java code
+ */
+public interface CxfRsEndpointConfigurer {
+    
+    /**
+     * Configure the CXF-RS Server/Client factory bean
+     * @param factoryBean
+     */
+    void configure(AbstractJAXRSFactoryBean factoryBean);
+    
+    /**
+     * Configure the CXF Client such as setting some parameters on the client conduit 
+     *
+     * @param client the CXF client
+     */
+    void configureClient(Client client);
+
+    /**
+     * Configure the CXF Server such as setting some parameters on the server destination 
+     *
+     * @param server the CXF server
+     */
+    void configureServer(Server server);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index 33045dd..afe20b4b 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -161,6 +161,7 @@ public class CxfRsProducer extends DefaultProducer {
             cfb.setBus(bus);
         }
         WebClient client = cfb.createWebClient();
+        ((CxfRsEndpoint) getEndpoint()).getChainedCxfRsEndpointConfigurer().configureClient(client);
         String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
         Class<?> responseClass = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Class.class);
         Type genericType = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_GENERIC_TYPE, Type.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java
new file mode 100644
index 0000000..e702b6a
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java
@@ -0,0 +1,54 @@
+/**
+ * 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.cxf.jaxrs;
+
+import javax.net.ssl.HostnameVerifier;
+
+import org.apache.camel.component.cxf.common.AbstractHostnameVerifierEndpointConfigurer;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public final class HostnameVerifierCxfRsEndpointConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfRsEndpointConfigurer {
+
+    private HostnameVerifierCxfRsEndpointConfigurer(HostnameVerifier hostnameVerifier) {
+        super(hostnameVerifier);
+    }
+
+    public static CxfRsEndpointConfigurer create(HostnameVerifier hostnameVerifier) {
+        if (hostnameVerifier == null) {
+            return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer();
+        } else {
+            return new HostnameVerifierCxfRsEndpointConfigurer(hostnameVerifier);
+        }
+    }
+    @Override
+    public void configure(AbstractJAXRSFactoryBean factoryBean) {
+    }
+
+    @Override
+    public void configureClient(Client client) {
+        HTTPConduit httpConduit = (HTTPConduit) WebClient.getConfig(client).getConduit();
+        setupHttpConduit(httpConduit);
+    }
+
+    @Override
+    public void configureServer(Server server) {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java
new file mode 100644
index 0000000..5ef5cad
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java
@@ -0,0 +1,56 @@
+/**
+ * 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.cxf.jaxrs;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.cxf.common.AbstractSslEndpointConfigurer;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public final class SslCxfRsEndpointConfigurer extends AbstractSslEndpointConfigurer implements CxfRsEndpointConfigurer {
+
+    private SslCxfRsEndpointConfigurer(SSLContextParameters sslContextParameters,
+                                       CamelContext camelContext) {
+        super(sslContextParameters, camelContext);
+    }
+
+    public static CxfRsEndpointConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) {
+        if (sslContextParameters == null) {
+            return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer();
+        } else {
+            return new SslCxfRsEndpointConfigurer(sslContextParameters, camelContext);
+        }
+    }
+
+    @Override
+    public void configure(AbstractJAXRSFactoryBean factoryBean) {
+    }
+
+    @Override
+    public void configureClient(Client client) {
+        HTTPConduit httpConduit = (HTTPConduit) WebClient.getConfig(client).getConduit();
+        setupHttpConduit(httpConduit);
+    }
+
+    @Override
+    public void configureServer(Server server) {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
index a40c2d8..a310066 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
@@ -79,4 +79,8 @@ public final class CXFTestSupport {
     public static int getPort6() {
         return PORT6;
     }
+
+    public static int getSslPort() {
+        return SSL_PORT;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSslProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSslProducerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSslProducerTest.java
new file mode 100644
index 0000000..d79df80
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSslProducerTest.java
@@ -0,0 +1,105 @@
+/**
+ * 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.cxf.jaxrs;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.hamcrest.core.Is.is;
+
+public class CxfRsSslProducerTest extends CamelSpringTestSupport {
+    private static int port1 = CXFTestSupport.getSslPort();
+
+    @Override
+    public boolean isCreateCamelContextPerClass() {
+        return true;
+    }
+
+    public int getPort1() {
+        return port1;
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {     
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsSpringSslProducer.xml");
+    }
+    
+    protected void setupDestinationURL(Message inMessage) {
+        // do nothing here
+    }
+    
+    @Test
+    public void testCorrectTrustStore() {
+        Exchange exchange = template.send("direct://trust", new MyProcessor());
+     
+        // get the response message 
+        Customer response = (Customer) exchange.getOut().getBody();
+        
+        assertNotNull("The response should not be null ", response);
+        assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
+        assertEquals("Get a wrong customer name", response.getName(), "John");
+        assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
+        assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
+    }
+
+    @Test
+    public void testNoTrustStore() {
+        Exchange exchange = template.send("direct://noTrust", new MyProcessor());
+        assertThat(exchange.isFailed(), is(true));
+        Exception e = exchange.getException();
+        assertThat(e.getCause().getClass().getCanonicalName(), is("javax.net.ssl.SSLHandshakeException"));
+    }
+
+    @Test
+    public void testWrongTrustStore() {
+        Exchange exchange = template.send("direct://wrongTrust", new MyProcessor());
+        assertThat(exchange.isFailed(), is(true));
+        Exception e = exchange.getException();
+        assertThat(e.getCause().getClass().getCanonicalName(), is("javax.net.ssl.SSLHandshakeException"));
+    }
+
+    private class MyProcessor implements Processor {
+
+        @Override
+        public void process(Exchange exchange) throws Exception {
+            exchange.setPattern(ExchangePattern.InOut);
+            Message inMessage = exchange.getIn();
+            setupDestinationURL(inMessage);
+            // using the http central client API
+            inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
+            // set the Http method
+            inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
+            // set the relative path
+            inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123");
+            // Specify the response class , cxfrs will use InputStream as the response object type
+            inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
+            // set a customer header
+            inMessage.setHeader("key", "value");
+            // since we use the Get method, so we don't need to set the message body
+            inMessage.setBody(null);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3cc803a1/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringSslProducer.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringSslProducer.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringSslProducer.xml
new file mode 100644
index 0000000..06f17d8
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringSslProducer.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://camel.apache.org/schema/cxf"
+       xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:sec="http://cxf.apache.org/configuration/security"
+       xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+       http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+       http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+    ">
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+    <import resource="classpath:META-INF/cxf/cxf.xml"/>
+
+    <httpj:engine-factory bus="cxf">
+        <!-- you just need to specify the TLS Server configuration for the certain port -->
+        <httpj:engine port="${CXFTestSupport.sslPort}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="changeit">
+                    <sec:keyStore type="JKS" password="changeit"
+                                  resource="/ssl/keystore-server.jks"/>
+                </sec:keyManagers>
+                <sec:clientAuthentication want="false" required="false"/>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+
+    <jaxrs:server id="restService"
+                  address="https://localhost:${CXFTestSupport.sslPort}/CxfRsProducerTest/"
+                  staticSubresourceResolution="true">
+        <jaxrs:serviceBeans>
+            <ref bean="customerService"/>
+        </jaxrs:serviceBeans>
+    </jaxrs:server>
+
+    <sslContextParameters xmlns="http://camel.apache.org/schema/spring"
+                          id="wrongSslContext">
+        <trustManagers>
+            <keyStore type="JKS" resource="/ssl/truststore-wrong.jks"
+                      password="changeit"/>
+        </trustManagers>
+    </sslContextParameters>
+    <sslContextParameters xmlns="http://camel.apache.org/schema/spring"
+                          id="mySslContext">
+        <trustManagers>
+            <keyStore type="JKS" resource="/ssl/truststore-client.jks"
+                      password="changeit"/>
+        </trustManagers>
+    </sslContextParameters>
+
+    <bean id="defaultHostnameVerifier"
+          class="org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifier"/>
+
+    <bean id="customerService" class="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"/>
+
+    <cxf:rsClient id="rsClientHttp" address="https://localhost:${CXFTestSupport.sslPort}/CxfRsProducerTest/"/>
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct://trust"/>
+            <to uri="cxfrs://bean://rsClientHttp?sslContextParameters=#mySslContext&amp;hostnameVerifier=#defaultHostnameVerifier"/>
+        </route>
+        <route>
+            <from uri="direct://wrongTrust"/>
+            <to uri="cxfrs://bean://rsClientHttp?sslContextParameters=#wrongSslContext&amp;hostnameVerifier=#defaultHostnameVerifier"/>
+        </route>
+        <route>
+            <from uri="direct://noTrust"/>
+            <to uri="cxfrs://bean://rsClientHttp?sslContextParameters=#wrongSslContext&amp;hostnameVerifier=#defaultHostnameVerifier"/>
+        </route>
+    </camelContext>
+
+</beans>