Package adams.core.net
Class ProxyHelper
- java.lang.Object
-
- adams.core.net.ProxyHelper
-
public class ProxyHelper extends Object
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILENAMEthe props file.static StringHTTP_AUTHENTICATIONwhether authentication is necessary for http proxy.static StringHTTP_HOSTthe http host.static StringHTTP_NOPROXYthe hosts that bypass the http proxy.static StringHTTP_PASSWORDthe http password.static StringHTTP_PORTthe http port.static StringHTTP_USERthe http user.protected booleanm_Modifiedwhether the settings got modified.protected Propertiesm_Propertiesthe properties.protected static ProxyHelperm_Singletonthe singleton.static StringPROXY_TYPEthe type of proxy to use.static StringSOCKS_AUTHENTICATIONwhether authentication is necessary.static StringSOCKS_HOSTthe socks host.static StringSOCKS_PASSWORDthe socks password.static StringSOCKS_PORTthe socks port.static StringSOCKS_USERthe socks user.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetAuthentication(Proxy.Type type)Returns whether authentication is necessary.StringgetHost(Proxy.Type type)Returns the host.String[]getNoProxy(Proxy.Type type)Returns the hosts that bypass the proxy.BasePasswordgetPassword(Proxy.Type type)Returns the proxy password.intgetPort(Proxy.Type type)Returns the port.Proxy.TypegetProxyType()Returns the proxy type.static ProxyHelpergetSingleton()Returns the singleton.StringgetUser(Proxy.Type type)Returns the proxy user.voidinitializeProxy()Initializes the proxy with the current settings.booleanisModified()Whether the settings got modified.static voidmain(String[] args)For testing only.voidreload()Reloads the properties file.booleansave()Saves the settings in the user's home directory.voidsetAuthentication(Proxy.Type type, boolean value)Sets whether authentication is required for the proxy.voidsetHost(Proxy.Type type, String value)Sets the host.voidsetNoProxy(Proxy.Type type, String[] value)Sets the hosts that bypass the proxy.voidsetPassword(Proxy.Type type, BasePassword value)Sets the proxy password.voidsetPort(Proxy.Type type, int value)Sets the HTTP port.voidsetProxyType(Proxy.Type value)Updates the proxy type.voidsetUser(Proxy.Type type, String value)Sets the proxy user.
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the props file.- See Also:
- Constant Field Values
-
PROXY_TYPE
public static final String PROXY_TYPE
the type of proxy to use.- See Also:
- Constant Field Values
-
HTTP_HOST
public static final String HTTP_HOST
the http host.- See Also:
- Constant Field Values
-
HTTP_PORT
public static final String HTTP_PORT
the http port.- See Also:
- Constant Field Values
-
HTTP_AUTHENTICATION
public static final String HTTP_AUTHENTICATION
whether authentication is necessary for http proxy.- See Also:
- Constant Field Values
-
HTTP_USER
public static final String HTTP_USER
the http user.- See Also:
- Constant Field Values
-
HTTP_PASSWORD
public static final String HTTP_PASSWORD
the http password.- See Also:
- Constant Field Values
-
HTTP_NOPROXY
public static final String HTTP_NOPROXY
the hosts that bypass the http proxy.- See Also:
- Constant Field Values
-
SOCKS_HOST
public static final String SOCKS_HOST
the socks host.- See Also:
- Constant Field Values
-
SOCKS_PORT
public static final String SOCKS_PORT
the socks port.- See Also:
- Constant Field Values
-
SOCKS_AUTHENTICATION
public static final String SOCKS_AUTHENTICATION
whether authentication is necessary.- See Also:
- Constant Field Values
-
SOCKS_USER
public static final String SOCKS_USER
the socks user.- See Also:
- Constant Field Values
-
SOCKS_PASSWORD
public static final String SOCKS_PASSWORD
the socks password.- See Also:
- Constant Field Values
-
m_Singleton
protected static ProxyHelper m_Singleton
the singleton.
-
m_Properties
protected Properties m_Properties
the properties.
-
m_Modified
protected boolean m_Modified
whether the settings got modified.
-
-
Method Detail
-
initializeProxy
public void initializeProxy()
Initializes the proxy with the current settings.
See following URL for Java properties: http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
-
isModified
public boolean isModified()
Whether the settings got modified.- Returns:
- true if modified
-
getProxyType
public Proxy.Type getProxyType()
Returns the proxy type.- Returns:
- the type
-
setProxyType
public void setProxyType(Proxy.Type value)
Updates the proxy type.- Parameters:
value- the proxy type
-
getHost
public String getHost(Proxy.Type type)
Returns the host.- Parameters:
type- the proxy type- Returns:
- the host
-
setHost
public void setHost(Proxy.Type type, String value)
Sets the host.- Parameters:
type- the proxy typevalue- the host
-
getPort
public int getPort(Proxy.Type type)
Returns the port.- Parameters:
type- the proxy type- Returns:
- the port
-
setPort
public void setPort(Proxy.Type type, int value)
Sets the HTTP port.- Parameters:
type- the proxy typevalue- the port
-
getAuthentication
public boolean getAuthentication(Proxy.Type type)
Returns whether authentication is necessary.- Parameters:
type- the proxy type- Returns:
- true if authentication is necessary
-
setAuthentication
public void setAuthentication(Proxy.Type type, boolean value)
Sets whether authentication is required for the proxy.- Parameters:
type- the proxy typevalue- if true then authentication is required
-
getUser
public String getUser(Proxy.Type type)
Returns the proxy user.- Parameters:
type- the proxy type- Returns:
- the user name
-
setUser
public void setUser(Proxy.Type type, String value)
Sets the proxy user.- Parameters:
type- the proxy typevalue- the user
-
getPassword
public BasePassword getPassword(Proxy.Type type)
Returns the proxy password.- Parameters:
type- the proxy type- Returns:
- the password
-
setPassword
public void setPassword(Proxy.Type type, BasePassword value)
Sets the proxy password.- Parameters:
type- the proxy typevalue- the password
-
getNoProxy
public String[] getNoProxy(Proxy.Type type)
Returns the hosts that bypass the proxy.- Parameters:
type- the proxy type- Returns:
- the hosts
-
setNoProxy
public void setNoProxy(Proxy.Type type, String[] value)
Sets the hosts that bypass the proxy.- Parameters:
type- the proxy typevalue- the hosts
-
reload
public void reload()
Reloads the properties file. Discards any unsaved settings.
-
save
public boolean save()
Saves the settings in the user's home directory.- Returns:
- true if successfully saved
-
getSingleton
public static ProxyHelper getSingleton()
Returns the singleton.- Returns:
- the singleton
-
main
public static void main(String[] args)
For testing only.- Parameters:
args- ignored
-
-