mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-13 12:38:07 +00:00
6912868: "java.net.useSystemProxies" behavior fails to check "use_same_proxy" in GNOME
Reviewed-by: alanb, chegar
This commit is contained in:
parent
642193f708
commit
6e3ed53d0a
@ -44,6 +44,7 @@
|
||||
* The GConf-2 settings used are:
|
||||
* - /system/http_proxy/use_http_proxy boolean
|
||||
* - /system/http_proxy/use_authentcation boolean
|
||||
* - /system/http_proxy/use_same_proxy boolean
|
||||
* - /system/http_proxy/host string
|
||||
* - /system/http_proxy/authentication_user string
|
||||
* - /system/http_proxy/authentication_password string
|
||||
@ -158,6 +159,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
char *mode = NULL;
|
||||
int pport = 0;
|
||||
int use_proxy;
|
||||
int use_same_proxy = 0;
|
||||
const char* urlhost;
|
||||
jobject isa = NULL;
|
||||
jobject proxy = NULL;
|
||||
@ -179,6 +181,15 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
* entries.
|
||||
*/
|
||||
|
||||
use_same_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_same_proxy", NULL);
|
||||
if (use_same_proxy) {
|
||||
use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL);
|
||||
if (use_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP:
|
||||
* /system/http_proxy/use_http_proxy (boolean)
|
||||
@ -188,8 +199,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
if (strcasecmp(cproto, "http") == 0) {
|
||||
use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL);
|
||||
if (use_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL);
|
||||
if (!use_same_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL);
|
||||
}
|
||||
CHECK_NULL(type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID));
|
||||
}
|
||||
}
|
||||
@ -203,8 +216,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
if (strcasecmp(cproto, "https") == 0) {
|
||||
mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
|
||||
if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/secure_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/secure_port", NULL);
|
||||
if (!use_same_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/secure_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/secure_port", NULL);
|
||||
}
|
||||
use_proxy = (phost != NULL);
|
||||
if (use_proxy)
|
||||
type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
|
||||
@ -220,8 +235,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
if (strcasecmp(cproto, "ftp") == 0) {
|
||||
mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
|
||||
if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/ftp_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/ftp_port", NULL);
|
||||
if (!use_same_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/ftp_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/ftp_port", NULL);
|
||||
}
|
||||
use_proxy = (phost != NULL);
|
||||
if (use_proxy)
|
||||
type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
|
||||
@ -237,8 +254,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
if (strcasecmp(cproto, "gopher") == 0) {
|
||||
mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
|
||||
if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/gopher_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/gopher_port", NULL);
|
||||
if (!use_same_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/gopher_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/gopher_port", NULL);
|
||||
}
|
||||
use_proxy = (phost != NULL);
|
||||
if (use_proxy)
|
||||
type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
|
||||
@ -254,8 +273,10 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxy(JNIEnv *env,
|
||||
if (strcasecmp(cproto, "socks") == 0) {
|
||||
mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
|
||||
if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/socks_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/socks_port", NULL);
|
||||
if (!use_same_proxy) {
|
||||
phost = (*my_get_string_func)(gconf_client, "/system/proxy/socks_host", NULL);
|
||||
pport = (*my_get_int_func)(gconf_client, "/system/proxy/socks_port", NULL);
|
||||
}
|
||||
use_proxy = (phost != NULL);
|
||||
if (use_proxy)
|
||||
type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_socksID);
|
||||
|
||||
61
jdk/test/java/net/ProxySelector/SystemProxies.java
Normal file
61
jdk/test/java/net/ProxySelector/SystemProxies.java
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a manual test to determine the proxies set on the system for various
|
||||
* protocols. See bug 6912868.
|
||||
*/
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
public class SystemProxies {
|
||||
|
||||
static final String uriAuthority = "myMachine/";
|
||||
static final ProxySelector proxySel = ProxySelector.getDefault();
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (! "true".equals(System.getProperty("java.net.useSystemProxies"))) {
|
||||
System.out.println("Usage: java -Djava.net.useSystemProxies SystemProxies");
|
||||
return;
|
||||
}
|
||||
|
||||
printProxies("http://");
|
||||
printProxies("https://");
|
||||
printProxies("ftp://");
|
||||
}
|
||||
|
||||
static void printProxies(String proto) {
|
||||
String uriStr = proto + uriAuthority;
|
||||
try {
|
||||
List<Proxy> proxies = proxySel.select(new URI(uriStr));
|
||||
System.out.println("Proxies returned for " + uriStr);
|
||||
for (Proxy proxy : proxies)
|
||||
System.out.println("\t" + proxy);
|
||||
} catch (URISyntaxException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user