当前位置: 首页>>代码示例>>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;未经允许,请勿转载。