Search in sources :

Example 46 with ProxySelector

use of java.net.ProxySelector in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method shouldGetProxySynthesis.

@Test
public void shouldGetProxySynthesis() throws URISyntaxException {
    ProxySelector proxySelector = mock(ProxySelector.class);
    when(proxySelector.select(any(URI.class))).thenReturn(Arrays.asList(new FakeProxy()));
    assertThat(DefaultHttpDownloader.BaseHttpDownloader.getProxySynthesis(new URI("http://an_url"), proxySelector)).isEqualTo("HTTP proxy: /123.45.67.89:4040");
}
Also used : ProxySelector(java.net.ProxySelector) URI(java.net.URI) Test(org.junit.Test)

Example 47 with ProxySelector

use of java.net.ProxySelector in project dbeaver by serge-rider.

the class SocksProxyImpl method setupProxyHandler.

private static void setupProxyHandler() {
    if (ProxySelector.getDefault() instanceof GlobalProxySelector) {
        return;
    }
    activateProxyService();
    // Init default network settings
    ProxySelector defProxySelector = GeneralUtils.adapt(DBWorkbench.getPlatform(), ProxySelector.class);
    if (defProxySelector == null) {
        defProxySelector = new GlobalProxySelector(ProxySelector.getDefault());
    }
    ProxySelector.setDefault(defProxySelector);
}
Also used : ProxySelector(java.net.ProxySelector) GlobalProxySelector(org.jkiss.dbeaver.runtime.net.GlobalProxySelector) GlobalProxySelector(org.jkiss.dbeaver.runtime.net.GlobalProxySelector)

Example 48 with ProxySelector

use of java.net.ProxySelector in project zm-mailbox by Zimbra.

the class TestSocks method testSystemProxy.

public void testSystemProxy() throws Exception {
    ProxySelector ps = ProxySelectors.nativeProxySelector();
    assertNotNull(ps);
    List<Proxy> proxies = ps.select(new URI("socket://www.vmware.com"));
    assertEquals(1, proxies.size());
    Proxy proxy = proxies.get(0);
    assertEquals(Proxy.Type.SOCKS, proxy.type());
    assertEquals(PROXY_ADDR, proxy.address());
}
Also used : ProxySelector(java.net.ProxySelector) Proxy(java.net.Proxy) URI(java.net.URI)

Example 49 with ProxySelector

use of java.net.ProxySelector in project zm-mailbox by Zimbra.

the class TestSocks method testHttpProxy.

public void testHttpProxy() throws Exception {
    ProxySelector ps = ProxySelectors.defaultProxySelector();
    List<Proxy> proxies = ps.select(new URI(HTTP_URL));
    for (Proxy proxy : proxies) {
        System.out.println("proxy = " + proxy);
    }
    URLConnection conn = new URL(HTTPS_URL).openConnection();
    conn.setConnectTimeout(3000);
    conn.connect();
    conn.getInputStream().read();
}
Also used : ProxySelector(java.net.ProxySelector) Proxy(java.net.Proxy) URI(java.net.URI) URLConnection(java.net.URLConnection) URL(java.net.URL)

Example 50 with ProxySelector

use of java.net.ProxySelector in project grpc-java by grpc.

the class ProxyDetectorImplTest method setUp.

@Before
public void setUp() throws Exception {
    proxySelectorSupplier = new Supplier<ProxySelector>() {

        @Override
        public ProxySelector get() {
            return proxySelector;
        }
    };
    proxyDetector = new ProxyDetectorImpl(proxySelectorSupplier, authenticator, null);
    unresolvedProxy = InetSocketAddress.createUnresolved("10.0.0.1", proxyPort);
    proxySocketAddress = HttpConnectProxiedSocketAddress.newBuilder().setTargetAddress(destination).setProxyAddress(new InetSocketAddress(InetAddress.getByName(unresolvedProxy.getHostName()), proxyPort)).build();
}
Also used : ProxySelector(java.net.ProxySelector) InetSocketAddress(java.net.InetSocketAddress) Before(org.junit.Before)

Aggregations

ProxySelector (java.net.ProxySelector)55 URI (java.net.URI)35 Proxy (java.net.Proxy)34 InetSocketAddress (java.net.InetSocketAddress)23 IOException (java.io.IOException)20 SocketAddress (java.net.SocketAddress)15 List (java.util.List)9 InetAddress (java.net.InetAddress)6 URL (java.net.URL)5 ArrayList (java.util.ArrayList)5 PasswordAuthentication (java.net.PasswordAuthentication)3 URISyntaxException (java.net.URISyntaxException)3 HttpHost (org.apache.http.HttpHost)3 Test (org.junit.Test)3 ManualProxySelector (org.kse.utilities.net.ManualProxySelector)3 NoProxySelector (org.kse.utilities.net.NoProxySelector)3 PacProxySelector (org.kse.utilities.net.PacProxySelector)3 ProxyAddress (org.kse.utilities.net.ProxyAddress)3 SystemProxySelector (org.kse.utilities.net.SystemProxySelector)3 InterruptedIOException (java.io.InterruptedIOException)2