当前位置: 首页>>代码示例>>Java>>正文


Java SecureCacheResponse.getLocalCertificateChain方法代码示例

本文整理汇总了Java中java.net.SecureCacheResponse.getLocalCertificateChain方法的典型用法代码示例。如果您正苦于以下问题:Java SecureCacheResponse.getLocalCertificateChain方法的具体用法?Java SecureCacheResponse.getLocalCertificateChain怎么用?Java SecureCacheResponse.getLocalCertificateChain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.SecureCacheResponse的用法示例。


在下文中一共展示了SecureCacheResponse.getLocalCertificateChain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLocalCertificates

import java.net.SecureCacheResponse; //导入方法依赖的package包/类
@Override public Certificate[] getLocalCertificates() {
  SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
  if (cacheResponse != null) {
    List<Certificate> result = cacheResponse.getLocalCertificateChain();
    return result != null ? result.toArray(new Certificate[result.size()]) : null;
  }
  SSLSocket sslSocket = getSslSocket();
  if (sslSocket != null) {
    return sslSocket.getSession().getLocalCertificates();
  }
  return null;
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:13,代码来源:HttpsURLConnectionImpl.java

示例2: getLocalCertificates

import java.net.SecureCacheResponse; //导入方法依赖的package包/类
@Override
public Certificate[] getLocalCertificates() {
    SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
    if (cacheResponse != null) {
        List<Certificate> result = cacheResponse.getLocalCertificateChain();
        return result != null ? result.toArray(new Certificate[result.size()]) : null;
    }
    SSLSocket sslSocket = getSslSocket();
    if (sslSocket != null) {
        return sslSocket.getSession().getLocalCertificates();
    }
    return null;
}
 
开发者ID:goodev,项目名称:android-discourse,代码行数:14,代码来源:HttpsURLConnectionImpl.java

示例3: createOkResponseForCacheGet

import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
 * Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
 * to supply the data.
 */
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
    throws IOException {

  // Build a cache request for the response to use.
  Headers responseHeaders = createHeaders(javaResponse.getHeaders());
  Headers varyHeaders;
  if (HttpHeaders.hasVaryAll(responseHeaders)) {
    // "*" means that this will be treated as uncacheable anyway.
    varyHeaders = new Headers.Builder().build();
  } else {
    varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
  }

  Request cacheRequest = new Request.Builder()
      .url(request.url())
      .method(request.method(), null)
      .headers(varyHeaders)
      .build();

  Response.Builder okResponseBuilder = new Response.Builder();

  // Request: Use the cacheRequest we built.
  okResponseBuilder.request(cacheRequest);

  // Status line: Java has this as one of the headers.
  StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
  okResponseBuilder.protocol(statusLine.protocol);
  okResponseBuilder.code(statusLine.code);
  okResponseBuilder.message(statusLine.message);

  // Response headers
  Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
  okResponseBuilder.headers(okHeaders);

  // Response body
  ResponseBody okBody = createOkBody(okHeaders, javaResponse);
  okResponseBuilder.body(okBody);

  // Handle SSL handshake information as needed.
  if (javaResponse instanceof SecureCacheResponse) {
    SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;

    // Handshake doesn't support null lists.
    List<Certificate> peerCertificates;
    try {
      peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
      peerCertificates = Collections.emptyList();
    }
    List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
    if (localCertificates == null) {
      localCertificates = Collections.emptyList();
    }

    String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
    CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
    Handshake handshake = Handshake.get(null, cipherSuite, peerCertificates, localCertificates);
    okResponseBuilder.handshake(handshake);
  }

  return okResponseBuilder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:67,代码来源:JavaApiConverter.java

示例4: createOkResponseForCacheGet

import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
 * Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
 * to supply the data.
 */
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
    throws IOException {

  // Build a cache request for the response to use.
  Headers responseHeaders = createHeaders(javaResponse.getHeaders());
  Headers varyHeaders;
  if (HttpHeaders.hasVaryAll(responseHeaders)) {
    // "*" means that this will be treated as uncacheable anyway.
    varyHeaders = new Headers.Builder().build();
  } else {
    varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
  }

  Request cacheRequest = new Request.Builder()
      .url(request.url())
      .method(request.method(), null)
      .headers(varyHeaders)
      .build();

  Response.Builder okResponseBuilder = new Response.Builder();

  // Request: Use the cacheRequest we built.
  okResponseBuilder.request(cacheRequest);

  // Status line: Java has this as one of the headers.
  StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
  okResponseBuilder.protocol(statusLine.protocol);
  okResponseBuilder.code(statusLine.code);
  okResponseBuilder.message(statusLine.message);

  // Response headers
  Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
  okResponseBuilder.headers(okHeaders);

  // Response body
  ResponseBody okBody = createOkBody(okHeaders, javaResponse);
  okResponseBuilder.body(okBody);

  // Handle SSL handshake information as needed.
  if (javaResponse instanceof SecureCacheResponse) {
    SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;

    // Handshake doesn't support null lists.
    List<Certificate> peerCertificates;
    try {
      peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
      peerCertificates = Collections.emptyList();
    }
    List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
    if (localCertificates == null) {
      localCertificates = Collections.emptyList();
    }

    String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
    CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
    Handshake handshake = Handshake.get(
        TlsVersion.SSL_3_0, cipherSuite, peerCertificates, localCertificates);
    okResponseBuilder.handshake(handshake);
  }

  return okResponseBuilder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:68,代码来源:JavaApiConverter.java

示例5: createOkResponseForCacheGet

import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
 * Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
 * to supply the data.
 */
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
    throws IOException {

  // Build a cache request for the response to use.
  Headers responseHeaders = createHeaders(javaResponse.getHeaders());
  Headers varyHeaders;
  if (OkHeaders.hasVaryAll(responseHeaders)) {
    // "*" means that this will be treated as uncacheable anyway.
    varyHeaders = new Headers.Builder().build();
  } else {
    varyHeaders = OkHeaders.varyHeaders(request.headers(), responseHeaders);
  }

  Request cacheRequest = new Request.Builder()
      .url(request.url())
      .method(request.method(), null)
      .headers(varyHeaders)
      .build();

  Response.Builder okResponseBuilder = new Response.Builder();

  // Request: Use the cacheRequest we built.
  okResponseBuilder.request(cacheRequest);

  // Status line: Java has this as one of the headers.
  StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
  okResponseBuilder.protocol(statusLine.protocol);
  okResponseBuilder.code(statusLine.code);
  okResponseBuilder.message(statusLine.message);

  // Response headers
  Headers okHeaders = extractOkHeaders(javaResponse);
  okResponseBuilder.headers(okHeaders);

  // Response body
  ResponseBody okBody = createOkBody(okHeaders, javaResponse);
  okResponseBuilder.body(okBody);

  // Handle SSL handshake information as needed.
  if (javaResponse instanceof SecureCacheResponse) {
    SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;

    // Handshake doesn't support null lists.
    List<Certificate> peerCertificates;
    try {
      peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
    } catch (SSLPeerUnverifiedException e) {
      peerCertificates = Collections.emptyList();
    }
    List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
    if (localCertificates == null) {
      localCertificates = Collections.emptyList();
    }

    String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
    CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
    Handshake handshake = Handshake.get(null, cipherSuite, peerCertificates, localCertificates);
    okResponseBuilder.handshake(handshake);
  }

  return okResponseBuilder.build();
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:67,代码来源:JavaApiConverter.java


注:本文中的java.net.SecureCacheResponse.getLocalCertificateChain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。