From 2bff5956a94057ecc75cd06180953479c60ae277 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 29 Aug 2014 14:38:42 +0200 Subject: [PATCH] cisco-vnmc: Don't create Protocol using deprecated SecureProtocolSocketFactory Latest httpclient library suggests when creating Protocol object for use with the apache common httpclient class, they should avoid using the deprecated Protocol signature which takes in SecureProtocolSocketFactory Signed-off-by: Rohit Yadav --- .../cisco/CiscoVnmcConnectionImpl.java | 3 +- .../ssl/EasySSLProtocolSocketFactory.java | 33 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java index e1caee549a4..0057e2e4da2 100644 --- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java +++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java @@ -1228,14 +1228,13 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection { } private String sendRequest(String service, String xmlRequest) throws ExecutionException { - org.apache.commons.httpclient.protocol.Protocol myhttps = null; HttpClient client = new HttpClient(); byte[] response = null; PostMethod method = new PostMethod("/xmlIM/" + service); method.setRequestBody(xmlRequest); try { - myhttps = new org.apache.commons.httpclient.protocol.Protocol("https", new EasySSLProtocolSocketFactory(), 443); + org.apache.commons.httpclient.protocol.Protocol myhttps = new org.apache.commons.httpclient.protocol.Protocol("https", new EasySSLProtocolSocketFactory(), 443); client.getHostConfiguration().setHost(_ip, 443, myhttps); int statusCode = client.executeMethod(method); 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 fab7d452b03..42650fcc257 100644 --- a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java +++ b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java @@ -19,6 +19,16 @@ package org.apache.commons.httpclient.contrib.ssl; +import org.apache.commons.httpclient.ConnectTimeoutException; +import org.apache.commons.httpclient.HttpClientError; +import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -26,20 +36,9 @@ import java.net.Socket; import java.net.SocketAddress; import java.net.UnknownHostException; -import javax.net.SocketFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.HttpClientError; -import org.apache.commons.httpclient.params.HttpConnectionParams; -import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** *

- * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s + * EasySSLProtocolSocketFactory can be used to create SSL {@link Socket}s * that accept self-signed certificates. *

*

@@ -84,7 +83,7 @@ import org.apache.commons.logging.LogFactory; *

*/ -public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory { +public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory { /** Log object for this class. */ private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class); @@ -117,7 +116,7 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory } /** - * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) + * @see ProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) */ @Override public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException { @@ -167,17 +166,13 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory } /** - * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) + * @see ProtocolSocketFactory#createSocket(java.lang.String,int) */ @Override public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return getSSLContext().getSocketFactory().createSocket(host, port); } - /** - * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) - */ - @Override public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose); }