本文整理汇总了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();
}
示例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);
}
}
};
}
示例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;
}
});
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例7: setUp
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
@Before public void setUp() throws Exception {
socketFactory = SocketFactory.getDefault();
hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
}
示例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);
}
示例9: getDefaultHostnameVerifier
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public static HostnameVerifier getDefaultHostnameVerifier() {
return HttpsURLConnection.getDefaultHostnameVerifier();
}