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


Java TypesWriter.writeUINT32方法代码示例

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


在下文中一共展示了TypesWriter.writeUINT32方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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:jianlinwei,项目名称:sshtunnel,代码行数:11,代码来源:AuthAgentForwardThread.java

示例6: init

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private void init() throws IOException
{
	/* Send SSH_FXP_INIT (version 3) */

	final int client_version = 3;

	if (debug != null)
		debug.println("Sending SSH_FXP_INIT (" + client_version + ")...");

	TypesWriter tw = new TypesWriter();
	tw.writeUINT32(client_version);
	sendMessage(Packet.SSH_FXP_INIT, 0, tw.getBytes());

	/* Receive SSH_FXP_VERSION */

	if (debug != null)
		debug.println("Waiting for SSH_FXP_VERSION...");

	TypesReader tr = new TypesReader(receiveMessage(34000)); /* Should be enough for any reasonable server */

	int type = tr.readByte();

	if (type != Packet.SSH_FXP_VERSION)
	{
		throw new IOException("The server did not send a SSH_FXP_VERSION packet (got " + type + ")");
	}

	protocol_version = tr.readUINT32();

	if (debug != null)
		debug.println("SSH_FXP_VERSION: protocol_version = " + protocol_version);

	if (protocol_version != 3)
		throw new IOException("Server version " + protocol_version + " is currently not supported");

	/* Read and save extensions (if any) for later use */

	while (tr.remain() != 0)
	{
		String name = tr.readString();
		byte[] value = tr.readByteString();
		server_extensions.put(name, value);

		if (debug != null)
			debug.println("SSH_FXP_VERSION: extension: " + name + " = '" + expandString(value, 0, value.length)
					+ "'");
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:49,代码来源:SFTPv3Client.java

示例7: createAttrs

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private byte[] createAttrs(SFTPv3FileAttributes attr)
{
	TypesWriter tw = new TypesWriter();

	int attrFlags = 0;

	if (attr == null)
	{
		tw.writeUINT32(0);
	}
	else
	{
		if (attr.size != null)
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE;

		if ((attr.uid != null) && (attr.gid != null))
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID;

		if (attr.permissions != null)
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS;

		if ((attr.atime != null) && (attr.mtime != null))
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME;

		tw.writeUINT32(attrFlags);

		if (attr.size != null)
			tw.writeUINT64(attr.size.longValue());

		if ((attr.uid != null) && (attr.gid != null))
		{
			tw.writeUINT32(attr.uid.intValue());
			tw.writeUINT32(attr.gid.intValue());
		}

		if (attr.permissions != null)
			tw.writeUINT32(attr.permissions.intValue());

		if ((attr.atime != null) && (attr.mtime != null))
		{
			tw.writeUINT32(attr.atime.intValue());
			tw.writeUINT32(attr.mtime.intValue());
		}
	}

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

示例8: openFile

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private SFTPv3FileHandle openFile(String fileName, int flags, SFTPv3FileAttributes attr) throws IOException
{
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(fileName, charsetName);
	tw.writeUINT32(flags);
	tw.writeBytes(createAttrs(attr));

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

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

	byte[] resp = receiveMessage(34000);

	TypesReader tr = new TypesReader(resp);

	int t = tr.readByte();

	int rep_id = tr.readUINT32();
	if (rep_id != req_id)
		throw new IOException("The server sent an invalid id field.");

	if (t == Packet.SSH_FXP_HANDLE)
	{
		if (debug != null)
		{
			debug.println("Got SSH_FXP_HANDLE.");
			debug.flush();
		}

		return new SFTPv3FileHandle(this, tr.readByteString());
	}

	if (t != Packet.SSH_FXP_STATUS)
		throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

	int errorCode = tr.readUINT32();
	String errorMessage = tr.readString();

	throw new SFTPException(errorMessage, errorCode);
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:47,代码来源:SFTPv3Client.java

示例9: createAttrs

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private byte[] createAttrs(SFTPv3FileAttributes attr) {
	TypesWriter tw = new TypesWriter();

	int attrFlags = 0;

	if (attr == null) {
		tw.writeUINT32(0);
	} else {
		if (attr.size != null)
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE;

		if ((attr.uid != null) && (attr.gid != null))
			attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID;

		if (attr.permissions != null)
			attrFlags = attrFlags
					| AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS;

		if ((attr.atime != null) && (attr.mtime != null))
			attrFlags = attrFlags
					| AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME;

		tw.writeUINT32(attrFlags);

		if (attr.size != null)
			tw.writeUINT64(attr.size.longValue());

		if ((attr.uid != null) && (attr.gid != null)) {
			tw.writeUINT32(attr.uid.intValue());
			tw.writeUINT32(attr.gid.intValue());
		}

		if (attr.permissions != null)
			tw.writeUINT32(attr.permissions.intValue());

		if ((attr.atime != null) && (attr.mtime != null)) {
			tw.writeUINT32(attr.atime.intValue());
			tw.writeUINT32(attr.mtime.intValue());
		}
	}

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

示例10: init

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private void init() throws IOException {
	/* Send SSH_FXP_INIT (version 3) */

	final int client_version = 3;

	if (debug != null)
		debug.println("Sending SSH_FXP_INIT (" + client_version + ")...");

	TypesWriter tw = new TypesWriter();
	tw.writeUINT32(client_version);
	sendMessage(Packet.SSH_FXP_INIT, 0, tw.getBytes());

	/* Receive SSH_FXP_VERSION */

	if (debug != null)
		debug.println("Waiting for SSH_FXP_VERSION...");

	TypesReader tr = new TypesReader(receiveMessage(34000)); /*
															 * Should be
															 * enough for
															 * any
															 * reasonable
															 * server
															 */

	int type = tr.readByte();

	if (type != Packet.SSH_FXP_VERSION) {
		throw new IOException(
				"The server did not send a SSH_FXP_VERSION packet (got "
						+ type + ")");
	}

	protocol_version = tr.readUINT32();

	if (debug != null)
		debug.println("SSH_FXP_VERSION: protocol_version = "
				+ protocol_version);

	if (protocol_version != 3)
		throw new IOException("Server version " + protocol_version
				+ " is currently not supported");

	/* Read and save extensions (if any) for later use */

	while (tr.remain() != 0) {
		String name = tr.readString();
		byte[] value = tr.readByteString();
		server_extensions.put(name, value);

		if (debug != null)
			debug.println("SSH_FXP_VERSION: extension: " + name + " = '"
					+ expandString(value, 0, value.length) + "'");
	}
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:56,代码来源:SFTPv3Client.java

示例11: openFile

import com.trilead.ssh2.packets.TypesWriter; //导入方法依赖的package包/类
private SFTPv3FileHandle openFile(String fileName, int flags,
		SFTPv3FileAttributes attr) throws IOException {
	int req_id = generateNextRequestID();

	TypesWriter tw = new TypesWriter();
	tw.writeString(fileName, charsetName);
	tw.writeUINT32(flags);
	tw.writeBytes(createAttrs(attr));

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

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

	byte[] resp = receiveMessage(34000);

	TypesReader tr = new TypesReader(resp);

	int t = tr.readByte();

	int rep_id = tr.readUINT32();
	if (rep_id != req_id)
		throw new IOException("The server sent an invalid id field.");

	if (t == Packet.SSH_FXP_HANDLE) {
		if (debug != null) {
			debug.println("Got SSH_FXP_HANDLE.");
			debug.flush();
		}

		return new SFTPv3FileHandle(this, tr.readByteString());
	}

	if (t != Packet.SSH_FXP_STATUS)
		throw new IOException(
				"The SFTP server sent an unexpected packet type (" + t
						+ ")");

	int errorCode = tr.readUINT32();
	String errorMessage = tr.readString();

	throw new SFTPException(errorMessage, errorCode);
}
 
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:46,代码来源:SFTPv3Client.java

示例12: 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:jianlinwei,项目名称:sshtunnel,代码行数:26,代码来源:SFTPv3Client.java


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