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

Java TypesWriter类代码示例

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

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



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

示例1: sendIdentities

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
private void sendIdentities() throws IOException
{
	Map<String,byte[]> keys = null;

	TypesWriter tw = new TypesWriter();
	tw.writeByte(SSH2_AGENT_IDENTITIES_ANSWER);
	int numKeys = 0;

	if (!authAgent.isAgentLocked())
		keys = authAgent.retrieveIdentities();

	if (keys != null)
		numKeys = keys.size();

	tw.writeUINT32(numKeys);

	if (keys != null) {
		for (Entry<String,byte[]> entry : keys.entrySet()) {
			byte[] keyBytes = entry.getValue();
			tw.writeString(keyBytes, 0, keyBytes.length);
			tw.writeString(entry.getKey());
		}
	}

	sendPacket(tw.getBytes());
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:27,代码来源:AuthAgentForwardThread.java


示例2: encodeSSHRSASignature

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHRSASignature(byte[] s) throws IOException
{
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-rsa");

	/* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as a string
	 * containing s (which is an integer, without lengths or padding, unsigned and in
	 * network byte order)."
	 */

	/* Remove first zero sign byte, if present */

	if ((s.length > 1) && (s[0] == 0x00))
		tw.writeString(s, 1, s.length - 1);
	else
		tw.writeString(s, 0, s.length);

	return tw.getBytes();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:21,代码来源:RSASHA1Verify.java


示例3: setstat

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 *  Modify the attributes of a file. Used for operations such as changing
 *  the ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param path See the {@link SFTPv3Client comment} for the class for more details.
 * @param attr A SFTPv3FileAttributes object. Specifies the modifications to be
 *             made to the attributes of the file. Empty fields will be ignored.
 * @throws IOException
 */
public void setstat(String path, SFTPv3FileAttributes attr) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(path, charsetName);
	tw.writeBytes(createAttrs(attr));

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_SETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:28,代码来源:SFTPv3Client.java


示例4: fsetstat

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * 	Modify the attributes of a file. Used for operations such as changing
 *  the ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param handle a SFTPv3FileHandle handle
 * @param attr A SFTPv3FileAttributes object. Specifies the modifications to be
 *             made to the attributes of the file. Empty fields will be ignored.
 * @throws IOException
 */
public void fsetstat(SFTPv3FileHandle handle, SFTPv3FileAttributes attr) throws IOException
{
	checkHandleValidAndOpen(handle);

	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
	tw.writeBytes(createAttrs(attr));

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_FSETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_FSETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:30,代码来源:SFTPv3Client.java


示例5: createSymlink

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Create a symbolic link on the server. Creates a link "src" that points
 * to "target".
 * 
 * @param src See the {@link SFTPv3Client comment} for the class for more details.
 * @param target See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void createSymlink(String src, String target) throws IOException
{
	int req_id = generateNextRequestID();

	/* Either I am too stupid to understand the SFTP draft
	 * or the OpenSSH guys changed the semantics of src and target.
	 */

	TypesWriter tw = new TypesWriter();
	tw.writeString(target, charsetName);
	tw.writeString(src, charsetName);

	if (debug != null)
	{
		debug.println("Sending SSH_FXP_SYMLINK...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:31,代码来源:SFTPv3Client.java


示例6: encodeSSHRSASignature

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHRSASignature(RSASignature sig) throws IOException
{
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-rsa");

	/* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as a string
	 * containing s (which is an integer, without lengths or padding, unsigned and in
	 * network byte order)."
	 */

	byte[] s = sig.getS().toByteArray();

	/* Remove first zero sign byte, if present */

	if ((s.length > 1) && (s[0] == 0x00))
		tw.writeString(s, 1, s.length - 1);
	else
		tw.writeString(s, 0, s.length);

	return tw.getBytes();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RSASHA1Verify.java


示例7: sendIdentities

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
private void sendIdentities() throws IOException {
	Map<String, byte[]> keys = null;

	TypesWriter tw = new TypesWriter();
	tw.writeByte(SSH2_AGENT_IDENTITIES_ANSWER);
	int numKeys = 0;

	if (!authAgent.isAgentLocked())
		keys = authAgent.retrieveIdentities();

	if (keys != null)
		numKeys = keys.size();

	tw.writeUINT32(numKeys);

	if (keys != null) {
		for (Entry<String, byte[]> entry : keys.entrySet()) {
			byte[] keyBytes = entry.getValue();
			tw.writeString(keyBytes, 0, keyBytes.length);
			tw.writeString(entry.getKey());
		}
	}

	sendPacket(tw.getBytes());
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:26,代码来源:AuthAgentForwardThread.java


示例8: encodeSSHRSASignature

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHRSASignature(RSASignature sig)
		throws IOException {
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-rsa");

	/*
	 * S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as
	 * a string containing s (which is an integer, without lengths or
	 * padding, unsigned and in network byte order)."
	 */

	byte[] s = sig.getS().toByteArray();

	/* Remove first zero sign byte, if present */

	if ((s.length > 1) && (s[0] == 0x00))
		tw.writeString(s, 1, s.length - 1);
	else
		tw.writeString(s, 0, s.length);

	return tw.getBytes();
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:24,代码来源:RSASHA1Verify.java


示例9: createSymlink

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Create a symbolic link on the server. Creates a link "src" that points to
 * "target".
 * 
 * @param src
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @param target
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @throws IOException
 */
public void createSymlink(String src, String target) throws IOException {
	int req_id = generateNextRequestID();

	/*
	 * Either I am too stupid to understand the SFTP draft or the OpenSSH
	 * guys changed the semantics of src and target.
	 */

	TypesWriter tw = new TypesWriter();
	tw.writeString(target, charsetName);
	tw.writeString(src, charsetName);

	if (debug != null) {
		debug.println("Sending SSH_FXP_SYMLINK...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:34,代码来源:SFTPv3Client.java


示例10: fsetstat

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Modify the attributes of a file. Used for operations such as changing the
 * ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param handle
 *            a SFTPv3FileHandle handle
 * @param attr
 *            A SFTPv3FileAttributes object. Specifies the modifications to
 *            be made to the attributes of the file. Empty fields will be
 *            ignored.
 * @throws IOException
 */
public void fsetstat(SFTPv3FileHandle handle, SFTPv3FileAttributes attr)
		throws IOException {
	checkHandleValidAndOpen(handle);

	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
	tw.writeBytes(createAttrs(attr));

	if (debug != null) {
		debug.println("Sending SSH_FXP_FSETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_FSETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:32,代码来源:SFTPv3Client.java


示例11: setstat

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Modify the attributes of a file. Used for operations such as changing the
 * ownership, permissions or access times, as well as for truncating a file.
 * 
 * @param path
 *            See the {@link SFTPv3Client comment} for the class for more
 *            details.
 * @param attr
 *            A SFTPv3FileAttributes object. Specifies the modifications to
 *            be made to the attributes of the file. Empty fields will be
 *            ignored.
 * @throws IOException
 */
public void setstat(String path, SFTPv3FileAttributes attr)
		throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(path, charsetName);
	tw.writeBytes(createAttrs(attr));

	if (debug != null) {
		debug.println("Sending SSH_FXP_SETSTAT...");
		debug.flush();
	}

	sendMessage(Packet.SSH_FXP_SETSTAT, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:31,代码来源:SFTPv3Client.java


示例12: sendPacket

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * @param tw
 * @throws IOException
 */
private void sendPacket(byte[] message) throws IOException
{
	TypesWriter packet = new TypesWriter();
	packet.writeUINT32(message.length);
	packet.writeBytes(message);
	os.write(packet.getBytes());
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:12,代码来源:AuthAgentForwardThread.java


示例13: encodeSSHDSAPublicKey

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk) throws IOException
{
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-dss");

	DSAParams params = pk.getParams();
	tw.writeMPInt(params.getP());
	tw.writeMPInt(params.getQ());
	tw.writeMPInt(params.getG());
	tw.writeMPInt(pk.getY());

	return tw.getBytes();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:15,代码来源:DSASHA1Verify.java


示例14: encodeSSHDSASignature

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Convert from Java's signature ASN.1 encoding to the SSH spec.
 * <p>
 * Java ASN.1 encoding:
 * <pre>
 * SEQUENCE ::= {
 *    r INTEGER,
 *    s INTEGER
 * }
 * </pre>
 */
public static byte[] encodeSSHDSASignature(byte[] ds)
{
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-dss");

	int len, index;

	index = 3;
	len = ds[index++] & 0xff;
	byte[] r = new byte[len];
	System.arraycopy(ds, index, r, 0, r.length);

	index = index + len + 1;
	len = ds[index++] & 0xff;
	byte[] s = new byte[len];
	System.arraycopy(ds, index, s, 0, s.length);

	byte[] a40 = new byte[40];

	/* Patch (unsigned) r and s into the target array. */

	int r_copylen = (r.length < 20) ? r.length : 20;
	int s_copylen = (s.length < 20) ? s.length : 20;

	System.arraycopy(r, r.length - r_copylen, a40, 20 - r_copylen, r_copylen);
	System.arraycopy(s, s.length - s_copylen, a40, 40 - s_copylen, s_copylen);

	tw.writeString(a40, 0, 40);

	return tw.getBytes();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:44,代码来源:DSASHA1Verify.java


示例15: encodeSSHRSAPublicKey

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHRSAPublicKey(RSAPublicKey pk) throws IOException
{
	TypesWriter tw = new TypesWriter();

	tw.writeString("ssh-rsa");
	tw.writeMPInt(pk.getPublicExponent());
	tw.writeMPInt(pk.getModulus());

	return tw.getBytes();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:11,代码来源:RSASHA1Verify.java


示例16: encodeSSHECDSASignature

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
public static byte[] encodeSSHECDSASignature(byte[] sig, ECParameterSpec params) throws IOException
{
	TypesWriter tw = new TypesWriter();

	String curveName = getCurveName(params);
	tw.writeString(ECDSA_SHA2_PREFIX + curveName);

	if ((sig[0] != 0x30) || (sig[1] != sig.length - 2) || (sig[2] != 0x02)) {
		throw new IOException("Invalid signature format");
	}

	int rLength = sig[3];
	if ((rLength + 6 > sig.length) || (sig[4 + rLength] != 0x02)) {
		throw new IOException("Invalid signature format");
	}

	int sLength = sig[5 + rLength];
	if (6 + rLength + sLength > sig.length) {
		throw new IOException("Invalid signature format");
	}

	byte[] rArray = new byte[rLength];
	byte[] sArray = new byte[sLength];

	System.arraycopy(sig, 4, rArray, 0, rLength);
	System.arraycopy(sig, 6 + rLength, sArray, 0, sLength);

	BigInteger r = new BigInteger(rArray);
	BigInteger s = new BigInteger(sArray);

	// Write the <r,s> to its own types writer.
	TypesWriter rsWriter = new TypesWriter();
	rsWriter.writeMPInt(r);
	rsWriter.writeMPInt(s);
	byte[] encoded = rsWriter.getBytes();
	tw.writeString(encoded, 0, encoded.length);

	return tw.getBytes();
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:40,代码来源:ECDSASHA2Verify.java


示例17: closeHandle

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
private final void closeHandle(byte[] handle) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(handle, 0, handle.length);

	sendMessage(Packet.SSH_FXP_CLOSE, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:12,代码来源:SFTPv3Client.java


示例18: mkdir

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Create a new directory.
 * 
 * @param dirName See the {@link SFTPv3Client comment} for the class for more details.
 * @param posixPermissions the permissions for this directory, e.g., "0700" (remember that
 *                         this is octal noation). The server will likely apply a umask.
 * 
 * @throws IOException
 */
public void mkdir(String dirName, int posixPermissions) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(dirName, charsetName);
	tw.writeUINT32(AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS);
	tw.writeUINT32(posixPermissions);

	sendMessage(Packet.SSH_FXP_MKDIR, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:23,代码来源:SFTPv3Client.java


示例19: rm

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Remove a file.
 * 
 * @param fileName See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void rm(String fileName) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(fileName, charsetName);

	sendMessage(Packet.SSH_FXP_REMOVE, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:18,代码来源:SFTPv3Client.java


示例20: rmdir

import com.trilead.ssh2.packets.TypesWriter; //导入依赖的package包/类
/**
 * Remove an empty directory. 
 * 
 * @param dirName See the {@link SFTPv3Client comment} for the class for more details.
 * @throws IOException
 */
public void rmdir(String dirName) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(dirName, charsetName);

	sendMessage(Packet.SSH_FXP_RMDIR, req_id, tw.getBytes());

	expectStatusOKMessage(req_id);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:18,代码来源:SFTPv3Client.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EventListener类代码示例发布时间:2022-05-23
下一篇:
Java IntValueHashMap类代码示例发布时间: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