blob: d4250351723f46c8b8e0fcb36f9d97304546148c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*******************************************************************************
* Copyright (c) 2008, 2017 compeople AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
* IBM Corporation - implementation
*******************************************************************************/
package org.eclipse.core.internal.net;
import java.net.URI;
import org.eclipse.core.internal.net.proxy.win32.winhttp.WinHttpProxyProvider;
import org.eclipse.core.net.proxy.IProxyData;
public class WindowsProxyProvider extends AbstractProxyProvider {
private static final String LIBRARY_NAME = "jWinHttp-1.0.0"; //$NON-NLS-1$
private static boolean jWinHttpLoaded = false;
static {
try {
System.loadLibrary(LIBRARY_NAME);
if (Policy.DEBUG_SYSTEM_PROVIDERS)
Policy.debug("Loaded " + LIBRARY_NAME + " library"); //$NON-NLS-1$ //$NON-NLS-2$
jWinHttpLoaded = true;
} catch (final UnsatisfiedLinkError e) {
Activator.logError(
"Could not load library: " + System.mapLibraryName(LIBRARY_NAME), e); //$NON-NLS-1$
}
}
private WinHttpProxyProvider winHttpProxyProvider;
public WindowsProxyProvider() {
if (jWinHttpLoaded) {
winHttpProxyProvider = new WinHttpProxyProvider();
} else {
winHttpProxyProvider = null;
}
}
@Override
public IProxyData[] select(URI uri) {
IProxyData[] proxies = new IProxyData[0];
if (jWinHttpLoaded) {
proxies = winHttpProxyProvider.getProxyData(uri);
}
if (Policy.DEBUG) {
Policy.debug("WindowsProxyProvider#select result for [" + uri + "]"); //$NON-NLS-1$ //$NON-NLS-2$
for (int i = 0; i < proxies.length; i++)
System.out.println(" " + proxies[i]); //$NON-NLS-1$
}
return proxies;
}
@Override
protected IProxyData[] getProxyData() {
if (jWinHttpLoaded) {
return winHttpProxyProvider.getProxyData();
}
return new IProxyData[0];
}
@Override
protected String[] getNonProxiedHosts() {
if (jWinHttpLoaded) {
return winHttpProxyProvider.getNonProxiedHosts();
}
return new String[0];
}
}
|