• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConnectionHandshakeException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: recvCerts

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
void recvCerts() throws ConnectionHandshakeException  {
	final Cell cell = expectCell(Cell.CERTS);
	final int ncerts = cell.getByte();
	if(ncerts != 2) {
		throw new ConnectionHandshakeException("Expecting 2 certificates and got "+ ncerts);
	}

	linkCertificate = null;
	identityCertificate = null;
	
	for(int i = 0; i < ncerts; i++) {
		int type = cell.getByte();
		if(type == 1) {
			linkCertificate = testAndReadCertificate(cell, linkCertificate, "Link (type = 1)");
		} else if(type == 2) {
			identityCertificate = testAndReadCertificate(cell, identityCertificate, "Identity (type = 2)");
		} else {
			throw new ConnectionHandshakeException("Unexpected certificate type = "+ type + " in CERTS cell");
		}
	}
	
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:23,代码来源:ConnectionHandshakeV3.java


示例2: verifyCertificates

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
void verifyCertificates() throws ConnectionHandshakeException {
	PublicKey publicKey = identityCertificate.getPublicKey();
	verifyIdentityKey(publicKey);
	RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
	
	if(rsaPublicKey.getModulus().bitLength() != 1024) {
		throw new ConnectionHandshakeException("Invalid RSA modulus length in router identity key");
	}
	
	try {
		identityCertificate.checkValidity();
		identityCertificate.verify(rsaPublicKey);
		linkCertificate.checkValidity();
		linkCertificate.verify(rsaPublicKey);
	} catch (GeneralSecurityException e) {
		throw new ConnectionHandshakeException("Router presented invalid certificate chain in CERTS cell");
	}

	RSAPublicKey rsa2 = (RSAPublicKey) linkCertificate.getPublicKey();
	if(!getConnectionPublicKey().getModulus().equals(rsa2.getModulus())) {
		throw new ConnectionHandshakeException("Link certificate in CERTS cell does not match connection certificate");
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:24,代码来源:ConnectionHandshakeV3.java


示例3: testAndReadCertificate

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
private X509Certificate testAndReadCertificate(Cell cell, X509Certificate currentValue, String type) throws ConnectionHandshakeException {
	if(currentValue == null) {
		return readCertificateFromCell(cell);
	} else {
		throw new ConnectionHandshakeException("Duplicate "+ type + " certificates in CERTS cell");
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ConnectionHandshakeV3.java


示例4: recvAuthChallengeAndNetinfo

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
void recvAuthChallengeAndNetinfo() throws ConnectionHandshakeException {
	final Cell cell = expectCell(Cell.AUTH_CHALLENGE, Cell.NETINFO);
	if(cell.getCommand() == Cell.NETINFO) {
		processNetInfo(cell);
		return;
	}
	final Cell netinfo = expectCell(Cell.NETINFO);
	processNetInfo(netinfo);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:ConnectionHandshakeV3.java


示例5: createHandshake

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
static ConnectionHandshake createHandshake(TorConfig config, ConnectionImpl connection, SSLSocket socket) throws ConnectionHandshakeException {
	if(config.getHandshakeV3Enabled() && ConnectionHandshakeV3.sessionSupportsHandshake(socket.getSession())) {
		return new ConnectionHandshakeV3(connection, socket);
	} else if(config.getHandshakeV2Enabled()) {
		return new ConnectionHandshakeV2(connection, socket);
	} else {
		throw new ConnectionHandshakeException("No valid handshake type available for this connection");
	}
		
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:ConnectionHandshake.java


示例6: expectCell

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
protected Cell expectCell(Integer... expectedTypes) throws ConnectionHandshakeException {
	try {
		final Cell c = connection.readConnectionControlCell();
		for(int t: expectedTypes) {
			if(c.getCommand() == t) {
				return c;
			}
		}
		final List<Integer> expected = Arrays.asList(expectedTypes);
		throw new ConnectionHandshakeException("Expecting Cell command "+ expected + " and got [ "+ c.getCommand() +" ] instead");
	} catch (ConnectionIOException e) {
		throw new ConnectionHandshakeException("Connection exception while performing handshake "+ e);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:ConnectionHandshake.java


示例7: verifyIdentityKey

import com.subgraph.orchid.ConnectionHandshakeException; //导入依赖的package包/类
protected void verifyIdentityKey(PublicKey publicKey) throws ConnectionHandshakeException {
	if(!(publicKey instanceof RSAPublicKey)) {
		throw new ConnectionHandshakeException("Identity certificate public key is not an RSA key as expected");
	}
	final TorPublicKey identityKey = new TorPublicKey((RSAPublicKey)publicKey);
	final Router router = connection.getRouter();
	if((router instanceof BridgeRouter) && (router.getIdentityHash() == null)) {
		logger.info("Setting Bridge fingerprint from connection handshake for "+ router);
		((BridgeRouter) router).setIdentity(identityKey.getFingerprint());
	} else if(!identityKey.getFingerprint().equals(router.getIdentityHash())) {
		throw new ConnectionHandshakeException("Router identity does not match certificate key");
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:ConnectionHandshake.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DatagramSessionConfig类代码示例发布时间:2022-05-23
下一篇:
Java MediaPlayer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap