• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Scheme类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.boye.httpclientandroidlib.conn.scheme.Scheme的典型用法代码示例。如果您正苦于以下问题:Java Scheme类的具体用法?Java Scheme怎么用?Java Scheme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Scheme类属于ch.boye.httpclientandroidlib.conn.scheme包,在下文中一共展示了Scheme类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateSecureConnection

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
public void updateSecureConnection(
        final OperatedClientConnection conn,
        final HttpHost target,
        final HttpContext context,
        final HttpParams params) throws IOException {
    Args.notNull(conn, "Connection");
    Args.notNull(target, "Target host");
    Args.notNull(params, "Parameters");
    Asserts.check(conn.isOpen(), "Connection must be open");

    final SchemeRegistry registry = getSchemeRegistry(context);
    final Scheme schm = registry.getScheme(target.getSchemeName());
    Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
        "Socket factory must implement SchemeLayeredSocketFactory");
    final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
    final Socket sock = lsf.createLayeredSocket(
            conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
    prepareSocket(sock, context, params);
    conn.update(sock, target, lsf.isSecure(sock), params);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:21,代码来源:DefaultClientConnectionOperator.java


示例2: enableTLSConnectionManager

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
private static ClientConnectionManager enableTLSConnectionManager() throws KeyManagementException, NoSuchAlgorithmException  {
  SSLContext sslContext = SSLContext.getInstance("TLS");
  sslContext.init(null, null, new SecureRandom());

  Logger.debug(LOG_TAG, "Using protocols and cipher suites for Android API " + android.os.Build.VERSION.SDK_INT);
  SSLSocketFactory sf = new SSLSocketFactory(sslContext, GlobalConstants.DEFAULT_PROTOCOLS, GlobalConstants.DEFAULT_CIPHER_SUITES, null);
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(new Scheme("https", 443, sf));
  schemeRegistry.register(new Scheme("http", 80, new PlainSocketFactory()));
  ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);

  cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
  cm.setDefaultMaxPerRoute(MAX_CONNECTIONS_PER_ROUTE);
  connManager = cm;
  return cm;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:17,代码来源:BaseResource.java


示例3: wrapClient

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
public static AbstractHttpClient wrapClient(HttpClient base) {
	try {
		SSLContext ctx = SSLContext.getInstance("TLS");
		X509TrustManager tm = new X509AlwaysTrust();

		ctx.init(null, new TrustManager[] { tm }, null);
		SSLSocketFactory ssf = new ch.boye.httpclientandroidlib.conn.ssl.SSLSocketFactory(
				ctx);
		ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
		ClientConnectionManager ccm = base.getConnectionManager();
		SchemeRegistry sr = ccm.getSchemeRegistry();
		sr.register(new Scheme("https", ssf, 443));
		return new DefaultHttpClient(ccm, base.getParams());
	} catch (Exception ex) {
		ex.printStackTrace();
		return null;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:19,代码来源:FileProvider7.java


示例4: createConnectRequest

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
/**
 * Creates the CONNECT request for tunnelling.
 * Called by {@link #createTunnelToTarget createTunnelToTarget}.
 *
 * @param route     the route to establish
 * @param context   the context for request execution
 *
 * @return  the CONNECT request for tunnelling
 */
protected HttpRequest createConnectRequest(final HttpRoute route,
                                           final HttpContext context) {
    // see RFC 2817, section 5.2 and
    // INTERNET-DRAFT: Tunneling TCP based protocols through
    // Web proxy servers

    final HttpHost target = route.getTargetHost();

    final String host = target.getHostName();
    int port = target.getPort();
    if (port < 0) {
        final Scheme scheme = connManager.getSchemeRegistry().
            getScheme(target.getSchemeName());
        port = scheme.getDefaultPort();
    }

    final StringBuilder buffer = new StringBuilder(host.length() + 6);
    buffer.append(host);
    buffer.append(':');
    buffer.append(Integer.toString(port));

    final String authority = buffer.toString();
    final ProtocolVersion ver = HttpProtocolParams.getVersion(params);
    final HttpRequest req = new BasicHttpRequest
        ("CONNECT", authority, ver);

    return req;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:38,代码来源:DefaultRequestDirector.java


示例5: determineRoute

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
public HttpRoute determineRoute(final HttpHost target,
                                final HttpRequest request,
                                final HttpContext context)
    throws HttpException {

    Args.notNull(request, "HTTP request");

    // If we have a forced route, we can do without a target.
    HttpRoute route =
        ConnRouteParams.getForcedRoute(request.getParams());
    if (route != null) {
        return route;
    }

    // If we get here, there is no forced route.
    // So we need a target to compute a route.

    Asserts.notNull(target, "Target host");

    final InetAddress local =
        ConnRouteParams.getLocalAddress(request.getParams());
    final HttpHost proxy = determineProxy(target, request, context);

    final Scheme schm =
        this.schemeRegistry.getScheme(target.getSchemeName());
    // as it is typically used for TLS/SSL, we assume that
    // a layered scheme implies a secure connection
    final boolean secure = schm.isLayered();

    if (proxy == null) {
        route = new HttpRoute(target, local, secure);
    } else {
        route = new HttpRoute(target, local, proxy, secure);
    }
    return route;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:37,代码来源:ProxySelectorRoutePlanner.java


示例6: createDefault

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
/**
 * Initializes default scheme registry based on JSSE defaults. System properties will
 * not be taken into consideration.
 */
public static SchemeRegistry createDefault() {
    final SchemeRegistry registry = new SchemeRegistry();
    registry.register(
            new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    registry.register(
            new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    return registry;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:13,代码来源:SchemeRegistryFactory.java


示例7: createDefaultSchemeRegistry

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
/**
 * Creates a new {@link org.apache.http.conn.scheme.SchemeRegistry} for
 * default ports with socket factories.
 * 
 * @return a new {@link org.apache.http.conn.scheme.SchemeRegistry}.
 */
protected SchemeRegistry createDefaultSchemeRegistry() {
	SchemeRegistry registry = new SchemeRegistry();
	registry.register(new Scheme("http", this.createDefaultSocketFactory(),
			80));
	registry.register(new Scheme("https", this
			.createDefaultSecureSocketFactory(), 443));
	return registry;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:15,代码来源:SardineImpl.java


示例8: init

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
private void init() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
    ClientConnectionManager cm = new PoolingClientConnectionManager(registry);
    mClient = new DefaultHttpClient(cm);
}
 
开发者ID:youtaya,项目名称:crabapple,代码行数:8,代码来源:SilkHttpBase.java


示例9: determineRoute

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
public HttpRoute determineRoute(final HttpHost target,
                                final HttpRequest request,
                                final HttpContext context)
    throws HttpException {

    Args.notNull(request, "HTTP request");

    // If we have a forced route, we can do without a target.
    HttpRoute route =
        ConnRouteParams.getForcedRoute(request.getParams());
    if (route != null) {
        return route;
    }

    // If we get here, there is no forced route.
    // So we need a target to compute a route.

    Asserts.notNull(target, "Target host");

    final InetAddress local =
        ConnRouteParams.getLocalAddress(request.getParams());
    final HttpHost proxy =
        ConnRouteParams.getDefaultProxy(request.getParams());

    final Scheme schm;
    try {
        schm = this.schemeRegistry.getScheme(target.getSchemeName());
    } catch (final IllegalStateException ex) {
        throw new HttpException(ex.getMessage());
    }
    // as it is typically used for TLS/SSL, we assume that
    // a layered scheme implies a secure connection
    final boolean secure = schm.isLayered();

    if (proxy == null) {
        route = new HttpRoute(target, local, secure);
    } else {
        route = new HttpRoute(target, local, proxy, secure);
    }
    return route;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:42,代码来源:DefaultHttpRoutePlanner.java


示例10: createSystemDefault

import ch.boye.httpclientandroidlib.conn.scheme.Scheme; //导入依赖的package包/类
/**
 * Initializes default scheme registry using system properties as described in
 * <a href="http://download.oracle.com/javase/1,5.0/docs/guide/security/jsse/JSSERefGuide.html">
 * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
 * Standard Edition 5</a>
 * <p>
 * The following system properties are taken into account by this method:
 * <ul>
 *  <li>ssl.TrustManagerFactory.algorithm</li>
 *  <li>javax.net.ssl.trustStoreType</li>
 *  <li>javax.net.ssl.trustStore</li>
 *  <li>javax.net.ssl.trustStoreProvider</li>
 *  <li>javax.net.ssl.trustStorePassword</li>
 *  <li>java.home</li>
 *  <li>ssl.KeyManagerFactory.algorithm</li>
 *  <li>javax.net.ssl.keyStoreType</li>
 *  <li>javax.net.ssl.keyStore</li>
 *  <li>javax.net.ssl.keyStoreProvider</li>
 *  <li>javax.net.ssl.keyStorePassword</li>
 * </ul>
 * <p>
 *
 * @since 4.2
 */
public static SchemeRegistry createSystemDefault() {
    final SchemeRegistry registry = new SchemeRegistry();
    registry.register(
            new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    registry.register(
            new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory()));
    return registry;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:33,代码来源:SchemeRegistryFactory.java



注:本文中的ch.boye.httpclientandroidlib.conn.scheme.Scheme类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PrivilegedGetTccl类代码示例发布时间:2022-05-22
下一篇:
Java OutputDocument类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap