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 2015/11/28 09:47:41 UTC
camel git commit: CAMEL-9374: The dummy impl should be in camel-mail
JAR
Repository: camel
Updated Branches:
refs/heads/master 6a0f016ef -> 6bc60647e
CAMEL-9374: The dummy impl should be in camel-mail JAR
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6bc60647
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6bc60647
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6bc60647
Branch: refs/heads/master
Commit: 6bc60647e12e52f2a40a232f80dd9343d70c7ca3
Parents: 6a0f016
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Nov 28 09:47:29 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Nov 28 09:47:29 2015 +0100
----------------------------------------------------------------------
components/camel-mail/pom.xml | 5 +-
.../component/mail/DummySSLSocketFactory.java | 95 ++++++++++++++++++++
.../camel/component/mail/DummyTrustManager.java | 58 ++++++++++++
.../camel/component/mail/MailConfiguration.java | 2 +-
.../mail/security/DummySSLSocketFactory.java | 95 --------------------
.../mail/security/DummyTrustManager.java | 58 ------------
6 files changed, 158 insertions(+), 155 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-mail/pom.xml b/components/camel-mail/pom.xml
index d5123ce..a3daa79 100644
--- a/components/camel-mail/pom.xml
+++ b/components/camel-mail/pom.xml
@@ -30,7 +30,10 @@
<description>Camel Mail support</description>
<properties>
- <camel.osgi.export.pkg>org.apache.camel.component.mail.*,org.apache.camel.dataformat.mime.multipart.*</camel.osgi.export.pkg>
+ <camel.osgi.export.pkg>
+ org.apache.camel.component.mail.*,
+ org.apache.camel.dataformat.mime.multipart.*
+ </camel.osgi.export.pkg>
<camel.osgi.export.service>
org.apache.camel.spi.ComponentResolver;component=imap,
org.apache.camel.spi.ComponentResolver;component=imaps,
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummySSLSocketFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummySSLSocketFactory.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummySSLSocketFactory.java
new file mode 100644
index 0000000..6d3c682
--- /dev/null
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummySSLSocketFactory.java
@@ -0,0 +1,95 @@
+/**
+ * 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.mail;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+import org.apache.camel.RuntimeCamelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DummySSLSocketFactory for testing with SSL - <b>NOT SECURE</b>.
+ * <p/>
+ * This factory is only to be used for testing purposes.
+ */
+public class DummySSLSocketFactory extends SSLSocketFactory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DummySSLSocketFactory.class);
+ private SSLSocketFactory factory;
+
+ public DummySSLSocketFactory() {
+ try {
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ TrustManager[] trustManagers = new TrustManager[] {new DummyTrustManager()};
+ sslContext.init(null, trustManagers, new java.security.SecureRandom());
+ factory = sslContext.getSocketFactory();
+ } catch (Exception e) {
+ throw new RuntimeCamelException("Error creating DummySSLSocketFactory: " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Must provide this getDefault operation for JavaMail to be able to use this factory.
+ */
+ public static SocketFactory getDefault() {
+ LOG.warn("Camel is using DummySSLSocketFactory as SSLSocketFactory (only to be used for testing purpose)");
+ return new DummySSLSocketFactory();
+ }
+
+ public String[] getDefaultCipherSuites() {
+ return factory.getDefaultCipherSuites();
+ }
+
+ public String[] getSupportedCipherSuites() {
+ return factory.getSupportedCipherSuites();
+ }
+
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
+ return factory.createSocket(socket, host, port, autoClose);
+ }
+
+ public Socket createSocket(String host, int port) throws IOException {
+ return factory.createSocket(host, port);
+ }
+
+ public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
+ throws IOException {
+ return factory.createSocket(host, port, localAddress, localPort);
+ }
+
+ public Socket createSocket(InetAddress host, int port) throws IOException {
+ return factory.createSocket(host, port);
+ }
+
+ public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
+ throws IOException {
+ return factory.createSocket(address, port, localAddress, localPort);
+ }
+
+ public Socket createSocket() throws IOException {
+ // must have this createSocket method
+ return factory.createSocket();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummyTrustManager.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummyTrustManager.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummyTrustManager.java
new file mode 100644
index 0000000..5923c1d
--- /dev/null
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/DummyTrustManager.java
@@ -0,0 +1,58 @@
+/**
+ * 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.mail;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DummyTrustManager that accepts any given certificate - <b>NOT SECURE</b>.
+ */
+public class DummyTrustManager implements X509TrustManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DummyTrustManager.class);
+
+ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ // everything is trusted
+ logCertificateChain("Client", chain);
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ // everything is trusted
+ logCertificateChain("Server", chain);
+ }
+
+ public X509Certificate[] getAcceptedIssuers() {
+ // everything is trusted
+ return new X509Certificate[0];
+ }
+
+ private static void logCertificateChain(String type, X509Certificate[] chain) {
+ if (LOG.isDebugEnabled()) {
+ for (X509Certificate certificate : chain) {
+ LOG.debug("{} certificate is trusted: {}", type, certificate);
+ }
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
index aa48657..d4d69e4 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
@@ -240,7 +240,7 @@ public class MailConfiguration implements Cloneable {
}
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.class", "org.apache.camel.component.mail.DummySSLSocketFactory");
properties.put("mail." + protocol + ".socketFactory.fallback", "false");
properties.put("mail." + protocol + ".socketFactory.port", "" + port);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummySSLSocketFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummySSLSocketFactory.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummySSLSocketFactory.java
deleted file mode 100644
index 58b97f0..0000000
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummySSLSocketFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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.mail.security;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-
-import org.apache.camel.RuntimeCamelException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * DummySSLSocketFactory for testing with SSL - <b>NOT SECURE</b>.
- * <p/>
- * This factory is only to be used for testing purposes.
- */
-public class DummySSLSocketFactory extends SSLSocketFactory {
-
- private static final Logger LOG = LoggerFactory.getLogger(DummySSLSocketFactory.class);
- private SSLSocketFactory factory;
-
- public DummySSLSocketFactory() {
- try {
- SSLContext sslContext = SSLContext.getInstance("TLS");
- TrustManager[] trustManagers = new TrustManager[] {new DummyTrustManager()};
- sslContext.init(null, trustManagers, new java.security.SecureRandom());
- factory = sslContext.getSocketFactory();
- } catch (Exception e) {
- throw new RuntimeCamelException("Error creating DummySSLSocketFactory: " + e.getMessage(), e);
- }
- }
-
- /**
- * Must provide this getDefault operation for JavaMail to be able to use this factory.
- */
- public static SocketFactory getDefault() {
- LOG.warn("Camel is using DummySSLSocketFactory as SSLSocketFactory (only to be used for testing purpose)");
- return new DummySSLSocketFactory();
- }
-
- public String[] getDefaultCipherSuites() {
- return factory.getDefaultCipherSuites();
- }
-
- public String[] getSupportedCipherSuites() {
- return factory.getSupportedCipherSuites();
- }
-
- public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
- return factory.createSocket(socket, host, port, autoClose);
- }
-
- public Socket createSocket(String host, int port) throws IOException {
- return factory.createSocket(host, port);
- }
-
- public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
- throws IOException {
- return factory.createSocket(host, port, localAddress, localPort);
- }
-
- public Socket createSocket(InetAddress host, int port) throws IOException {
- return factory.createSocket(host, port);
- }
-
- public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
- throws IOException {
- return factory.createSocket(address, port, localAddress, localPort);
- }
-
- public Socket createSocket() throws IOException {
- // must have this createSocket method
- return factory.createSocket();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6bc60647/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummyTrustManager.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummyTrustManager.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummyTrustManager.java
deleted file mode 100644
index d062f11..0000000
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/security/DummyTrustManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.mail.security;
-
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.X509TrustManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * DummyTrustManager that accepts any given certificate - <b>NOT SECURE</b>.
- */
-public class DummyTrustManager implements X509TrustManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(DummyTrustManager.class);
-
- public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- // everything is trusted
- logCertificateChain("Client", chain);
- }
-
- public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- // everything is trusted
- logCertificateChain("Server", chain);
- }
-
- public X509Certificate[] getAcceptedIssuers() {
- // everything is trusted
- return new X509Certificate[0];
- }
-
- private static void logCertificateChain(String type, X509Certificate[] chain) {
- if (LOG.isDebugEnabled()) {
- for (X509Certificate certificate : chain) {
- LOG.debug("{} certificate is trusted: {}", type, certificate);
- }
- }
- }
-
-}
-