Class JavaProxySearchStrategy
- java.lang.Object
-
- com.github.markusbernhardt.proxy.search.java.JavaProxySearchStrategy
-
- All Implemented Interfaces:
ProxySearchStrategy
public class JavaProxySearchStrategy extends java.lang.Object implements ProxySearchStrategy
Reads some java system properties and extracts the proxy settings from them. The following variables are read:- http.proxyHost (default: none)
- http.proxyPort (default: 80 if http.proxyHost specified)
- http.nonProxyHosts (default: none)
- https.proxyHost (default: none)
- https.proxyPort (default: 443 if https.proxyHost specified)
- ftp.proxyHost (default: none)
- ftp.proxyPort (default: 80 if ftp.proxyHost specified)
- ftp.nonProxyHosts (default: none)
- socksProxyHost
- socksProxyPort (default: 1080)
This is based on information found here:
If the "http.proxyHost" property is not set then the no proxy selector is setup This property is used as marker to signal that the System settings should be used.
http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
-
-
Constructor Summary
Constructors Constructor Description JavaProxySearchStrategy()Constructor Will use the default environment variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()Gets the printable name of the search strategy.java.net.ProxySelectorgetProxySelector()Loads the proxy settings from environment variables.private voidsetupProxyForProtocol(ProtocolDispatchSelector ps, java.lang.String protocol, int defaultPort)Parse properties for the given protocol.private booleansetupSocktProxy(ProtocolDispatchSelector ps)Parse SOCKS settings
-
-
-
Method Detail
-
getProxySelector
public java.net.ProxySelector getProxySelector()
Loads the proxy settings from environment variables.- Specified by:
getProxySelectorin interfaceProxySearchStrategy- Returns:
- a configured ProxySelector, null if none is found.
-
getName
public java.lang.String getName()
Gets the printable name of the search strategy.- Specified by:
getNamein interfaceProxySearchStrategy- Returns:
- the printable name of the search strategy
-
setupSocktProxy
private boolean setupSocktProxy(ProtocolDispatchSelector ps)
Parse SOCKS settings- Parameters:
ps-- Throws:
java.lang.NumberFormatException
-
setupProxyForProtocol
private void setupProxyForProtocol(ProtocolDispatchSelector ps, java.lang.String protocol, int defaultPort)
Parse properties for the given protocol.- Parameters:
ps-protocol-- Throws:
java.lang.NumberFormatException
-
-