public class SftpSubsystem extends AbstractLoggingBean implements Command, Runnable, SessionAware, FileSystemAware
| Modifier and Type | Field and Description |
|---|---|
static String |
ALL_SFTP_IMPL |
protected ExitCallback |
callback |
static String |
CLIENT_EXTENSIONS_PROP
Allows controlling reports of which client extensions are supported
(and reported via "support" and "support2" server
extensions) as a comma-separate list of names.
|
protected boolean |
closed |
static int |
DEFAULT_FILE_HANDLE_ROUNDS |
static int |
DEFAULT_FILE_HANDLE_SIZE |
static int |
DEFAULT_MAX_OPEN_HANDLES |
static int |
DEFAULT_MAX_PACKET_LENGTH |
static List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
DEFAULT_OPEN_SSH_EXTENSIONS |
static List<String> |
DEFAULT_OPEN_SSH_EXTENSIONS_NAMES |
static Set<String> |
DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
The default reported supported client extensions
|
static List<String> |
DEFAULT_UNIX_VIEW |
protected Path |
defaultDir |
protected Environment |
env |
protected OutputStream |
err |
protected ExecutorService |
executors |
protected Map<String,byte[]> |
extensions |
static String |
FILE_HANDLE_SIZE
Size in bytes of the opaque handle value
|
static Map<String,FileInfoExtractor<?>> |
FILEATTRS_RESOLVERS
A
Map of FileInfoExtractors to be used to complete
attributes that are deemed important enough to warrant an extra
effort if not accessible via the file system attributes views |
protected int |
fileHandleSize |
protected FileSystem |
fileSystem |
protected Map<String,Handle> |
handles |
static int |
HIGHER_SFTP_IMPL |
protected InputStream |
in |
static int |
LOWER_SFTP_IMPL |
static String |
MAX_FILE_HANDLE_RAND_ROUNDS
Max.
|
static int |
MAX_FILE_HANDLE_ROUNDS |
static int |
MAX_FILE_HANDLE_SIZE |
static String |
MAX_OPEN_HANDLES_PER_SESSION
Properties key for the maximum of available open handles per session.
|
static String |
MAX_PACKET_LENGTH_PROP
Force the use of a max.
|
protected int |
maxFileHandleRounds |
static int |
MIN_FILE_HANDLE_ROUNDS |
static int |
MIN_FILE_HANDLE_SIZE |
static String |
OPENSSH_EXTENSIONS_PROP
Comma-separated list of which
OpenSSH extensions are reported and
what version is reported for each - format: name=version. |
protected OutputStream |
out |
protected Future<?> |
pendingFuture |
protected Random |
randomizer |
protected long |
requestsCount |
protected ServerSession |
session |
static String |
SFTP_VERSION
Force the use of a given sftp version
|
protected boolean |
shutdownExecutor |
protected UnsupportedAttributePolicy |
unsupportedAttributePolicy |
protected int |
version |
protected byte[] |
workBuf |
log| Constructor and Description |
|---|
SftpSubsystem(ExecutorService executorService,
boolean shutdownOnExit,
UnsupportedAttributePolicy policy) |
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,Object> |
addMissingAttribute(Path file,
Map<String,Object> current,
String name,
FileInfoExtractor<?> x,
LinkOption... options) |
protected void |
appendExtensions(Buffer buffer,
String supportedVersions) |
protected void |
appendNewlineExtension(Buffer buffer,
String value)
Appends the "newline" extension to the buffer.
|
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
appendOpenSSHExtensions(Buffer buffer) |
protected void |
appendSupported2Extension(Buffer buffer,
Collection<String> extras)
Appends the "supported2" extension to the buffer.
|
protected void |
appendSupportedExtension(Buffer buffer,
Collection<String> extras)
Appends the "supported" extension to the buffer.
|
protected void |
appendVendorIdExtension(Buffer buffer,
Map<String,?> versionProperties)
Appends the "vendor-id" extension to the buffer.
|
protected void |
appendVersionsExtension(Buffer buffer,
String value)
Appends the "versions" extension to the buffer.
|
protected String |
checkVersionCompatibility(Buffer buffer,
int id,
int proposed,
int failureOpcode)
Checks if a proposed version is within supported range.
|
protected void |
createLink(int id,
String targetPath,
String linkPath,
boolean symLink) |
void |
destroy()
Destroy the shell.
|
protected void |
doBlock(Buffer buffer,
int id) |
protected void |
doBlock(int id,
String handle,
long offset,
long length,
int mask) |
protected void |
doCheckFileHash(Buffer buffer,
int id,
String targetType) |
protected void |
doCheckFileHash(int id,
Path file,
NamedFactory<? extends Digest> factory,
long startOffset,
long length,
int blockSize,
Buffer buffer) |
protected void |
doCheckFileHash(int id,
String targetType,
String target,
Collection<String> algos,
long startOffset,
long length,
int blockSize,
Buffer buffer) |
protected void |
doClose(Buffer buffer,
int id) |
protected void |
doClose(int id,
String handle) |
protected void |
doCopyData(Buffer buffer,
int id) |
protected void |
doCopyData(int id,
String readHandle,
long readOffset,
long readLength,
String writeHandle,
long writeOffset) |
protected void |
doCopyFile(Buffer buffer,
int id) |
protected void |
doCopyFile(int id,
String srcFile,
String dstFile,
boolean overwriteDestination) |
protected void |
doCopyFile(int id,
String srcFile,
String dstFile,
Collection<CopyOption> opts) |
protected void |
doExtended(Buffer buffer,
int id) |
protected void |
doFSetStat(Buffer buffer,
int id) |
protected void |
doFSetStat(int id,
String handle,
Map<String,?> attrs) |
protected void |
doFStat(Buffer buffer,
int id) |
protected Map<String,Object> |
doFStat(int id,
String handle,
int flags) |
protected void |
doInit(Buffer buffer,
int id) |
protected void |
doLink(Buffer buffer,
int id) |
protected void |
doLink(int id,
String targetPath,
String linkPath,
boolean symLink) |
protected void |
doLStat(Buffer buffer,
int id) |
protected Map<String,Object> |
doLStat(int id,
String path,
int flags) |
protected void |
doMakeDirectory(Buffer buffer,
int id) |
protected void |
doMakeDirectory(int id,
String path,
Map<String,?> attrs,
LinkOption... options) |
protected void |
doMD5Hash(Buffer buffer,
int id,
String targetType) |
protected byte[] |
doMD5Hash(int id,
Path path,
long startOffset,
long length,
byte[] quickCheckHash) |
protected byte[] |
doMD5Hash(int id,
String targetType,
String target,
long startOffset,
long length,
byte[] quickCheckHash) |
protected void |
doOpen(Buffer buffer,
int id) |
protected String |
doOpen(int id,
String path,
int pflags,
int access,
Map<String,Object> attrs) |
protected void |
doOpenDir(Buffer buffer,
int id) |
protected String |
doOpenDir(int id,
String path,
LinkOption... options) |
protected void |
doOpenSSHFsync(Buffer buffer,
int id) |
protected void |
doOpenSSHFsync(int id,
String handle) |
protected void |
doRead(Buffer buffer,
int id) |
protected int |
doRead(int id,
String handle,
long offset,
int length,
byte[] data,
int doff) |
protected void |
doReadDir(Buffer buffer,
int id) |
protected int |
doReadDir(int id,
DirectoryHandle dir,
Buffer buffer,
int maxSize) |
protected void |
doReadLink(Buffer buffer,
int id) |
protected String |
doReadLink(int id,
String path) |
protected void |
doRealPath(Buffer buffer,
int id) |
protected Pair<Path,Boolean> |
doRealPathV345(int id,
String path,
LinkOption... options) |
protected Pair<Path,Boolean> |
doRealPathV6(int id,
String path,
Collection<String> extraPaths,
LinkOption... options) |
protected void |
doRemove(Buffer buffer,
int id) |
protected void |
doRemove(int id,
String path,
LinkOption... options) |
protected void |
doRemoveDirectory(Buffer buffer,
int id) |
protected void |
doRemoveDirectory(int id,
String path,
LinkOption... options) |
protected void |
doRename(Buffer buffer,
int id) |
protected void |
doRename(int id,
String oldPath,
String newPath,
Collection<CopyOption> opts) |
protected void |
doRename(int id,
String oldPath,
String newPath,
int flags) |
protected void |
doSetStat(Buffer buffer,
int id) |
protected void |
doSetStat(int id,
String path,
Map<String,?> attrs) |
protected void |
doSpaceAvailable(Buffer buffer,
int id) |
protected SpaceAvailableExtensionInfo |
doSpaceAvailable(int id,
String path) |
protected void |
doStat(Buffer buffer,
int id) |
protected Map<String,Object> |
doStat(int id,
String path,
int flags) |
protected void |
doSymLink(Buffer buffer,
int id) |
protected void |
doSymLink(int id,
String targetPath,
String linkPath) |
protected void |
doTextSeek(Buffer buffer,
int id) |
protected void |
doTextSeek(int id,
String handle,
long line) |
protected void |
doUnblock(Buffer buffer,
int id) |
protected boolean |
doUnblock(int id,
String handle,
long offset,
long length) |
protected void |
doVersionSelect(Buffer buffer,
int id) |
protected void |
doWrite(Buffer buffer,
int id) |
protected void |
doWrite(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
int remaining) |
protected void |
executeExtendedCommand(Buffer buffer,
int id,
String extension) |
protected String |
generateFileHandle(Path file) |
protected Map<String,Object> |
getAttributes(Path file,
int flags,
LinkOption... options) |
protected Map<String,Object> |
getAttributes(Path file,
LinkOption... options) |
protected String |
getLongName(Path f,
LinkOption... options) |
protected String |
getShortName(Path f) |
protected Collection<String> |
getSupportedClientExtensions() |
UnsupportedAttributePolicy |
getUnsupportedAttributePolicy() |
int |
getVersion() |
protected Map<String,Object> |
handleReadFileAttributesException(Path file,
String view,
LinkOption[] options,
IOException e) |
protected Map<String,Object> |
handleUnknownStatusFileAttributes(Path file,
int flags,
LinkOption... options) |
protected void |
handleUnsupportedAttributes(Collection<String> attributes) |
protected void |
handleUserPrincipalLookupServiceException(Class<? extends Principal> principalType,
String name,
IOException e) |
protected Path |
normalize(Path f) |
protected void |
process(Buffer buffer) |
protected Map<String,Object> |
readAttrs(Buffer buffer) |
protected Map<String,Object> |
readFileAttributes(Path file,
String view,
LinkOption... options) |
protected Path |
resolveFile(String remotePath) |
protected Map<String,Object> |
resolveFileAttributes(Path file,
int flags,
LinkOption... options) |
protected Map<String,Object> |
resolveMissingFileAttributes(Path file,
int flags,
Map<String,Object> current,
LinkOption... options)
Called by
getAttributes(Path, int, LinkOption...) in order
to complete any attributes that could not be retrieved via the supported
file system views. |
protected Object |
resolveMissingFileAttributeValue(Path file,
String name,
Object value,
FileInfoExtractor<?> x,
LinkOption... options) |
protected Path |
resolveNormalizedLocation(String remotePath) |
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
resolveOpenSSHExtensions() |
void |
run() |
protected void |
send(Buffer buffer) |
protected void |
sendAttrs(Buffer buffer,
int id,
Map<String,?> attributes) |
protected void |
sendHandle(Buffer buffer,
int id,
String handle) |
protected void |
sendLink(Buffer buffer,
int id,
String link) |
protected void |
sendPath(Buffer buffer,
int id,
Path f,
Map<String,?> attrs) |
protected void |
sendStatus(Buffer buffer,
int id,
Exception e) |
protected void |
sendStatus(Buffer buffer,
int id,
int substatus,
String msg) |
protected void |
sendStatus(Buffer buffer,
int id,
int substatus,
String msg,
String lang) |
protected void |
setAttributes(Path file,
Map<String,?> attributes) |
void |
setErrorStream(OutputStream err)
Set the error stream that can be used by the shell to write its errors.
|
void |
setExitCallback(ExitCallback callback)
Set the callback that the shell has to call when it is closed.
|
void |
setFileSystem(FileSystem fileSystem)
Set the file system in which this shell will be executed.
|
void |
setInputStream(InputStream in)
Set the input stream that can be used by the shell to read input.
|
void |
setOutputStream(OutputStream out)
Set the output stream that can be used by the shell to write its output.
|
void |
setSession(ServerSession session) |
void |
start(Environment env)
Starts the shell.
|
protected <H extends Handle> |
validateHandle(String handle,
Handle h,
Class<H> type) |
protected Boolean |
validateProposedVersion(Buffer buffer,
int id,
String proposed) |
protected Pair<Path,Boolean> |
validateRealPath(int id,
String path,
Path f,
LinkOption... options) |
protected void |
writeAttrs(Buffer buffer,
Map<String,?> attributes) |
protected void |
writeDirEntry(int id,
DirectoryHandle dir,
Buffer buffer,
int index,
Path f,
String shortName,
LinkOption... options) |
public 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 SFTP_VERSION
public static final int LOWER_SFTP_IMPL
public static final int HIGHER_SFTP_IMPL
public static final String ALL_SFTP_IMPL
public static final String MAX_PACKET_LENGTH_PROP
doReadDir(Buffer, int)
and doRead(Buffer, int) methodsDEFAULT_MAX_PACKET_LENGTH,
Constant Field Valuespublic static final int DEFAULT_MAX_PACKET_LENGTH
public static final String CLIENT_EXTENSIONS_PROP
executeExtendedCommand(Buffer, int, String)
command accordingly. If empty string is set then no server extensions
are reportedpublic static final Set<String> DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
public static final String OPENSSH_EXTENSIONS_PROP
OpenSSH extensions are reported and
what version is reported for each - format: name=version. If empty
value set, then no such extensions are reported. Otherwise, the
DEFAULT_OPEN_SSH_EXTENSIONS are usedpublic static final List<AbstractOpenSSHExtensionParser.OpenSSHExtension> DEFAULT_OPEN_SSH_EXTENSIONS
public static final List<String> DEFAULT_OPEN_SSH_EXTENSIONS_NAMES
public static final Map<String,FileInfoExtractor<?>> FILEATTRS_RESOLVERS
Map of FileInfoExtractors to be used to complete
attributes that are deemed important enough to warrant an extra
effort if not accessible via the file system attributes viewsprotected ExitCallback callback
protected InputStream in
protected OutputStream out
protected OutputStream err
protected Environment env
protected Random randomizer
protected int fileHandleSize
protected int maxFileHandleRounds
protected ServerSession session
protected boolean closed
protected ExecutorService executors
protected boolean shutdownExecutor
protected Future<?> pendingFuture
protected byte[] workBuf
protected FileSystem fileSystem
protected Path defaultDir
protected long requestsCount
protected int version
protected final UnsupportedAttributePolicy unsupportedAttributePolicy
public SftpSubsystem(ExecutorService executorService, boolean shutdownOnExit, UnsupportedAttributePolicy policy)
executorService - The ExecutorService to be used by
the SftpSubsystem command when starting execution. If
null then a single-threaded ad-hoc service is used.shutdownOnExit - If true the ExecutorService.shutdownNow()
will be called when subsystem terminates - unless it is the ad-hoc
service, which will be shutdown regardlesspolicy - The UnsupportedAttributePolicy to use if failed to access
some local file attributesThreadUtils.newSingleThreadExecutor(String)public int getVersion()
public final UnsupportedAttributePolicy getUnsupportedAttributePolicy()
public void setSession(ServerSession session)
setSession in interface SessionAwaresession - The ServerSession in which this shell will be executed.public void setFileSystem(FileSystem fileSystem)
FileSystemAwaresetFileSystem in interface FileSystemAwarefileSystem - the file systempublic void setExitCallback(ExitCallback callback)
CommandsetExitCallback in interface Commandcallback - The ExitCallback to call when shell is closedpublic void setInputStream(InputStream in)
CommandsetInputStream in interface Commandin - The InputStream used by the shell to read input.public void setOutputStream(OutputStream out)
CommandsetOutputStream in interface Commandout - The OutputStream used by the shell to write its outputpublic void setErrorStream(OutputStream err)
CommandsetErrorStream in interface Commanderr - The OutputStream used by the shell to write its errorspublic void start(Environment env) throws IOException
Command
Thread(this).start();
start in interface Commandenv - The EnvironmentIOException - If failed to startprotected void process(Buffer buffer) throws IOException
IOExceptionprotected void doExtended(Buffer buffer, int id) throws IOException
IOExceptionprotected void executeExtendedCommand(Buffer buffer, int id, String extension) throws IOException
buffer - The command Bufferid - The request idextension - The extension nameIOException - If failed to execute the extensionprotected void doSpaceAvailable(Buffer buffer, int id) throws IOException
IOExceptionprotected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException
IOExceptionprotected void doTextSeek(Buffer buffer, int id) throws IOException
IOExceptionprotected void doTextSeek(int id,
String handle,
long line)
throws IOException
IOExceptionprotected void doOpenSSHFsync(Buffer buffer, int id) throws IOException
IOExceptionprotected void doOpenSSHFsync(int id,
String handle)
throws IOException
IOExceptionprotected void doCheckFileHash(Buffer buffer, int id, String targetType) throws IOException
IOExceptionprotected void doCheckFileHash(int id,
String targetType,
String target,
Collection<String> algos,
long startOffset,
long length,
int blockSize,
Buffer buffer)
throws Exception
Exceptionprotected void doCheckFileHash(int id,
Path file,
NamedFactory<? extends Digest> factory,
long startOffset,
long length,
int blockSize,
Buffer buffer)
throws Exception
Exceptionprotected void doMD5Hash(Buffer buffer, int id, String targetType) throws IOException
IOExceptionprotected byte[] doMD5Hash(int id,
String targetType,
String target,
long startOffset,
long length,
byte[] quickCheckHash)
throws Exception
Exceptionprotected byte[] doMD5Hash(int id,
Path path,
long startOffset,
long length,
byte[] quickCheckHash)
throws Exception
Exceptionprotected void doVersionSelect(Buffer buffer, int id) throws IOException
IOExceptionprotected Boolean validateProposedVersion(Buffer buffer, int id, String proposed) throws IOException
buffer - The Buffer holding the requestid - The request idproposed - The proposed valueBoolean indicating whether to accept/reject the proposal.
If null then rejection response has been sent, otherwise and
appropriate response is generatedIOException - If failed send an independent rejection responseprotected String checkVersionCompatibility(Buffer buffer, int id, int proposed, int failureOpcode) throws IOException
SFTP_VERSION
property, then it is used to validate the proposed valuebuffer - The Buffer containing the requestid - The SSH message ID to be used to send the failure message
if requiredproposed - The proposed version valuefailureOpcode - The failure opcode to send if validation failsString of comma separated values representing all
the supported version - null if validation failed and an
appropriate status message was sentIOException - If failed to send the failure status messageprotected void doBlock(Buffer buffer, int id) throws IOException
IOExceptionprotected void doBlock(int id,
String handle,
long offset,
long length,
int mask)
throws IOException
IOExceptionprotected void doUnblock(Buffer buffer, int id) throws IOException
IOExceptionprotected boolean doUnblock(int id,
String handle,
long offset,
long length)
throws IOException
IOExceptionprotected void doLink(Buffer buffer, int id) throws IOException
IOExceptionprotected void doLink(int id,
String targetPath,
String linkPath,
boolean symLink)
throws IOException
IOExceptionprotected void doSymLink(Buffer buffer, int id) throws IOException
IOExceptionprotected void doSymLink(int id,
String targetPath,
String linkPath)
throws IOException
IOExceptionprotected void createLink(int id,
String targetPath,
String linkPath,
boolean symLink)
throws IOException
IOExceptionprotected void doReadLink(Buffer buffer, int id) throws IOException
IOExceptionprotected String doReadLink(int id, String path) throws IOException
IOExceptionprotected void doRename(Buffer buffer, int id) throws IOException
IOExceptionprotected void doRename(int id,
String oldPath,
String newPath,
int flags)
throws IOException
IOExceptionprotected void doRename(int id,
String oldPath,
String newPath,
Collection<CopyOption> opts)
throws IOException
IOExceptionprotected void doCopyData(Buffer buffer, int id) throws IOException
IOExceptionprotected void doCopyData(int id,
String readHandle,
long readOffset,
long readLength,
String writeHandle,
long writeOffset)
throws IOException
IOExceptionprotected void doCopyFile(Buffer buffer, int id) throws IOException
IOExceptionprotected void doCopyFile(int id,
String srcFile,
String dstFile,
boolean overwriteDestination)
throws IOException
IOExceptionprotected void doCopyFile(int id,
String srcFile,
String dstFile,
Collection<CopyOption> opts)
throws IOException
IOExceptionprotected void doStat(Buffer buffer, int id) throws IOException
IOExceptionprotected Map<String,Object> doStat(int id, String path, int flags) throws IOException
IOExceptionprotected void doRealPath(Buffer buffer, int id) throws IOException
IOExceptionprotected Pair<Path,Boolean> doRealPathV6(int id, String path, Collection<String> extraPaths, LinkOption... options) throws IOException
IOExceptionprotected Pair<Path,Boolean> doRealPathV345(int id, String path, LinkOption... options) throws IOException
IOExceptionprotected Pair<Path,Boolean> validateRealPath(int id, String path, Path f, LinkOption... options) throws IOException
id - The request identifierpath - The original pathf - The resolve Pathoptions - The LinkOptions to use to verify file existence and accessPair whose left-hand is the absolute normalized
Path and right-hand is a Boolean indicating its statusIOException - If failed to validate the fileIoUtils.checkFileExists(Path, LinkOption...)protected void doRemoveDirectory(Buffer buffer, int id) throws IOException
IOExceptionprotected void doRemoveDirectory(int id,
String path,
LinkOption... options)
throws IOException
IOExceptionprotected void doMakeDirectory(Buffer buffer, int id) throws IOException
IOExceptionprotected void doMakeDirectory(int id,
String path,
Map<String,?> attrs,
LinkOption... options)
throws IOException
IOExceptionprotected void doRemove(Buffer buffer, int id) throws IOException
IOExceptionprotected void doRemove(int id,
String path,
LinkOption... options)
throws IOException
IOExceptionprotected void doReadDir(Buffer buffer, int id) throws IOException
IOExceptionprotected void doOpenDir(Buffer buffer, int id) throws IOException
IOExceptionprotected String doOpenDir(int id, String path, LinkOption... options) throws IOException
IOExceptionprotected void doFSetStat(Buffer buffer, int id) throws IOException
IOExceptionprotected void doFSetStat(int id,
String handle,
Map<String,?> attrs)
throws IOException
IOExceptionprotected void doSetStat(Buffer buffer, int id) throws IOException
IOExceptionprotected void doSetStat(int id,
String path,
Map<String,?> attrs)
throws IOException
IOExceptionprotected void doFStat(Buffer buffer, int id) throws IOException
IOExceptionprotected Map<String,Object> doFStat(int id, String handle, int flags) throws IOException
IOExceptionprotected void doLStat(Buffer buffer, int id) throws IOException
IOExceptionprotected Map<String,Object> doLStat(int id, String path, int flags) throws IOException
IOExceptionprotected void doWrite(Buffer buffer, int id) throws IOException
IOExceptionprotected void doWrite(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
int remaining)
throws IOException
IOExceptionprotected void doRead(Buffer buffer, int id) throws IOException
IOExceptionprotected int doRead(int id,
String handle,
long offset,
int length,
byte[] data,
int doff)
throws IOException
IOExceptionprotected void doClose(Buffer buffer, int id) throws IOException
IOExceptionprotected void doClose(int id,
String handle)
throws IOException
IOExceptionprotected void doOpen(Buffer buffer, int id) throws IOException
IOExceptionprotected String doOpen(int id, String path, int pflags, int access, Map<String,Object> attrs) throws IOException
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 void doInit(Buffer buffer, int id) throws IOException
IOExceptionprotected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> appendOpenSSHExtensions(Buffer buffer)
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> resolveOpenSSHExtensions()
protected Collection<String> getSupportedClientExtensions()
protected void appendVersionsExtension(Buffer buffer, String value)
buffer - The Buffer to append tovalue - The recommended valueSftpConstants.EXT_VERSIONSprotected void appendNewlineExtension(Buffer buffer, String value)
buffer - The Buffer to append tovalue - The recommended valueSftpConstants.EXT_NEWLINEprotected void appendVendorIdExtension(Buffer buffer, Map<String,?> versionProperties)
buffer - The Buffer to append toversionProperties - The currently available version propertiesSftpConstants.EXT_VENDOR_ID,
DRAFT 09 - section 4.4protected void appendSupportedExtension(Buffer buffer, Collection<String> extras)
buffer - The Buffer to append toextras - The extra extensions that are available and can be reported
- may be null/emptyprotected void appendSupported2Extension(Buffer buffer, Collection<String> extras)
buffer - The Buffer to append toextras - The extra extensions that are available and can be reported
- may be null/emptySftpConstants.EXT_SUPPORTED,
DRAFT 13 section 5.4protected void sendHandle(Buffer buffer, int id, String handle) throws IOException
IOExceptionprotected void sendAttrs(Buffer buffer, int id, Map<String,?> attributes) throws IOException
IOExceptionprotected void sendPath(Buffer buffer, int id, Path f, Map<String,?> attrs) throws IOException
IOExceptionprotected void sendLink(Buffer buffer, int id, String link) throws IOException
IOExceptionprotected int doReadDir(int id,
DirectoryHandle dir,
Buffer buffer,
int maxSize)
throws IOException
id - Request iddir - The DirectoryHandlebuffer - The Buffer to write the resultsmaxSize - Max. buffer sizeIOException - If failed to generate an entryprotected void writeDirEntry(int id,
DirectoryHandle dir,
Buffer buffer,
int index,
Path f,
String shortName,
LinkOption... options)
throws IOException
id - Request iddir - The DirectoryHandlebuffer - The Buffer to write the resultsindex - Zero-based index of the entry to be writtenf - The entry PathshortName - The entry short nameoptions - The LinkOptions to use for querying the entry-s attributesIOException - If failed to generate the entry dataprotected String getLongName(Path f, LinkOption... options) throws IOException
IOExceptionprotected String getShortName(Path f) throws IOException
IOExceptionprotected Map<String,Object> resolveFileAttributes(Path file, int flags, LinkOption... options) throws IOException
IOExceptionprotected void writeAttrs(Buffer buffer, Map<String,?> attributes) throws IOException
IOExceptionprotected Map<String,Object> getAttributes(Path file, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> handleUnknownStatusFileAttributes(Path file, int flags, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> getAttributes(Path file, int flags, LinkOption... options) throws IOException
file - The Path location for the required attributesflags - A mask of the original required attributes - ignored by the
default implementationoptions - The LinkOptions to use in order to access the file
if necessaryMap of the retrieved attributesIOException - If failed to access the fileresolveMissingFileAttributes(Path, int, Map, LinkOption...)protected Map<String,Object> resolveMissingFileAttributes(Path file, int flags, Map<String,Object> current, LinkOption... options) throws IOException
getAttributes(Path, int, LinkOption...) in order
to complete any attributes that could not be retrieved via the supported
file system views. These attributes are deemed important so an extra
effort is made to provide a value for themfile - The Path location for the required attributesflags - A mask of the original required attributes - ignored by the
default implementationcurrent - The Map of attributes already retrieved - may be
null/empty and/or unmodifiableoptions - The LinkOptions to use in order to access the file
if necessaryMap of the extra attributes whose values need to be
updated in the original map. Note: it is allowed to specify values
which override existing ones - the default implementation does not
override values that have a non-null valueIOException - If failed to access the attributes - in which case
an error is returned to the SFTP clientFILEATTRS_RESOLVERSprotected Object resolveMissingFileAttributeValue(Path file, String name, Object value, FileInfoExtractor<?> x, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> addMissingAttribute(Path file, Map<String,Object> current, String name, FileInfoExtractor<?> x, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> readFileAttributes(Path file, String view, LinkOption... options) throws IOException
IOExceptionprotected Map<String,Object> handleReadFileAttributesException(Path file, String view, LinkOption[] options, IOException e) throws IOException
IOExceptionprotected void setAttributes(Path file, Map<String,?> attributes) throws IOException
IOExceptionprotected void handleUnsupportedAttributes(Collection<String> attributes)
protected void handleUserPrincipalLookupServiceException(Class<? extends Principal> principalType, String name, IOException e) throws IOException
IOExceptionprotected Map<String,Object> readAttrs(Buffer buffer) throws IOException
IOExceptionprotected <H extends Handle> H validateHandle(String handle, Handle h, Class<H> type) throws IOException
H - The generic handle typehandle - The original handle idh - The resolved Handle instancetype - The expected handle typeFileNotFoundException - If the handle instance is nullInvalidHandleException - If the handle instance is not of the expected typeIOExceptionprotected void sendStatus(Buffer buffer, int id, Exception e) throws IOException
IOExceptionprotected void sendStatus(Buffer buffer, int id, int substatus, String msg) throws IOException
IOExceptionprotected void sendStatus(Buffer buffer, int id, int substatus, String msg, String lang) throws IOException
IOExceptionprotected void send(Buffer buffer) throws IOException
IOExceptionpublic void destroy()
Commandprotected Path resolveNormalizedLocation(String remotePath) throws IOException, InvalidPathException
IOExceptionInvalidPathExceptionprotected Path resolveFile(String remotePath) throws IOException, InvalidPathException
remotePath - The remote path - separated by '/'PathIOException - If failed to resolve the local pathInvalidPathException - If bad local path specificationCopyright © 2008–2015 The Apache Software Foundation. All rights reserved.