public class SftpSubsystem extends AbstractSftpSubsystemHelper implements Runnable, org.apache.sshd.common.file.FileSystemAware, org.apache.sshd.common.util.threads.ExecutorServiceCarrier, AsyncCommand, ChannelDataReceiver
Modifier and Type | Field and Description |
---|---|
protected org.apache.sshd.common.util.buffer.Buffer |
buffer |
protected ExitCallback |
callback |
protected static org.apache.sshd.common.util.buffer.Buffer |
CLOSE |
protected AtomicBoolean |
closed |
protected Path |
defaultDir |
protected Environment |
env |
protected org.apache.sshd.common.util.threads.CloseableExecutorService |
executorService |
protected Map<String,byte[]> |
extensions |
protected int |
fileHandleSize |
protected FileSystem |
fileSystem |
protected Map<String,Handle> |
handles |
protected int |
maxFileHandleRounds |
protected int |
maxHandleCount |
protected IoOutputStream |
out |
protected Future<?> |
pendingFuture |
protected org.apache.sshd.common.random.Random |
randomizer |
protected BlockingQueue<org.apache.sshd.common.util.buffer.Buffer> |
requests |
protected AtomicLong |
requestsCount |
protected Deque<String> |
unusedHandles |
protected int |
version |
protected byte[] |
workBuf |
DEFAULT_ACL_SUPPORTED_MASK, DEFAULT_OPEN_SSH_EXTENSIONS, DEFAULT_OPEN_SSH_EXTENSIONS_NAMES, DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
log
ALL_SFTP_IMPL, HIGHER_SFTP_IMPL, LOWER_SFTP_IMPL, SUPPORTED_SFTP_VERSIONS
Constructor and Description |
---|
SftpSubsystem(ChannelSession channel,
SftpSubsystemConfigurator configurator) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
closeAllHandles() |
protected void |
createLink(int id,
String existingPath,
String linkPath,
boolean symLink) |
int |
data(ChannelSession channel,
byte[] buf,
int start,
int len) |
void |
destroy(ChannelSession channel) |
protected void |
doBlock(int id,
String handle,
long offset,
long length,
int mask) |
protected void |
doCheckFileHash(int id,
String targetType,
String target,
Collection<String> algos,
long startOffset,
long length,
int blockSize,
org.apache.sshd.common.util.buffer.Buffer buffer) |
protected void |
doClose(int id,
String handle) |
protected void |
doCopyData(int id,
String readHandle,
long readOffset,
long readLength,
String writeHandle,
long writeOffset) |
protected void |
doFSetStat(int id,
String handle,
Map<String,?> attrs) |
protected Map<String,Object> |
doFStat(int id,
String handle,
int flags) |
protected void |
doInit(org.apache.sshd.common.util.buffer.Buffer buffer,
int id) |
protected byte[] |
doMD5Hash(int id,
String targetType,
String target,
long startOffset,
long length,
byte[] quickCheckHash) |
protected String |
doOpen(int id,
String path,
int pflags,
int access,
Map<String,Object> attrs) |
protected String |
doOpenDir(int id,
String path,
Path dir,
LinkOption... options) |
protected void |
doOpenSSHFsync(int id,
String handle) |
protected void |
doProcess(org.apache.sshd.common.util.buffer.Buffer buffer,
int length,
int type,
int id) |
protected int |
doRead(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
AtomicReference<Boolean> eof) |
protected void |
doReadDir(org.apache.sshd.common.util.buffer.Buffer buffer,
int id) |
protected void |
doTextSeek(int id,
String handle,
long line) |
protected void |
doUnblock(int id,
String handle,
long offset,
long length) |
protected void |
doVersionSelect(org.apache.sshd.common.util.buffer.Buffer buffer,
int id,
String proposed) |
protected void |
doWrite(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
int remaining) |
protected String |
generateFileHandle(Path file)
Generates a file handle, which is used as key in a
Map to record open file handles across requests. |
Path |
getDefaultDirectory() |
org.apache.sshd.common.util.threads.CloseableExecutorService |
getExecutorService() |
ServerSession |
getServerSession() |
int |
getVersion() |
protected void |
initializeSessionRelatedMember(ServerSession session,
ChannelSession channel) |
protected org.apache.sshd.common.util.buffer.Buffer |
prepareReply(org.apache.sshd.common.util.buffer.Buffer buffer) |
protected ChannelDataReceiver |
resolveErrorDataChannelReceiver(ChannelSession channelSession,
ChannelDataReceiver receiver) |
void |
run() |
protected void |
send(org.apache.sshd.common.util.buffer.Buffer buffer) |
void |
setErrorStream(OutputStream err) |
void |
setExitCallback(ExitCallback callback) |
void |
setFileSystem(FileSystem fileSystem) |
void |
setInputStream(InputStream in) |
void |
setIoErrorStream(IoOutputStream err) |
void |
setIoInputStream(IoInputStream in) |
void |
setIoOutputStream(IoOutputStream out) |
void |
setOutputStream(OutputStream out) |
void |
start(ChannelSession channel,
Environment env) |
addMissingAttribute, addSftpEventListener, appendAclSupportedExtension, appendExtensions, appendNewlineExtension, appendOpenSSHExtensions, appendSupported2Extension, appendSupportedExtension, appendVendorIdExtension, appendVersionsExtension, checkSymlinkState, checkVersionCompatibility, doBlock, doCheckFileHash, doCheckFileHash, doClose, doCopyData, doCopyFile, doCopyFile, doCopyFile, doExtended, doFSetStat, doFStat, doLink, doLink, doLStat, doLStat, doMakeDirectory, doMakeDirectory, doMD5Hash, doMD5Hash, doOpen, doOpenDir, doOpenSSHFsync, doOpenSSHHardLink, doOpenSSHHardLink, doOpenSSHLimits, doPosixRename, doRead, doReadDir, doReadLink, doReadLink, doRealPath, doRealPathV345, doRealPathV6, doRemove, doRemove, doRemoveDirectory, doRemoveDirectory, doRemoveFile, doRename, doRename, doRename, doSetAttributes, doSetStat, doSetStat, doSpaceAvailable, doSpaceAvailable, doStat, doStat, doSymLink, doSymLink, doTextSeek, doUnblock, doUnsupported, doUnsupportedExtension, doVersionSelect, doWrite, executeExtendedCommand, getAttributes, getAttributes, getErrorStatusDataHandler, getFileSystemAccessor, getLongName, getLongName, getLongName, getLongName, getOpenSSHLimitsExtensionInfo, getPathResolutionLinkOption, getServerChannelSession, getSftpEventListenerProxy, getShortName, getSupportedClientExtensions, getUnsupportedAttributePolicy, handleReadFileAttributesException, handleSetFileAttributeFailure, handleUnknownStatusFileAttributes, handleUnsupportedAttributes, handleUserPrincipalLookupServiceException, normalize, process, readAttrs, readFileAttributes, removeSftpEventListener, resolveAclSupportedCapabilities, resolveFile, resolveFileAttributes, resolveMissingFileAttributes, resolveMissingFileAttributeValue, resolveNewlineValue, resolveNormalizedLocation, resolveOpenSSHExtensions, resolvePathResolutionFollowLinks, resolveReportedFileAttributes, sendAttrs, sendHandle, sendLink, sendPath, sendStatus, sendStatus, sendStatus, setFileAccessControl, setFileAttribute, setFileAttributes, setFileExtensions, setFileOwnership, setFilePermissions, setFileRawViewAttribute, setFileTime, signalOpenFailure, signalRemovalPreConditionFailure, toGroup, toUser, validateHandle, validateParentExistWithNoSymlinksIfNeverFollowSymlinks, validateProposedVersion, validateRealPath, writeAttrs, writeDirEntry, writeDirEntry
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setFileSystemFactory
getSession
getSessionContext
protected static final org.apache.sshd.common.util.buffer.Buffer CLOSE
protected final AtomicBoolean closed
protected final AtomicLong requestsCount
protected final org.apache.sshd.common.util.buffer.Buffer buffer
protected final BlockingQueue<org.apache.sshd.common.util.buffer.Buffer> requests
protected ExitCallback callback
protected IoOutputStream out
protected Environment env
protected org.apache.sshd.common.random.Random randomizer
protected int maxHandleCount
protected int fileHandleSize
protected int maxFileHandleRounds
protected Future<?> pendingFuture
protected byte[] workBuf
protected FileSystem fileSystem
protected Path defaultDir
protected int version
protected org.apache.sshd.common.util.threads.CloseableExecutorService executorService
public SftpSubsystem(ChannelSession channel, SftpSubsystemConfigurator configurator)
channel
- The ChannelSession
through which the command was receivedconfigurator
- The SftpSubsystemConfigurator
to useprotected ChannelDataReceiver resolveErrorDataChannelReceiver(ChannelSession channelSession, ChannelDataReceiver receiver)
public int getVersion()
getVersion
in interface SftpSubsystemEnvironment
public Path getDefaultDirectory()
getDefaultDirectory
in interface SftpSubsystemEnvironment
chroot
locationpublic org.apache.sshd.common.util.threads.CloseableExecutorService getExecutorService()
getExecutorService
in interface org.apache.sshd.common.util.threads.ExecutorServiceCarrier
protected void initializeSessionRelatedMember(ServerSession session, ChannelSession channel)
public ServerSession getServerSession()
getServerSession
in interface ServerSessionHolder
public void setFileSystem(FileSystem fileSystem)
setFileSystem
in interface org.apache.sshd.common.file.FileSystemAware
public void setExitCallback(ExitCallback callback)
setExitCallback
in interface Command
public void setInputStream(InputStream in)
setInputStream
in interface CommandDirectInputStreamAware
public void setOutputStream(OutputStream out)
setOutputStream
in interface CommandDirectOutputStreamAware
public void setErrorStream(OutputStream err)
setErrorStream
in interface CommandDirectErrorStreamAware
public void setIoInputStream(IoInputStream in)
setIoInputStream
in interface AsyncCommandInputStreamAware
public void setIoOutputStream(IoOutputStream out)
setIoOutputStream
in interface AsyncCommandOutputStreamAware
public void setIoErrorStream(IoOutputStream err)
setIoErrorStream
in interface AsyncCommandErrorStreamAware
public void start(ChannelSession channel, Environment env) throws IOException
start
in interface CommandLifecycle
IOException
public int data(ChannelSession channel, byte[] buf, int start, int len) throws IOException
data
in interface ChannelDataReceiver
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void doProcess(org.apache.sshd.common.util.buffer.Buffer buffer, int length, int type, int id) throws IOException
doProcess
in class AbstractSftpSubsystemHelper
IOException
protected void createLink(int id, String existingPath, String linkPath, boolean symLink) throws IOException
createLink
in class AbstractSftpSubsystemHelper
IOException
protected void doTextSeek(int id, String handle, long line) throws IOException
doTextSeek
in class AbstractSftpSubsystemHelper
IOException
protected void doOpenSSHFsync(int id, String handle) throws IOException
doOpenSSHFsync
in class AbstractSftpSubsystemHelper
IOException
protected void doCheckFileHash(int id, String targetType, String target, Collection<String> algos, long startOffset, long length, int blockSize, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception
doCheckFileHash
in class AbstractSftpSubsystemHelper
Exception
protected byte[] doMD5Hash(int id, String targetType, String target, long startOffset, long length, byte[] quickCheckHash) throws Exception
doMD5Hash
in class AbstractSftpSubsystemHelper
Exception
protected void doVersionSelect(org.apache.sshd.common.util.buffer.Buffer buffer, int id, String proposed) throws IOException
doVersionSelect
in class AbstractSftpSubsystemHelper
IOException
protected void doBlock(int id, String handle, long offset, long length, int mask) throws IOException
doBlock
in class AbstractSftpSubsystemHelper
IOException
protected void doUnblock(int id, String handle, long offset, long length) throws IOException
doUnblock
in class AbstractSftpSubsystemHelper
IOException
protected void doCopyData(int id, String readHandle, long readOffset, long readLength, String writeHandle, long writeOffset) throws IOException
doCopyData
in class AbstractSftpSubsystemHelper
IOException
protected void doReadDir(org.apache.sshd.common.util.buffer.Buffer buffer, int id) throws IOException
doReadDir
in class AbstractSftpSubsystemHelper
IOException
protected String doOpenDir(int id, String path, Path dir, LinkOption... options) throws IOException
doOpenDir
in class AbstractSftpSubsystemHelper
IOException
protected void doFSetStat(int id, String handle, Map<String,?> attrs) throws IOException
doFSetStat
in class AbstractSftpSubsystemHelper
IOException
protected Map<String,Object> doFStat(int id, String handle, int flags) throws IOException
doFStat
in class AbstractSftpSubsystemHelper
IOException
protected void doWrite(int id, String handle, long offset, int length, byte[] data, int doff, int remaining) throws IOException
doWrite
in class AbstractSftpSubsystemHelper
IOException
protected int doRead(int id, String handle, long offset, int length, byte[] data, int doff, AtomicReference<Boolean> eof) throws IOException
doRead
in class AbstractSftpSubsystemHelper
IOException
protected void doClose(int id, String handle) throws IOException
doClose
in class AbstractSftpSubsystemHelper
IOException
protected String doOpen(int id, String path, int pflags, int access, Map<String,Object> attrs) throws IOException
doOpen
in class AbstractSftpSubsystemHelper
id
- Request idpath
- Pathpflags
- Open mode flags - see SSH_FXF_XXX
flagsaccess
- Access mode flags - see ACE4_XXX
flagsattrs
- Requested attributesIOException
- if failed to executeprotected String generateFileHandle(Path file) throws IOException
Map
to record open file handles across requests. For
historical reasons, the handle is returned as a String
, and other APIs also use String
for
handles, so we're kind of stuck with that.
As of version 2.10.1, the result must be encoded using StandardCharsets.ISO_8859_1
, and it must
not have more than 256 IOS-8859-1 characters (i.e., bytes).
This method is called with the monitor on the handles
Map
held.
file
- to generate a handle forIOException
- if no handle could be generatedprotected void doInit(org.apache.sshd.common.util.buffer.Buffer buffer, int id) throws IOException
doInit
in class AbstractSftpSubsystemHelper
IOException
protected org.apache.sshd.common.util.buffer.Buffer prepareReply(org.apache.sshd.common.util.buffer.Buffer buffer)
prepareReply
in class AbstractSftpSubsystemHelper
protected void send(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
send
in class AbstractSftpSubsystemHelper
IOException
public void destroy(ChannelSession channel)
destroy
in interface CommandLifecycle
protected void closeAllHandles()
Copyright © 2018–2024 The Apache Software Foundation. All rights reserved.