View | Details | Raw Unified | Return to bug 180921 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/net/ProxyData.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 83-86 Link Here
83
		requiresAuthentication = false;
83
		requiresAuthentication = false;
84
	}
84
	}
85
85
86
	public String toString() {
87
		StringBuffer stringBuffer = new StringBuffer();
88
		stringBuffer.append("host: "); //$NON-NLS-1$
89
		stringBuffer.append(host);
90
		stringBuffer.append(" port: "); //$NON-NLS-1$
91
		stringBuffer.append(port);
92
		stringBuffer.append(" user: "); //$NON-NLS-1$
93
		stringBuffer.append(user);
94
		stringBuffer.append(" password: "); //$NON-NLS-1$
95
		stringBuffer.append(password);
96
		stringBuffer.append(" reqAuth: "); //$NON-NLS-1$
97
		stringBuffer.append(requiresAuthentication);
98
		return stringBuffer.toString(); 
99
	}
100
86
}
101
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpCurrentUserIEProxyConfig.java (+95 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
/**
14
 * Wrapper for Win32 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG structure.
15
 * <p>
16
 * The fields will be written by the jni glue code.
17
 * </p>
18
 */
19
public class WinHttpCurrentUserIEProxyConfig {
20
21
	public boolean isAutoDetect;
22
23
	public String autoConfigUrl;
24
25
	public String proxy;
26
27
	public String proxyBypass;
28
29
	/**
30
	 * @return the autoConfigUrl
31
	 */
32
	public String getAutoConfigUrl() {
33
		return autoConfigUrl;
34
	}
35
36
	/**
37
	 * @return the isAutoDetect
38
	 */
39
	public boolean isAutoDetect() {
40
		return isAutoDetect;
41
	}
42
43
	/**
44
	 * @return the proxy
45
	 */
46
	public String getProxy() {
47
		return proxy;
48
	}
49
50
	/**
51
	 * @return the proxyBypass
52
	 */
53
	public String getProxyBypass() {
54
		return proxyBypass;
55
	}
56
57
	/**
58
	 * @see java.lang.Object#equals(java.lang.Object)
59
	 */
60
	public boolean equals(Object obj) {
61
		if (this == obj)
62
			return true;
63
		if (obj instanceof WinHttpCurrentUserIEProxyConfig) {
64
			WinHttpCurrentUserIEProxyConfig that= (WinHttpCurrentUserIEProxyConfig)obj;
65
			return (this.isAutoDetect == that.isAutoDetect) && equals(this.autoConfigUrl, that.autoConfigUrl) && equals(this.proxy, that.proxy) && equals(this.proxyBypass, that.proxyBypass);
66
		}
67
68
		return false;
69
	}
70
71
	/**
72
	 * Tests equality of the given strings.
73
	 * 
74
	 * @param sequence1 candidate 1, may be null
75
	 * @param sequence2 candidate 2, may be null
76
	 * @return true if both sequences are null or the sequences are equal
77
	 */
78
	private static final boolean equals(final CharSequence sequence1, final CharSequence sequence2) {
79
		if (sequence1 == sequence2) {
80
			return true;
81
		} else if (sequence1 == null || sequence2 == null) {
82
			return false;
83
		} else {
84
			return sequence1.equals(sequence2);
85
		}
86
	}
87
88
	/**
89
	 * @see java.lang.Object#hashCode()
90
	 */
91
	public int hashCode() {
92
		return (autoConfigUrl + proxy).hashCode();
93
	}
94
95
}
(-)src/org/eclipse/core/internal/net/WindowsProxyProvider.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net;
12
13
import java.net.URI;
14
15
import org.eclipse.core.internal.net.proxy.win32.winhttp.WinHttpProxyProvider;
16
import org.eclipse.core.net.proxy.IProxyData;
17
18
public class WindowsProxyProvider extends AbstractProxyProvider {
19
20
	static {
21
		System.loadLibrary("jWinHttp"); //$NON-NLS-1$
22
	}
23
24
	private WinHttpProxyProvider winHttpProxyProvider;
25
26
	public WindowsProxyProvider() {
27
		winHttpProxyProvider = new WinHttpProxyProvider();
28
		Activator.logInfo("WinProxyProvider initialized", null); //$NON-NLS-1$
29
	}
30
31
	protected IProxyData[] getProxyData(URI uri) {
32
		return winHttpProxyProvider.getProxyData(uri);
33
	}
34
35
}
(-)natives/win32/org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp.h (+69 lines)
Added Link Here
1
/* DO NOT EDIT THIS FILE - it is machine generated */
2
#include <jni.h>
3
/* Header for class org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp */
4
5
#ifndef _Included_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
6
#define _Included_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
7
#ifdef __cplusplus
8
extern "C" {
9
#endif
10
/*
11
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
12
 * Method:    open
13
 * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)I
14
 */
15
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_open
16
  (JNIEnv *, jclass, jstring, jint, jstring, jstring, jint);
17
18
/*
19
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
20
 * Method:    closeHandle
21
 * Signature: (I)Z
22
 */
23
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_closeHandle
24
  (JNIEnv *, jclass, jint);
25
26
/*
27
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
28
 * Method:    getIEProxyConfigForCurrentUser
29
 * Signature: (Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpCurrentUserIEProxyConfig;)Z
30
 */
31
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getIEProxyConfigForCurrentUser
32
  (JNIEnv *, jclass, jobject);
33
34
/*
35
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
36
 * Method:    getProxyForUrl
37
 * Signature: (ILjava/lang/String;Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpAutoProxyOptions;Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyInfo;)Z
38
 */
39
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getProxyForUrl
40
  (JNIEnv *, jclass, jint, jstring, jobject, jobject);
41
42
/*
43
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
44
 * Method:    detectAutoProxyConfigUrl
45
 * Signature: (Lorg/eclipse/core/internal/net/proxy/win32/winhttp/AutoProxyHolder;)Z
46
 */
47
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_detectAutoProxyConfigUrl
48
  (JNIEnv *, jclass, jobject);
49
50
/*
51
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
52
 * Method:    getLastError
53
 * Signature: ()I
54
 */
55
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getLastError
56
  (JNIEnv *, jclass);
57
58
/*
59
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
60
 * Method:    getLastErrorMessage
61
 * Signature: ()Ljava/lang/String;
62
 */
63
JNIEXPORT jstring JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getLastErrorMessage
64
  (JNIEnv *, jclass);
65
66
#ifdef __cplusplus
67
}
68
#endif
69
#endif
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java (+114 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
import java.net.URI;
14
import java.util.regex.Pattern;
15
16
/**
17
 * Encapsulates the windows specific proxy bypass list. It transforms the native API proxy bypass
18
 * list into queryable java object.
19
 * 
20
 * @see "http://msdn2.microsoft.com/en-us/library/aa383912(VS.85).aspx"
21
 */
22
public class ProxyBypass {
23
24
	private final String proxyBypass;
25
26
	private final Pattern proxyBypassPattern;
27
28
	private final static String BYPASS_LOCAL_ADDESSES_TOKEN= "<local>"; //$NON-NLS-1$
29
30
	/**
31
	 * Create a ProxyBypass instance from the proxy bypass list string.
32
	 * 
33
	 * @param proxyBypass
34
	 */
35
	public ProxyBypass(String proxyBypass) {
36
		this.proxyBypass= proxyBypass != null ? proxyBypass : ""; //$NON-NLS-1$
37
38
		if (proxyBypass != null) {
39
			String regExp= replace(proxyBypass, ";", "|"); //$NON-NLS-1$ //$NON-NLS-2$
40
			regExp= replace(regExp, ".", "\\."); //$NON-NLS-1$ //$NON-NLS-2$
41
			regExp= replace(regExp, "*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$
42
			this.proxyBypassPattern= Pattern.compile(regExp);
43
		} else {
44
			this.proxyBypassPattern= Pattern.compile(""); //$NON-NLS-1$
45
		}
46
	}
47
48
	/**
49
	 * Check whether the given uri should bypass the proxy.
50
	 * 
51
	 * @param uri
52
	 * @return true if the the uri should bypass the proxy; otherwise false
53
	 */
54
	public boolean bypassProxyFor(URI uri) {
55
		final String host= uri.getHost();
56
		if (host == null)
57
			return false;
58
		return (isLocal(host) && isBypassLocalAddresses(proxyBypass)) || isInBypassList(host);
59
	}
60
61
	/**
62
	 * @param proxyBypass
63
	 * @param uri
64
	 * @return
65
	 */
66
	private boolean isInBypassList(String host) {
67
		return proxyBypassPattern.matcher(host).matches();
68
	}
69
70
	/**
71
	 * @param uri
72
	 * @return
73
	 */
74
	private static boolean isLocal(String host) {
75
		return host.indexOf(".") == -1; //$NON-NLS-1$
76
	}
77
78
	/**
79
	 * @param addressListString
80
	 * @return
81
	 */
82
	private static boolean isBypassLocalAddresses(String proxyBypass) {
83
		return proxyBypass.indexOf(BYPASS_LOCAL_ADDESSES_TOKEN) != -1;
84
	}
85
86
	/**
87
	 * Replace within <code>source</code> the occurrences of <code>from</code> with
88
	 * <code>to</code>.
89
	 * 
90
	 * @param source
91
	 * @param from
92
	 * @param to
93
	 * @return the substituted string
94
	 */
95
	private static String replace(String source, String from, String to) {
96
		if (from.length() == 0)
97
			return source;
98
		StringBuffer buffer= new StringBuffer();
99
		int current= 0;
100
		int pos= 0;
101
		while (pos != -1) {
102
			pos= source.indexOf(from, current);
103
			if (pos == -1) {
104
				buffer.append(source.substring(current));
105
			} else {
106
				buffer.append(source.substring(current, pos));
107
				buffer.append(to);
108
				current= pos + from.length();
109
			}
110
		}
111
		return buffer.toString();
112
	}
113
114
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/AutoProxyHolder.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
/**
14
 * This holder class just helps passing parameters into a native function and retrieve information
15
 * from it.
16
 * <p>
17
 * The fields will be written/read by the jni glue code.
18
 * </p>
19
 */
20
public class AutoProxyHolder {
21
22
	public int autoDetectFlags;
23
24
	public String autoConfigUrl;
25
26
	/**
27
	 * Set the auto detect flags.
28
	 * 
29
	 * @param autoDetectFlags
30
	 */
31
	public void setAutoDetectFlags(int autoDetectFlags) {
32
		this.autoDetectFlags= autoDetectFlags;
33
	}
34
35
	/**
36
	 * Get the auto config url.
37
	 * 
38
	 * @return the auto config url (pac file)
39
	 */
40
	public String getAutoConfigUrl() {
41
		return autoConfigUrl;
42
	}
43
44
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpConfig.java (+60 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
import java.net.URI;
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
/**
20
 * WinHttpConfig unwraps the information from WinHttpCurrentIEProxyConfig.
21
 * <p>
22
 * The fields will be written by the jni glue code.
23
 * </p>
24
 */
25
public class WinHttpConfig {
26
27
	public List universalProxies= new ArrayList();
28
29
	public Map protocolSpecificProxies= new HashMap();
30
31
	public ProxyBypass proxyBypass;
32
33
	/**
34
	 * @param proxyConfig
35
	 */
36
	public WinHttpConfig(WinHttpCurrentUserIEProxyConfig proxyConfig) {
37
		ProxySelectorUtils.fillProxyLists(proxyConfig.getProxy(), universalProxies, protocolSpecificProxies);
38
		proxyBypass= new ProxyBypass(proxyConfig.getProxyBypass());
39
	}
40
41
	public boolean useUniversalProxy() {
42
		return !universalProxies.isEmpty();
43
	}
44
45
	public boolean useProtocolSpecificProxies() {
46
		return !protocolSpecificProxies.isEmpty();
47
	}
48
49
	public List getProtocolSpecificProxies(URI uri) {
50
		return (List)protocolSpecificProxies.get(uri.getScheme());
51
	}
52
53
	public List getUniversalProxies() {
54
		return universalProxies;
55
	}
56
57
	public boolean bypassProxyFor(URI uri) {
58
		return proxyBypass.bypassProxyFor(uri);
59
	}
60
}
(-)natives/win32/jWinHttp.cpp (+479 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
12
13
#if _MSC_VER > 1000
14
#pragma once
15
#endif // _MSC_VER > 1000
16
17
18
#define WIN32_LEAN_AND_MEAN	
19
20
#include <stdio.h>
21
#include <iostream>
22
#include <windows.h>
23
#include <winhttp.h>
24
#include <objbase.h>
25
26
#include <org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp.h>
27
28
using namespace std;
29
30
// Remember the GetLastError() after a failed WinHttp... call.
31
static int lastError;
32
33
BOOL APIENTRY DllMain( HANDLE hModule, 
34
                       DWORD  ul_reason_for_call, 
35
                       LPVOID lpReserved
36
					 ) {
37
    switch (ul_reason_for_call) {
38
		case DLL_PROCESS_ATTACH:
39
			#ifdef _DEBUG
40
				cout << "DLL_PROCESS_ATTACH - jWinHttp" << endl;
41
			#endif
42
			break;
43
		case DLL_THREAD_ATTACH:
44
			#ifdef _DEBUG
45
				cout << "DLL_THREAD_ATTACH - jWinHttp" << endl;
46
			#endif
47
			break;
48
		case DLL_THREAD_DETACH:
49
			#ifdef _DEBUG
50
				cout << "DLL_THREAD_DETACH - jWinHttp" << endl;
51
			#endif
52
			break;
53
		case DLL_PROCESS_DETACH:
54
			#ifdef _DEBUG
55
				cout << "DLL_PROCESS_DETACH - jWinHttp" << endl;
56
			#endif
57
			break;
58
    }
59
    return TRUE;
60
}
61
62
63
/*
64
 * Helper for some ugly things!
65
 * ............................
66
 */
67
68
const jchar * getStringChars( JNIEnv * env, jstring jString ) {
69
	if ( jString != NULL ) {
70
		return env->GetStringChars( jString, NULL );
71
	} else {
72
		return NULL;
73
	}
74
}
75
76
void releaseStringChars( JNIEnv * env, jstring jString, const jchar * jCharString ) {
77
	if ( jString != NULL ) {
78
		env->ReleaseStringChars( jString, jCharString );
79
	}
80
}
81
82
jobject newString( JNIEnv * env, LPWSTR string ) {
83
	return env->NewString( (const jchar *)string, lstrlenW( string ) );
84
}
85
86
void setStringField( JNIEnv * env, jclass jClass, jobject jObject, const char * field, LPWSTR value ) {
87
	if ( value != NULL ) {
88
		jfieldID jFieldId = env->GetFieldID( jClass, field, "Ljava/lang/String;" );
89
		env->SetObjectField( jObject, jFieldId, newString( env, value ) );
90
		GlobalFree( value );
91
	}
92
}
93
94
jstring getStringField( JNIEnv * env, jclass jClass, jobject jObject, const char * field ) {
95
	jfieldID jFieldId = env->GetFieldID( jClass, field, "Ljava/lang/String;" );
96
	return (jstring)env->GetObjectField( jObject, jFieldId );
97
}
98
99
void setBooleanField( JNIEnv * env, jclass jClass, jobject jObject, const char * field, BOOL value ) {
100
	jfieldID jFieldId = env->GetFieldID( jClass, field, "Z" );
101
	env->SetBooleanField( jObject, jFieldId, value );
102
}
103
104
jboolean getBooleanField( JNIEnv * env, jclass jClass, jobject jObject, const char * field ) {
105
	jfieldID jFieldId = env->GetFieldID( jClass, field, "Z" );
106
	return env->GetBooleanField( jObject, jFieldId );
107
}
108
109
void setIntField( JNIEnv * env, jclass jClass, jobject jObject, const char * field, jint value ) {
110
	jfieldID jFieldId = env->GetFieldID( jClass, field, "I" );
111
	env->SetIntField( jObject, jFieldId, value );
112
}
113
114
jint getIntField( JNIEnv * env, jclass jClass, jobject jObject, const char * field ) {
115
	jfieldID jFieldId = env->GetFieldID( jClass, field, "I" );
116
	return env->GetIntField( jObject, jFieldId );
117
}
118
119
#ifdef _DEBUG
120
	LPCWSTR null( const LPCWSTR string ) {
121
		if ( string == NULL ) {
122
			return (LPCWSTR) L"null";
123
		} else {
124
			return string;
125
		}
126
	}
127
128
	LPWSTR null( const LPWSTR string ) {
129
		if ( string == NULL ) {
130
			return (LPWSTR) L"null";
131
		} else {
132
			return string;
133
		}
134
	}
135
#endif
136
137
/*
138
 * The real ugly work goes on here!
139
 * ................................
140
 */
141
142
143
/*
144
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
145
 * Method:    open
146
 * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)I
147
 */
148
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_open
149
  (JNIEnv * env, jclass jClass, jstring jUserAgent, jint jAccessType, jstring jProxyName, jstring jProxyBypass, jint jFlags ) {
150
151
	#ifdef _DEBUG
152
		cout << "WinHttp_open - entered" << endl;
153
	#endif
154
155
	const jchar * userAgent = (const jchar *) L"jWinHttp Java Wrapper";
156
	const jchar * proxyName = NULL;
157
	const jchar * proxyBypass = NULL;
158
159
	userAgent = getStringChars( env, jUserAgent );
160
	proxyName = getStringChars( env, jProxyName );
161
	proxyBypass = getStringChars( env, jProxyBypass );
162
163
	CoInitialize( NULL );    // --> http://support.microsoft.com/?kbid=834742
164
165
	int hInternet = (int) WinHttpOpen( (LPCWSTR)userAgent, jAccessType, (LPCWSTR)proxyName, (LPCWSTR)proxyBypass, jFlags );
166
167
	if ( hInternet == NULL ) {
168
		lastError = GetLastError();
169
		#ifdef _DEBUG
170
			cout << "WinHttpOpen() failed with " << lastError << endl; 
171
		#endif
172
	} else {
173
		lastError = 0;
174
	}
175
176
177
	#ifdef _DEBUG
178
		cout << "WinHttpOpen() returned: " << hInternet << endl;
179
	#endif
180
	
181
182
	releaseStringChars( env, jUserAgent, userAgent );
183
	releaseStringChars( env, jProxyName, proxyName );
184
	releaseStringChars( env, jProxyBypass, proxyBypass );
185
	
186
	#ifdef _DEBUG
187
		cout << "WinHttp_open - exit" << endl;
188
	#endif
189
190
	return hInternet;
191
}
192
193
/*
194
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
195
 * Method:    closeHandle
196
 * Signature: (I)Z
197
 */
198
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_closeHandle
199
  (JNIEnv * env, jclass jClass, jint jInternet) {
200
201
	#ifdef _DEBUG
202
		cout << "WinHttp_closeHandle - entered" << endl;
203
	#endif
204
205
	BOOL ok = WinHttpCloseHandle( (void *) jInternet );
206
207
	if ( ! ok ) {
208
		lastError = GetLastError();
209
		#ifdef _DEBUG
210
			cout << "WinHttpClose() failed with " << lastError << endl; 
211
		#endif
212
	} else {
213
		lastError = 0;
214
	}
215
216
	CoUninitialize();
217
218
	#ifdef _DEBUG
219
		cout << "WinHttp_closeHandle - exit" << endl;
220
	#endif
221
222
	return ok;
223
}
224
225
/*
226
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
227
 * Method:    getIEProxyConfigForCurrentUser
228
 * Signature: (Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpCurrentUserIEProxyConfig;)Z
229
 */
230
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getIEProxyConfigForCurrentUser
231
  (JNIEnv * env, jclass jClass, jobject jWinHttpCurrentUserIEProxyConfig)  {
232
233
	#ifdef _DEBUG
234
		cout << "WinHttp_getIEProxyConfigForCurrentUser - entered" << endl;
235
	#endif
236
237
	WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig;
238
	ZeroMemory( &proxyConfig, sizeof( proxyConfig ) );
239
240
	BOOL ok = WinHttpGetIEProxyConfigForCurrentUser( &proxyConfig );
241
242
	if ( ! ok ) {
243
		lastError = GetLastError();
244
		#ifdef _DEBUG
245
			cout << "HttpGetIEProxyConfigForCurrentUser() failed with " << lastError << endl; 
246
		#endif
247
	}
248
249
	if ( ok ) {
250
251
		#ifdef _DEBUG
252
			cout << "proxyConfig.fAutoDetect: " << proxyConfig.fAutoDetect << endl;
253
			wcout << L"proxyConfig.lpszProxy: " << null( proxyConfig.lpszProxy ) << endl;
254
			wcout << L"proxyConfig.lpszProxyBypass: " << null( proxyConfig.lpszProxyBypass ) << endl;
255
		#endif
256
257
		lastError = 0;
258
		jclass jWinHttpCurrentUserIEProxyConfigClass = env->GetObjectClass( jWinHttpCurrentUserIEProxyConfig );
259
		setBooleanField( env,jWinHttpCurrentUserIEProxyConfigClass, jWinHttpCurrentUserIEProxyConfig, "isAutoDetect", proxyConfig.fAutoDetect );
260
		setStringField( env, jWinHttpCurrentUserIEProxyConfigClass, jWinHttpCurrentUserIEProxyConfig, "autoConfigUrl", proxyConfig.lpszAutoConfigUrl );
261
		setStringField( env, jWinHttpCurrentUserIEProxyConfigClass, jWinHttpCurrentUserIEProxyConfig, "proxy", proxyConfig.lpszProxy );
262
		setStringField( env, jWinHttpCurrentUserIEProxyConfigClass, jWinHttpCurrentUserIEProxyConfig, "proxyBypass", proxyConfig.lpszProxyBypass );
263
	}
264
265
266
	#ifdef _DEBUG
267
		cout << "WinHttp_getIEProxyConfigForCurrentUser - exit" << endl;
268
	#endif
269
270
	return ok;
271
}
272
273
/*
274
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
275
 * Method:    getProxyForUrl
276
 * Signature: (ILjava/lang/String;Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpAutoProxyOptions;Lorg/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyInfo;)Z
277
 */
278
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getProxyForUrl
279
  (JNIEnv * env, jclass jClass, jint jInternet, jstring jUrl, jobject jWinHttpAutoProxyOptions, jobject jWinHttpProxyInfo )  {
280
281
	#ifdef _DEBUG
282
		cout << "WinHttp_getProxyForUrl - entered" << endl;
283
	#endif
284
285
	WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions;
286
	ZeroMemory( &autoProxyOptions, sizeof( autoProxyOptions ) );
287
288
	jclass jWinHttpAutoProxyOptionsClass = env->GetObjectClass( jWinHttpAutoProxyOptions );
289
290
	autoProxyOptions.dwFlags = getIntField( env, jWinHttpAutoProxyOptionsClass, jWinHttpAutoProxyOptions, "flags" );
291
	autoProxyOptions.dwAutoDetectFlags = getIntField( env, jWinHttpAutoProxyOptionsClass, jWinHttpAutoProxyOptions, "autoDetectFlags" );
292
	jstring jAutoConfigUrl = getStringField( env, jWinHttpAutoProxyOptionsClass, jWinHttpAutoProxyOptions, "autoConfigUrl" );
293
	autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)getStringChars( env, jAutoConfigUrl );
294
295
	// The ´reserved´ fields will not be transfered!
296
	// - String reservedPointer
297
	// - int reservedInt
298
299
	autoProxyOptions.fAutoLogonIfChallenged = getBooleanField( env, jWinHttpAutoProxyOptionsClass, jWinHttpAutoProxyOptions, "autoLogonIfChallenged" );
300
301
	#ifdef _DEBUG
302
		cout << "autoProxyOptions.dwFlags: " << autoProxyOptions.dwFlags << endl;
303
		cout << "autoProxyOptions.dwAutoDetectFlags: " << autoProxyOptions.dwAutoDetectFlags << endl;
304
		wcout << L"autoProxyOptions.lpszAutoConfigUrl: " << null( autoProxyOptions.lpszAutoConfigUrl ) << endl;
305
		cout << "autoProxyOptions.fAutoLogonIfChallenged: " << autoProxyOptions.fAutoLogonIfChallenged << endl;
306
	#endif
307
308
	WINHTTP_PROXY_INFO proxyInfo;
309
	ZeroMemory( &proxyInfo, sizeof( proxyInfo ) );
310
311
	const jchar * url = getStringChars( env, jUrl );
312
313
	BOOL ok = WinHttpGetProxyForUrl( (void *)jInternet, (LPCWSTR)url, &autoProxyOptions, &proxyInfo );
314
315
	if ( ! ok ) {
316
		lastError = GetLastError();
317
		#ifdef _DEBUG
318
			cout << "WinHttpGetProxyForUrl() failed with " << lastError << endl; 
319
		#endif
320
	}
321
322
	releaseStringChars( env, jUrl, url );
323
	releaseStringChars( env, jAutoConfigUrl, (const jchar *)autoProxyOptions.lpszAutoConfigUrl );
324
325
	if ( ok ) {
326
		lastError = 0;
327
		jclass jWinHttpProxyInfoClass = env->GetObjectClass( jWinHttpProxyInfo );
328
329
		#ifdef _DEBUG
330
			cout << "proxyInfo.dwAccessType: " << proxyInfo.dwAccessType << endl;
331
			wcout << L"proxyInfo.lpszProxy: " << null( proxyInfo.lpszProxy ) << endl;
332
			wcout << L"proxyInfo.lpszProxyBypass: " << null( proxyInfo.lpszProxyBypass ) << endl;
333
		#endif
334
335
		setIntField( env, jWinHttpProxyInfoClass, jWinHttpProxyInfo, "accessType", proxyInfo.dwAccessType );
336
		setStringField( env, jWinHttpProxyInfoClass, jWinHttpProxyInfo, "proxy", proxyInfo.lpszProxy );
337
		setStringField( env, jWinHttpProxyInfoClass, jWinHttpProxyInfo, "proxyBypass", proxyInfo.lpszProxyBypass );
338
	}
339
340
	#ifdef _DEBUG
341
		cout << "WinHttp_getProxyForUrl - exit" << endl;
342
	#endif
343
344
	return ok;
345
}
346
347
/*
348
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
349
 * Method:    detectAutoProxyConfigUrl
350
 * Signature: (Lorg/eclipse/core/internal/net/proxy/win32/winhttp/AutoProxyHolder;)Z
351
 */
352
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_detectAutoProxyConfigUrl
353
  (JNIEnv * env, jclass jClass, jobject jAutoProxyHolder) {
354
355
	#ifdef _DEBUG
356
		cout << "WinHttp_detectAutoProxyConfigUrl - entered" << endl;
357
	#endif
358
359
	jclass jAutoProxyHolderClass = env->GetObjectClass( jAutoProxyHolder );
360
	DWORD dwAutoDetectFlags = getIntField( env, jAutoProxyHolderClass, jAutoProxyHolder, "autoDetectFlags" );
361
362
	#ifdef _DEBUG
363
		cout << "autoProxyHolder.autoDetectFlags: " << dwAutoDetectFlags << endl;
364
	#endif
365
366
	LPWSTR pwszAutoConfigUrl;
367
368
	BOOL ok = WinHttpDetectAutoProxyConfigUrl( dwAutoDetectFlags, &pwszAutoConfigUrl );
369
370
	if ( ! ok ) {
371
		lastError = GetLastError();
372
		#ifdef _DEBUG
373
			cout << "WinHttpDetectAutoProxyConfigUrl() failed with " << lastError << endl; 
374
		#endif
375
	}
376
377
	if ( ok ) {
378
		lastError = 0;
379
380
		#ifdef _DEBUG
381
			wcout << L"autoConfigUrl: " << null( pwszAutoConfigUrl ) << endl;
382
		#endif
383
384
		setStringField( env, jAutoProxyHolderClass, jAutoProxyHolder, "autoConfigUrl", pwszAutoConfigUrl );
385
	}
386
387
	#ifdef _DEBUG
388
		cout << "WinHttp_detectAutoProxyConfigUrl - exit" << endl;
389
	#endif
390
391
	return ok;
392
}
393
394
395
/*
396
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
397
 * Method:    getLastError
398
 * Signature: ()I
399
 */
400
JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getLastError
401
  (JNIEnv * env, jclass jClass) {
402
403
	#ifdef _DEBUG
404
		cout << "WinHttp_getLastError - entered" << endl;
405
	#endif
406
407
	#ifdef _DEBUG
408
		cout << "WinHttp_getLastError - exit" << endl;
409
	#endif
410
411
	return lastError;
412
}
413
414
/*
415
 * Class:     org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp
416
 * Method:    getLastErrorMessage
417
 * Signature: ()Ljava/lang/String;
418
 */
419
JNIEXPORT jstring JNICALL Java_org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp_getLastErrorMessage
420
  (JNIEnv * env, jclass jClass) {
421
422
	#ifdef _DEBUG
423
		cout << "WinHttp_getLastErrorMessage - entered" << endl;
424
	#endif
425
426
	LPVOID lpMsgBuf = NULL;
427
	DWORD result = 0;
428
429
	if ( lastError >= WINHTTP_ERROR_BASE && lastError <= WINHTTP_ERROR_LAST ) {
430
		HMODULE hModule = GetModuleHandle( "winhttp.dll" );
431
432
		if ( hModule == NULL ) {
433
			lpMsgBuf = "Could not retrieve error message, because ´GetModuleHandle( \"winhttp.dll\" )´ failed.";
434
		} else {
435
			result = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | 
436
									FORMAT_MESSAGE_FROM_HMODULE | 
437
									FORMAT_MESSAGE_IGNORE_INSERTS,
438
									hModule,
439
									lastError,
440
									MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
441
					 				(LPTSTR) &lpMsgBuf,
442
									0,
443
									NULL );
444
		}
445
446
	} else {
447
		result = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | 
448
								FORMAT_MESSAGE_FROM_SYSTEM | 
449
								FORMAT_MESSAGE_IGNORE_INSERTS,
450
								NULL,
451
								lastError,
452
								MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
453
					 			(LPTSTR) &lpMsgBuf,
454
								0,
455
								NULL );
456
	}
457
		
458
	if ( lpMsgBuf == NULL ) {	
459
		#ifdef _DEBUG
460
			cout << "WinHttp_getLastErrorMessage() failed with " << GetLastError() << " for error code " << lastError << endl; 
461
		#endif
462
463
		lpMsgBuf = "Could not retrieve error message.";
464
	}
465
466
	jstring string = env->NewStringUTF( (char *) lpMsgBuf );
467
468
	if ( result > 0 ) {
469
		// Free dynamically allocated buffer
470
		LocalFree( lpMsgBuf );
471
	}
472
473
	#ifdef _DEBUG
474
		cout << "WinHttp_getLastErrorMessage - exit" << endl;
475
	#endif
476
477
	return string;
478
}
479
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyInfo.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
/**
14
 * Wrapper for Win32 WINHTTP_PROXY_INFO Structure.
15
 * <p>
16
 * The fields will be written by the jni glue code.
17
 * </p>
18
 */
19
public class WinHttpProxyInfo {
20
21
	// WinHttpOpen dwAccessType values (also for
22
	// WINHTTP_PROXY_INFO::dwAccessType)
23
	public static final int WINHTTP_ACCESS_TYPE_DEFAULT_PROXY= 0;
24
25
	public static final int WINHTTP_ACCESS_TYPE_NO_PROXY= 1;
26
27
	public static final int WINHTTP_ACCESS_TYPE_NAMED_PROXY= 3;
28
29
	public int accessType;
30
31
	public String proxy;
32
33
	public String proxyBypass;
34
35
	/**
36
	 * @return the accessType
37
	 */
38
	public int getAccessType() {
39
		return accessType;
40
	}
41
42
	/**
43
	 * @return the proxy
44
	 */
45
	public String getProxy() {
46
		return proxy;
47
	}
48
49
	/**
50
	 * @return the proxyBypass
51
	 */
52
	public String getProxyBypass() {
53
		return proxyBypass;
54
	}
55
56
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java (+164 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
import java.net.URI;
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.List;
17
18
import org.eclipse.core.internal.net.Activator;
19
import org.eclipse.core.internal.net.ProxyData;
20
import org.eclipse.core.net.proxy.IProxyData;
21
22
/**
23
 * The provider that gets its settings from the "internet options >> connection settings". For this
24
 * it uses the Windows WinHttp API.
25
 * 
26
 * @see "http://msdn2.microsoft.com/en-us/library/aa382925(VS.85).aspx"
27
 */
28
public class WinHttpProxyProvider {
29
30
	private WinHttpCurrentUserIEProxyConfig proxyConfig= null;
31
32
	private WinHttpConfig winHttpConfig;
33
34
	private String wpadAutoConfigUrl;
35
36
	private boolean retryWpad= false;
37
38
	private static final ProxyData[] EMPTY_PROXIES= new ProxyData[0];
39
40
	private static final String MY_NAME= WinHttpProxyProvider.class.getName();
41
42
	/**
43
	 * Retrieve the proxies that are suitable for the given uri. An empty array of proxies indicates
44
	 * that no proxy should be used. This method considers already the ´no proxy for´ definition of
45
	 * the internet options dialog.
46
	 * 
47
	 * @param uri
48
	 * @return an array of proxies
49
	 */
50
	public IProxyData[] getProxyData(URI uri) {
51
		WinHttpCurrentUserIEProxyConfig newProxyConfig= new WinHttpCurrentUserIEProxyConfig();
52
		if (!WinHttp.getIEProxyConfigForCurrentUser(newProxyConfig)) {
53
			Activator.logError("WinHttp.GetIEProxyConfigForCurrentUser failed with error '" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
54
			return EMPTY_PROXIES;
55
		}
56
57
		if (proxyConfig == null) {
58
			proxyConfig= newProxyConfig;
59
			retryWpad= proxyConfig.isAutoDetect();
60
		}
61
62
		// Let´s find out if auto detect has changed.
63
		if (newProxyConfig.isAutoDetect() != proxyConfig.isAutoDetect())
64
			retryWpad= proxyConfig.isAutoDetect();
65
66
		boolean proxyConfigChanged= !newProxyConfig.equals(proxyConfig);
67
68
		if (proxyConfigChanged)
69
			proxyConfig= newProxyConfig;
70
71
		List proxies= new ArrayList();
72
73
		// Explicit proxies defined?
74
		if (proxyConfig.getProxy() != null && proxyConfig.getProxy().length() != 0) {
75
			// Yes, let´s see if we are still up-to-date or not yet initialized.
76
			if (proxyConfigChanged || winHttpConfig == null) {
77
				winHttpConfig= new WinHttpConfig(proxyConfig);
78
			}
79
80
			if (!winHttpConfig.bypassProxyFor(uri)) {
81
				if (winHttpConfig.useProtocolSpecificProxies()) {
82
					List protocolSpecificProxies= winHttpConfig.getProtocolSpecificProxies(uri);
83
					if (protocolSpecificProxies != null) {
84
						proxies.addAll(protocolSpecificProxies);
85
					}
86
				} else {
87
					proxies.addAll(winHttpConfig.getUniversalProxies());
88
				}
89
			}
90
		}
91
92
		boolean isPac= proxyConfig.getAutoConfigUrl() != null;
93
		boolean isWpad= proxyConfig.isAutoDetect();
94
95
		if (!isPac && !isWpad)
96
			return toArray(proxies);
97
98
		// Create the WinHTTP session.
99
		int hHttpSession= WinHttp.open(MY_NAME, WinHttpProxyInfo.WINHTTP_ACCESS_TYPE_NO_PROXY, WinHttp.NO_PROXY_NAME, WinHttp.NO_PROXY_BYPASS, 0);
100
		if (hHttpSession == 0) {
101
			Activator.logError("WinHttp.Open failed with error'" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
102
			return toArray(proxies);
103
		}
104
105
		try {
106
			// PAC file?
107
			if (isPac) {
108
				proxies.addAll(pacSelect(hHttpSession, uri));
109
			}
110
111
			// WPAD?
112
			if (isWpad) {
113
				proxies.addAll(wpadSelect(hHttpSession, uri));
114
			}
115
		} finally {
116
			WinHttp.closeHandle(hHttpSession);
117
		}
118
119
		return toArray(proxies);
120
	}
121
122
	private static IProxyData[] toArray(List proxies) {
123
		return (IProxyData[])proxies.toArray(new IProxyData[proxies.size()]);
124
	}
125
126
	protected List pacSelect(int hHttpSession, URI uri) {
127
		return pacSelect(hHttpSession, proxyConfig.getAutoConfigUrl(), uri);
128
	}
129
130
	protected List pacSelect(int hHttpSession, String configUrl, URI uri) {
131
		// Set up the autoproxy call.
132
		WinHttpAutoProxyOptions autoProxyOptions= new WinHttpAutoProxyOptions();
133
		autoProxyOptions.setFlags(WinHttpAutoProxyOptions.WINHTTP_AUTOPROXY_CONFIG_URL);
134
		autoProxyOptions.setAutoConfigUrl(configUrl);
135
		autoProxyOptions.setAutoLogonIfChallenged(true);
136
		WinHttpProxyInfo proxyInfo= new WinHttpProxyInfo();
137
138
		boolean ok= WinHttp.getProxyForUrl(hHttpSession, uri.toString(), autoProxyOptions, proxyInfo);
139
		if (!ok) {
140
			Activator.logError("WinHttp.GetProxyForUrl for pac failed with error '" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
141
			return Collections.EMPTY_LIST;
142
		}
143
		ProxyBypass proxyBypass= new ProxyBypass(proxyInfo.getProxyBypass());
144
		if (proxyBypass.bypassProxyFor(uri))
145
			return Collections.EMPTY_LIST;
146
		return ProxySelectorUtils.getProxies(proxyInfo.getProxy());
147
	}
148
149
	protected List wpadSelect(int hHttpSession, URI uri) {
150
		if (wpadAutoConfigUrl == null || retryWpad) {
151
			AutoProxyHolder autoProxyHolder= new AutoProxyHolder();
152
			autoProxyHolder.setAutoDetectFlags(WinHttpAutoProxyOptions.WINHTTP_AUTO_DETECT_TYPE_DHCP | WinHttpAutoProxyOptions.WINHTTP_AUTO_DETECT_TYPE_DNS_A);
153
			boolean ok= WinHttp.detectAutoProxyConfigUrl(autoProxyHolder);
154
			if (!ok) {
155
				Activator.logError("WinHttp.DetectAutoProxyConfigUrl for wpad failed with error '" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
156
				return Collections.EMPTY_LIST;
157
			}
158
			wpadAutoConfigUrl= autoProxyHolder.getAutoConfigUrl();
159
			retryWpad= false;
160
		}
161
		return pacSelect(hHttpSession, wpadAutoConfigUrl, uri);
162
	}
163
164
}
(-)natives/win32/jWinHttp.vcproj (+252 lines)
Added Link Here
1
<?xml version="1.0" encoding="Windows-1252"?>
2
<VisualStudioProject
3
	ProjectType="Visual C++"
4
	Version="9,00"
5
	Name="jWinHttp"
6
	ProjectGUID="{463DB2C1-6B11-4DC9-A29D-E3AD15E5FAD1}"
7
	TargetFrameworkVersion="0"
8
	>
9
	<Platforms>
10
		<Platform
11
			Name="Win32"
12
		/>
13
	</Platforms>
14
	<ToolFiles>
15
	</ToolFiles>
16
	<Configurations>
17
		<Configuration
18
			Name="Debug|Win32"
19
			OutputDirectory=".\Debug"
20
			IntermediateDirectory=".\Debug"
21
			ConfigurationType="2"
22
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
23
			UseOfMFC="0"
24
			ATLMinimizesCRunTimeLibraryUsage="false"
25
			CharacterSet="2"
26
			>
27
			<Tool
28
				Name="VCPreBuildEventTool"
29
			/>
30
			<Tool
31
				Name="VCCustomBuildTool"
32
			/>
33
			<Tool
34
				Name="VCXMLDataGeneratorTool"
35
			/>
36
			<Tool
37
				Name="VCWebServiceProxyGeneratorTool"
38
			/>
39
			<Tool
40
				Name="VCMIDLTool"
41
				PreprocessorDefinitions="_DEBUG"
42
				MkTypLibCompatible="true"
43
				SuppressStartupBanner="true"
44
				TargetEnvironment="1"
45
				TypeLibraryName=".\Debug/jWinHttp.tlb"
46
				HeaderFileName=""
47
			/>
48
			<Tool
49
				Name="VCCLCompilerTool"
50
				Optimization="0"
51
				AdditionalIncludeDirectories="include"
52
				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;WINHTTP_EXPORTS"
53
				MinimalRebuild="true"
54
				BasicRuntimeChecks="3"
55
				RuntimeLibrary="1"
56
				UsePrecompiledHeader="0"
57
				AssemblerListingLocation=".\Debug/"
58
				ObjectFile=".\Debug/"
59
				ProgramDataBaseFileName=".\Debug/"
60
				BrowseInformation="1"
61
				WarningLevel="3"
62
				SuppressStartupBanner="true"
63
				DebugInformationFormat="4"
64
			/>
65
			<Tool
66
				Name="VCManagedResourceCompilerTool"
67
			/>
68
			<Tool
69
				Name="VCResourceCompilerTool"
70
				PreprocessorDefinitions="_DEBUG"
71
				Culture="1031"
72
			/>
73
			<Tool
74
				Name="VCPreLinkEventTool"
75
			/>
76
			<Tool
77
				Name="VCLinkerTool"
78
				AdditionalDependencies="odbc32.lib odbccp32.lib winhttp.lib"
79
				OutputFile=".\Debug/jWinHttp.dll"
80
				LinkIncremental="2"
81
				SuppressStartupBanner="true"
82
				GenerateDebugInformation="true"
83
				ProgramDatabaseFile=".\Debug/jWinHttp.pdb"
84
				ImportLibrary=".\Debug/jWinHttp.lib"
85
				TargetMachine="1"
86
			/>
87
			<Tool
88
				Name="VCALinkTool"
89
			/>
90
			<Tool
91
				Name="VCManifestTool"
92
			/>
93
			<Tool
94
				Name="VCXDCMakeTool"
95
			/>
96
			<Tool
97
				Name="VCBscMakeTool"
98
				SuppressStartupBanner="true"
99
				OutputFile=".\Debug/jWinHttp.bsc"
100
			/>
101
			<Tool
102
				Name="VCFxCopTool"
103
			/>
104
			<Tool
105
				Name="VCAppVerifierTool"
106
			/>
107
			<Tool
108
				Name="VCPostBuildEventTool"
109
			/>
110
		</Configuration>
111
		<Configuration
112
			Name="Release|Win32"
113
			OutputDirectory=".\Release"
114
			IntermediateDirectory=".\Release"
115
			ConfigurationType="2"
116
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
117
			UseOfMFC="0"
118
			ATLMinimizesCRunTimeLibraryUsage="false"
119
			CharacterSet="2"
120
			>
121
			<Tool
122
				Name="VCPreBuildEventTool"
123
			/>
124
			<Tool
125
				Name="VCCustomBuildTool"
126
			/>
127
			<Tool
128
				Name="VCXMLDataGeneratorTool"
129
			/>
130
			<Tool
131
				Name="VCWebServiceProxyGeneratorTool"
132
			/>
133
			<Tool
134
				Name="VCMIDLTool"
135
				PreprocessorDefinitions="NDEBUG"
136
				MkTypLibCompatible="true"
137
				SuppressStartupBanner="true"
138
				TargetEnvironment="1"
139
				TypeLibraryName=".\Release/jWinHttp.tlb"
140
				HeaderFileName=""
141
			/>
142
			<Tool
143
				Name="VCCLCompilerTool"
144
				Optimization="2"
145
				InlineFunctionExpansion="1"
146
				AdditionalIncludeDirectories="include"
147
				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;WINHTTP_EXPORTS"
148
				StringPooling="true"
149
				RuntimeLibrary="0"
150
				EnableFunctionLevelLinking="true"
151
				UsePrecompiledHeader="0"
152
				AssemblerListingLocation=".\Release/"
153
				ObjectFile=".\Release/"
154
				ProgramDataBaseFileName=".\Release/"
155
				WarningLevel="3"
156
				SuppressStartupBanner="true"
157
			/>
158
			<Tool
159
				Name="VCManagedResourceCompilerTool"
160
			/>
161
			<Tool
162
				Name="VCResourceCompilerTool"
163
				PreprocessorDefinitions="NDEBUG"
164
				Culture="1031"
165
				AdditionalIncludeDirectories="include"
166
			/>
167
			<Tool
168
				Name="VCPreLinkEventTool"
169
			/>
170
			<Tool
171
				Name="VCLinkerTool"
172
				AdditionalDependencies="winhttp.lib"
173
				OutputFile=".\Release/jWinHttp.dll"
174
				LinkIncremental="1"
175
				SuppressStartupBanner="true"
176
				ProgramDatabaseFile=".\Release/jWinHttp.pdb"
177
				ImportLibrary=".\Release/jWinHttp.lib"
178
				TargetMachine="1"
179
			/>
180
			<Tool
181
				Name="VCALinkTool"
182
			/>
183
			<Tool
184
				Name="VCManifestTool"
185
			/>
186
			<Tool
187
				Name="VCXDCMakeTool"
188
			/>
189
			<Tool
190
				Name="VCBscMakeTool"
191
				SuppressStartupBanner="true"
192
				OutputFile=".\Release/jWinHttp.bsc"
193
			/>
194
			<Tool
195
				Name="VCFxCopTool"
196
			/>
197
			<Tool
198
				Name="VCAppVerifierTool"
199
			/>
200
			<Tool
201
				Name="VCPostBuildEventTool"
202
			/>
203
		</Configuration>
204
	</Configurations>
205
	<References>
206
	</References>
207
	<Files>
208
		<Filter
209
			Name="Quellcodedateien"
210
			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
211
			>
212
			<File
213
				RelativePath="jWinHttp.cpp"
214
				>
215
				<FileConfiguration
216
					Name="Debug|Win32"
217
					>
218
					<Tool
219
						Name="VCCLCompilerTool"
220
						AdditionalIncludeDirectories=""
221
						PreprocessorDefinitions=""
222
					/>
223
				</FileConfiguration>
224
				<FileConfiguration
225
					Name="Release|Win32"
226
					>
227
					<Tool
228
						Name="VCCLCompilerTool"
229
						AdditionalIncludeDirectories=""
230
						PreprocessorDefinitions=""
231
					/>
232
				</FileConfiguration>
233
			</File>
234
		</Filter>
235
		<Filter
236
			Name="Header-Dateien"
237
			Filter="h;hpp;hxx;hm;inl"
238
			>
239
			<File
240
				RelativePath=".\include\org_eclipse_core_internal_net_proxy_win32_winhttp_WinHttp.h"
241
				>
242
			</File>
243
		</Filter>
244
		<Filter
245
			Name="Ressourcendateien"
246
			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
247
			>
248
		</Filter>
249
	</Files>
250
	<Globals>
251
	</Globals>
252
</VisualStudioProject>
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxySelectorUtils.java (+247 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
import java.net.URI;
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.StringTokenizer;
21
22
import org.eclipse.core.internal.net.Activator;
23
import org.eclipse.core.internal.net.ProxyData;
24
import org.eclipse.core.net.proxy.IProxyData;
25
26
/**
27
 * A helper class that transforms strings (proxy lists, ..) from the native API into a format
28
 * suitable for the proxy provider API.
29
 */
30
public final class ProxySelectorUtils {
31
32
	static private int PROXY_DEFAULT_PORT= 80;
33
34
	static private int HTTPPROXY_DEFAULT_PORT= PROXY_DEFAULT_PORT;
35
36
	static private int HTTPSPROXY_DEFAULT_PORT= 443;
37
38
	static private int SOCKSPROXY_DEFAULT_PORT= 1080;
39
40
	private ProxySelectorUtils() {
41
		super();
42
	}
43
44
	/**
45
	 * Scan the proxy list string and fill this information in the correct list or map. <br>
46
	 * The proxy list contains one or more of the following strings separated by semicolons:<br>
47
	 * <code><pre>
48
	 * ([&lt;scheme&gt;=][&lt;scheme&gt; &quot;://&quot; ]&lt;server&gt;[ &quot;:&quot; &lt;port&gt;])
49
	 * </pre></code>
50
	 * 
51
	 * @param proxyList the proxy list as a string
52
	 * @param universalProxies the list of proxies receiving the universal proxies
53
	 * @param protocolSpecificProxies a map from http schemes to the list of scheme specific proxies
54
	 */
55
	public static void fillProxyLists(String proxyList, List universalProxies, Map protocolSpecificProxies) {
56
		StringTokenizer tokenizer= new StringTokenizer(proxyList, ";"); //$NON-NLS-1$
57
		while (tokenizer.hasMoreTokens()) {
58
			createProxy(tokenizer.nextToken(), universalProxies, protocolSpecificProxies);
59
		}
60
	}
61
62
	private static void createProxy(final String proxyDefinition, List universalProxies, Map protocolSpecificProxies) {
63
		String protocol= null;
64
		String host= null;
65
		int port= 0;
66
67
		int urlStart= 0;
68
		// if there is no '=' character within the proxy definition we have a
69
		// proxy definition that serves all protocols. In this case we MUST
70
		// ignore the protocol, otherwise the protocol MUST be used to determine
71
		// the specific proxy settings
72
		if (proxyDefinition.indexOf("=") != -1) { //$NON-NLS-1$
73
			protocol= proxyDefinition.substring(0, proxyDefinition.indexOf("=")); //$NON-NLS-1$
74
			urlStart= proxyDefinition.indexOf("=") + 1; //$NON-NLS-1$
75
		}
76
77
		try {
78
			// The scheme of the uri is irrelevant. We add the http://
79
			// scheme to enable class URI to parse the stuff
80
			String augmentedURI= proxyDefinition.substring(urlStart);
81
			if (augmentedURI.indexOf("://") == -1) { //$NON-NLS-1$
82
				augmentedURI= "http://" + augmentedURI; //$NON-NLS-1$
83
			}
84
			URI uri= new URI(augmentedURI);
85
			host= uri.getHost();
86
			port= uri.getPort() > 0 ? uri.getPort() : getProxyDefaultPort(protocol);
87
		} catch (Exception ex) {
88
			Activator.logError("not a valid proxy definition: '" + proxyDefinition + "'.", ex); //$NON-NLS-1$ //$NON-NLS-2$
89
			return;
90
		}
91
92
		if (host == null) {
93
			Activator.logError("not a valid proxy definition: '" + proxyDefinition + "'.", null); //$NON-NLS-1$ //$NON-NLS-2$
94
			return;
95
		}
96
97
		if (protocol == null) {
98
			universalProxies.add(createProxy(IProxyData.HTTP_PROXY_TYPE, host, port));
99
		} else {
100
			addProtocolSpecificProxy(protocolSpecificProxies, protocol, createProxy(resolveProxyType(protocol), host, port));
101
		}
102
	}
103
104
	private static int getProxyDefaultPort(String protocol) {
105
		if (protocol == null)
106
			return PROXY_DEFAULT_PORT;
107
		if ("http".equalsIgnoreCase(protocol)) //$NON-NLS-1$
108
			return HTTPPROXY_DEFAULT_PORT;
109
		if ("https".equalsIgnoreCase(protocol)) //$NON-NLS-1$
110
			return HTTPSPROXY_DEFAULT_PORT;
111
		if ("socks".equalsIgnoreCase(protocol)) //$NON-NLS-1$
112
			return SOCKSPROXY_DEFAULT_PORT;
113
		if ("socket".equalsIgnoreCase(protocol)) //$NON-NLS-1$
114
			return SOCKSPROXY_DEFAULT_PORT;
115
116
		return PROXY_DEFAULT_PORT;
117
	}
118
119
	private static void addProtocolSpecificProxy(Map protocolSpecificProxies, String protocol, IProxyData proxy) {
120
		List list= (List)protocolSpecificProxies.get(protocol);
121
		if (list == null) {
122
			list= new ArrayList();
123
			protocolSpecificProxies.put(protocol, list);
124
		}
125
126
		list.add(proxy);
127
	}
128
129
	private static String resolveProxyType(String protocol) {
130
		// TODO: return HTTP proxy for well-known high level protocols only?
131
		if (protocol.equalsIgnoreCase("socks") || protocol.equalsIgnoreCase("socket")) //$NON-NLS-1$ //$NON-NLS-2$
132
			return IProxyData.SOCKS_PROXY_TYPE;
133
		if (protocol.equalsIgnoreCase("https")) //$NON-NLS-1$ 
134
			return IProxyData.HTTPS_PROXY_TYPE;
135
		return IProxyData.HTTP_PROXY_TYPE;
136
	}
137
138
	private static IProxyData createProxy(String scheme, String host, int port) {
139
		String type= resolveProxyType(scheme);
140
		IProxyData proxy= new ProxyData(type);
141
		proxy.setHost(host);
142
		proxy.setPort(port);
143
		return proxy;
144
	}
145
146
	/*
147
	 * Pac related helper methods below here.
148
	 */
149
150
	private static final Map PROXY_TYPE_MAP;
151
152
	/*
153
	 * @see "http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html"
154
	 */
155
	private static final String PAC_PROXY_TYPE_DIRECT= "DIRECT"; //$NON-NLS-1$
156
157
	private static final String PAC_PROXY_TYPE_PROXY= "PROXY"; //$NON-NLS-1$
158
159
	private static final String PAC_PROXY_TYPE_SOCKS= "SOCKS"; //$NON-NLS-1$
160
161
	private static final String NO_PROXY= "DIRECT"; //$NON-NLS-1$
162
163
	static {
164
		// mapping of pacProgram proxy type names to java proxy types:
165
		final Map temp= new HashMap();
166
		temp.put(PAC_PROXY_TYPE_DIRECT, NO_PROXY);
167
		temp.put(PAC_PROXY_TYPE_PROXY, IProxyData.HTTP_PROXY_TYPE);
168
		temp.put(PAC_PROXY_TYPE_SOCKS, IProxyData.SOCKS_PROXY_TYPE);
169
		PROXY_TYPE_MAP= Collections.unmodifiableMap(temp);
170
	}
171
172
	/**
173
	 * @param pacFindProxyForUrlResult
174
	 * @return a list of IProxyData objects
175
	 */
176
	public static List getProxies(String pacFindProxyForUrlResult) {
177
		if (pacFindProxyForUrlResult == null || pacFindProxyForUrlResult.trim().length() == 0)
178
			return Collections.EMPTY_LIST;
179
180
		final List result= new ArrayList();
181
		final StringTokenizer scanner= new StringTokenizer(pacFindProxyForUrlResult, ";"); //$NON-NLS-1$
182
		while (scanner.hasMoreTokens()) {
183
			final String pacProxy= scanner.nextToken().trim();
184
			final IProxyData proxy= getProxy(pacProxy);
185
			if (proxy != null) {
186
				result.add(proxy);
187
			}
188
		}
189
190
		return result;
191
	}
192
193
	private static IProxyData getProxy(String pacProxy) {
194
		if (pacProxy == null || pacProxy.length() == 0)
195
			return null;
196
197
		if (!startsWithProxyType(pacProxy)) {
198
			// Assume "PROXY" type!
199
			pacProxy= "PROXY " + pacProxy; //$NON-NLS-1$
200
		}
201
		StringTokenizer scanner= new StringTokenizer(pacProxy);
202
		String pacProxyType= scanner.nextToken();
203
		String proxyType= (String)PROXY_TYPE_MAP.get(pacProxyType);
204
		if (proxyType == null || proxyType.equals(NO_PROXY))
205
			return null;
206
207
		String pacHostnameAndPort= null;
208
		if (scanner.hasMoreTokens()) {
209
			pacHostnameAndPort= scanner.nextToken();
210
		}
211
		String hostname= getHostname(pacHostnameAndPort);
212
		if (hostname != null) {
213
			int port= getPort(pacHostnameAndPort);
214
			IProxyData proxy= new ProxyData(proxyType);
215
			proxy.setHost(hostname);
216
			proxy.setPort(port);
217
			return proxy;
218
		}
219
		return null;
220
	}
221
222
	private static boolean startsWithProxyType(String pacProxy) {
223
		Iterator iter= PROXY_TYPE_MAP.keySet().iterator();
224
		while (iter.hasNext()) {
225
			if (pacProxy.startsWith((String)iter.next())) {
226
				return true;
227
			}
228
		}
229
230
		return false;
231
	}
232
233
	static String getHostname(String pacHostnameAndPort) {
234
		if (pacHostnameAndPort != null) {
235
			return pacHostnameAndPort.substring(0, pacHostnameAndPort.indexOf(':'));
236
		}
237
		return null;
238
	}
239
240
	static int getPort(String pacHostnameAndPort) {
241
		if (pacHostnameAndPort != null && pacHostnameAndPort.indexOf(':') > -1) {
242
			return Integer.parseInt(pacHostnameAndPort.substring(pacHostnameAndPort.indexOf(':') + 1));
243
		}
244
		return 0;
245
	}
246
247
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpAutoProxyOptions.java (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
/**
14
 * Wrapper for Win32 WINHTTP_AUTOPROXY_OPTIONS Structure.
15
 * <p>
16
 * The fields will be read by the jni glue code.
17
 * </p>
18
 */
19
public class WinHttpAutoProxyOptions {
20
21
	// Flags for WINHTTP_AUTOPROXY_OPTIONS::dwFlags
22
	public static final int WINHTTP_AUTOPROXY_AUTO_DETECT= 0x00000001;
23
24
	public static final int WINHTTP_AUTOPROXY_CONFIG_URL= 0x00000002;
25
26
	public static final int WINHTTP_AUTOPROXY_RUN_INPROCESS= 0x00010000;
27
28
	public static final int WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY= 0x00020000;
29
30
	// Flags for WINHTTP_AUTOPROXY_OPTIONS::dwAutoDetectFlags 
31
	public static final int WINHTTP_AUTO_DETECT_TYPE_DHCP= 0x00000001;
32
33
	public static final int WINHTTP_AUTO_DETECT_TYPE_DNS_A= 0x00000002;
34
35
	public int flags;
36
37
	public int autoDetectFlags;
38
39
	public String autoConfigUrl;
40
41
	public String reservedPointer;
42
43
	public int reservedInt;
44
45
	public boolean autoLogonIfChallenged;
46
47
	/**
48
	 * @param autoConfigUrl the autoConfigUrl to set
49
	 */
50
	public void setAutoConfigUrl(String autoConfigUrl) {
51
		this.autoConfigUrl= autoConfigUrl;
52
	}
53
54
	/**
55
	 * @param autoDetectFlags the autoDetectFlags to set
56
	 */
57
	public void setAutoDetectFlags(int autoDetectFlags) {
58
		this.autoDetectFlags= autoDetectFlags;
59
	}
60
61
	/**
62
	 * @param autoLogonIfChallenged the autoLogonIfChallenged to set
63
	 */
64
	public void setAutoLogonIfChallenged(boolean autoLogonIfChallenged) {
65
		this.autoLogonIfChallenged= autoLogonIfChallenged;
66
	}
67
68
	/**
69
	 * @param flags the flags to set
70
	 */
71
	public void setFlags(int flags) {
72
		this.flags= flags;
73
	}
74
75
}
(-)src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttp.java (+92 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 compeople AG and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * 	compeople AG (Stefan Liebig) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.net.proxy.win32.winhttp;
12
13
/**
14
 * This is the Win32 WinHttp wrapper.
15
 * <p>
16
 * Not complete, but offers what we currently need
17
 * </p>
18
 */
19
public final class WinHttp {
20
21
	/**
22
	 * The constant indicates the null proxy name parameter
23
	 */
24
	static final String NO_PROXY_NAME= null;
25
26
	/**
27
	 * The constant indicates the null proxy bypass parameter
28
	 */
29
	static final String NO_PROXY_BYPASS= null;
30
31
	/**
32
	 * WinHttpOpen - see Microsoft SDK Documentation
33
	 * 
34
	 * @param userAgent
35
	 * @param accessType
36
	 * @param proxyName
37
	 * @param proxyBypass
38
	 * @param flags
39
	 * @return the handle
40
	 */
41
	public static native int open(String userAgent, int accessType, String proxyName, String proxyBypass, int flags);
42
43
	/**
44
	 * WinHttpCloseHandle - see Microsoft SDK Documentation
45
	 * 
46
	 * @param hInternet
47
	 * @return true on success
48
	 */
49
	public static native boolean closeHandle(int hInternet);
50
51
	/**
52
	 * WinHttpGetIEProxyConfigForCurrentUser - see Microsoft SDK Documentation
53
	 * 
54
	 * @param proxyConfig
55
	 * @return true on success
56
	 */
57
	public static native boolean getIEProxyConfigForCurrentUser(WinHttpCurrentUserIEProxyConfig proxyConfig);
58
59
	/**
60
	 * WinHttpGetProxyForUrl - see Microsoft SDK Documentation
61
	 * 
62
	 * @param hSession
63
	 * @param url
64
	 * @param autoProxyOptions
65
	 * @param proxyInfo
66
	 * @return true on success
67
	 */
68
	public static native boolean getProxyForUrl(int hSession, String url, WinHttpAutoProxyOptions autoProxyOptions, WinHttpProxyInfo proxyInfo);
69
70
	/**
71
	 * WinHttpDetectAutoProxyConfigUrl - see Microsoft SDK Documentation
72
	 * 
73
	 * @param autoProxyHolder
74
	 * @return true on success
75
	 */
76
	public static native boolean detectAutoProxyConfigUrl(AutoProxyHolder autoProxyHolder);
77
78
	/**
79
	 * GetLastError - see Microsoft SDK Documentation
80
	 * 
81
	 * @return the last error code (win32)
82
	 */
83
	public static native int getLastError();
84
85
	/**
86
	 * GetLastErrorMessage - formats the last error
87
	 * 
88
	 * @return the readable last error code
89
	 */
90
	public static native String getLastErrorMessage();
91
92
}

Return to bug 180921