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


Java HttpsURLConnection.getDefaultHostnameVerifier方法代码示例

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


在下文中一共展示了HttpsURLConnection.getDefaultHostnameVerifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getHostnameVerifier

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
/**
 * 主机名校验方法,请把”192.168.0.10”换成你们公司的主机IP:
 */
public static HostnameVerifier getHostnameVerifier() {
    return new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            if ("192.168.0.10".equals(hostname)) {
                return true;
            } else {
                HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
                return hv.verify(hostname, session);
            }
        }
    };
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:17,代码来源:HttpsUtils.java

示例3: 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

示例4: init

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public void init() {
    LOG.info("enabled: {}, trustAll: {}", enabled, trustAll);
    if (enabled) {
        oldHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
        LOG.info("Register me as DefaultHostnameVerifier, and backup the old one {}",
                oldHostnameVerifier);
        HttpsURLConnection.setDefaultHostnameVerifier(this);
        meAsDefaultHostnameVerifier = true;
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:11,代码来源:HttpsHostnameVerifier.java

示例5: shutdown

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public void shutdown() {
    if (meAsDefaultHostnameVerifier
            && HttpsURLConnection.getDefaultHostnameVerifier() == this) {
        LOG.info("Unregister me as DefaultHostnameVerifier, and reuse the old one {}",
                oldHostnameVerifier);
        HttpsURLConnection.setDefaultHostnameVerifier(oldHostnameVerifier);
        meAsDefaultHostnameVerifier = false;
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:10,代码来源:HttpsHostnameVerifier.java

示例6: VertxClientEngine

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public VertxClientEngine(final HttpClient httpClient) {

        try {
            this.httpClient = httpClient;
            sslContext = SSLContext.getDefault();
            hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
        } catch (final NoSuchAlgorithmException e) {
            throw new ExceptionInInitializerError(e);
        }
    }
 
开发者ID:trajano,项目名称:app-ms,代码行数:11,代码来源:VertxClientEngine.java

示例7: setUp

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
@Before public void setUp() throws Exception {
  socketFactory = SocketFactory.getDefault();
  hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:RouteSelectorTest.java

示例8: verify

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
@Override
public boolean verify(String hostname, SSLSession session) {
    System.out.println("verify " + hostname);
    HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
    return hv.verify(hostname, session);
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:7,代码来源:HttpsUtils.java

示例9: getDefaultHostnameVerifier

import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public static HostnameVerifier getDefaultHostnameVerifier() {
	return HttpsURLConnection.getDefaultHostnameVerifier();
}
 
开发者ID:haducloc,项目名称:appslandia-sweetsop,代码行数:4,代码来源:HttpClient.java


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