Package com.sshtools.common.sftp
Class SftpSubsystem
java.lang.Object
com.sshtools.common.ssh.Subsystem
com.sshtools.common.sftp.SftpSubsystem
- All Implemented Interfaces:
SftpSpecification
This class provides the SFTP subsystem. The subsystem obtains an instance of
the configured
com.sshtools.common.sftp.FileSystem to serve files
through the SFTP protocol. This implementation currently supports up to
version 3 of the protocol.- Author:
- Lee David Painter
-
Field Summary
FieldsFields inherited from class com.sshtools.common.ssh.Subsystem
context, session, SUBSYSTEM_INCOMING, SUBSYSTEM_OUTGOINGFields inherited from interface com.sshtools.common.sftp.SftpSpecification
SSH_FX_BYTE_RANGE_LOCK_CONFLICT, SSH_FX_BYTE_RANGE_LOCK_REFUSED, SSH_FX_CANNOT_DELETE, SSH_FX_DELETE_PENDING, SSH_FX_DIR_NOT_EMPTY, SSH_FX_FILE_ALREADY_EXISTS, SSH_FX_FILE_CORRUPT, SSH_FX_FILE_IS_A_DIRECTORY, SSH_FX_GROUP_INVALID, SSH_FX_INVALID_FILENAME, SSH_FX_INVALID_HANDLE, SSH_FX_INVALID_PARAMETER, SSH_FX_LINK_LOOP, SSH_FX_LOCK_CONFLICT, SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK, SSH_FX_NO_MEDIA, SSH_FX_NO_SPACE_ON_FILESYSTEM, SSH_FX_NO_SUCH_PATH, SSH_FX_NOT_A_DIRECTORY, SSH_FX_OWNER_INVALID, SSH_FX_QUOTA_EXCEEDED, SSH_FX_UNKNOWN_PRINCIPAL, SSH_FX_WRITE_PROTECT, SSH_FXF_ACCESS_APPEND_DATA, SSH_FXF_ACCESS_APPEND_DATA_ATOMIC, SSH_FXF_ACCESS_AUDIT_ALARM_INFO, SSH_FXF_ACCESS_BACKUP, SSH_FXF_ACCESS_BLOCK_ADVISORY, SSH_FXF_ACCESS_BLOCK_DELETE, SSH_FXF_ACCESS_BLOCK_READ, SSH_FXF_ACCESS_BLOCK_WRITE, SSH_FXF_ACCESS_DISPOSITION, SSH_FXF_ACCESS_TEXT_MODE, SSH_FXF_BACKUP_STREAM, SSH_FXF_CREATE_NEW, SSH_FXF_CREATE_TRUNCATE, SSH_FXF_DELETE_ON_CLOSE, SSH_FXF_NOFOLLOW, SSH_FXF_OPEN_EXISTING, SSH_FXF_OPEN_OR_CREATE, SSH_FXF_OVERRIDE_OWNER, SSH_FXF_TRUNCATE_EXISTING, SSH_FXP_ATTRS, SSH_FXP_BLOCK, SSH_FXP_CLOSE, SSH_FXP_DATA, SSH_FXP_EXTENDED, SSH_FXP_EXTENDED_REPLY, SSH_FXP_FSETSTAT, SSH_FXP_FSTAT, SSH_FXP_HANDLE, SSH_FXP_INIT, SSH_FXP_LINK, SSH_FXP_LSTAT, SSH_FXP_MKDIR, SSH_FXP_NAME, SSH_FXP_OPEN, SSH_FXP_OPENDIR, SSH_FXP_READ, SSH_FXP_READDIR, SSH_FXP_READLINK, SSH_FXP_REALPATH, SSH_FXP_REMOVE, SSH_FXP_RENAME, SSH_FXP_RMDIR, SSH_FXP_SETSTAT, SSH_FXP_STAT, SSH_FXP_STATUS, SSH_FXP_SYMLINK, SSH_FXP_UNBLOCK, SSH_FXP_VERSION, SSH_FXP_WRITE, STATUS_FX_EOF, STATUS_FX_FAILURE, STATUS_FX_NO_SUCH_FILE, STATUS_FX_OK, STATUS_FX_OP_UNSUPPORTED, STATUS_FX_PERMISSION_DENIED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransferEvent(String handle, TransferEvent evt) voidaddWrapper(SftpOperationWrapper wrapper) checkDefaultPath(String path) protected voidprotected voidfireCloseFileEvent(byte[] handle, Exception error) protected voidfireCloseFileEvent(TransferEvent evt, Exception error) voidprotected voidfireMakeDirectoryEvent(String path, Date started, Exception error) protected voidfireOpenDirectoryEvent(String path, Date started, byte[] handle, Exception error) protected voidfireOpenFileEvent(com.sshtools.common.util.UnsignedInteger32 flags, SftpFileAttributes attrs, String path, Date started, byte[] handle, Exception error) protected voidfireOpenInitEvent(com.sshtools.common.util.UnsignedInteger32 flags, SftpFileAttributes attrs, String path, Date started, Exception error) protected voidfireRemoveFileEvent(String path, Date started, Exception error) protected voidfireRenameFileEvent(String oldpath, String newpath, Date started, Exception error) protected voidfireRmDirEvent(String path, Date started, Exception error) protected voidfireSetStatEvent(String path, SftpFileAttributes old, SftpFileAttributes attrs, Date started, Exception error) protected voidfireStatEvent(String path, SftpFileAttributes attrs, Date started, Exception error) protected voidfireSymlinkEvent(String linkpath, String targetpath, Date started, Exception error) intvoidinit(SessionChannel session, Context context) Initialize the subsystem with the current session and configuration.protected voidonMessageReceived(byte[] msg) Called when a subsystem message has been extracted from the incoming data stream.protected voidCalled to free the subsystem and its resources.voidremoveWrapper(SftpOperationWrapper wrapper) voidsendAttributesMessage(int id, SftpFileAttributes attrs) intsendFilenameMessage(int id, SftpFile[] files, boolean isRealPath, boolean isAbsolute) voidsendHandleMessage(int id, byte[] handle) voidsendStatusMessage(int id, int reason, String description) voidsubmitTask(Runnable runnable) Methods inherited from class com.sshtools.common.ssh.Subsystem
cleanup, executeOperation, free, getConnection, getContext, getSession, onFreeMessage, parseMessage, processMessage, sendMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sshtools.common.sftp.SftpSpecification
sendMessage
-
Field Details
-
SFTP_QUEUE
-
SUBSYSTEM_NAME
- See Also:
-
-
Constructor Details
-
SftpSubsystem
public SftpSubsystem()
-
-
Method Details
-
init
public void init(SessionChannel session, Context context) throws IOException, PermissionDeniedException Description copied from class:SubsystemInitialize the subsystem with the current session and configuration.- Overrides:
initin classSubsystem- Throws:
IOExceptionPermissionDeniedException
-
cleanupSubsystem
protected void cleanupSubsystem()- Specified by:
cleanupSubsystemin classSubsystem
-
onSubsystemFree
protected void onSubsystemFree()Called to free the subsystem and its resources.- Specified by:
onSubsystemFreein classSubsystem
-
onMessageReceived
Description copied from class:SubsystemCalled when a subsystem message has been extracted from the incoming data stream.- Specified by:
onMessageReceivedin classSubsystem- Throws:
IOException
-
fireSetStatEvent
protected void fireSetStatEvent(String path, SftpFileAttributes old, SftpFileAttributes attrs, Date started, Exception error) -
fireStatEvent
-
fireSymlinkEvent
-
fireRmDirEvent
-
fireRenameFileEvent
-
fireRemoveFileEvent
-
fireOpenFileEvent
protected void fireOpenFileEvent(com.sshtools.common.util.UnsignedInteger32 flags, SftpFileAttributes attrs, String path, Date started, byte[] handle, Exception error) -
fireOpenInitEvent
protected void fireOpenInitEvent(com.sshtools.common.util.UnsignedInteger32 flags, SftpFileAttributes attrs, String path, Date started, Exception error) -
sendHandleMessage
- Throws:
IOException
-
fireCloseFileEvent
-
fireCloseFileEvent
-
sendAttributesMessage
- Throws:
IOException
-
fireOpenDirectoryEvent
-
sendStatusMessage
- Specified by:
sendStatusMessagein interfaceSftpSpecification
-
sendFilenameMessage
public int sendFilenameMessage(int id, SftpFile[] files, boolean isRealPath, boolean isAbsolute) throws IOException - Throws:
IOException
-
fireMakeDirectoryEvent
-
checkDefaultPath
- Throws:
IOExceptionPermissionDeniedException
-
fireEvent
-
getFileSystem
- Specified by:
getFileSystemin interfaceSftpSpecification
-
submitTask
-
addWrapper
-
removeWrapper
-
getCharsetEncoding
-
addTransferEvent
-
getVersion
public int getVersion()
-