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


Java MemorizingTrustManager.wrapHostnameVerifier方法代码示例

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


在下文中一共展示了MemorizingTrustManager.wrapHostnameVerifier方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTlsFactoryVerifier

import de.duenndns.ssl.MemorizingTrustManager; //导入方法依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
	final SSLContext sc = SSLSocketHelper.getSSLContext();
	MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
	KeyManager[] keyManager;
	if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
		keyManager = new KeyManager[]{mKeyManager};
	} else {
		keyManager = null;
	}
	sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager : trustManager.getNonInteractive()}, mXmppConnectionService.getRNG());
	final SSLSocketFactory factory = sc.getSocketFactory();
	final HostnameVerifier verifier;
	if (mInteractive) {
		verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier());
	} else {
		verifier = trustManager.wrapHostnameVerifierNonInteractive(new XmppDomainVerifier());
	}

	return new TlsFactoryVerifier(factory, verifier);
}
 
开发者ID:Frozenbox,项目名称:frozenchat,代码行数:21,代码来源:XmppConnection.java

示例2: getTlsFactoryVerifier

import de.duenndns.ssl.MemorizingTrustManager; //导入方法依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
	final SSLContext sc = SSLSocketHelper.getSSLContext();
	MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
	KeyManager[] keyManager;
	if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
		keyManager = new KeyManager[]{new MyKeyManager()};
	} else {
		keyManager = null;
	}
	String domain = account.getJid().getDomainpart();
	sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
	final SSLSocketFactory factory = sc.getSocketFactory();
	final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
	return new TlsFactoryVerifier(factory, verifier);
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:16,代码来源:XmppConnection.java

示例3: getTlsFactoryVerifier

import de.duenndns.ssl.MemorizingTrustManager; //导入方法依赖的package包/类
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
    final SSLContext sc = SSLSocketHelper.getSSLContext();
    MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
    KeyManager[] keyManager;
    if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
        keyManager = new KeyManager[]{new MyKeyManager()};
    } else {
        keyManager = null;
    }
    String domain = account.getJid().getDomainpart();
    sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
    final SSLSocketFactory factory = sc.getSocketFactory();
    final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
    return new TlsFactoryVerifier(factory, verifier);
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:16,代码来源:XmppConnection.java

示例4: switchOverToTls

import de.duenndns.ssl.MemorizingTrustManager; //导入方法依赖的package包/类
private void switchOverToTls(final Tag currentTag) throws XmlPullParserException, IOException {
	tagReader.readTag();
	try {
		final SSLContext sc = SSLContext.getInstance("TLS");
		MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
		KeyManager[] keyManager;
		if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
			keyManager = new KeyManager[]{ mKeyManager };
		} else {
			keyManager = null;
		}
		sc.init(keyManager,new X509TrustManager[]{mInteractive ? trustManager : trustManager.getNonInteractive()},mXmppConnectionService.getRNG());
		final SSLSocketFactory factory = sc.getSocketFactory();
		final HostnameVerifier verifier;
		if (mInteractive) {
			verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier());
		} else {
			verifier = trustManager.wrapHostnameVerifierNonInteractive(new XmppDomainVerifier());
		}
		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;
		final Collection<String> supportedProtocols = new LinkedList<>(
				Arrays.asList(sslSocket.getSupportedProtocols()));
		supportedProtocols.remove("SSLv3");
		supportProtocols = supportedProtocols.toArray(new String[supportedProtocols.size()]);

		sslSocket.setEnabledProtocols(supportProtocols);

		final String[] cipherSuites = CryptoHelper.getOrderedCipherSuites(
				sslSocket.getSupportedCipherSuites());
		//Log.d(Config.LOGTAG, "Using ciphers: " + Arrays.toString(cipherSuites));
		if (cipherSuites.length > 0) {
			sslSocket.setEnabledCipherSuites(cipherSuites);
		}

		if (!verifier.verify(account.getServer().getDomainpart(),sslSocket.getSession())) {
			Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
			throw new SecurityException();
		}
		tagReader.setInputStream(sslSocket.getInputStream());
		tagWriter.setOutputStream(sslSocket.getOutputStream());
		sendStartStream();
		Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
		features.encryptionEnabled = true;
		final Tag tag = tagReader.readTag();
		if (tag != null && tag.isStart("stream")) {
			processStream();
		} else {
			throw new IOException("server didn't restart stream after STARTTLS");
		}
		sslSocket.close();
	} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
		Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": TLS certificate verification failed");
		throw new SecurityException();
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:68,代码来源:XmppConnection.java


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