FileDocCategorySizeDatePackage
ProxySetup.javaAPI DocApache Ant 1.704656Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.util

ProxySetup

public class ProxySetup extends Object
Code to do proxy setup. This is just factored out of the main system just to keep everything else less convoluted.
since
Ant1.7

Fields Summary
private org.apache.tools.ant.Project
owner
owner project; used for logging and extracting properties
public static final String
USE_SYSTEM_PROXIES
Java1.5 property that enables use of system proxies.
public static final String
HTTP_PROXY_HOST
the http proxyhost property
public static final String
HTTP_PROXY_PORT
the http proxyport property
public static final String
HTTPS_PROXY_HOST
the https proxyhost property
public static final String
HTTPS_PROXY_PORT
the https proxyport property
public static final String
FTP_PROXY_HOST
the ftp proxyhost property
public static final String
FTP_PROXY_PORT
the ftp proxyport property
public static final String
HTTP_NON_PROXY_HOSTS
the ftp proxyport property
public static final String
HTTPS_NON_PROXY_HOSTS
the http hosts not to be proxied property
public static final String
FTP_NON_PROXY_HOSTS
the ftp hosts not to be proxied property
public static final String
HTTP_PROXY_USERNAME
the http proxy username property
public static final String
HTTP_PROXY_PASSWORD
the http proxy password property
public static final String
SOCKS_PROXY_HOST
the socks proxy host property
public static final String
SOCKS_PROXY_PORT
the socks proxy port property
public static final String
SOCKS_PROXY_USERNAME
the socks proxy username property
public static final String
SOCKS_PROXY_PASSWORD
the socks proxy password property
Constructors Summary
public ProxySetup(org.apache.tools.ant.Project owner)
create a proxy setup class bound to this project

param
owner the project that owns this setup.



                          
       
        this.owner = owner;
    
Methods Summary
public voidenableProxies()
turn proxies on; if the proxy key is already set to some value: leave alone. if an ant property of the value {@link #USE_SYSTEM_PROXIES} is set, use that instead. Else set to "true".

        if (!(getSystemProxySetting() != null)) {
            String proxies = owner.getProperty(USE_SYSTEM_PROXIES);
            if (proxies == null || Project.toBoolean(proxies)) {
                proxies = "true";
            }
            String message = "setting " + USE_SYSTEM_PROXIES + " to " + proxies;
            try {
                owner.log(message, Project.MSG_DEBUG);
                System.setProperty(USE_SYSTEM_PROXIES, proxies);
            } catch (SecurityException e) {
                //log security exceptions and continue; it aint that
                //important and may be quite common running Ant embedded.
                owner.log("Security Exception when " + message);
            }
        }
    
public static java.lang.StringgetSystemProxySetting()
Get the current system property settings

return
current value; null for none or no access

        try {
            return System.getProperty(USE_SYSTEM_PROXIES);
        } catch (SecurityException e) {
            //if you cannot read it, you won't be able to write it either
            return null;
        }