public class ProxyOptions extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ProxyOptions.Type
The type of the proxy.
|
Constructor and Description |
---|
ProxyOptions(ProxyOptions.Type type,
InetSocketAddress address)
Creates ProxyOptions.
|
Modifier and Type | Method and Description |
---|---|
static ProxyOptions |
fromConfiguration(Configuration configuration)
Attempts to load a proxy from the environment.
|
static ProxyOptions |
fromConfiguration(Configuration configuration,
boolean createUnresolved)
Attempts to load a proxy from the environment.
|
InetSocketAddress |
getAddress() |
String |
getNonProxyHosts() |
String |
getPassword() |
ProxyOptions.Type |
getType() |
String |
getUsername() |
ProxyOptions |
setCredentials(String username,
String password)
Set the proxy credentials.
|
ProxyOptions |
setNonProxyHosts(String nonProxyHosts)
Sets the hosts which bypass the proxy.
|
public ProxyOptions(ProxyOptions.Type type, InetSocketAddress address)
type
- the proxy typeaddress
- the proxy address (ip and port number)public ProxyOptions setCredentials(String username, String password)
username
- proxy user namepassword
- proxy passwordpublic ProxyOptions setNonProxyHosts(String nonProxyHosts)
The expected format of the passed string is a '|'
delimited list of hosts which should bypass the proxy.
Individual host strings may contain regex characters such as '*'
.
nonProxyHosts
- Hosts that bypass the proxy.public InetSocketAddress getAddress()
public ProxyOptions.Type getType()
public String getUsername()
public String getPassword()
public String getNonProxyHosts()
public static ProxyOptions fromConfiguration(Configuration configuration)
If a proxy is found and loaded the proxy address is DNS resolved.
Environment configurations are loaded in this order:
null
will be returned if no proxy was found in the environment.
configuration
- The Configuration
that is used to load proxy configurations from the environment. If
null
is passed then Configuration.getGlobalConfiguration()
will be used. If Configuration.NONE
is passed IllegalArgumentException
will be thrown.ProxyOptions
reflecting a proxy loaded from the environment, if no proxy is found null
will be returned.IllegalArgumentException
- If configuration
is Configuration.NONE
.public static ProxyOptions fromConfiguration(Configuration configuration, boolean createUnresolved)
If a proxy is found and loaded, the proxy address is DNS resolved based on createUnresolved
. When createUnresolved
is true resolving ProxyOptions.getAddress()
may be required before using the address in network
calls.
Environment configurations are loaded in this order:
null
will be returned if no proxy was found in the environment.
configuration
- The Configuration
that is used to load proxy configurations from the environment. If
null
is passed then Configuration.getGlobalConfiguration()
will be used. If Configuration.NONE
is passed IllegalArgumentException
will be thrown.createUnresolved
- Flag determining whether the returned ProxyOptions
is unresolved.ProxyOptions
reflecting a proxy loaded from the environment, if no proxy is found null
will be returned.IllegalArgumentException
- If configuration
is Configuration.NONE
.Copyright © 2021 Microsoft Corporation. All rights reserved.