当前位置: 首页>>代码示例>>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;未经允许,请勿转载。