Fix SSLProtocolSocketFactory with HttpClient 3.1
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@505 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
a095d60835
commit
de3790a86b
|
@ -1,29 +1,29 @@
|
||||||
package davmail.http;
|
package davmail.http;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
|
import davmail.Settings;
|
||||||
|
import davmail.ui.tray.DavGatewayTray;
|
||||||
|
import org.apache.commons.httpclient.HttpsURL;
|
||||||
|
import org.apache.commons.httpclient.params.HttpConnectionParams;
|
||||||
import org.apache.commons.httpclient.protocol.Protocol;
|
import org.apache.commons.httpclient.protocol.Protocol;
|
||||||
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
|
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
|
||||||
import org.apache.commons.httpclient.HttpsURL;
|
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import davmail.Settings;
|
|
||||||
import davmail.ui.tray.DavGatewayTray;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manual Socket Factory.
|
* Manual Socket Factory.
|
||||||
* Let user choose to accept or reject certificate
|
* Let user choose to accept or reject certificate
|
||||||
*/
|
*/
|
||||||
public class DavGatewaySSLProtocolSocketFactory extends SSLProtocolSocketFactory {
|
public class DavGatewaySSLProtocolSocketFactory implements SecureProtocolSocketFactory {
|
||||||
/**
|
/**
|
||||||
* Register custom Socket Factory to let user accept or reject certificate
|
* Register custom Socket Factory to let user accept or reject certificate
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +73,18 @@ public class DavGatewaySSLProtocolSocketFactory extends SSLProtocolSocketFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort, HttpConnectionParams params) throws IOException {
|
||||||
|
try {
|
||||||
|
return getSSLContext().getSocketFactory().createSocket(host, port, clientHost, clientPort);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
throw new IOException(e+" "+e.getMessage());
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
throw new IOException(e+" "+e.getMessage());
|
||||||
|
} catch (KeyStoreException e) {
|
||||||
|
throw new IOException(e+" "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Socket createSocket(String host, int port) throws IOException {
|
public Socket createSocket(String host, int port) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
@ -86,7 +98,6 @@ public class DavGatewaySSLProtocolSocketFactory extends SSLProtocolSocketFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
|
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
|
||||||
try {
|
try {
|
||||||
return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose);
|
return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose);
|
||||||
|
|
Loading…
Reference in New Issue