cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [10/22] git commit: updated refs/heads/4.5 to 78b9be0
Date Thu, 05 Feb 2015 11:51:46 GMT
improve protocol enabling based on socket object type

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit d62d511f47ae8118544259b15c9382185364052e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 125abe8234ad465514a6487badadad43f386a17c
Parents: 6fc97f9
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Thu Feb 5 15:48:21 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Feb 5 15:49:01 2015 +0530

----------------------------------------------------------------------
 .../opendaylight/api/NeutronRestApi.java        | 30 ++++++++++++++------
 .../cloud/utils/rest/RESTServiceConnector.java  | 24 +++++++++++-----
 .../ssl/EasySSLProtocolSocketFactory.java       | 30 ++++++++++++++------
 3 files changed, 59 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/125abe82/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java
index 63d81a8..528a4ac 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java
@@ -189,22 +189,28 @@ public class NeutronRestApi {
 
         @Override
         public Socket createSocket(final String host, final int port) throws IOException
{
-            SSLSocket s = (SSLSocket) ssf.createSocket(host, port);
-            s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+            Socket s = ssf.createSocket(host, port);
+            if (s instanceof SSLSocket) {
+                ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+            }
             return s;
         }
 
         @Override
         public Socket createSocket(final String address, final int port, final InetAddress
localAddress, final int localPort) throws IOException, UnknownHostException {
-            SSLSocket s = (SSLSocket) ssf.createSocket(address, port, localAddress, localPort);
-            s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+            Socket s = ssf.createSocket(address, port, localAddress, localPort);
+            if (s instanceof SSLSocket) {
+                ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+            }
             return s;
         }
 
         @Override
         public Socket createSocket(final Socket socket, final String host, final int port,
final boolean autoClose) throws IOException, UnknownHostException {
-            SSLSocket s = (SSLSocket) ssf.createSocket(socket, host, port, autoClose);
-            s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+            Socket s = ssf.createSocket(socket, host, port, autoClose);
+            if (s instanceof SSLSocket) {
+                ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+            }
             return s;
         }
 
@@ -213,10 +219,16 @@ public class NeutronRestApi {
                 UnknownHostException, ConnectTimeoutException {
             int timeout = params.getConnectionTimeout();
             if (timeout == 0) {
-                return createSocket(host, port, localAddress, localPort);
+                Socket s = createSocket(host, port, localAddress, localPort);
+                if (s instanceof SSLSocket) {
+                    ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+                }
+                return s;
             } else {
-                SSLSocket s = (SSLSocket) ssf.createSocket();
-                s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+                Socket s = ssf.createSocket();
+                if (s instanceof SSLSocket) {
+                    ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+                }
                 s.bind(new InetSocketAddress(localAddress, localPort));
                 s.connect(new InetSocketAddress(host, port), timeout);
                 return s;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/125abe82/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/RESTServiceConnector.java b/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
index 487610a..cdacd1f 100644
--- a/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
+++ b/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
@@ -356,15 +356,19 @@ public class RESTServiceConnector {
 
         @Override
         public Socket createSocket(final String address, final int port, final InetAddress
localAddress, final int localPort) throws IOException, UnknownHostException {
-            SSLSocket socket = (SSLSocket) ssf.createSocket(address, port, localAddress,
localPort);
-            socket.setEnabledProtocols(SSLUtils.getSupportedProtocols(socket.getEnabledProtocols()));
+            Socket socket = ssf.createSocket(address, port, localAddress, localPort);
+            if (socket instanceof SSLSocket) {
+                ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+            }
             return socket;
         }
 
         @Override
         public Socket createSocket(final Socket socket, final String host, final int port,
final boolean autoClose) throws IOException, UnknownHostException {
-            SSLSocket s = (SSLSocket) ssf.createSocket(socket, host, port, autoClose);
-            s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+            Socket s = ssf.createSocket(socket, host, port, autoClose);
+            if (s instanceof SSLSocket) {
+                ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+            }
             return s;
         }
 
@@ -373,10 +377,16 @@ public class RESTServiceConnector {
                 throws IOException, UnknownHostException, ConnectTimeoutException {
             final int timeout = params.getConnectionTimeout();
             if (timeout == 0) {
-                return createSocket(host, port, localAddress, localPort);
+                Socket socket = createSocket(host, port, localAddress, localPort);
+                if (socket instanceof SSLSocket) {
+                    ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+                }
+                return socket;
             } else {
-                final SSLSocket s = (SSLSocket) ssf.createSocket();
-                s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+                final Socket s = ssf.createSocket();
+                if (s instanceof SSLSocket) {
+                    ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+                }
                 s.bind(new InetSocketAddress(localAddress, localPort));
                 s.connect(new InetSocketAddress(host, port), timeout);
                 return s;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/125abe82/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
index d180f5d..5ff5819 100644
--- a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
+++ b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
@@ -122,8 +122,10 @@ public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory
{
      */
     @Override
     public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort)
throws IOException, UnknownHostException {
-        SSLSocket socket = (SSLSocket) getSSLContext().getSocketFactory().createSocket(host,
port, clientHost, clientPort);
-        socket.setEnabledProtocols(SSLUtils.getSupportedProtocols(socket.getEnabledProtocols()));
+        Socket socket = getSSLContext().getSocketFactory().createSocket(host, port, clientHost,
clientPort);
+        if (socket instanceof SSLSocket) {
+            ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+        }
         return socket;
     }
 
@@ -157,10 +159,16 @@ public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory
{
         int timeout = params.getConnectionTimeout();
         SocketFactory socketfactory = getSSLContext().getSocketFactory();
         if (timeout == 0) {
-            return socketfactory.createSocket(host, port, localAddress, localPort);
+            Socket socket = socketfactory.createSocket(host, port, localAddress, localPort);
+            if (socket instanceof SSLSocket) {
+                ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+            }
+            return socket;
         } else {
-            SSLSocket socket = (SSLSocket)  socketfactory.createSocket();
-            socket.setEnabledProtocols(SSLUtils.getSupportedProtocols(socket.getEnabledProtocols()));
+            Socket socket = socketfactory.createSocket();
+            if (socket instanceof SSLSocket) {
+                ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+            }
             SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
             SocketAddress remoteaddr = new InetSocketAddress(host, port);
             socket.bind(localaddr);
@@ -174,14 +182,18 @@ public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory
{
      */
     @Override
     public Socket createSocket(String host, int port) throws IOException, UnknownHostException
{
-        SSLSocket socket = (SSLSocket) getSSLContext().getSocketFactory().createSocket(host,
port);
-        socket.setEnabledProtocols(SSLUtils.getSupportedProtocols(socket.getEnabledProtocols()));
+        Socket socket = (Socket) getSSLContext().getSocketFactory().createSocket(host, port);
+        if (socket instanceof SSLSocket) {
+            ((SSLSocket)socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)socket).getEnabledProtocols()));
+        }
         return socket;
     }
 
     public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws
IOException, UnknownHostException {
-        SSLSocket s= (SSLSocket) getSSLContext().getSocketFactory().createSocket(socket,
host, port, autoClose);
-        s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
+        Socket s = getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose);
+        if (s instanceof SSLSocket) {
+            ((SSLSocket)s).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket)s).getEnabledProtocols()));
+        }
         return s;
     }
 


Mime
View raw message