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

Java DSAPublicKey类代码示例

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

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



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

示例1: verifySignature

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private boolean verifySignature(byte[] sig, byte[] hostkey)
		throws IOException {
	if (kxs.np.server_host_key_algo.equals("ssh-rsa")) {
		RSASignature rs = RSASHA1Verify.decodeSSHRSASignature(sig);
		RSAPublicKey rpk = RSASHA1Verify.decodeSSHRSAPublicKey(hostkey);

		log.log(50, "Verifying ssh-rsa signature");

		return RSASHA1Verify.verifySignature(kxs.H, rs, rpk);
	}

	if (kxs.np.server_host_key_algo.equals("ssh-dss")) {
		DSASignature ds = DSASHA1Verify.decodeSSHDSASignature(sig);
		DSAPublicKey dpk = DSASHA1Verify.decodeSSHDSAPublicKey(hostkey);

		log.log(50, "Verifying ssh-dss signature");

		return DSASHA1Verify.verifySignature(kxs.H, ds, dpk);
	}

	throw new IOException("Unknown server host key algorithm '"
			+ kxs.np.server_host_key_algo + "'");
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:24,代码来源:KexManager.java


示例2: addHostkey

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
/**
 * Adds a single public key entry to the database. Note: this will NOT add
 * the public key to any physical file (e.g., "~/.ssh/known_hosts") - use
 * <code>addHostkeyToFile()</code> for that purpose. This method is designed
 * to be used in a {@link ServerHostKeyVerifier}.
 * 
 * @param hostnames
 *            a list of hostname patterns - at least one most be specified.
 *            Check out the OpenSSH sshd man page for a description of the
 *            pattern matching algorithm.
 * @param serverHostKeyAlgorithm
 *            as passed to the {@link ServerHostKeyVerifier}.
 * @param serverHostKey
 *            as passed to the {@link ServerHostKeyVerifier}.
 * @throws IOException
 */
public void addHostkey(String hostnames[], String serverHostKeyAlgorithm,
		byte[] serverHostKey) throws IOException {
	if (hostnames == null)
		throw new IllegalArgumentException("hostnames may not be null");

	if ("ssh-rsa".equals(serverHostKeyAlgorithm)) {
		RSAPublicKey rpk = RSASHA1Verify
				.decodeSSHRSAPublicKey(serverHostKey);

		synchronized (publicKeys) {
			publicKeys.add(new KnownHostsEntry(hostnames, rpk));
		}
	} else if ("ssh-dss".equals(serverHostKeyAlgorithm)) {
		DSAPublicKey dpk = DSASHA1Verify
				.decodeSSHDSAPublicKey(serverHostKey);

		synchronized (publicKeys) {
			publicKeys.add(new KnownHostsEntry(hostnames, dpk));
		}
	} else
		throw new IOException("Unknwon host key type ("
				+ serverHostKeyAlgorithm + ")");
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:40,代码来源:KnownHosts.java


示例3: verifySignature

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private boolean verifySignature(byte[] sig, byte[] hostkey) throws IOException
{
	if (kxs.np.server_host_key_algo.equals("ssh-rsa"))
	{
		RSASignature rs = RSASHA1Verify.decodeSSHRSASignature(sig);
		RSAPublicKey rpk = RSASHA1Verify.decodeSSHRSAPublicKey(hostkey);

		log.log(50, "Verifying ssh-rsa signature");

		return RSASHA1Verify.verifySignature(kxs.H, rs, rpk);
	}

	if (kxs.np.server_host_key_algo.equals("ssh-dss"))
	{
		DSASignature ds = DSASHA1Verify.decodeSSHDSASignature(sig);
		DSAPublicKey dpk = DSASHA1Verify.decodeSSHDSAPublicKey(hostkey);

		log.log(50, "Verifying ssh-dss signature");

		return DSASHA1Verify.verifySignature(kxs.H, ds, dpk);
	}

	throw new IOException("Unknown server host key algorithm '" + kxs.np.server_host_key_algo + "'");
}
 
开发者ID:runsoftdev,项目名称:bVnc,代码行数:25,代码来源:KexManager.java


示例4: addHostkey

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
/**
 * Adds a single public key entry to the database. Note: this will NOT add the public key
 * to any physical file (e.g., "~/.ssh/known_hosts") - use <code>addHostkeyToFile()</code> for that purpose.
 * This method is designed to be used in a {@link ServerHostKeyVerifier}.
 * 
 * @param hostnames a list of hostname patterns - at least one most be specified. Check out the
 *        OpenSSH sshd man page for a description of the pattern matching algorithm.
 * @param serverHostKeyAlgorithm as passed to the {@link ServerHostKeyVerifier}.
 * @param serverHostKey as passed to the {@link ServerHostKeyVerifier}.
 * @throws IOException
 */
public void addHostkey(String hostnames[], String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException
{
	if (hostnames == null)
		throw new IllegalArgumentException("hostnames may not be null");

	if ("ssh-rsa".equals(serverHostKeyAlgorithm))
	{
		RSAPublicKey rpk = RSASHA1Verify.decodeSSHRSAPublicKey(serverHostKey);

		synchronized (publicKeys)
		{
			publicKeys.add(new KnownHostsEntry(hostnames, rpk));
		}
	}
	else if ("ssh-dss".equals(serverHostKeyAlgorithm))
	{
		DSAPublicKey dpk = DSASHA1Verify.decodeSSHDSAPublicKey(serverHostKey);

		synchronized (publicKeys)
		{
			publicKeys.add(new KnownHostsEntry(hostnames, dpk));
		}
	}
	else
		throw new IOException("Unknwon host key type (" + serverHostKeyAlgorithm + ")");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:KnownHosts.java


示例5: matchKeys

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private final boolean matchKeys(Object key1, Object key2)
{
	if ((key1 instanceof RSAPublicKey) && (key2 instanceof RSAPublicKey))
	{
		RSAPublicKey savedRSAKey = (RSAPublicKey) key1;
		RSAPublicKey remoteRSAKey = (RSAPublicKey) key2;

		if (savedRSAKey.getE().equals(remoteRSAKey.getE()) == false)
			return false;

		if (savedRSAKey.getN().equals(remoteRSAKey.getN()) == false)
			return false;

		return true;
	}

	if ((key1 instanceof DSAPublicKey) && (key2 instanceof DSAPublicKey))
	{
		DSAPublicKey savedDSAKey = (DSAPublicKey) key1;
		DSAPublicKey remoteDSAKey = (DSAPublicKey) key2;

		if (savedDSAKey.getG().equals(remoteDSAKey.getG()) == false)
			return false;

		if (savedDSAKey.getP().equals(remoteDSAKey.getP()) == false)
			return false;

		if (savedDSAKey.getQ().equals(remoteDSAKey.getQ()) == false)
			return false;

		if (savedDSAKey.getY().equals(remoteDSAKey.getY()) == false)
			return false;

		return true;
	}

	return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:KnownHosts.java


示例6: matchKeys

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private final boolean matchKeys(Object key1, Object key2) {
	if ((key1 instanceof RSAPublicKey) && (key2 instanceof RSAPublicKey)) {
		RSAPublicKey savedRSAKey = (RSAPublicKey) key1;
		RSAPublicKey remoteRSAKey = (RSAPublicKey) key2;

		if (savedRSAKey.getE().equals(remoteRSAKey.getE()) == false)
			return false;

		if (savedRSAKey.getN().equals(remoteRSAKey.getN()) == false)
			return false;

		return true;
	}

	if ((key1 instanceof DSAPublicKey) && (key2 instanceof DSAPublicKey)) {
		DSAPublicKey savedDSAKey = (DSAPublicKey) key1;
		DSAPublicKey remoteDSAKey = (DSAPublicKey) key2;

		if (savedDSAKey.getG().equals(remoteDSAKey.getG()) == false)
			return false;

		if (savedDSAKey.getP().equals(remoteDSAKey.getP()) == false)
			return false;

		if (savedDSAKey.getQ().equals(remoteDSAKey.getQ()) == false)
			return false;

		if (savedDSAKey.getY().equals(remoteDSAKey.getY()) == false)
			return false;

		return true;
	}

	return false;
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:36,代码来源:KnownHosts.java


示例7: recommendHostkeyAlgorithms

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private String[] recommendHostkeyAlgorithms(String hostname)
{
	String preferredAlgo = null;

	Vector keys = getAllKeys(hostname);

	for (int i = 0; i < keys.size(); i++)
	{
		String thisAlgo = null;

		if (keys.elementAt(i) instanceof RSAPublicKey)
			thisAlgo = "ssh-rsa";
		else if (keys.elementAt(i) instanceof DSAPublicKey)
			thisAlgo = "ssh-dss";
		else
			continue;

		if (preferredAlgo != null)
		{
			/* If we find different key types, then return null */

			if (preferredAlgo.compareTo(thisAlgo) != 0)
				return null;

			/* OK, we found the same algo again, optimize */

			continue;
		}
	}

	/* If we did not find anything that we know of, return null */

	if (preferredAlgo == null)
		return null;

	/* Now put the preferred algo to the start of the array.
	 * You may ask yourself why we do it that way - basically, we could just
	 * return only the preferred algorithm: since we have a saved key of that
	 * type (sent earlier from the remote host), then that should work out.
	 * However, imagine that the server is (for whatever reasons) not offering
	 * that type of hostkey anymore (e.g., "ssh-rsa" was disabled and
	 * now "ssh-dss" is being used). If we then do not let the server send us
	 * a fresh key of the new type, then we shoot ourself into the foot:
	 * the connection cannot be established and hence the user cannot decide
	 * if he/she wants to accept the new key.
	 */

	if (preferredAlgo.equals("ssh-rsa"))
		return new String[] { "ssh-rsa", "ssh-dss" };

	return new String[] { "ssh-dss", "ssh-rsa" };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:53,代码来源:KnownHosts.java


示例8: recommendHostkeyAlgorithms

import com.trilead.ssh2.signature.DSAPublicKey; //导入依赖的package包/类
private String[] recommendHostkeyAlgorithms(String hostname) {
	String preferredAlgo = null;

	Vector keys = getAllKeys(hostname);

	for (int i = 0; i < keys.size(); i++) {
		String thisAlgo = null;

		if (keys.elementAt(i) instanceof RSAPublicKey)
			thisAlgo = "ssh-rsa";
		else if (keys.elementAt(i) instanceof DSAPublicKey)
			thisAlgo = "ssh-dss";
		else
			continue;

		if (preferredAlgo != null) {
			/* If we find different key types, then return null */

			if (preferredAlgo.compareTo(thisAlgo) != 0)
				return null;

			/* OK, we found the same algo again, optimize */

			continue;
		}
	}

	/* If we did not find anything that we know of, return null */

	if (preferredAlgo == null)
		return null;

	/*
	 * Now put the preferred algo to the start of the array. You may ask
	 * yourself why we do it that way - basically, we could just return only
	 * the preferred algorithm: since we have a saved key of that type (sent
	 * earlier from the remote host), then that should work out. However,
	 * imagine that the server is (for whatever reasons) not offering that
	 * type of hostkey anymore (e.g., "ssh-rsa" was disabled and now
	 * "ssh-dss" is being used). If we then do not let the server send us a
	 * fresh key of the new type, then we shoot ourself into the foot: the
	 * connection cannot be established and hence the user cannot decide if
	 * he/she wants to accept the new key.
	 */

	if (preferredAlgo.equals("ssh-rsa"))
		return new String[] { "ssh-rsa", "ssh-dss" };

	return new String[] { "ssh-dss", "ssh-rsa" };
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:51,代码来源:KnownHosts.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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