Workaround for bug 3168560, synchronize system proxy access
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1612 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
9225305e48
commit
801148e890
|
@ -60,6 +60,7 @@ public final class DavGatewayHttpClientFacade {
|
|||
static final String IE_USER_AGENT = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
|
||||
static final int MAX_REDIRECTS = 10;
|
||||
static final Object LOCK = new Object();
|
||||
static final Object PROXY_LOCK = new Object();
|
||||
private static boolean needNTLM;
|
||||
|
||||
static final long ONE_MINUTE = 60000;
|
||||
|
@ -111,8 +112,8 @@ public final class DavGatewayHttpClientFacade {
|
|||
* Set credentials on HttpClient instance.
|
||||
*
|
||||
* @param httpClient httpClient instance
|
||||
* @param userName user name
|
||||
* @param password user password
|
||||
* @param userName user name
|
||||
* @param password user password
|
||||
*/
|
||||
public static void setCredentials(HttpClient httpClient, String userName, String password) {
|
||||
// some Exchange servers redirect to a different host for freebusy, use wide auth scope
|
||||
|
@ -165,22 +166,22 @@ public final class DavGatewayHttpClientFacade {
|
|||
if (useSystemProxies) {
|
||||
// get proxy for url from system settings
|
||||
System.setProperty("java.net.useSystemProxies", "true");
|
||||
try {
|
||||
List<Proxy> proxyList = ProxySelector.getDefault().select(new java.net.URI(url));
|
||||
if (!proxyList.isEmpty() && proxyList.get(0).address() != null) {
|
||||
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyList.get(0).address();
|
||||
proxyHost = inetSocketAddress.getHostName();
|
||||
proxyPort = inetSocketAddress.getPort();
|
||||
synchronized (PROXY_LOCK) {
|
||||
try {
|
||||
List<Proxy> proxyList = ProxySelector.getDefault().select(new java.net.URI(url));
|
||||
if (!proxyList.isEmpty() && proxyList.get(0).address() != null) {
|
||||
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyList.get(0).address();
|
||||
proxyHost = inetSocketAddress.getHostName();
|
||||
proxyPort = inetSocketAddress.getPort();
|
||||
|
||||
// we may still need authentication credentials
|
||||
proxyUser = Settings.getProperty("davmail.proxyUser");
|
||||
proxyPassword = Settings.getProperty("davmail.proxyPassword");
|
||||
// we may still need authentication credentials
|
||||
proxyUser = Settings.getProperty("davmail.proxyUser");
|
||||
proxyPassword = Settings.getProperty("davmail.proxyPassword");
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new DavMailException("LOG_INVALID_URL", url);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new DavMailException("LOG_INVALID_URL", url);
|
||||
}
|
||||
|
||||
|
||||
} else if (enableProxy) {
|
||||
proxyHost = Settings.getProperty("davmail.proxyHost");
|
||||
proxyPort = Settings.getIntProperty("davmail.proxyPort");
|
||||
|
@ -216,7 +217,7 @@ public final class DavGatewayHttpClientFacade {
|
|||
* Get Http Status code for the given URL
|
||||
*
|
||||
* @param httpClient httpClient instance
|
||||
* @param url url string
|
||||
* @param url url string
|
||||
* @return HttpStatus code
|
||||
* @throws IOException on error
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue