You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dv...@apache.org on 2011/11/15 16:29:04 UTC

svn commit: r1202242 - in /camel/trunk/components: camel-cometd/src/main/java/org/apache/camel/component/cometd/ camel-cometd/src/test/java/org/apache/camel/component/cometd/ camel-irc/ camel-irc/src/main/java/org/apache/camel/component/irc/ camel-irc/...

Author: dvaleri
Date: Tue Nov 15 15:29:04 2011
New Revision: 1202242

URL: http://svn.apache.org/viewvc?rev=1202242&view=rev
Log:
[CAMEL-4679] [CAMEL-4664] Corrrected URI parsing issues with password and port settings.  Added support for JSSE Config Utility.

Added:
    camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersCometdProducerConsumerTest.java   (with props)
    camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersInUriCometdProducerConsumerTest.java   (with props)
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/CamelSSLIRCConnection.java   (with props)
    camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java   (with props)
    camel/trunk/components/camel-irc/src/test/resources/localhost.ks   (with props)
    camel/trunk/components/camel-irc/src/test/unrealircd/
    camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd   (with props)
    camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem   (with props)
    camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem   (with props)
    camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf   (with props)
Modified:
    camel/trunk/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdComponent.java
    camel/trunk/components/camel-irc/pom.xml
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
    camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java
    camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java

Modified: camel/trunk/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdComponent.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdComponent.java (original)
+++ camel/trunk/components/camel-cometd/src/main/java/org/apache/camel/component/cometd/CometdComponent.java Tue Nov 15 15:29:04 2011
@@ -22,12 +22,17 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.camel.Endpoint;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.cometd.bayeux.server.BayeuxServer;
 import org.cometd.bayeux.server.SecurityPolicy;
 import org.cometd.server.BayeuxServerImpl;
 import org.cometd.server.CometdServlet;
+import org.eclipse.jetty.http.ssl.SslContextFactory;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
@@ -56,6 +61,7 @@ public class CometdComponent extends Def
     private SslSocketConnector sslSocketConnector;
     private SecurityPolicy securityPolicy;
     private List<BayeuxServer.Extension> extensions;
+    private SSLContextParameters sslContextParameters;
 
     class ConnectorRef {
         Connector connector;
@@ -197,16 +203,28 @@ public class CometdComponent extends Def
     }
 
     public synchronized SslSocketConnector getSslSocketConnector() {
-        if (sslSocketConnector == null) {
-            sslSocketConnector = new SslSocketConnector();
-            // with default null values, jetty ssl system properties
-            // and console will be read by jetty implementation
-            sslSocketConnector.getSslContextFactory().setKeyManagerPassword(sslPassword);
-            sslSocketConnector.getSslContextFactory().setKeyStorePassword(sslKeyPassword);
-            if (sslKeystore != null) {
-                sslSocketConnector.getSslContextFactory().setKeyStore(sslKeystore);
+        if (sslContextParameters != null && sslSocketConnector == null) {
+            SslContextFactory sslContextFactory = new CometdComponentSslContextFactory();
+            try {
+                sslContextFactory.setSslContext(sslContextParameters.createSSLContext());
+            } catch (Exception e) {
+               throw new RuntimeCamelException("Error initiating SSLContext.", e);
+            }
+            sslSocketConnector = new SslSocketConnector(sslContextFactory);
+        }
+        else {
+            if (sslSocketConnector == null) {
+                sslSocketConnector = new SslSocketConnector();
+                // with default null values, jetty ssl system properties
+                // and console will be read by jetty implementation
+                sslSocketConnector.getSslContextFactory().setKeyManagerPassword(sslPassword);
+                sslSocketConnector.getSslContextFactory().setKeyStorePassword(sslKeyPassword);
+                if (sslKeystore != null) {
+                    sslSocketConnector.getSslContextFactory().setKeyStore(sslKeystore);
+                }
             }
         }
+        
         return sslSocketConnector;
     }
 
@@ -267,6 +285,14 @@ public class CometdComponent extends Def
         }
         extensions.add(extension);
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 
     protected Server createServer() throws Exception {
         Server server = new Server();
@@ -292,4 +318,14 @@ public class CometdComponent extends Def
     protected void doStart() throws Exception {
         super.doStart();
     }
+    
+    /**
+     * Override the key/trust store check method as it does not account for a factory that has
+     * a pre-configured {@link SSLContext}.
+     */
+    private static final class CometdComponentSslContextFactory extends SslContextFactory {
+        @Override
+        public void checkKeyStore() {
+        }
+    }
 }

Added: camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersCometdProducerConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersCometdProducerConsumerTest.java?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersCometdProducerConsumerTest.java (added)
+++ camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersCometdProducerConsumerTest.java Tue Nov 15 15:29:04 2011
@@ -0,0 +1,120 @@
+/**
+ * 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.cometd;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+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;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit testing for using a CometdProducer and a CometdConsumer
+ */
+public class SslContextParametersCometdProducerConsumerTest extends CamelTestSupport {
+
+    private int port;
+    private String uri;
+    
+    @Test
+    public void testProducer() throws Exception {
+        Person person = new Person("David", "Greco");
+        template.requestBody("direct:input", person);
+        MockEndpoint ep = (MockEndpoint) context.getEndpoint("mock:test");
+        List<Exchange> exchanges = ep.getReceivedExchanges();
+        for (Exchange exchange : exchanges) {
+            Person person1 = (Person) exchange.getIn().getBody();
+            assertEquals("David", person1.getName());
+            assertEquals("Greco", person1.getSurname());
+        }
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        port = AvailablePortFinder.getNextAvailable(23500);
+        uri = "cometds://127.0.0.1:" + port + "/service/test?baseResource=file:./target/test-classes/webapp&"
+                + "timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2";
+
+        super.setUp();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                KeyStoreParameters ksp = new KeyStoreParameters();
+                ksp.setResource("jsse/localhost.ks");
+                ksp.setPassword("changeit");
+                
+                KeyManagersParameters kmp = new KeyManagersParameters();
+                kmp.setKeyPassword("changeit");
+                kmp.setKeyStore(ksp);
+                
+                TrustManagersParameters tmp = new TrustManagersParameters();
+                tmp.setKeyStore(ksp);
+
+                SSLContextParameters sslContextParameters = new SSLContextParameters();
+                sslContextParameters.setKeyManagers(kmp);
+                sslContextParameters.setTrustManagers(tmp);
+                
+                CometdComponent component = (CometdComponent) context.getComponent("cometds");
+                component.setSslContextParameters(sslContextParameters);
+
+                from("direct:input").to(uri);
+
+                from(uri).to("mock:test");
+            }
+        };
+    }
+
+    public static class Person {
+
+        private String name;
+        private String surname;
+
+        Person(String name, String surname) {
+            this.name = name;
+            this.surname = surname;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getSurname() {
+            return surname;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public void setSurname(String surname) {
+            this.surname = surname;
+        }
+    }
+}

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

Added: camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersInUriCometdProducerConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersInUriCometdProducerConsumerTest.java?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersInUriCometdProducerConsumerTest.java (added)
+++ camel/trunk/components/camel-cometd/src/test/java/org/apache/camel/component/cometd/SslContextParametersInUriCometdProducerConsumerTest.java Tue Nov 15 15:29:04 2011
@@ -0,0 +1,126 @@
+/**
+ * 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.cometd;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+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;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit testing for using a CometdProducer and a CometdConsumer
+ */
+public class SslContextParametersInUriCometdProducerConsumerTest extends CamelTestSupport {
+
+    private int port;
+    private String uri;
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource("jsse/localhost.ks");
+        ksp.setPassword("changeit");
+        
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword("changeit");
+        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;
+    }
+
+    @Test
+    public void testProducer() throws Exception {
+        Person person = new Person("David", "Greco");
+        template.requestBody("direct:input", person);
+        MockEndpoint ep = (MockEndpoint) context.getEndpoint("mock:test");
+        List<Exchange> exchanges = ep.getReceivedExchanges();
+        for (Exchange exchange : exchanges) {
+            Person person1 = (Person) exchange.getIn().getBody();
+            assertEquals("David", person1.getName());
+            assertEquals("Greco", person1.getSurname());
+        }
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        port = AvailablePortFinder.getNextAvailable(23500);
+        uri = "cometds://127.0.0.1:" + port + "/service/test?baseResource=file:./target/test-classes/webapp&"
+                + "timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2&"
+                + "sslContextParameters=#sslContextParameters";
+
+        super.setUp();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:input").to(uri);
+
+                from(uri).to("mock:test");
+            }
+        };
+    }
+
+    public static class Person {
+
+        private String name;
+        private String surname;
+
+        Person(String name, String surname) {
+            this.name = name;
+            this.surname = surname;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getSurname() {
+            return surname;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public void setSurname(String surname) {
+            this.surname = surname;
+        }
+    }
+}

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

Modified: camel/trunk/components/camel-irc/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/pom.xml?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/pom.xml (original)
+++ camel/trunk/components/camel-irc/pom.xml Tue Nov 15 15:29:04 2011
@@ -70,18 +70,4 @@
         <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <excludes>
-            <exclude>**/IrcsRouteTest.*</exclude>
-          </excludes>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>

Added: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/CamelSSLIRCConnection.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/CamelSSLIRCConnection.java?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/CamelSSLIRCConnection.java (added)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/CamelSSLIRCConnection.java Tue Nov 15 15:29:04 2011
@@ -0,0 +1,111 @@
+/**
+ * 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.irc;
+
+import java.io.IOException;
+import java.net.SocketException;
+import java.security.GeneralSecurityException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.schwering.irc.lib.ssl.SSLIRCConnection;
+import org.schwering.irc.lib.ssl.SSLNotSupportedException;
+
+/**
+ * Customized version of {@link SSLIRCConnection} used to support the use of an {@link SSLContextParameters} instance
+ * for JSSE configuration.
+ */
+public class CamelSSLIRCConnection extends SSLIRCConnection {
+    
+    private SSLContextParameters sslContextParameters;
+
+    public CamelSSLIRCConnection(String host, int portMin, int portMax, String pass, 
+                                 String nick, String username, String realname,
+                                 SSLContextParameters sslContextParameters) {
+        super(host, portMin, portMax, pass, nick, username, realname);
+        this.sslContextParameters = sslContextParameters;
+    }
+
+    public CamelSSLIRCConnection(String host, int[] ports, String pass,
+                                 String nick, String username, String realname,
+                                 SSLContextParameters sslContextParameters) {
+        super(host, ports, pass, nick, username, realname);
+        this.sslContextParameters = sslContextParameters;
+    }
+
+    @Override
+    public void connect() throws IOException {
+        
+        if (sslContextParameters == null) {
+            super.connect();
+        } else {
+            if (level != 0) {
+                throw new SocketException("Socket closed or already open (" + level + ")");
+            }
+            
+            IOException exception = null;
+            
+            final SSLContext sslContext;
+            try {
+                sslContext = sslContextParameters.createSSLContext();
+            } catch (GeneralSecurityException e) {
+                throw new RuntimeCamelException("Error in SSLContextParameters configuration or instantiation.", e);
+            }
+            
+            final SSLSocketFactory sf = sslContext.getSocketFactory();
+            
+            SSLSocket s = null;
+            
+            for (int i = 0; i < ports.length && s == null; i++) {
+                try {
+                    s = (SSLSocket)sf.createSocket(host, ports[i]);
+                    s.startHandshake();
+                    exception = null;
+                } catch (SSLNotSupportedException exc) {
+                    if (s != null) {
+                        s.close();
+                    }
+                    s = null;
+                    throw exc;
+                } catch (IOException exc) {
+                    if (s != null) {
+                        s.close();
+                    }
+                    s = null;
+                    exception = exc; 
+                }
+            }
+            if (exception != null) {
+                throw exception; // connection wasn't successful at any port
+            }
+            
+            prepare(s);
+        }        
+    }
+
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+}

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

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java (original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java Tue Nov 15 15:29:04 2011
@@ -21,7 +21,6 @@ import java.util.Map;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.schwering.irc.lib.IRCConnection;
 import org.schwering.irc.lib.IRCEventListener;
 import org.schwering.irc.lib.ssl.SSLIRCConnection;
@@ -66,16 +65,23 @@ public class IrcComponent extends Defaul
         IRCEventListener ircLogger;
 
         if (configuration.getUsingSSL()) {
+            
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Creating SSL Connection to {} destination(s): {} nick: {} user: {}",
                     new Object[]{configuration.getHostname(), configuration.getListOfChannels(), configuration.getNickname(), configuration.getUsername()});
             }
-            SSLIRCConnection sconn = new SSLIRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(),
-                    configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
-
-            sconn.addTrustManager(configuration.getTrustManager());
-            conn = sconn;
+            
+            if (configuration.getSslContextParameters() != null) {
+                conn = new CamelSSLIRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(),
+                                                 configuration.getNickname(), configuration.getUsername(), configuration.getRealname(),
+                                                 configuration.getSslContextParameters());
+            } else {
+                SSLIRCConnection sconn = new SSLIRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(),
+                        configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
 
+                sconn.addTrustManager(configuration.getTrustManager());
+                conn = sconn;
+            }
         } else {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Creating Connection to {} destination(s): {} nick: {} user: {}",

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java (original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java Tue Nov 15 15:29:04 2011
@@ -22,19 +22,14 @@ import java.net.URISyntaxException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.schwering.irc.lib.ssl.SSLDefaultTrustManager;
 import org.schwering.irc.lib.ssl.SSLTrustManager;
 import org.slf4j.Logger;
@@ -64,6 +59,7 @@ public class IrcConfiguration implements
     private boolean onPrivmsg = true;
     private boolean autoRejoin = true;
     private int[] ports = {6667, 6668, 6669};
+    private SSLContextParameters sslContextParameters;
 
     public IrcConfiguration() {
     }
@@ -121,9 +117,30 @@ public class IrcConfiguration implements
 
         URI uri = new URI(uriStr);
 
-        setNickname(uri.getUserInfo());
-        setUsername(uri.getUserInfo());
-        setRealname(uri.getUserInfo());
+        // Because we can get a "sanitized" URI, we need to deal with the situation where the
+        // user info includes the username and password together or else we get a mangled username
+        // that includes the user's secret being sent to the server.
+        String userInfo = uri.getUserInfo();
+        String username = null;
+        String password = null;
+        if (userInfo != null) {
+            int colonIndex = userInfo.indexOf(":");
+            if (colonIndex != -1) {
+                username = userInfo.substring(0, colonIndex);
+                password = userInfo.substring(colonIndex + 1);
+            } else {
+                username = userInfo;
+            }
+        }
+        
+        if (uri.getPort() != -1) {
+            setPorts(new int[] {uri.getPort()});
+        }
+        
+        setNickname(username);
+        setUsername(username);
+        setRealname(username);
+        setPassword(password);
         setHostname(uri.getHost());
 
         String path = uri.getPath();
@@ -314,6 +331,14 @@ public class IrcConfiguration implements
     public void setAutoRejoin(boolean autoRejoin) {
         this.autoRejoin = autoRejoin;
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 
     public String toString() {
         return "IrcConfiguration[hostname: " + hostname + ", ports=" + Arrays.toString(ports) + ", username=" + username + "]";

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java (original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java Tue Nov 15 15:29:04 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.irc;
 
-import java.util.List;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;

Modified: camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java (original)
+++ camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteTest.java Tue Nov 15 15:29:04 2011
@@ -23,7 +23,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -35,7 +34,7 @@ public class IrcRouteTest extends CamelT
     protected String body2 = "Message Two";
     private boolean sentMessages;    
 
-    @Ignore("test manual")
+    
     @Test
     public void testIrcMessages() throws Exception {
         resultEndpoint = (MockEndpoint) context.getEndpoint("mock:result");
@@ -67,11 +66,11 @@ public class IrcRouteTest extends CamelT
     }
 
     protected String sendUri() {
-        return "irc://camel-prd@irc.codehaus.org:6667/#camel-test?nickname=camel-prd";
+        return "irc://camel-prd-user@irc.codehaus.org:6667/#camel-test?nickname=camel-prd";
     }
 
     protected String fromUri() {
-        return "irc://camel-con@irc.codehaus.org:6667/#camel-test?nickname=camel-con";
+        return "irc://camel-con-user@irc.codehaus.org:6667/#camel-test?nickname=camel-con";
     }    
     
     /**

Modified: camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java (original)
+++ camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsRouteTest.java Tue Nov 15 15:29:04 2011
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.irc;
 
+import org.junit.Ignore;
+
+@Ignore
 public class IrcsRouteTest extends IrcRouteTest {
 
     // TODO This test is disabled until we can find a public SSL enabled IRC 

Added: camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java (added)
+++ camel/trunk/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcsWithSslContextParamsRouteTest.java Tue Nov 15 15:29:04 2011
@@ -0,0 +1,68 @@
+/**
+ * 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.irc;
+
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
+import org.junit.Ignore;
+
+@Ignore
+public class IrcsWithSslContextParamsRouteTest extends IrcRouteTest {
+
+    // TODO This test is disabled until we can find a public SSL enabled IRC 
+    // server to test against. To use this test, follow the following procedures:
+    // 1) Download and install UnrealIRCd 3.2.9 from http://www.unrealircd.com/
+    // 2) Copy the contents of the src/test/unrealircd folder into the installation
+    //    folder of UnrealIRCd.
+    // 3) Start UnrealIRCd and execute this test.  Often the test executes quicker than
+    //    the IRC server responds and the assertion will fail.  In order to get the test to
+    //    pass reliably, you may need to set a break point in IrcEndpoint#joinChanel in order
+    //    to slow the route creation down enough for the event listener to be in place
+    //    when camel-con joins the room.
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource("localhost.ks");
+        ksp.setPassword("changeit");
+        
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setKeyStore(ksp);
+        
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setTrustManagers(tmp);
+        
+        
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("sslContextParameters", sslContextParameters);
+
+        return registry;
+    }
+
+    @Override
+    protected String sendUri() {
+        return "ircs://camel-prd-user@localhost:6669/#camel-test?nickname=camel-prd&password=password&sslContextParameters=#sslContextParameters";
+    }
+
+    @Override    
+    protected String fromUri() {
+        return "ircs://camel-con-user@localhost:6669/#camel-test?nickname=camel-con&password=password&sslContextParameters=#sslContextParameters";
+    }    
+
+}
\ No newline at end of file

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

Added: camel/trunk/components/camel-irc/src/test/resources/localhost.ks
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/resources/localhost.ks?rev=1202242&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-irc/src/test/resources/localhost.ks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd (added)
+++ camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd Tue Nov 15 15:29:04 2011
@@ -0,0 +1 @@
+Hi!
\ No newline at end of file

Propchange: camel/trunk/components/camel-irc/src/test/unrealircd/ircd.motd
------------------------------------------------------------------------------
    svn:executable = *

Added: camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem (added)
+++ camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem Tue Nov 15 15:29:04 2011
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICZTCCAc6gAwIBAgIJAKNUHEnxsizpMA0GCSqGSIb3DQEBBQUAMGkxCzAJBgNV
+BAYTAlVTMREwDwYDVQQIEwhWaXJnaW5pYTEQMA4GA1UEBxMHQXNoYnVybjESMBAG
+A1UEChMJSVJDIGdlZWtzMQ0wCwYDVQQLEwRJUkNkMRIwEAYDVQQDEwlsb2NhbGhv
+c3QwHhcNMTExMTE0MTY0MzM5WhcNMTIxMTEzMTY0MzM5WjBpMQswCQYDVQQGEwJV
+UzERMA8GA1UECBMIVmlyZ2luaWExEDAOBgNVBAcTB0FzaGJ1cm4xEjAQBgNVBAoT
+CUlSQyBnZWVrczENMAsGA1UECxMESVJDZDESMBAGA1UEAxMJbG9jYWxob3N0MIGf
+MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqibJ+VZBEgXjDdnD4fJ+1CW+hKs7s
+Ndxv0LFQTvS67W/WAZHKxuief4UcR8gVNWGxj2TbvM9wWQGkfzZ+sWhiJY/HjgaY
+y9XEh/UtHTZ6pFGY0jp7ZlkNNHMj9qlprGNqz1XcrMghQGlfW7KfZqQ8nOYawjWZ
+1Nwvwqs9vLQXiwIDAQABoxUwEzARBglghkgBhvhCAQEEBAMCBkAwDQYJKoZIhvcN
+AQEFBQADgYEABvJJnG0Q+iHBU3GOLbZ+kW9TylXvOYa0jlV+rPVcjHi/MwZUPjW2
+0ehllVrsm/NnpLq/H9074rVCr2hPl+rShLeQLghyh0kw2QI+wJtXbtht35F241TL
+1kHwODDYx4nclTUR2QT561b3WywECXcPFC49Gp4jv5K77hIcu39jKYA=
+-----END CERTIFICATE-----

Propchange: camel/trunk/components/camel-irc/src/test/unrealircd/server.cert.pem
------------------------------------------------------------------------------
    svn:executable = *

Added: camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem (added)
+++ camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem Tue Nov 15 15:29:04 2011
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKqJsn5VkESBeMN2
+cPh8n7UJb6Eqzuw13G/QsVBO9Lrtb9YBkcrG6J5/hRxHyBU1YbGPZNu8z3BZAaR/
+Nn6xaGIlj8eOBpjL1cSH9S0dNnqkUZjSOntmWQ00cyP2qWmsY2rPVdysyCFAaV9b
+sp9mpDyc5hrCNZnU3C/Cqz28tBeLAgMBAAECgYBLJoLRyULZ7XQaLod5+PEoBhB7
+JTIqRVHutDhu+1w9Q4SU+fwVL7Iypl8yJy+0qOF0LYx0iK+hApgGtUh+bA9i+HNK
+1t7B87M6Tyy3dT3EwP0MTeDtUqQWEJHi4YgtjiHUdVO+86Y2Kj0b+Pusf2zyRdZO
+atYQcJIC3zV956yxgQJBANqZlifOSQUT7aK8sKWYJt/PW2RSKRIIRp14cOhSLqES
+T50mBEUIMZfLV5+x7oI9DvLeCuwS1M8MbyZqrHsmfiUCQQDHtwzb/oJjJdiTdx2R
+Gemw66RxDWGdfIYEQiZ5UrNCNbXeApBuy570Uxb/cfaSxKDN1oatrM91jOu3IB1E
+AxfvAkEA16GfK77h6p9gzyHAQmjXF/kMVuZw2vfM6HKxNYozsvFEFWk11v6hJPIR
+ilbTRieCwnHjZkGhKGhEkCmz4Hr0/QJBAKzi1Hn5J6xmzcZSfkDnGrryMoc/Wzp2
+2pkDHsU2B0IQtuB6fce78110NFtrr1U8bCvkQvBDwc/z7vW3Ej6XIvcCQB3YhPif
+JMZBlWCX9ouOnequEC9BXybeXcb46hWnkTS+KmjwpEXA0lbBwmOpq7Y7yAbsezuY
+xT9i1Ry944+nRLU=
+-----END PRIVATE KEY-----

Propchange: camel/trunk/components/camel-irc/src/test/unrealircd/server.key.pem
------------------------------------------------------------------------------
    svn:executable = *

Added: camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf?rev=1202242&view=auto
==============================================================================
--- camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf (added)
+++ camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf Tue Nov 15 15:29:04 2011
@@ -0,0 +1,184 @@
+loadmodule "modules/commands.dll";
+loadmodule "modules/cloak.dll";
+
+include "help.conf";
+include "badwords.channel.conf";
+include "badwords.message.conf";
+include "badwords.quit.conf";
+include "spamfilter.conf";
+
+me
+{
+	name "localhost.net";
+	info "FooNet Server";
+	numeric 1;
+};
+
+admin {
+	"Bob Smith";
+	"bob";
+	"widely@used.name";
+};
+
+class           clients
+{
+	pingfreq 90;
+	maxclients 500;
+	sendq 100000;
+	recvq 8000;
+};
+
+allow {
+	ip             *@*;
+	hostname       *@*;
+	class          clients;
+	password "password";
+	maxperip 5;
+};
+
+allow           channel {
+	channel "#camel-test";
+};
+
+listen         *:6667
+{
+	options
+	{
+		clientsonly;
+	};
+};
+
+listen         *:6669
+{
+	options
+	{
+		ssl;
+		clientsonly;
+	};
+};
+
+files
+{
+	/* The Message Of The Day shown to users who log in: */
+	motd ircd.motd;
+
+	/*
+	 * A short MOTD. If this file exists, it will be displayed to
+	 * the user in place of the MOTD. Users can still view the
+	 * full MOTD by using the /MOTD command.
+	 */
+	/* shortmotd ircd.smotd; */
+
+	/* Shown when an operator /OPERs up */
+	/* opermotd oper.motd; */
+
+	/* Services MOTD append. */
+	/* svsmotd ircd.svsmotd; */
+
+	/* Bot MOTD */
+	/* botmotd bot.motd; */
+
+	/* Shown upon /RULES */
+	/* rules ircd.rules; */
+
+	/*
+	 * Where the IRCd stores and loads a few values which should
+	 * be persistent across server restarts. Must point to an
+	 * existing file which the IRCd has permission to alter or to
+	 * a file in a folder within which the IRCd may create files.
+	 */
+	/* tunefile ircd.tune; */
+
+	/* Where to save the IRCd's pid. Should be writable by the IRCd. */
+	/* pidfile ircd.pid; */
+};
+
+/* Network configuration */
+set {
+	network-name 		"TestNet";
+	default-server 		"irc.roxnet.org";
+	services-server 	"junk.org";
+	help-channel 		"#TestNet";
+	hiddenhost-prefix	"rox";
+	/* prefix-quit 		"no"; */
+	/* Cloak keys should be the same at all servers on the network.
+	 * They are used for generating masked hosts and should be kept secret.
+	 * The keys should be 3 random strings of 5-100 characters
+	 * (10-20 chars is just fine) and must consist of lowcase (a-z),
+	 * upcase (A-Z) and digits (0-9) [see first key example].
+	 * HINT: On *NIX, you can run './unreal gencloak' in your shell to let
+	 *       Unreal generate 3 random strings for you.
+	 */
+	cloak-keys {
+		"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";
+		"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpD";
+		"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpF";
+	};
+	/* on-oper host */
+	hosts {
+		local		"locop.roxnet.org";
+		global		"ircop.roxnet.org";
+		coadmin		"coadmin.roxnet.org";
+		admin		"admin.roxnet.org";
+		servicesadmin 	"csops.roxnet.org";
+		netadmin 	"netadmin.roxnet.org";
+		host-on-oper-up "no";
+	};
+};
+
+/* Server specific configuration */
+
+set {
+	kline-address "spam@mailinator.com";
+	modes-on-connect "+xw";
+	modes-on-oper	 "+xwgs";
+	oper-auto-join "#opers";
+	options {
+		hide-ulines;
+		/* You can enable ident checking here if you want */
+		/* identd-check; */
+		show-connect-info;
+	};
+
+	maxchannelsperuser 10;
+	/* The minimum time a user must be connected before being allowed to use a QUIT message,
+	 * This will hopefully help stop spam */
+	anti-spam-quit-message-time 10s;
+	/* Make the message in static-quit show in all quits - meaning no
+           custom quits are allowed on local server */
+	/* static-quit "Client quit";	*/
+
+	/* You can also block all part reasons by uncommenting this and say 'yes',
+	 * or specify some other text (eg: "Bye bye!") to always use as a comment.. */
+	/* static-part yes; */
+
+	/* This allows you to make certain stats oper only, use * for all stats,
+	 * leave it out to allow users to see all stats. Type '/stats' for a full list.
+	 * Some admins might want to remove the 'kGs' to allow normal users to list
+	 * klines, glines and shuns.
+	 */
+	oper-only-stats "okfGsMRUEelLCXzdD";
+
+	/* Throttling: this example sets a limit of 3 connection attempts per 60s (per host). */
+	throttle {
+		connections 50;
+		period 60s;
+	};
+
+	/* Anti flood protection */
+	anti-flood {
+		nick-flood 3:60;	/* 3 nickchanges per 60 seconds (the default) */
+	};
+
+	/* Spam filter */
+	spamfilter {
+		ban-time 1d; /* default duration of a *line ban set by spamfilter */
+		ban-reason "Spam/Advertising"; /* default reason */
+		virus-help-channel "#help"; /* channel to use for 'viruschan' action */
+		/* except "#help"; channel to exempt from filtering */
+	};
+	ssl {
+		certificate "C:\Program Files\Unreal3.2\server.cert.pem";
+		key "C:\Program Files\Unreal3.2\server.key.pem";
+	};
+};
\ No newline at end of file

Propchange: camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-irc/src/test/unrealircd/unrealircd.conf
------------------------------------------------------------------------------
    svn:executable = *

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?rev=1202242&r1=1202241&r2=1202242&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java Tue Nov 15 15:29:04 2011
@@ -24,8 +24,10 @@ import javax.mail.Authenticator;
 import javax.mail.Message;
 import javax.mail.PasswordAuthentication;
 import javax.mail.Session;
+import javax.net.ssl.SSLContext;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.springframework.mail.javamail.JavaMailSender;
 import org.springframework.mail.javamail.JavaMailSenderImpl;
 
@@ -63,6 +65,7 @@ public class MailConfiguration implement
     private boolean useInlineAttachments;
     private boolean ignoreUnsupportedCharset;
     private boolean disconnect;
+    private SSLContextParameters sslContextParameters;
 
     public MailConfiguration() {
     }
@@ -176,8 +179,16 @@ public class MailConfiguration implement
             // add more debug for the SSL communication as well
             properties.put("javax.net.debug", "all");
         }
-
-        if (dummyTrustManager && isSecureProtocol()) {
+        
+        if (sslContextParameters != null && isSecureProtocol()) {
+            SSLContext sslContext;
+            try {
+                sslContext = sslContextParameters.createSSLContext();
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Error initializing SSLContext.", e);
+            }
+            properties.put("mail." + protocol + ".socketFactory", sslContext.getSocketFactory());
+        } else if (dummyTrustManager && isSecureProtocol()) {
             // set the custom SSL properties
             properties.put("mail." + protocol + ".socketFactory.class", "org.apache.camel.component.mail.security.DummySSLSocketFactory");
             properties.put("mail." + protocol + ".socketFactory.fallback", "false");
@@ -463,7 +474,7 @@ public class MailConfiguration implement
     public void setIgnoreUnsupportedCharset(boolean ignoreUnsupportedCharset) {
         this.ignoreUnsupportedCharset = ignoreUnsupportedCharset;
     }
-
+    
     public boolean isDisconnect() {
         return disconnect;
     }
@@ -471,4 +482,12 @@ public class MailConfiguration implement
     public void setDisconnect(boolean disconnect) {
         this.disconnect = disconnect;
     }
+
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 }