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


Java SecureCacheResponse類代碼示例

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


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

示例1: get

import java.net.SecureCacheResponse; //導入依賴的package包/類
@Override public CacheResponse get(URI uri, String requestMethod,
    Map<String, List<String>> requestHeaders) throws IOException {
  final CacheResponse response = delegate.get(uri, requestMethod, requestHeaders);
  if (response instanceof SecureCacheResponse) {
    return new CacheResponse() {
      @Override public InputStream getBody() throws IOException {
        return response.getBody();
      }

      @Override public Map<String, List<String>> getHeaders() throws IOException {
        return response.getHeaders();
      }
    };
  }
  return response;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ResponseCacheTest.java

示例2: createJavaCacheResponse_httpGet

import java.net.SecureCacheResponse; //導入依賴的package包/類
@Test public void createJavaCacheResponse_httpGet() throws Exception {
  Request okRequest =
      createArbitraryOkRequest().newBuilder()
          .url("http://insecure/request")
          .get()
          .build();
  Response okResponse = createArbitraryOkResponse(okRequest).newBuilder()
      .protocol(Protocol.HTTP_1_1)
      .code(200)
      .message("Fantastic")
      .addHeader("key1", "value1_1")
      .addHeader("key2", "value2")
      .addHeader("key1", "value1_2")
      .body(null)
      .build();
  CacheResponse javaCacheResponse = JavaApiConverter.createJavaCacheResponse(okResponse);
  assertFalse(javaCacheResponse instanceof SecureCacheResponse);
  Map<String, List<String>> javaHeaders = javaCacheResponse.getHeaders();
  assertEquals(Arrays.asList("value1_1", "value1_2"), javaHeaders.get("key1"));
  assertEquals(Arrays.asList("HTTP/1.1 200 Fantastic"), javaHeaders.get(null));
  assertNull(javaCacheResponse.getBody());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:JavaApiConverterTest.java

示例3: createJavaCacheResponse_httpPost

import java.net.SecureCacheResponse; //導入依賴的package包/類
@Test public void createJavaCacheResponse_httpPost() throws Exception {
  Request okRequest =
      createArbitraryOkRequest().newBuilder()
          .url("http://insecure/request")
          .post(createRequestBody("RequestBody"))
          .build();
  ResponseBody responseBody = createResponseBody("ResponseBody");
  Response okResponse = createArbitraryOkResponse(okRequest).newBuilder()
      .protocol(Protocol.HTTP_1_1)
      .code(200)
      .message("Fantastic")
      .addHeader("key1", "value1_1")
      .addHeader("key2", "value2")
      .addHeader("key1", "value1_2")
      .body(responseBody)
      .build();
  CacheResponse javaCacheResponse = JavaApiConverter.createJavaCacheResponse(okResponse);
  assertFalse(javaCacheResponse instanceof SecureCacheResponse);
  Map<String, List<String>> javaHeaders = javaCacheResponse.getHeaders();
  assertEquals(Arrays.asList("value1_1", "value1_2"), javaHeaders.get("key1"));
  assertEquals(Arrays.asList("HTTP/1.1 200 Fantastic"), javaHeaders.get(null));
  assertEquals("ResponseBody", readAll(javaCacheResponse.getBody()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:JavaApiConverterTest.java

示例4: getLocalCertificates

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the certificate chain the client sent to the
 * server, or null if the client did not authenticate.
 */
public java.security.cert.Certificate[] getLocalCertificates() {
    if (cachedResponse != null) {
        List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
        if (l == null) {
            return null;
        } else {
            return l.toArray(new java.security.cert.Certificate[0]);
        }
    }
    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
        return (((HttpsClient)http).getLocalCertificates ());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:AbstractDelegateHttpsURLConnection.java

示例5: getServerCertificates

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the server's certificate chain, or throws
 * SSLPeerUnverified Exception if
 * the server did not authenticate.
 */
public java.security.cert.Certificate[] getServerCertificates()
        throws SSLPeerUnverifiedException {
    if (cachedResponse != null) {
        List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
        if (l == null) {
            return null;
        } else {
            return l.toArray(new java.security.cert.Certificate[0]);
        }
    }

    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
        return (((HttpsClient)http).getServerCertificates ());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:AbstractDelegateHttpsURLConnection.java

示例6: getServerCertificates

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the server's certificate chain, or throws
 * SSLPeerUnverified Exception if
 * the server did not authenticate.
 */
public java.security.cert.Certificate[] getServerCertificates()
        throws SSLPeerUnverifiedException {
    if (cachedResponse != null) {
        List<java.security.cert.Certificate> l =
                ((SecureCacheResponse)cachedResponse)
                        .getServerCertificateChain();
        if (l == null) {
            return null;
        } else {
            return l.toArray(new java.security.cert.Certificate[0]);
        }
    }

    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
        return (((HttpsClient)http).getServerCertificates ());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:AbstractDelegateHttpsURLConnection.java

示例7: getCipherSuite

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the cipher suite in use on this connection.
 */
public String getCipherSuite()
{
	if (cachedResponse != null)
	{
		return ((SecureCacheResponse) cachedResponse).getCipherSuite();
	}
	if (http == null)
	{
		throw new IllegalStateException("connection not yet open");
	}
	else
	{
		return ((HttpsClient) http).getCipherSuite();
	}
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:19,代碼來源:HttpsURLConnection.java

示例8: getLocalCertificates

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the certificate chain the client sent to the server, or null if
 * the client did not authenticate.
 */
public java.security.cert.Certificate[] getLocalCertificates()
{
	if (cachedResponse != null)
	{
		final List<java.security.cert.Certificate> l = ((SecureCacheResponse) cachedResponse)
				.getLocalCertificateChain();
		if (l == null)
		{
			return null;
		}
		else
		{
			return (java.security.cert.Certificate[]) l.toArray();
		}
	}
	if (http == null)
	{
		throw new IllegalStateException("connection not yet open");
	}
	else
	{
		return (((HttpsClient) http).getLocalCertificates());
	}
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:29,代碼來源:HttpsURLConnection.java

示例9: getPeerPrincipal

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the server's principal, or throws SSLPeerUnverifiedException if
 * the server did not authenticate.
 */
Principal getPeerPrincipal() throws SSLPeerUnverifiedException
{
	if (cachedResponse != null)
	{
		return ((SecureCacheResponse) cachedResponse).getPeerPrincipal();
	}

	if (http == null)
	{
		throw new IllegalStateException("connection not yet open");
	}
	else
	{
		return (((HttpsClient) http).getPeerPrincipal());
	}
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:21,代碼來源:HttpsURLConnection.java

示例10: getLocalPrincipal

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the principal the client sent to the server, or null if the
 * client did not authenticate.
 */
Principal getLocalPrincipal()
{
	if (cachedResponse != null)
	{
		return ((SecureCacheResponse) cachedResponse).getLocalPrincipal();
	}

	if (http == null)
	{
		throw new IllegalStateException("connection not yet open");
	}
	else
	{
		return (((HttpsClient) http).getLocalPrincipal());
	}
}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:21,代碼來源:HttpsURLConnection.java

示例11: createJavaCacheResponse_httpsPost

import java.net.SecureCacheResponse; //導入依賴的package包/類
@Test public void createJavaCacheResponse_httpsPost() throws Exception {
  Request okRequest =
      createArbitraryOkRequest().newBuilder()
          .url("https://secure/request")
          .post(createRequestBody("RequestBody"))
          .build();
  ResponseBody responseBody = createResponseBody("ResponseBody");
  Handshake handshake = Handshake.get(null, CipherSuite.TLS_RSA_WITH_NULL_MD5,
      Arrays.<Certificate>asList(SERVER_CERT), Arrays.<Certificate>asList(LOCAL_CERT));
  Response okResponse = createArbitraryOkResponse(okRequest).newBuilder()
      .protocol(Protocol.HTTP_1_1)
      .code(200)
      .message("Fantastic")
      .addHeader("key1", "value1_1")
      .addHeader("key2", "value2")
      .addHeader("key1", "value1_2")
      .body(responseBody)
      .handshake(handshake)
      .build();
  SecureCacheResponse javaCacheResponse =
      (SecureCacheResponse) JavaApiConverter.createJavaCacheResponse(okResponse);
  Map<String, List<String>> javaHeaders = javaCacheResponse.getHeaders();
  assertEquals(Arrays.asList("value1_1", "value1_2"), javaHeaders.get("key1"));
  assertEquals(Arrays.asList("HTTP/1.1 200 Fantastic"), javaHeaders.get(null));
  assertEquals("ResponseBody", readAll(javaCacheResponse.getBody()));
  assertEquals(handshake.cipherSuite().javaName(), javaCacheResponse.getCipherSuite());
  assertEquals(handshake.localCertificates(), javaCacheResponse.getLocalCertificateChain());
  assertEquals(handshake.peerCertificates(), javaCacheResponse.getServerCertificateChain());
  assertEquals(handshake.localPrincipal(), javaCacheResponse.getLocalPrincipal());
  assertEquals(handshake.peerPrincipal(), javaCacheResponse.getPeerPrincipal());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:JavaApiConverterTest.java

示例12: createJavaCacheResponse_httpsPost

import java.net.SecureCacheResponse; //導入依賴的package包/類
@Test public void createJavaCacheResponse_httpsPost() throws Exception {
  Request okRequest =
      createArbitraryOkRequest().newBuilder()
          .url("https://secure/request")
          .post(createRequestBody("RequestBody"))
          .build();
  ResponseBody responseBody = createResponseBody("ResponseBody");
  Handshake handshake = Handshake.get(TlsVersion.SSL_3_0, CipherSuite.TLS_RSA_WITH_NULL_MD5,
      Arrays.<Certificate>asList(SERVER_CERT), Arrays.<Certificate>asList(LOCAL_CERT));
  Response okResponse = createArbitraryOkResponse(okRequest).newBuilder()
      .protocol(Protocol.HTTP_1_1)
      .code(200)
      .message("Fantastic")
      .addHeader("key1", "value1_1")
      .addHeader("key2", "value2")
      .addHeader("key1", "value1_2")
      .body(responseBody)
      .handshake(handshake)
      .build();
  SecureCacheResponse javaCacheResponse =
      (SecureCacheResponse) JavaApiConverter.createJavaCacheResponse(okResponse);
  Map<String, List<String>> javaHeaders = javaCacheResponse.getHeaders();
  assertEquals(Arrays.asList("value1_1", "value1_2"), javaHeaders.get("key1"));
  assertEquals(Arrays.asList("HTTP/1.1 200 Fantastic"), javaHeaders.get(null));
  assertEquals("ResponseBody", readAll(javaCacheResponse.getBody()));
  assertEquals(handshake.cipherSuite().javaName(), javaCacheResponse.getCipherSuite());
  assertEquals(handshake.localCertificates(), javaCacheResponse.getLocalCertificateChain());
  assertEquals(handshake.peerCertificates(), javaCacheResponse.getServerCertificateChain());
  assertEquals(handshake.localPrincipal(), javaCacheResponse.getLocalPrincipal());
  assertEquals(handshake.peerPrincipal(), javaCacheResponse.getPeerPrincipal());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:JavaApiConverterTest.java

示例13: getCipherSuite

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the cipher suite in use on this connection.
 */
public String getCipherSuite () {
    if (cachedResponse != null) {
        return ((SecureCacheResponse)cachedResponse).getCipherSuite();
    }
    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
       return ((HttpsClient)http).getCipherSuite ();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:AbstractDelegateHttpsURLConnection.java

示例14: getPeerPrincipal

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the server's principal, or throws SSLPeerUnverifiedException
 * if the server did not authenticate.
 */
Principal getPeerPrincipal()
        throws SSLPeerUnverifiedException
{
    if (cachedResponse != null) {
        return ((SecureCacheResponse)cachedResponse).getPeerPrincipal();
    }

    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
        return (((HttpsClient)http).getPeerPrincipal());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:AbstractDelegateHttpsURLConnection.java

示例15: getLocalPrincipal

import java.net.SecureCacheResponse; //導入依賴的package包/類
/**
 * Returns the principal the client sent to the
 * server, or null if the client did not authenticate.
 */
Principal getLocalPrincipal()
{
    if (cachedResponse != null) {
        return ((SecureCacheResponse)cachedResponse).getLocalPrincipal();
    }

    if (http == null) {
        throw new IllegalStateException("connection not yet open");
    } else {
        return (((HttpsClient)http).getLocalPrincipal());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:AbstractDelegateHttpsURLConnection.java


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