/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
Copyright (c) 2002-2008 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jcraft.jsch;
import java.io.*;
import java.util.Vector;
public class ChannelSftp extends ChannelSession{
private static final byte SSH_FXP_INIT= 1;
private static final byte SSH_FXP_VERSION= 2;
private static final byte SSH_FXP_OPEN= 3;
private static final byte SSH_FXP_CLOSE= 4;
private static final byte SSH_FXP_READ= 5;
private static final byte SSH_FXP_WRITE= 6;
private static final byte SSH_FXP_LSTAT= 7;
private static final byte SSH_FXP_FSTAT= 8;
private static final byte SSH_FXP_SETSTAT= 9;
private static final byte SSH_FXP_FSETSTAT= 10;
private static final byte SSH_FXP_OPENDIR= 11;
private static final byte SSH_FXP_READDIR= 12;
private static final byte SSH_FXP_REMOVE= 13;
private static final byte SSH_FXP_MKDIR= 14;
private static final byte SSH_FXP_RMDIR= 15;
private static final byte SSH_FXP_REALPATH= 16;
private static final byte SSH_FXP_STAT= 17;
private static final byte SSH_FXP_RENAME= 18;
private static final byte SSH_FXP_READLINK= 19;
private static final byte SSH_FXP_SYMLINK= 20;
private static final byte SSH_FXP_STATUS= 101;
private static final byte SSH_FXP_HANDLE= 102;
private static final byte SSH_FXP_DATA= 103;
private static final byte SSH_FXP_NAME= 104;
private static final byte SSH_FXP_ATTRS= 105;
private static final byte SSH_FXP_EXTENDED= (byte)200;
private static final byte SSH_FXP_EXTENDED_REPLY= (byte)201;
// pflags
private static final int SSH_FXF_READ= 0x00000001;
private static final int SSH_FXF_WRITE= 0x00000002;
private static final int SSH_FXF_APPEND= 0x00000004;
private static final int SSH_FXF_CREAT= 0x00000008;
private static final int SSH_FXF_TRUNC= 0x00000010;
private static final int SSH_FXF_EXCL= 0x00000020;
private static final int SSH_FILEXFER_ATTR_SIZE= 0x00000001;
private static final int SSH_FILEXFER_ATTR_UIDGID= 0x00000002;
private static final int SSH_FILEXFER_ATTR_PERMISSIONS= 0x00000004;
private static final int SSH_FILEXFER_ATTR_ACMODTIME= 0x00000008;
private static final int SSH_FILEXFER_ATTR_EXTENDED= 0x80000000;
public static final int SSH_FX_OK= 0;
public static final int SSH_FX_EOF= 1;
public static final int SSH_FX_NO_SUCH_FILE= 2;
public static final int SSH_FX_PERMISSION_DENIED= 3;
public static final int SSH_FX_FAILURE= 4;
public static final int SSH_FX_BAD_MESSAGE= 5;
public static final int SSH_FX_NO_CONNECTION= 6;
public static final int SSH_FX_CONNECTION_LOST= 7;
public static final int SSH_FX_OP_UNSUPPORTED= 8;
/*
SSH_FX_OK
Indicates successful completion of the operation.
SSH_FX_EOF
indicates end-of-file condition; for SSH_FX_READ it means that no
more data is available in the file, and for SSH_FX_READDIR it
indicates that no more files are contained in the directory.
SSH_FX_NO_SUCH_FILE
is returned when a reference is made to a file which should exist
but doesn't.
SSH_FX_PERMISSION_DENIED
is returned when the authenticated user does not have sufficient
permissions to perform the operation.
SSH_FX_FAILURE
is a generic catch-all error message; it should be returned if an
error occurs for which there is no more specific error code
defined.
SSH_FX_BAD_MESSAGE
may be returned if a badly formatted packet or protocol
incompatibility is detected.
SSH_FX_NO_CONNECTION
is a pseudo-error which indicates that the client has no
connection to the server (it can only be generated locally by the
client, and MUST NOT be returned by servers).
SSH_FX_CONNECTION_LOST
is a pseudo-error which indicates that the connection to the
server has been lost (it can only be generated locally by the
client, and MUST NOT be returned by servers).
SSH_FX_OP_UNSUPPORTED
indicates that an attempt was made to perform an operation which
is not supported for the server (it may be generated locally by
the client if e.g. the version number exchange indicates that a
required feature is not supported by the server, or it may be
returned by the server if the server does not implement an
operation).
*/
private static final int MAX_MSG_LENGTH = 256* 1024;
public static final int OVERWRITE=0;
public static final int RESUME=1;
public static final int APPEND=2;
private boolean interactive=false;
private int seq=1;
private int[] ackid=new int[1];
private Buffer buf;
private Packet packet=new Packet(buf);
private int client_version=3;
private int server_version=3;
private String version=String.valueOf(client_version);
private java.util.Hashtable extensions=null;
private InputStream io_in=null;
/*
10. Changes from previous protocol versions
The SSH File Transfer Protocol has changed over time, before it's
standardization. The following is a description of the incompatible
changes between different versions.
10.1 Changes between versions 3 and 2
o The SSH_FXP_READLINK and SSH_FXP_SYMLINK messages were added.
o The SSH_FXP_EXTENDED and SSH_FXP_EXTENDED_REPLY messages were added.
o The SSH_FXP_STATUS message was changed to include fields `error
message' and `language tag'.
10.2 Changes between versions 2 and 1
o The SSH_FXP_RENAME message was added.
10.3 Changes between versions 1 and 0
o Implementation changes, no actual protocol changes.
*/
private static final String file_separator=java.io.File.separator;
private static final char file_separatorc=java.io.File.separatorChar;
private static boolean fs_is_bs=(byte)java.io.File.separatorChar == '\\';
private String cwd;
private String home;
private String lcwd;
private static final String UTF8="UTF-8";
private String fEncoding=UTF8;
private boolean fEncoding_is_utf8=true;
void init(){
}
public void start() throws JSchException{
try{
PipedOutputStream pos=new PipedOutputStre
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jcraft源代码,java连接SSH (120个子文件)
ChannelSftp.java 69KB
Session.java 51KB
IdentityFile.java 23KB
KeyPair.java 17KB
Channel.java 16KB
Sftp.java 15KB
KnownHosts.java 13KB
Util.java 12KB
ProxySOCKS5.java 11KB
JSch.java 10KB
KeyPairRSA.java 10KB
DHGEX.java 10KB
DHG1.java 9KB
SftpATTRS.java 9KB
ChannelForwardedTCPIP.java 9KB
UserAuthPublicKey.java 8KB
ChannelSession.java 7KB
ChannelX11.java 7KB
ProxySOCKS4.java 7KB
KeyPairDSA.java 7KB
UserAuthGSSAPIWithMIC.java 7KB
UserAuthKeyboardInteractive.java 7KB
ChannelAgentForwarding.java 6KB
ScpFrom.java 6KB
Util.java 6KB
PortWatcher.java 6KB
ScpToNoneCipher.java 6KB
UserAuthPassword.java 6KB
GSSContextKrb5.java 6KB
ScpTo.java 6KB
KeyExchange.java 6KB
Exec.java 5KB
ProxyHTTP.java 5KB
ChannelDirectTCPIP.java 5KB
KnownHosts.java 5KB
SignatureDSA.java 5KB
Subsystem.java 5KB
Logger.java 5KB
UserAuthPubKey.java 5KB
StreamForwarding.java 5KB
PortForwardingL.java 5KB
PortForwardingR.java 4KB
X11Forwarding.java 4KB
ViaSOCKS5.java 4KB
ViaHTTP.java 4KB
AES.java 4KB
UserAuthKI.java 4KB
Shell.java 4KB
Compression.java 4KB
UserAuthNone.java 4KB
Buffer.java 4KB
IO.java 4KB
DH.java 4KB
HostKey.java 3KB
HMAC.java 3KB
SignatureRSA.java 3KB
CommendScript.java 3KB
TripleDESCBC.java 3KB
ChannelSubsystem.java 3KB
Random.java 3KB
KeyPairGenRSA.java 3KB
ChannelExec.java 3KB
AES128CBC.java 3KB
AES256CBC.java 3KB
AES192CBC.java 3KB
BlowfishCBC.java 3KB
HMACSHA196.java 3KB
HMACMD596.java 3KB
RequestWindowChange.java 3KB
RequestPtyReq.java 3KB
RequestX11.java 3KB
HMACSHA1.java 3KB
HMACMD5.java 3KB
Request.java 3KB
KeyPairGenDSA.java 2KB
ChannelShell.java 2KB
UserAuth.java 2KB
RequestExec.java 2KB
RequestSubsystem.java 2KB
RequestAgentForwarding.java 2KB
RequestEnv.java 2KB
RequestShell.java 2KB
Logger.java 2KB
RequestSignal.java 2KB
RequestSftp.java 2KB
SftpException.java 2KB
SHA1.java 2KB
MD5.java 2KB
HMACSHA196.java 2KB
HMACMD596.java 2KB
HMACSHA1.java 2KB
HostKeyRepository.java 2KB
HMACMD5.java 2KB
JSchException.java 2KB
CipherNone.java 2KB
JSchPartialAuthException.java 2KB
SignatureDSA.java 2KB
Identity.java 2KB
JSchAuthCancelException.java 2KB
SocketFactory.java 2KB
共 120 条
- 1
- 2
chai168
- 粉丝: 0
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页