public class SftpSubsystem extends AbstractSftpSubsystemHelper implements Command, Runnable, SessionAware, FileSystemAware, org.apache.sshd.common.util.threads.ExecutorServiceCarrier, AsyncCommand, ChannelSessionAware, ChannelDataReceiver
ACL_SUPPORTED_MASK_PROP, AUTO_FOLLOW_LINKS, CLIENT_EXTENSIONS_PROP, DEFAULT_ACL_SUPPORTED_MASK, DEFAULT_AUTO_FOLLOW_LINKS, DEFAULT_MAX_READDATA_PACKET_LENGTH, DEFAULT_OPEN_SSH_EXTENSIONS, DEFAULT_OPEN_SSH_EXTENSIONS_NAMES, DEFAULT_SUPPORTED_CLIENT_EXTENSIONS, MAX_READDATA_PACKET_LENGTH_PROP, NEWLINE_VALUE, OPENSSH_EXTENSIONS_PROPlogALL_SFTP_IMPL, HIGHER_SFTP_IMPL, LOWER_SFTP_IMPL, SFTP_VERSION| Constructor and Description |
|---|
SftpSubsystem(org.apache.sshd.common.util.threads.CloseableExecutorService executorService,
UnsupportedAttributePolicy policy,
SftpFileSystemAccessor accessor,
SftpErrorStatusDataHandler errorStatusDataHandler) |
| 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() |
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 p,
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) |
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) |
Path |
getDefaultDirectory() |
org.apache.sshd.common.util.threads.CloseableExecutorService |
getExecutorService() |
ServerSession |
getServerSession() |
int |
getVersion() |
protected org.apache.sshd.common.util.buffer.Buffer |
prepareReply(org.apache.sshd.common.util.buffer.Buffer buffer) |
void |
run() |
protected void |
send(org.apache.sshd.common.util.buffer.Buffer buffer) |
void |
setChannelSession(ChannelSession session) |
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 |
setSession(ServerSession session) |
void |
start(Environment env) |
addMissingAttribute, addSftpEventListener, appendAclSupportedExtension, appendExtensions, appendNewlineExtension, appendOpenSSHExtensions, appendSupported2Extension, appendSupportedExtension, appendVendorIdExtension, appendVersionsExtension, 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, doRead, doReadDir, doReadLink, doReadLink, doRealPath, doRealPathV345, doRealPathV6, doRemove, doRemove, doRemove, doRemoveDirectory, doRemoveDirectory, 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, getPathResolutionLinkOption, getSftpEventListenerProxy, getShortName, getSupportedClientExtensions, getUnsupportedAttributePolicy, handleReadFileAttributesException, handleSetFileAttributeFailure, handleUnknownStatusFileAttributes, handleUnsupportedAttributes, handleUserPrincipalLookupServiceException, normalize, process, readAttrs, readFileAttributes, removeSftpEventListener, resolveAclSupportedCapabilities, resolveFile, resolveFileAttributes, resolveMissingFileAttributes, resolveMissingFileAttributeValue, resolveNewlineValue, resolveNormalizedLocation, resolveOpenSSHExtensions, sendAttrs, sendHandle, sendLink, sendPath, sendStatus, sendStatus, sendStatus, setFileAccessControl, setFileAttribute, setFileAttributes, setFileExtensions, setFileOwnership, setFilePermissions, setFileTime, signalOpenFailure, signalRemovalPreConditionFailure, toGroup, toUser, validateHandle, validateProposedVersion, validateRealPath, writeAttrs, writeDirEntrygetSimplifiedLoggerpublic static final String MAX_OPEN_HANDLES_PER_SESSION
public static final int DEFAULT_MAX_OPEN_HANDLES
public static final String FILE_HANDLE_SIZE
DEFAULT_FILE_HANDLE_SIZE,
Constant Field Valuespublic static final int MIN_FILE_HANDLE_SIZE
public static final int DEFAULT_FILE_HANDLE_SIZE
public static final int MAX_FILE_HANDLE_SIZE
public static final String MAX_FILE_HANDLE_RAND_ROUNDS
public static final int MIN_FILE_HANDLE_ROUNDS
public static final int DEFAULT_FILE_HANDLE_ROUNDS
public static final int MAX_FILE_HANDLE_ROUNDS
public static final String MAX_READDIR_DATA_SIZE_PROP
doReadDir(Buffer, int)public static final int DEFAULT_MAX_READDIR_DATA_SIZE
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 IoOutputStream err
protected Environment env
protected org.apache.sshd.common.random.Random randomizer
protected int fileHandleSize
protected int maxFileHandleRounds
protected Future<?> pendingFuture
protected byte[] workBuf
protected FileSystem fileSystem
protected Path defaultDir
protected int version
protected ServerSession serverSession
protected ChannelSession channelSession
protected org.apache.sshd.common.util.threads.CloseableExecutorService executorService
public SftpSubsystem(org.apache.sshd.common.util.threads.CloseableExecutorService executorService, UnsupportedAttributePolicy policy, SftpFileSystemAccessor accessor, SftpErrorStatusDataHandler errorStatusDataHandler)
executorService - The CloseableExecutorService to be used by
the SftpSubsystem command when starting execution. If
null then a single-threaded ad-hoc service is used.policy - The UnsupportedAttributePolicy to use if failed to access
some local file attributesaccessor - The SftpFileSystemAccessor to use for opening files and directorieserrorStatusDataHandler - The (never null) SftpErrorStatusDataHandler to
use when generating failed commands error messagesThreadUtils.newSingleThreadExecutor(String)public int getVersion()
getVersion in interface SftpSubsystemEnvironmentpublic Path getDefaultDirectory()
getDefaultDirectory in interface SftpSubsystemEnvironmentchroot locationpublic org.apache.sshd.common.util.threads.CloseableExecutorService getExecutorService()
getExecutorService in interface org.apache.sshd.common.util.threads.ExecutorServiceCarrierpublic void setSession(ServerSession session)
setSession in interface SessionAwarepublic ServerSession getServerSession()
getServerSession in interface ServerSessionHolderpublic void setChannelSession(ChannelSession session)
setChannelSession in interface ChannelSessionAwarepublic void setFileSystem(FileSystem fileSystem)
setFileSystem in interface FileSystemAwarepublic void setExitCallback(ExitCallback callback)
setExitCallback in interface Commandpublic void setInputStream(InputStream in)
setInputStream in interface Commandpublic void setOutputStream(OutputStream out)
setOutputStream in interface Commandpublic void setErrorStream(OutputStream err)
setErrorStream in interface Commandpublic void setIoInputStream(IoInputStream in)
setIoInputStream in interface AsyncCommandpublic void setIoOutputStream(IoOutputStream out)
setIoOutputStream in interface AsyncCommandpublic void setIoErrorStream(IoOutputStream err)
setIoErrorStream in interface AsyncCommandpublic void start(Environment env) throws IOException
start in interface CommandLifecycleIOExceptionpublic int data(ChannelSession channel, byte[] buf, int start, int len) throws IOException
data in interface ChannelDataReceiverIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelDataReceiverIOExceptionprotected void doProcess(org.apache.sshd.common.util.buffer.Buffer buffer, int length, int type, int id) throws IOException
doProcess in class AbstractSftpSubsystemHelperIOExceptionprotected void createLink(int id,
String existingPath,
String linkPath,
boolean symLink)
throws IOException
createLink in class AbstractSftpSubsystemHelperIOExceptionprotected void doTextSeek(int id,
String handle,
long line)
throws IOException
doTextSeek in class AbstractSftpSubsystemHelperIOExceptionprotected void doOpenSSHFsync(int id,
String handle)
throws IOException
doOpenSSHFsync in class AbstractSftpSubsystemHelperIOExceptionprotected 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 AbstractSftpSubsystemHelperExceptionprotected byte[] doMD5Hash(int id,
String targetType,
String target,
long startOffset,
long length,
byte[] quickCheckHash)
throws Exception
doMD5Hash in class AbstractSftpSubsystemHelperExceptionprotected void doVersionSelect(org.apache.sshd.common.util.buffer.Buffer buffer, int id, String proposed) throws IOException
doVersionSelect in class AbstractSftpSubsystemHelperIOExceptionprotected void doBlock(int id,
String handle,
long offset,
long length,
int mask)
throws IOException
doBlock in class AbstractSftpSubsystemHelperIOExceptionprotected void doUnblock(int id,
String handle,
long offset,
long length)
throws IOException
doUnblock in class AbstractSftpSubsystemHelperIOExceptionprotected void doCopyData(int id,
String readHandle,
long readOffset,
long readLength,
String writeHandle,
long writeOffset)
throws IOException
doCopyData in class AbstractSftpSubsystemHelperIOExceptionprotected void doReadDir(org.apache.sshd.common.util.buffer.Buffer buffer, int id) throws IOException
doReadDir in class AbstractSftpSubsystemHelperIOExceptionprotected String doOpenDir(int id, String path, Path p, LinkOption... options) throws IOException
doOpenDir in class AbstractSftpSubsystemHelperIOExceptionprotected void doFSetStat(int id,
String handle,
Map<String,?> attrs)
throws IOException
doFSetStat in class AbstractSftpSubsystemHelperIOExceptionprotected Map<String,Object> doFStat(int id, String handle, int flags) throws IOException
doFStat in class AbstractSftpSubsystemHelperIOExceptionprotected void doWrite(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
int remaining)
throws IOException
doWrite in class AbstractSftpSubsystemHelperIOExceptionprotected int doRead(int id,
String handle,
long offset,
int length,
byte[] data,
int doff)
throws IOException
doRead in class AbstractSftpSubsystemHelperIOExceptionprotected void doClose(int id,
String handle)
throws IOException
doClose in class AbstractSftpSubsystemHelperIOExceptionprotected String doOpen(int id, String path, int pflags, int access, Map<String,Object> attrs) throws IOException
doOpen in class AbstractSftpSubsystemHelperid - 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
IOExceptionprotected void doInit(org.apache.sshd.common.util.buffer.Buffer buffer, int id) throws IOException
doInit in class AbstractSftpSubsystemHelperIOExceptionprotected org.apache.sshd.common.util.buffer.Buffer prepareReply(org.apache.sshd.common.util.buffer.Buffer buffer)
prepareReply in class AbstractSftpSubsystemHelperprotected void send(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException
send in class AbstractSftpSubsystemHelperIOExceptionpublic void destroy()
destroy in interface CommandLifecycleprotected void closeAllHandles()
Copyright © 2018 The Apache Software Foundation. All rights reserved.