當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。