camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r790967 - in /camel/trunk/components/camel-irc/src: main/java/org/apache/camel/component/irc/IrcComponent.java main/java/org/apache/camel/component/irc/IrcConfiguration.java test/java/org/apache/camel/component/irc/IrcsRouteTest.java
Date Fri, 03 Jul 2009 17:15:52 GMT
Author: janstey
Date: Fri Jul  3 17:15:52 2009
New Revision: 790967

URL: http://svn.apache.org/viewvc?rev=790967&view=rev
Log:
support trustmanager configuration via the registry

Modified:
    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/test/java/org/apache/camel/component/irc/IrcsRouteTest.java

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=790967&r1=790966&r2=790967&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
Fri Jul  3 17:15:52 2009
@@ -28,7 +28,6 @@
 import org.schwering.irc.lib.IRCConnection;
 
 import org.schwering.irc.lib.ssl.SSLIRCConnection;
-import org.schwering.irc.lib.ssl.SSLTrustManager;
 
 /**
  * Defines the <a href="http://camel.apache.org/irc.html">IRC Component</a>
@@ -87,14 +86,7 @@
             }
             SSLIRCConnection sconn = new SSLIRCConnection(configuration.getHostname(), configuration.getPorts(),
configuration.getPassword(),
                                                          configuration.getNickname(), configuration.getUsername(),
configuration.getRealname());
-            try {
-                configuration.setTrustManager((SSLTrustManager)Class.forName(configuration.getTrustManagerClass()).newInstance());
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using trust manager: " + configuration.getTrustManager().getClass().getName());
-                }
-            } catch (Exception e) {
-                LOG.warn("Using default trust manager: " + configuration.getTrustManager().getClass().getName());
-            }
+
             sconn.addTrustManager(configuration.getTrustManager());
             conn = sconn;
 

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=790967&r1=790966&r2=790967&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
Fri Jul  3 17:15:52 2009
@@ -32,8 +32,7 @@
     private String nickname;
     private String realname;
     private String username;
-    private String trustManagerClass;
-    private SSLTrustManager trustManager;
+    private SSLTrustManager trustManager = new SSLDefaultTrustManager();
     private boolean usingSSL = false;
     private boolean persistent = true;
     private boolean colors = true;
@@ -46,7 +45,7 @@
     private boolean onTopic = true;
     private boolean onPrivmsg = true;
     private int[] ports = {6667, 6668, 6669};
-
+    
     public IrcConfiguration() {
     }
 
@@ -81,13 +80,13 @@
 
     public void configure(URI uri) {
         // fix provided URI and handle that we can use # to indicate the IRC room
-
         String fixedUri = uri.toString();
 
-        if (fixedUri.startsWith("ircs://")) {
+        if (fixedUri.startsWith("ircs")) {
             setUsingSSL(true);
-            setTrustManager(new SSLDefaultTrustManager());
-            setTrustManagerClass(getTrustManager().getClass().getName());
+            if (!fixedUri.startsWith("ircs://")) {
+                fixedUri = fixedUri.replace("ircs:", "ircs://");
+            }
         } else if (!fixedUri.startsWith("irc://")) {
             fixedUri = fixedUri.replace("irc:", "irc://");
         }
@@ -113,16 +112,6 @@
         setTarget("#" + channel);
     }
 
-    public void setTrustManagerClass(String trustManagerClass)
-    {
-        this.trustManagerClass = trustManagerClass;
-    }
-
-    public String getTrustManagerClass()
-    {
-        return trustManagerClass;
-    }
-
     public void setTrustManager(SSLTrustManager trustManager)
     {
         this.trustManager = trustManager;

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=790967&r1=790966&r2=790967&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
Fri Jul  3 17:15:52 2009
@@ -16,20 +16,42 @@
  */
 package org.apache.camel.component.irc;
 
+import java.security.cert.X509Certificate;
+
+import javax.naming.Context;
+
+import org.apache.camel.util.jndi.JndiContext;
+import org.schwering.irc.lib.ssl.SSLDefaultTrustManager;
+
 public class IrcsRouteTest extends IrcRouteTest {
 
     // TODO This test is disabled until we can find a public SSL enabled IRC 
     // server to test against. To use this you'll need to change the server 
     // information below and the username/password. 
-
+    
+    @Override
+    protected Context createJndiContext() throws Exception {
+        JndiContext answer = new JndiContext();
+        answer.bind("myCustomManager", new SSLDefaultTrustManager() {@Override
+        public boolean isTrusted(X509Certificate[] chain) {
+            return true;
+        }
+        @Override
+            public String toString() {             
+                return "MyCustomManager!";
+            }
+        });
+        return answer;
+    }   
+    
     @Override
     protected String sendUri() {
-        return "ircs://camel-prd@irc.codehaus.org:6667/#camel-test?nickname=camel-prd&password=blah";
+        return "ircs://camel-prd@irc.codehaus.org:6667/%23camel-test?trustManager=#myCustomManager";
     }
 
     @Override    
     protected String fromUri() {
-        return "ircs://camel-con@irc.codehaus.org:6667/#camel-test?nickname=camel-con&password=blah";
+        return "ircs://camel-con@irc.codehaus.org:6667/%23camel-test?trustManager=#myCustomManager";
     }    
 
 }
\ No newline at end of file



Mime
View raw message