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


Java StrictHostnameVerifier类代码示例

本文整理汇总了Java中org.apache.http.conn.ssl.StrictHostnameVerifier的典型用法代码示例。如果您正苦于以下问题:Java StrictHostnameVerifier类的具体用法?Java StrictHostnameVerifier怎么用?Java StrictHostnameVerifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StrictHostnameVerifier类属于org.apache.http.conn.ssl包,在下文中一共展示了StrictHostnameVerifier类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupTrustManager

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) {
	final X509TrustManager trustManager;
	final HostnameVerifier hostnameVerifier = mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier(), interactive);
	if (interactive) {
		trustManager = mXmppConnectionService.getMemorizingTrustManager().getInteractive();
	} else {
		trustManager = mXmppConnectionService.getMemorizingTrustManager().getNonInteractive();
	}
	try {
		final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[]{trustManager}, mXmppConnectionService.getRNG());
		connection.setSSLSocketFactory(sf);
		connection.setHostnameVerifier(hostnameVerifier);
	} catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:16,代码来源:HttpConnectionManager.java

示例2: setupTrustManager

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) {
	final X509TrustManager trustManager;
	final HostnameVerifier hostnameVerifier;
	if (interactive) {
		trustManager = mXmppConnectionService.getMemorizingTrustManager();
		hostnameVerifier = mXmppConnectionService
				.getMemorizingTrustManager().wrapHostnameVerifier(
						new StrictHostnameVerifier());
	} else {
		trustManager = mXmppConnectionService.getMemorizingTrustManager()
				.getNonInteractive();
		hostnameVerifier = mXmppConnectionService
				.getMemorizingTrustManager()
				.wrapHostnameVerifierNonInteractive(
						new StrictHostnameVerifier());
	}
	try {
		final SSLContext sc = SSLContext.getInstance("TLS");
		sc.init(null, new X509TrustManager[]{trustManager},
				mXmppConnectionService.getRNG());

		final SSLSocketFactory sf = sc.getSocketFactory();
		final String[] cipherSuites = CryptoHelper.getOrderedCipherSuites(
				sf.getSupportedCipherSuites());
		if (cipherSuites.length > 0) {
			sc.getDefaultSSLParameters().setCipherSuites(cipherSuites);

		}

		connection.setSSLSocketFactory(sf);
		connection.setHostnameVerifier(hostnameVerifier);
	} catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:35,代码来源:HttpConnectionManager.java

示例3: initialize

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
@Override
public List<Exception> initialize() {
	SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
	Base64.setEncoder(AndroidBase64Encoder.getInstance());
	Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance());
	return null;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:AndroidSmackInitializer.java

示例4: setupTrustManager

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) {
    final X509TrustManager trustManager;
    final HostnameVerifier hostnameVerifier = mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier(), interactive);
    if (interactive) {
        trustManager = mXmppConnectionService.getMemorizingTrustManager().getInteractive();
    } else {
        trustManager = mXmppConnectionService.getMemorizingTrustManager().getNonInteractive();
    }
    try {
        final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[]{trustManager}, mXmppConnectionService.getRNG());
        connection.setSSLSocketFactory(sf);
        connection.setHostnameVerifier(hostnameVerifier);
    } catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:16,代码来源:HttpConnectionManager.java

示例5: setupTrustManager

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) {
	final X509TrustManager trustManager;
	final HostnameVerifier hostnameVerifier;
	if (interactive) {
		trustManager = mXmppConnectionService.getMemorizingTrustManager();
		hostnameVerifier = mXmppConnectionService
				.getMemorizingTrustManager().wrapHostnameVerifier(
						new StrictHostnameVerifier());
	} else {
		trustManager = mXmppConnectionService.getMemorizingTrustManager()
				.getNonInteractive();
		hostnameVerifier = mXmppConnectionService
				.getMemorizingTrustManager()
				.wrapHostnameVerifierNonInteractive(
						new StrictHostnameVerifier());
	}
	try {
		final SSLContext sc = SSLSocketHelper.getSSLContext();
		sc.init(null, new X509TrustManager[]{trustManager},
				mXmppConnectionService.getRNG());

		final SSLSocketFactory sf = sc.getSocketFactory();
		final String[] cipherSuites = CryptoHelper.getOrderedCipherSuites(
				sf.getSupportedCipherSuites());
		if (cipherSuites.length > 0) {
			sc.getDefaultSSLParameters().setCipherSuites(cipherSuites);

		}

		connection.setSSLSocketFactory(sf);
		connection.setHostnameVerifier(hostnameVerifier);
	} catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
	}
}
 
开发者ID:Frozenbox,项目名称:frozenchat,代码行数:35,代码来源:HttpConnectionManager.java

示例6: switchOverToTls

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
private void switchOverToTls(final Tag currentTag) throws XmlPullParserException, IOException {
	tagReader.readTag();
	try {
		final SSLContext sc = SSLContext.getInstance("TLS");
		sc.init(null,new X509TrustManager[]{this.mXmppConnectionService.getMemorizingTrustManager()},mXmppConnectionService.getRNG());
		final SSLSocketFactory factory = sc.getSocketFactory();
		final HostnameVerifier verifier = this.mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier());
		final InetAddress address = socket == null ? null : socket.getInetAddress();

		if (factory == null || address == null || verifier == null) {
			throw new IOException("could not setup ssl");
		}

		final SSLSocket sslSocket = (SSLSocket) factory.createSocket(socket,address.getHostAddress(), socket.getPort(),true);

		if (sslSocket == null) {
			throw new IOException("could not initialize ssl socket");
		}

		final String[] supportProtocols;
		if (enableLegacySSL()) {
			supportProtocols = sslSocket.getSupportedProtocols();
		} else {
			final Collection<String> supportedProtocols = new LinkedList<>(
					Arrays.asList(sslSocket.getSupportedProtocols()));
			supportedProtocols.remove("SSLv3");
			supportProtocols = new String[supportedProtocols.size()];
			supportedProtocols.toArray(supportProtocols);
		}
		sslSocket.setEnabledProtocols(supportProtocols);

		if (!verifier.verify(account.getServer().getDomainpart(),sslSocket.getSession())) {
			Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
			disconnect(true);
			changeStatus(Account.State.SECURITY_ERROR);
		}
		tagReader.setInputStream(sslSocket.getInputStream());
		tagWriter.setOutputStream(sslSocket.getOutputStream());
		sendStartStream();
		Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
		features.encryptionEnabled = true;
		processStream(tagReader.readTag());
		sslSocket.close();
	} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
		Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
		disconnect(true);
		changeStatus(Account.State.SECURITY_ERROR);
	}
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:50,代码来源:XmppConnection.java

示例7: sslConnectionSocketFactory

import org.apache.http.conn.ssl.StrictHostnameVerifier; //导入依赖的package包/类
private SSLConnectionSocketFactory sslConnectionSocketFactory() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
    return new SSLConnectionSocketFactory(sslContext(), new StrictHostnameVerifier());
}
 
开发者ID:jscep,项目名称:jester,代码行数:4,代码来源:EstClientLibestIT.java


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