flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject [3/3] flume git commit: FLUME-2533: HTTPS tests fail on Java 6
Date Thu, 06 Nov 2014 21:17:12 GMT
FLUME-2533: HTTPS tests fail on Java 6

(Hari Shreedharan via Jarek Jarcec Cecho)


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

Branch: refs/heads/flume-1.5
Commit: ab00f5c5d4ab8c3adccbc1ee296a18b2bfa412d3
Parents: 8229cc3
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Nov 5 16:53:13 2014 -0800
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Thu Nov 6 13:16:41 2014 -0800

----------------------------------------------------------------------
 .../flume/source/http/TestHTTPSource.java       | 77 ++++++++++++++++++--
 1 file changed, 71 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/ab00f5c5/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java
----------------------------------------------------------------------
diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java
b/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java
index 9ba0a8c..64111be 100644
--- a/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java
+++ b/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java
@@ -367,6 +367,7 @@ public class TestHTTPSource {
       }};
 
       SSLContext sc = null;
+      javax.net.ssl.SSLSocketFactory factory = null;
       if (System.getProperty("java.vendor").contains("IBM")) {
         sc = SSLContext.getInstance("SSL_TLS");
       } else {
@@ -379,11 +380,11 @@ public class TestHTTPSource {
         }
       };
       sc.init(null, trustAllCerts, new SecureRandom());
-      javax.net.ssl.SSLSocketFactory factory = null;
+
       if(protocol != null) {
-        factory = new TestSSLSocketFactory(sc.getSocketFactory(), protocol);
+        factory = new DisabledProtocolsSocketFactory(sc.getSocketFactory(), protocol);
       } else {
-        factory = sc.getSocketFactory();
+        factory = new EnabledProtocolsSocketFactory(sc.getSocketFactory());
       }
       HttpsURLConnection.setDefaultSSLSocketFactory(factory);
       HttpsURLConnection.setDefaultHostnameVerifier(
@@ -490,16 +491,16 @@ public class TestHTTPSource {
     }
   }
 
-  private class TestSSLSocketFactory extends javax.net.ssl.SSLSocketFactory {
+  private class DisabledProtocolsSocketFactory extends javax.net.ssl.SSLSocketFactory {
 
     private final javax.net.ssl.SSLSocketFactory socketFactory;
     private final String[] protocols;
 
-    TestSSLSocketFactory(javax.net.ssl.SSLSocketFactory factory, String protocol) {
+    DisabledProtocolsSocketFactory(javax.net.ssl.SSLSocketFactory factory, String protocol)
{
       this.socketFactory = factory;
       if(protocol.equals("SSLv2Hello")) {
         protocols = new String[2];
-        protocols[0] = "TLSv1.2";
+        protocols[0] = "TLSv1";
         protocols[1] = protocol;
       } else {
         protocols = new String[1];
@@ -559,4 +560,68 @@ public class TestHTTPSource {
       return sc;
     }
   }
+
+  private class EnabledProtocolsSocketFactory extends javax.net.ssl.SSLSocketFactory {
+
+    private final javax.net.ssl.SSLSocketFactory socketFactory;
+    private final String[] protocols;
+
+    EnabledProtocolsSocketFactory(javax.net.ssl.SSLSocketFactory factory) {
+      this.socketFactory = factory;
+      protocols = new String[1];
+      protocols[0] = "TLSv1";
+    }
+
+    @Override
+    public String[] getDefaultCipherSuites() {
+      return socketFactory.getDefaultCipherSuites();
+    }
+
+    @Override
+    public String[] getSupportedCipherSuites() {
+      return socketFactory.getSupportedCipherSuites();
+    }
+
+    @Override
+    public Socket createSocket(Socket socket, String s, int i, boolean b)
+      throws IOException {
+      SSLSocket sc = (SSLSocket) socketFactory.createSocket(socket, s, i, b);
+      sc.setEnabledProtocols(protocols);
+      return sc;
+    }
+
+    @Override
+    public Socket createSocket(String s, int i)
+      throws IOException, UnknownHostException {
+      SSLSocket sc = (SSLSocket)socketFactory.createSocket(s, i);
+      sc.setEnabledProtocols(protocols);
+      return sc;
+    }
+
+    @Override
+    public Socket createSocket(String s, int i, InetAddress inetAddress, int i2)
+      throws IOException, UnknownHostException {
+      SSLSocket sc = (SSLSocket)socketFactory.createSocket(s, i, inetAddress,
+        i2);
+      sc.setEnabledProtocols(protocols);
+      return sc;
+    }
+
+    @Override
+    public Socket createSocket(InetAddress inetAddress, int i)
+      throws IOException {
+      SSLSocket sc = (SSLSocket)socketFactory.createSocket(inetAddress, i);
+      sc.setEnabledProtocols(protocols);
+      return sc;
+    }
+
+    @Override
+    public Socket createSocket(InetAddress inetAddress, int i,
+      InetAddress inetAddress2, int i2) throws IOException {
+      SSLSocket sc = (SSLSocket)socketFactory.createSocket(inetAddress, i,
+        inetAddress2, i2);
+      sc.setEnabledProtocols(protocols);
+      return sc;
+    }
+  }
 }


Mime
View raw message