Class ProxySettings.Builder
- Enclosing class:
- ProxySettings
ProxySettings.-
Method Summary
Modifier and TypeMethodDescriptionapplyConnectionString(ConnectionString connectionString) Takes the proxy settings from the givenConnectionStringand applies them to theProxySettings.Builder.applySettings(ProxySettings proxySettings) Applies the providedProxySettingsto this builder instance.build()Build an instance ofProxySettings.Sets the SOCKS5 proxy host to establish a connection through.Sets the password for authenticating with the SOCKS5 proxy server.port(int port) Sets the port number for the SOCKS5 proxy server.Sets the username for authenticating with the SOCKS5 proxy server.
-
Method Details
-
applySettings
Applies the providedProxySettingsto this builder instance.Note: This method overwrites all existing proxy settings previously configured in this builder.
- Parameters:
proxySettings- TheProxySettingsinstance containing the proxy configuration to apply.- Returns:
- This
ProxySettings.Builderinstance with the updated proxy settings applied. - Throws:
IllegalArgumentException- If the providedProxySettingsinstance is null.
-
host
Sets the SOCKS5 proxy host to establish a connection through.The host can be specified as an IPv4 address (e.g., "192.168.1.1"), an IPv6 address (e.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334"), or a domain name (e.g., "proxy.example.com").
- Parameters:
host- The SOCKS5 proxy host to set.- Returns:
- This ProxySettings.Builder instance, configured with the specified proxy host.
- Throws:
IllegalArgumentException- If the provided host is null or empty after trimming.- See Also:
-
port
Sets the port number for the SOCKS5 proxy server. The port should be a non-negative integer representing the port through which the SOCKS5 proxy connection will be established.If a port is specified via this method, a corresponding host must be provided using the
host(String)method.If no port is provided, the default port 1080 will be used.
- Parameters:
port- The port number to set for the SOCKS5 proxy server.- Returns:
- This ProxySettings.Builder instance, configured with the specified proxy port.
- Throws:
IllegalArgumentException- If the provided port is negative.- See Also:
-
username
Sets the username for authenticating with the SOCKS5 proxy server. The provided username should not be empty or null.If a username is specified, the corresponding password and proxy host must also be specified using the
password(String)andhost(String)methods, respectively.- Parameters:
username- The username to set for proxy authentication.- Returns:
- This ProxySettings.Builder instance, configured with the specified username.
- Throws:
IllegalArgumentException- If the provided username is empty or null.- See Also:
-
password
Sets the password for authenticating with the SOCKS5 proxy server. The provided password should not be empty or null.If a password is specified, the corresponding username and proxy host must also be specified using the
username(String)andhost(String)methods, respectively.- Parameters:
password- The password to set for proxy authentication.- Returns:
- This ProxySettings.Builder instance, configured with the specified password.
- Throws:
IllegalArgumentException- If the provided password is empty or null.- See Also:
-
applyConnectionString
Takes the proxy settings from the givenConnectionStringand applies them to theProxySettings.Builder.- Parameters:
connectionString- the connection string containing details of how to connect to proxy server.- Returns:
- this.
- See Also:
-
build
Build an instance ofProxySettings.- Returns:
- the
ProxySettings.
-