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 String
FILENAME
the props file.static String
HTTP_AUTHENTICATION
whether authentication is necessary for http proxy.static String
HTTP_HOST
the http host.static String
HTTP_NOPROXY
the hosts that bypass the http proxy.static String
HTTP_PASSWORD
the http password.static String
HTTP_PORT
the http port.static String
HTTP_USER
the http user.protected boolean
m_Modified
whether the settings got modified.protected Properties
m_Properties
the properties.protected static ProxyHelper
m_Singleton
the singleton.static String
PROXY_TYPE
the type of proxy to use.static String
SOCKS_AUTHENTICATION
whether authentication is necessary.static String
SOCKS_HOST
the socks host.static String
SOCKS_PASSWORD
the socks password.static String
SOCKS_PORT
the socks port.static String
SOCKS_USER
the socks user.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getAuthentication(Proxy.Type type)
Returns whether authentication is necessary.String
getHost(Proxy.Type type)
Returns the host.String[]
getNoProxy(Proxy.Type type)
Returns the hosts that bypass the proxy.BasePassword
getPassword(Proxy.Type type)
Returns the proxy password.int
getPort(Proxy.Type type)
Returns the port.Proxy.Type
getProxyType()
Returns the proxy type.static ProxyHelper
getSingleton()
Returns the singleton.String
getUser(Proxy.Type type)
Returns the proxy user.void
initializeProxy()
Initializes the proxy with the current settings.boolean
isModified()
Whether the settings got modified.static void
main(String[] args)
For testing only.void
reload()
Reloads the properties file.boolean
save()
Saves the settings in the user's home directory.void
setAuthentication(Proxy.Type type, boolean value)
Sets whether authentication is required for the proxy.void
setHost(Proxy.Type type, String value)
Sets the host.void
setNoProxy(Proxy.Type type, String[] value)
Sets the hosts that bypass the proxy.void
setPassword(Proxy.Type type, BasePassword value)
Sets the proxy password.void
setPort(Proxy.Type type, int value)
Sets the HTTP port.void
setProxyType(Proxy.Type value)
Updates the proxy type.void
setUser(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
-
-