當前位置: 首頁>>代碼示例>>Java>>正文


Java Type類代碼示例

本文整理匯總了Java中java.net.Proxy.Type的典型用法代碼示例。如果您正苦於以下問題:Java Type類的具體用法?Java Type怎麽用?Java Type使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Type類屬於java.net.Proxy包,在下文中一共展示了Type類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: a

import java.net.Proxy.Type; //導入依賴的package包/類
private static HttpURLConnection a(Context context, String str) {
    try {
        URL url = new URL(str);
        if (context.getPackageManager().checkPermission(z[43], context.getPackageName()) == 0) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(z[44])).getActiveNetworkInfo();
            if (!(activeNetworkInfo == null || activeNetworkInfo.getType() == 1)) {
                String extraInfo = activeNetworkInfo.getExtraInfo();
                if (extraInfo != null && (extraInfo.equals(z[40]) || extraInfo.equals(z[41]) || extraInfo.equals(z[42]))) {
                    return (HttpURLConnection) url.openConnection(new Proxy(Type.HTTP, new InetSocketAddress(z[45], 80)));
                }
            }
        }
        return (HttpURLConnection) url.openConnection();
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e2) {
        e2.printStackTrace();
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:p.java

示例2: createProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@VisibleForTesting
public Proxy createProxy(URI uri) {
  Preconditions.checkNotNull(uri, "uri is null");
  Preconditions.checkArgument(!"http".equals(uri.getScheme()), "http is not a supported schema");

  IProxyService proxyServiceCopy = proxyService;
  if (proxyServiceCopy == null) {
    return Proxy.NO_PROXY;
  }

  IProxyData[] proxyDataForUri = proxyServiceCopy.select(uri);
  for (final IProxyData iProxyData : proxyDataForUri) {
    switch (iProxyData.getType()) {
      case IProxyData.HTTPS_PROXY_TYPE:
        return new Proxy(Type.HTTP, new InetSocketAddress(iProxyData.getHost(),
                                                          iProxyData.getPort()));
      case IProxyData.SOCKS_PROXY_TYPE:
        return new Proxy(Type.SOCKS, new InetSocketAddress(iProxyData.getHost(),
                                                           iProxyData.getPort()));
      default:
        logger.warning("Unsupported proxy type: " + iProxyData.getType());
        break;
    }
  }
  return Proxy.NO_PROXY;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:27,代碼來源:ProxyFactory.java

示例3: setProxy

import java.net.Proxy.Type; //導入依賴的package包/類
/**
 * Define the proxy to use for all GA tracking requests.
 * <p>
 * Call this static method early (before creating any tracking requests).
 *
 * @param proxyAddr
 *            "addr:port" of the proxy to use; may also be given as URL
 *            ("http://addr:port/").
 */
public static void setProxy(String proxyAddr)
{
	if(proxyAddr != null)
	{
		Scanner s = new Scanner(proxyAddr);
		
		// Split into "proxyAddr:proxyPort".
		proxyAddr = null;
		int proxyPort = 8080;
		try
		{
			s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
			MatchResult m = s.match();
			
			if(m.groupCount() >= 2)
				proxyAddr = m.group(2);
			
			if(m.groupCount() >= 4 && !(m.group(4).length() == 0))
				proxyPort = Integer.parseInt(m.group(4));
		}finally
		{
			s.close();
		}
		
		if(proxyAddr != null)
		{
			SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
			setProxy(new Proxy(Type.HTTP, sa));
		}
	}
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:41,代碼來源:JGoogleAnalyticsTracker.java

示例4: clientHttpRequestFactory

import java.net.Proxy.Type; //導入依賴的package包/類
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory() {
	List<ClientHttpRequestInterceptor> interceptors = Arrays
			.asList(getSecurityInterceptor());
	SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
	Proxy proxy = this.properties.getRemote().getProxy();
	if (proxy.getHost() != null && proxy.getPort() != null) {
		requestFactory.setProxy(new java.net.Proxy(Type.HTTP,
				new InetSocketAddress(proxy.getHost(), proxy.getPort())));
	}
	return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:RemoteClientConfiguration.java

示例5: actionPerformed

import java.net.Proxy.Type; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent actionEvent) {
    int returnVal = fileChooser.showOpenDialog(frame);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File proxyFile = fileChooser.getSelectedFile();
        LambdaAttack.getLogger().log(Level.INFO, "Opening: {0}.", proxyFile.getName());

        botManager.getThreadPool().submit(() -> {
            try {
                List<Proxy> proxies = Files.lines(proxyFile.toPath()).distinct().map((line) -> {
                    String host = line.split(":")[0];
                    int port = Integer.parseInt(line.split(":")[1]);

                    InetSocketAddress address = new InetSocketAddress(host, port);
                    return new Proxy(Type.SOCKS, address);
                }).collect(Collectors.toList());

                LambdaAttack.getLogger().log(Level.INFO, "Loaded {0} proxies", proxies.size());

                botManager.setProxies(proxies);
            } catch (Exception ex) {
                LambdaAttack.getLogger().log(Level.SEVERE, null, ex);
            }
        });
    }
}
 
開發者ID:games647,項目名稱:LambdaAttack,代碼行數:27,代碼來源:LoadProxiesListener.java

示例6: setProxy

import java.net.Proxy.Type; //導入依賴的package包/類
/**
 * Define the proxy to use for all GA tracking requests.
 * <p>
 * Call this static method early (before creating any tracking requests).
 *
 * @param proxyAddr
 *            "addr:port" of the proxy to use; may also be given as URL
 *            ("http://addr:port/").
 */
public static void setProxy(String proxyAddr) {
    if (proxyAddr != null) {

        String oldProxyAddr = proxyAddr;
        // Split into "proxyAddr:proxyPort".
        proxyAddr = null;
        int proxyPort = 8080;
        try (Scanner s = new Scanner(oldProxyAddr)) {
            s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
            MatchResult m = s.match();

            if (m.groupCount() >= 2) proxyAddr = m.group(2);

            if (m.groupCount() >= 4 && !(m.group(4).length() == 0)) proxyPort = Integer.parseInt(m.group(4));
        }

        if (proxyAddr != null) {
            SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
            setProxy(new Proxy(Type.HTTP, sa));
        }
    }
}
 
開發者ID:null-dev,項目名稱:EvenWurse,代碼行數:32,代碼來源:JGoogleAnalyticsTracker.java

示例7: connectFailed

import java.net.Proxy.Type; //導入依賴的package包/類
public final void connectFailed(Connection paramConnection, IOException paramIOException)
{
  if (Internal.instance.recycleCount(paramConnection) > 0) {}
  for (;;)
  {
    return;
    Route localRoute1 = paramConnection.route;
    if ((localRoute1.proxy.type() != Proxy.Type.DIRECT) && (this.address.proxySelector != null)) {
      this.address.proxySelector.connectFailed(this.uri, localRoute1.proxy.address(), paramIOException);
    }
    this.routeDatabase.failed(localRoute1);
    if ((!(paramIOException instanceof SSLHandshakeException)) && (!(paramIOException instanceof SSLProtocolException))) {
      while (this.nextSpecIndex < this.connectionSpecs.size())
      {
        List localList = this.connectionSpecs;
        int i = this.nextSpecIndex;
        this.nextSpecIndex = (i + 1);
        ConnectionSpec localConnectionSpec = (ConnectionSpec)localList.get(i);
        boolean bool = shouldSendTlsFallbackIndicator(localConnectionSpec);
        Route localRoute2 = new Route(this.address, this.lastProxy, this.lastInetSocketAddress, localConnectionSpec, bool);
        this.routeDatabase.failed(localRoute2);
      }
    }
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:26,代碼來源:RouteSelector.java

示例8: convert

import java.net.Proxy.Type; //導入依賴的package包/類
protected void convert(String pacResult, List<Proxy> result) {
    Matcher m = PAC_RESULT_PATTERN.matcher(pacResult);
    while (m.find()) {
        String scriptProxyType = m.group(1);
        if ("DIRECT".equals(scriptProxyType)) {
            result.add(Proxy.NO_PROXY);
        } else {
            Type proxyType;
            if ("PROXY".equals(scriptProxyType)) {
                proxyType = Type.HTTP;
            } else if ("SOCKS".equals(scriptProxyType)) {
                proxyType = Type.SOCKS;
            } else {
                // Should never happen, already filtered by Pattern.
                throw new RuntimeException("Unrecognized proxy type.");
            }
            result.add(new Proxy(proxyType, new InetSocketAddress(m
                    .group(2), Integer.parseInt(m.group(3)))));
        }
    }
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:22,代碼來源:PacProxySelector.java

示例9: testBrowserManualSameProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testBrowserManualSameProxy() throws URISyntaxException {
    browserPrefs.put("network.proxy.type", "1" /* = manual */);
    browserPrefs.put("network.proxy.share_proxy_settings", "true");
    browserPrefs.put("network.proxy.http", PROXY_HOST);
    browserPrefs.put("network.proxy.http_port", String.valueOf(PROXY_PORT));

    List<Proxy> result;

    result = getProxy(config, browserPrefs, new URI("https://example.org"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, PROXY_ADDRESS), result.get(0));

    result = getProxy(config, browserPrefs, new URI("socket://example.org"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, PROXY_ADDRESS), result.get(0));

}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:21,代碼來源:BrowserAwareProxySelectorTest.java

示例10: testManualHttpProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testManualHttpProxy() throws URISyntaxException {
    String HTTP_HOST = "example.org";
    int HTTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_HOST, HTTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_PORT, String.valueOf(HTTP_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:17,代碼來源:JNLPProxySelectorTest.java

示例11: testManualHttpsProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testManualHttpsProxy() throws URISyntaxException {
    String HTTPS_HOST = "example.org";
    int HTTPS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTPS_HOST, HTTPS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTPS_PORT, String.valueOf(HTTPS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("https://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTPS_HOST, HTTPS_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:17,代碼來源:JNLPProxySelectorTest.java

示例12: testManualFtpProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testManualFtpProxy() throws URISyntaxException {
    String FTP_HOST = "example.org";
    int FTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_FTP_HOST, FTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_FTP_PORT, String.valueOf(FTP_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("ftp://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(FTP_HOST, FTP_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:17,代碼來源:JNLPProxySelectorTest.java

示例13: testManualSocksProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testManualSocksProxy() throws URISyntaxException {
    String SOCKS_HOST = "example.org";
    int SOCKS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST, SOCKS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT, String.valueOf(SOCKS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("socket://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:17,代碼來源:JNLPProxySelectorTest.java

示例14: testHttpFallsBackToManualSocksProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testHttpFallsBackToManualSocksProxy() throws URISyntaxException {
    String SOCKS_HOST = "example.org";
    int SOCKS_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST, SOCKS_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT, String.valueOf(SOCKS_PORT));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:17,代碼來源:JNLPProxySelectorTest.java

示例15: testManualSameProxy

import java.net.Proxy.Type; //導入依賴的package包/類
@Test
public void testManualSameProxy() throws URISyntaxException {
    final String HTTP_HOST = "example.org";
    final int HTTP_PORT = 42;

    DeploymentConfiguration config = new DeploymentConfiguration();
    config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_HOST, HTTP_HOST);
    config.setProperty(DeploymentConfiguration.KEY_PROXY_HTTP_PORT, String.valueOf(HTTP_PORT));
    config.setProperty(DeploymentConfiguration.KEY_PROXY_SAME, String.valueOf(true));

    JNLPProxySelector selector = new TestProxySelector(config);
    List<Proxy> result;

    result = selector.select(new URI("http://example.org/"));

    assertEquals(1, result.size());
    assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:20,代碼來源:JNLPProxySelectorTest.java


注:本文中的java.net.Proxy.Type類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。