public class GlobalProxyConfiguration extends Object
Usage example 1: The following shows how to set a global HTTP proxy.
InetSocketAddress inetSocketAddress = new InetSocketAddress("proxy.example.com", "8080"); GlobalProxyConfiguration.HTTP.setGlobalProxy(inetSocketAddress);
Usage example 2: The following shows how to unset the global HTTP proxy.
GlobalProxyConfiguration.HTTP.unsetGlobalProxy();
Modifier and Type | Field and Description |
---|---|
static GlobalProxyConfiguration |
FTP
FTP proxy related settings
|
static GlobalProxyConfiguration |
HTTP
HTTP proxy related settings
|
static GlobalProxyConfiguration |
HTTPS
HTTPS proxy related settings
The HTTPS protocol handler will use the same
nonProxyHosts property
as the HTTP protocol. |
static GlobalProxyConfiguration |
SOCKS
SOCKS proxy related properties
The SOCKS protocol handler does not support the
nonProxyHosts
property. |
Modifier | Constructor and Description |
---|---|
protected |
GlobalProxyConfiguration(String name,
Proxy.Type type,
int defaultPort,
String hostProperty,
String portProperty,
Optional<String> nonProxyHostsProperty,
Optional<Collection<String>> defaultNonProxyHosts)
Creates a new
GlobalProxyConfiguration instance. |
Modifier and Type | Method and Description |
---|---|
void |
addNonProxyHosts(String... nonProxyHosts)
Appends all of
nonProxyHosts to the current protocols
nonProxyHosts property if it is not already present. |
Optional<Collection<String>> |
getDefaultNonProxyHosts()
Default
nonProxyHosts |
int |
getDefaultPort()
Default proxy port
|
String |
getHostProperty()
Host property name
|
String |
getName()
Name
|
Set<String> |
getNonProxyHosts()
Returns all patterns of the current protocols
nonProxyHosts property. |
Optional<String> |
getNonProxyHostsProperty()
nonProxyHosts property name |
protected String |
getNonProxyHostsPropertyOrThrow()
Returns the current protocols
nonProxyHosts property name. |
String |
getPortProperty()
Port property name
|
Proxy.Type |
getType()
Proxy type
|
void |
removeNonProxyHosts(String... nonProxyHosts)
Removes all given patterns from the current protocols
nonProxyHosts
property. |
void |
resetNonProxyHosts()
Resets the current protocols
nonProxyHosts property. |
void |
setGlobalProxy(InetSocketAddress inetSocketAddress)
Overwrites the JVM global current protocols proxy properties with the given
host and port.
|
void |
setNonProxyHosts(Collection<String> nonProxyHosts)
Overwrites the current protocols
nonProxyHosts property with the
given patterns. |
void |
unsetGlobalProxy()
Overwrites the JVM global current protocols proxy properties.
|
public static final GlobalProxyConfiguration FTP
public static final GlobalProxyConfiguration HTTP
public static final GlobalProxyConfiguration HTTPS
The HTTPS protocol handler will use the same nonProxyHosts
property
as the HTTP protocol. Use HTTP
to modify that property.
public static final GlobalProxyConfiguration SOCKS
The SOCKS protocol handler does not support the nonProxyHosts
property.
protected GlobalProxyConfiguration(String name, Proxy.Type type, int defaultPort, String hostProperty, String portProperty, Optional<String> nonProxyHostsProperty, Optional<Collection<String>> defaultNonProxyHosts)
GlobalProxyConfiguration
instance.name
- Nametype
- Proxy typedefaultPort
- Default proxy porthostProperty
- Host property nameportProperty
- Port property namenonProxyHostsProperty
- nonProxyHosts
property namedefaultNonProxyHosts
- Default nonProxyHosts
public void addNonProxyHosts(String... nonProxyHosts)
nonProxyHosts
to the current protocols
nonProxyHosts
property if it is not already present.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
nonProxyHosts
- any number of hosts that should be accessed
without going through the proxyUnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertypublic Set<String> getNonProxyHosts()
nonProxyHosts
property.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
nonProxyHosts
propertyUnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertyprotected String getNonProxyHostsPropertyOrThrow()
nonProxyHosts
property name.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
nonProxyHosts
property nameUnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertypublic void removeNonProxyHosts(String... nonProxyHosts)
nonProxyHosts
property.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
nonProxyHosts
- any number of hosts that should not be accessed
with going through the proxyUnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertypublic void resetNonProxyHosts()
nonProxyHosts
property.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
Afterwards nothing but the default nonProxyHosts
are set.
UnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertypublic void setGlobalProxy(InetSocketAddress inetSocketAddress)
inetSocketAddress
- host and port to apply globallypublic void setNonProxyHosts(Collection<String> nonProxyHosts)
nonProxyHosts
property with the
given patterns.
For protocols not supporting the nonProxyHosts
property an
UnsupportedOperationException
is thrown.
nonProxyHosts
- any number of hosts that should be accessed
without going through the proxyUnsupportedOperationException
- for protocols not supporting the
nonProxyHosts
propertypublic void unsetGlobalProxy()
public String getName()
public Proxy.Type getType()
public int getDefaultPort()
public String getHostProperty()
public String getPortProperty()
public Optional<String> getNonProxyHostsProperty()
nonProxyHosts
property namenonProxyHosts
property namepublic Optional<Collection<String>> getDefaultNonProxyHosts()
nonProxyHosts
nonProxyHosts
Copyright © 2025. All rights reserved.