Skip to content

Commit 2bff595

Browse files
committed
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 <rohit.yadav@shapeblue.com>
1 parent ef0adc1 commit 2bff595

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

plugins/network-elements/cisco-vnmc/src/com/cloud/network/cisco/CiscoVnmcConnectionImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,14 +1228,13 @@ public boolean unassignAsa1000v(String tenantName, String firewallDn) throws Exe
12281228
}
12291229

12301230
private String sendRequest(String service, String xmlRequest) throws ExecutionException {
1231-
org.apache.commons.httpclient.protocol.Protocol myhttps = null;
12321231
HttpClient client = new HttpClient();
12331232
byte[] response = null;
12341233
PostMethod method = new PostMethod("/xmlIM/" + service);
12351234
method.setRequestBody(xmlRequest);
12361235

12371236
try {
1238-
myhttps = new org.apache.commons.httpclient.protocol.Protocol("https", new EasySSLProtocolSocketFactory(), 443);
1237+
org.apache.commons.httpclient.protocol.Protocol myhttps = new org.apache.commons.httpclient.protocol.Protocol("https", new EasySSLProtocolSocketFactory(), 443);
12391238
client.getHostConfiguration().setHost(_ip, 443, myhttps);
12401239
int statusCode = client.executeMethod(method);
12411240

utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,26 @@
1919

2020
package org.apache.commons.httpclient.contrib.ssl;
2121

22+
import org.apache.commons.httpclient.ConnectTimeoutException;
23+
import org.apache.commons.httpclient.HttpClientError;
24+
import org.apache.commons.httpclient.params.HttpConnectionParams;
25+
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
26+
import org.apache.commons.logging.Log;
27+
import org.apache.commons.logging.LogFactory;
28+
29+
import javax.net.SocketFactory;
30+
import javax.net.ssl.SSLContext;
31+
import javax.net.ssl.TrustManager;
2232
import java.io.IOException;
2333
import java.net.InetAddress;
2434
import java.net.InetSocketAddress;
2535
import java.net.Socket;
2636
import java.net.SocketAddress;
2737
import java.net.UnknownHostException;
2838

29-
import javax.net.SocketFactory;
30-
import javax.net.ssl.SSLContext;
31-
import javax.net.ssl.TrustManager;
32-
33-
import org.apache.commons.httpclient.ConnectTimeoutException;
34-
import org.apache.commons.httpclient.HttpClientError;
35-
import org.apache.commons.httpclient.params.HttpConnectionParams;
36-
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
37-
import org.apache.commons.logging.Log;
38-
import org.apache.commons.logging.LogFactory;
39-
4039
/**
4140
* <p>
42-
* EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s
41+
* EasySSLProtocolSocketFactory can be used to create SSL {@link Socket}s
4342
* that accept self-signed certificates.
4443
* </p>
4544
* <p>
@@ -84,7 +83,7 @@
8483
* </p>
8584
*/
8685

87-
public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory {
86+
public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory {
8887

8988
/** Log object for this class. */
9089
private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class);
@@ -117,7 +116,7 @@ private SSLContext getSSLContext() {
117116
}
118117

119118
/**
120-
* @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
119+
* @see ProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
121120
*/
122121
@Override
123122
public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException {
@@ -167,17 +166,13 @@ public Socket createSocket(final String host, final int port, final InetAddress
167166
}
168167

169168
/**
170-
* @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
169+
* @see ProtocolSocketFactory#createSocket(java.lang.String,int)
171170
*/
172171
@Override
173172
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
174173
return getSSLContext().getSocketFactory().createSocket(host, port);
175174
}
176175

177-
/**
178-
* @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
179-
*/
180-
@Override
181176
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
182177
return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose);
183178
}

0 commit comments

Comments
 (0)