@Test public void testFtpSystemProxy() { R.CONFIG.put("proxy_protocols", "ftp"); SystemProxy.setupProxy(); Assert.assertEquals(System.getProperty("ftp.proxyHost"), host); Assert.assertEquals(System.getProperty("ftp.proxyPort"), port); Assert.assertEquals(System.getProperty("http.proxyHost"), ""); Assert.assertEquals(System.getProperty("https.proxyHost"), ""); Assert.assertEquals(System.getProperty("socksProxyHost"), ""); Assert.assertEquals(System.getProperty("http.proxyPort"), ""); Assert.assertEquals(System.getProperty("https.proxyPort"), ""); Assert.assertEquals(System.getProperty("socksProxyPort"), ""); }
public static void setupProxy() { String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); String noProxy = Configuration.get(Parameter.NO_PROXY); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty() && Configuration.getBoolean(Parameter.PROXY_SET_TO_SYSTEM)) { if (protocols.contains("http")) { LOGGER.info(String.format("HTTP client will use http: %s:%s", proxyHost, proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("http.nonProxyHosts", proxyPort); } } if (protocols.contains("https")) { LOGGER.info(String.format("HTTP client will use https proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("https.nonProxyHosts", proxyPort); } } if (protocols.contains("ftp")) { LOGGER.info(String.format("HTTP client will use ftp proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("ftp.proxyHost", proxyHost); System.setProperty("ftp.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("ftp.nonProxyHosts", proxyPort); } } if (protocols.contains("socks")) { LOGGER.info(String.format("HTTP client will use socks proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("socksProxyHost", proxyHost); System.setProperty("socksProxyPort", proxyPort); } } }
SystemProxy { public static void setupProxy() { String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); String noProxy = Configuration.get(Parameter.NO_PROXY); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty() && Configuration.getBoolean(Parameter.PROXY_SET_TO_SYSTEM)) { if (protocols.contains("http")) { LOGGER.info(String.format("HTTP client will use http: %s:%s", proxyHost, proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("http.nonProxyHosts", proxyPort); } } if (protocols.contains("https")) { LOGGER.info(String.format("HTTP client will use https proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("https.nonProxyHosts", proxyPort); } } if (protocols.contains("ftp")) { LOGGER.info(String.format("HTTP client will use ftp proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("ftp.proxyHost", proxyHost); System.setProperty("ftp.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("ftp.nonProxyHosts", proxyPort); } } if (protocols.contains("socks")) { LOGGER.info(String.format("HTTP client will use socks proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("socksProxyHost", proxyHost); System.setProperty("socksProxyPort", proxyPort); } } } }
SystemProxy { public static void setupProxy() { String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); String noProxy = Configuration.get(Parameter.NO_PROXY); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty() && Configuration.getBoolean(Parameter.PROXY_SET_TO_SYSTEM)) { if (protocols.contains("http")) { LOGGER.info(String.format("HTTP client will use http: %s:%s", proxyHost, proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("http.nonProxyHosts", proxyPort); } } if (protocols.contains("https")) { LOGGER.info(String.format("HTTP client will use https proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("https.nonProxyHosts", proxyPort); } } if (protocols.contains("ftp")) { LOGGER.info(String.format("HTTP client will use ftp proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("ftp.proxyHost", proxyHost); System.setProperty("ftp.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("ftp.nonProxyHosts", proxyPort); } } if (protocols.contains("socks")) { LOGGER.info(String.format("HTTP client will use socks proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("socksProxyHost", proxyHost); System.setProperty("socksProxyPort", proxyPort); } } }  }
SystemProxy { public static void setupProxy() { String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); String noProxy = Configuration.get(Parameter.NO_PROXY); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty() && Configuration.getBoolean(Parameter.PROXY_SET_TO_SYSTEM)) { if (protocols.contains("http")) { LOGGER.info(String.format("HTTP client will use http: %s:%s", proxyHost, proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("http.nonProxyHosts", proxyPort); } } if (protocols.contains("https")) { LOGGER.info(String.format("HTTP client will use https proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("https.nonProxyHosts", proxyPort); } } if (protocols.contains("ftp")) { LOGGER.info(String.format("HTTP client will use ftp proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("ftp.proxyHost", proxyHost); System.setProperty("ftp.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("ftp.nonProxyHosts", proxyPort); } } if (protocols.contains("socks")) { LOGGER.info(String.format("HTTP client will use socks proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("socksProxyHost", proxyHost); System.setProperty("socksProxyPort", proxyPort); } } }  static void setupProxy(); }
SystemProxy { public static void setupProxy() { String proxyHost = Configuration.get(Parameter.PROXY_HOST); String proxyPort = Configuration.get(Parameter.PROXY_PORT); String noProxy = Configuration.get(Parameter.NO_PROXY); List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+")); if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty() && Configuration.getBoolean(Parameter.PROXY_SET_TO_SYSTEM)) { if (protocols.contains("http")) { LOGGER.info(String.format("HTTP client will use http: %s:%s", proxyHost, proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("http.nonProxyHosts", proxyPort); } } if (protocols.contains("https")) { LOGGER.info(String.format("HTTP client will use https proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("https.nonProxyHosts", proxyPort); } } if (protocols.contains("ftp")) { LOGGER.info(String.format("HTTP client will use ftp proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("ftp.proxyHost", proxyHost); System.setProperty("ftp.proxyPort", proxyPort); if (!noProxy.isEmpty()) { System.setProperty("ftp.nonProxyHosts", proxyPort); } } if (protocols.contains("socks")) { LOGGER.info(String.format("HTTP client will use socks proxies: %s:%s", proxyHost, proxyPort)); System.setProperty("socksProxyHost", proxyHost); System.setProperty("socksProxyPort", proxyPort); } } }  static void setupProxy();  }