Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: aec4489544e5da72edd78fc2c5541cc399f45c44 (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
/*******************************************************************************
 * Copyright (c) 2008, 2009 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;
		}
	}

	protected IProxyData[] getProxyData(URI uri) {
		if (jWinHttpLoaded) {
			return winHttpProxyProvider.getProxyData(uri);
		}
		return new IProxyData[0];
	}

	protected IProxyData[] getProxyData() {
		if (jWinHttpLoaded) {
			return winHttpProxyProvider.getProxyData();
		}
		return new IProxyData[0];
	}

	protected String[] getNonProxiedHosts() {
		if (jWinHttpLoaded) {
			return winHttpProxyProvider.getNonProxiedHosts();
		}
		return new String[0];
	}

}

Back to the top