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


Java HttpsURLConnection.getDefaultSSLSocketFactory方法代碼示例

本文整理匯總了Java中javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpsURLConnection.getDefaultSSLSocketFactory方法的具體用法?Java HttpsURLConnection.getDefaultSSLSocketFactory怎麽用?Java HttpsURLConnection.getDefaultSSLSocketFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.HttpsURLConnection的用法示例。


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

示例1: TestEnvironment

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
public TestEnvironment() {
    this.tmpDir = System.getProperty("java.io.tmpdir");
    if (tmpDir == null || tmpDir.length() == 0) {
        throw new AssertionError("tmpDir is null or empty: " + tmpDir);
    }
    System.setProperties(null); // Reset.

    // From "L" release onwards, calling System.setProperties(null) clears the java.io.tmpdir,
    // so we set it again. No-op on earlier releases.
    System.setProperty("java.io.tmpdir", tmpDir);

    String userHome = System.getProperty("user.home");
    String userDir = System.getProperty("user.dir");
    if (userHome == null || userDir == null) {
        throw new NullPointerException("user.home=" + userHome + ", user.dir=" + userDir);
    }

    defaultHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
    defaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();

    disableSecurity();
}
 
開發者ID:dryganets,項目名稱:vogar,代碼行數:23,代碼來源:TestEnvironment.java

示例2: register

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
/**
 * Easy way of not worrying about stupid SSL validation.
 */
public static void register()
{
	if( !(HttpsURLConnection.getDefaultSSLSocketFactory() instanceof BlindSSLSocketFactory) )
	{
		originalFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
		originalHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
		LOGGER.info("Registering BlindSSLSocketFactory");

		HttpsURLConnection.setDefaultSSLSocketFactory(getDefaultSSL());
		// I'm not sure if you need this...
		HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
		{
			@Override
			public boolean verify(String hostname, SSLSession session)
			{
				return true;
			}
		});
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:24,代碼來源:BlindSSLSocketFactory.java

示例3: copyWithDefaults

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:27,代碼來源:OkHttpClient.java

示例4: initSocketFactoryDefault

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
private static void initSocketFactoryDefault()
{
	try
	{
		socketFactoryDefault = HttpsURLConnection.getDefaultSSLSocketFactory();
		javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
		javax.net.ssl.TrustManager tm = new TM();
		trustAllCerts[0] = tm;
		javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
		sc.init(null, trustAllCerts, null);
		socketFactory = sc.getSocketFactory();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:18,代碼來源:HttpCommon.java

示例5: NoSSLv3SocketFactory

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
public NoSSLv3SocketFactory() {
    this.delegate = HttpsURLConnection.getDefaultSSLSocketFactory();
}
 
開發者ID:cerisara,項目名稱:mousetodon,代碼行數:4,代碼來源:NoSSLv3SocketFactory.java

示例6: testHTTPS

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
@Test
public void testHTTPS() throws Exception {
  Config config = buildHTTPSConfig();
  startServer(config);

  // Turn off actual checking of the dummy SSL cert
  SSLContext sslContext = SSLContext.getInstance("SSL");
  sslContext.init(null, new TrustManager[] { ACCEPT_ALL_TM }, null);
  SSLSocketFactory originalFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
  HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());

  try {
    String response = Resources.toString(
        new URL("https://localhost:" + getHTTPSPort() + "/helloWorld"),
        StandardCharsets.UTF_8);
    assertEquals("Hello, World", response);
  } finally {
    // Restore original SSL factory
    HttpsURLConnection.setDefaultSSLSocketFactory(originalFactory);
    Files.delete(Paths.get(config.getString("oryx.serving.api.keystore-file")));
  }
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:23,代碼來源:SecureAPIConfigIT.java

示例7: getDefaultSSLSocketFactory

import javax.net.ssl.HttpsURLConnection; //導入方法依賴的package包/類
public static SSLSocketFactory getDefaultSSLSocketFactory() {
	return HttpsURLConnection.getDefaultSSLSocketFactory();
}
 
開發者ID:haducloc,項目名稱:appslandia-sweetsop,代碼行數:4,代碼來源:HttpClient.java


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