public abstract class AbstractSftpSubsystemHelper extends AbstractLoggingBean implements SftpSubsystemProxy
Modifier and Type | Field and Description |
---|---|
static Set<Integer> |
DEFAULT_ACL_SUPPORTED_MASK |
static List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
DEFAULT_OPEN_SSH_EXTENSIONS |
static List<String> |
DEFAULT_OPEN_SSH_EXTENSIONS_NAMES |
static NavigableMap<String,OptionalFeature> |
DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
The default reported supported client extensions (case insensitive)
|
log
ALL_SFTP_IMPL, HIGHER_SFTP_IMPL, LOWER_SFTP_IMPL, SUPPORTED_SFTP_VERSIONS
Modifier | Constructor and Description |
---|---|
protected |
AbstractSftpSubsystemHelper(ChannelSession channelSession,
SftpSubsystemConfigurator configurator) |
Modifier and Type | Method and Description |
---|---|
protected NavigableMap<String,Object> |
addMissingAttribute(Path file,
NavigableMap<String,Object> current,
String name,
FileInfoExtractor<?> x,
LinkOption... options) |
boolean |
addSftpEventListener(SftpEventListener listener)
Register a listener instance
|
protected int |
appendAclSupportedExtension(Buffer buffer,
ServerSession session) |
protected void |
appendExtensions(Buffer buffer,
String supportedVersions) |
protected String |
appendNewlineExtension(Buffer buffer,
ServerSession session)
Appends the "newline" extension to the buffer.
|
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
appendOpenSSHExtensions(Buffer buffer,
ServerSession session) |
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 Map<String,?> |
appendVendorIdExtension(Buffer buffer,
Map<String,?> versionProperties,
ServerSession session)
Appends the "vendor-id" extension to the buffer.
|
protected String |
appendVersionsExtension(Buffer buffer,
String value,
ServerSession session)
Appends the "versions" extension to the buffer.
|
Boolean |
checkSymlinkState(Path path,
boolean neverFollowSymLinks,
LinkOption[] options)
A utility function to validate that the directories leading up to a file are not symlinks
|
protected Map.Entry<Integer,String> |
checkVersionCompatibility(Buffer buffer,
int id,
int proposed,
int failureOpcode)
Checks if a proposed version is within supported range.
|
protected abstract void |
createLink(int id,
String existingPath,
String linkPath,
boolean symLink) |
protected void |
doBlock(Buffer buffer,
int id) |
protected abstract 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 abstract 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 abstract void |
doClose(int id,
String handle) |
protected void |
doCopyData(Buffer buffer,
int id) |
protected abstract 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 abstract void |
doFSetStat(int id,
String handle,
Map<String,?> attrs) |
protected void |
doFStat(Buffer buffer,
int id) |
protected abstract Map<String,Object> |
doFStat(int id,
String handle,
int flags) |
protected abstract 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) |
protected void |
doMD5Hash(Buffer buffer,
int id,
String targetType) |
protected byte[] |
doMD5Hash(int id,
Path path,
long startOffset,
long length,
byte[] quickCheckHash) |
protected abstract byte[] |
doMD5Hash(int id,
String targetType,
String target,
long startOffset,
long length,
byte[] quickCheckHash) |
protected void |
doOpen(Buffer buffer,
int id) |
protected abstract String |
doOpen(int id,
String path,
int pflags,
int access,
Map<String,Object> attrs) |
protected void |
doOpenDir(Buffer buffer,
int id) |
protected abstract String |
doOpenDir(int id,
String path,
Path p,
LinkOption... options) |
protected void |
doOpenSSHFsync(Buffer buffer,
int id) |
protected abstract void |
doOpenSSHFsync(int id,
String handle) |
protected void |
doOpenSSHHardLink(Buffer buffer,
int id) |
protected void |
doOpenSSHHardLink(int id,
String srcFile,
String dstFile) |
protected void |
doOpenSSHLimits(Buffer buffer,
int id) |
protected void |
doPosixRename(Buffer buffer,
int id) |
protected void |
doProcess(Buffer buffer,
int length,
int type,
int id) |
protected void |
doRead(Buffer buffer,
int id) |
protected abstract int |
doRead(int id,
String handle,
long offset,
int length,
byte[] data,
int doff,
AtomicReference<Boolean> eof) |
protected abstract void |
doReadDir(Buffer buffer,
int id) |
protected int |
doReadDir(int id,
String handle,
DirectoryHandle dir,
Buffer buffer,
int maxSize,
boolean followLinks) |
protected void |
doReadLink(Buffer buffer,
int id) |
protected AbstractMap.SimpleImmutableEntry<Path,String> |
doReadLink(int id,
String path) |
protected void |
doRealPath(Buffer buffer,
int id) |
protected AbstractMap.SimpleImmutableEntry<Path,Boolean> |
doRealPathV345(int id,
String path,
Path p,
LinkOption... options) |
protected AbstractMap.SimpleImmutableEntry<Path,Boolean> |
doRealPathV6(int id,
String path,
Collection<String> extraPaths,
Path p,
LinkOption... options) |
protected void |
doRemove(Buffer buffer,
int id) |
protected void |
doRemove(int id,
Path p,
boolean isDirectory)
Called when need to delete a file / directory - also informs the
SftpEventListener |
protected void |
doRemoveDirectory(Buffer buffer,
int id) |
protected void |
doRemoveDirectory(int id,
String path) |
protected void |
doRemoveFile(int id,
String path) |
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 |
doSetAttributes(int cmd,
String extension,
Path file,
Map<String,?> attributes,
boolean followLinks) |
protected void |
doSetStat(Buffer buffer,
int id,
String extension,
int cmd,
Boolean followLinks) |
protected void |
doSetStat(int id,
String path,
int cmd,
String extension,
Map<String,?> attrs,
Boolean followLinks) |
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 abstract void |
doTextSeek(int id,
String handle,
long line) |
protected void |
doUnblock(Buffer buffer,
int id) |
protected abstract void |
doUnblock(int id,
String handle,
long offset,
long length) |
protected void |
doUnsupported(Buffer buffer,
int length,
int type,
int id) |
protected void |
doUnsupportedExtension(Buffer buffer,
int id,
String extension) |
protected void |
doVersionSelect(Buffer buffer,
int id) |
protected abstract void |
doVersionSelect(Buffer buffer,
int id,
String proposed) |
protected void |
doWrite(Buffer buffer,
int id) |
protected abstract 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 NavigableMap<String,Object> |
getAttributes(Path path,
int flags,
LinkOption... options) |
protected NavigableMap<String,Object> |
getAttributes(Path file,
LinkOption... options) |
SftpErrorStatusDataHandler |
getErrorStatusDataHandler() |
SftpFileSystemAccessor |
getFileSystemAccessor() |
protected String |
getLongName(Path f,
String shortName,
boolean sendAttrs,
LinkOption... options) |
protected String |
getLongName(Path f,
String shortName,
LinkOption... options) |
protected String |
getLongName(Path f,
String shortName,
Map<String,?> attributes) |
protected String |
getLongName(Path f,
String shortName,
SftpClient.Attributes attributes) |
protected OpenSSHLimitsExtensionInfo |
getOpenSSHLimitsExtensionInfo(int id,
ChannelSession channel) |
protected LinkOption[] |
getPathResolutionLinkOption(int cmd,
String extension,
Path path) |
ChannelSession |
getServerChannelSession() |
SftpEventListener |
getSftpEventListenerProxy() |
protected String |
getShortName(Path f) |
protected Map<String,OptionalFeature> |
getSupportedClientExtensions(ServerSession session) |
UnsupportedAttributePolicy |
getUnsupportedAttributePolicy() |
protected NavigableMap<String,Object> |
handleReadFileAttributesException(Path file,
String view,
LinkOption[] options,
IOException e) |
protected void |
handleSetFileAttributeFailure(Path file,
String view,
String attribute,
Object value,
Collection<String> unsupported,
Exception e) |
protected NavigableMap<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 abstract Buffer |
prepareReply(Buffer buffer) |
protected void |
process(Buffer buffer)
Process an SFTP command.
|
protected Map<String,Object> |
readAttrs(Buffer buffer) |
protected NavigableMap<String,Object> |
readFileAttributes(Path file,
String view,
LinkOption... options) |
boolean |
removeSftpEventListener(SftpEventListener listener)
Remove a listener instance
|
protected Collection<Integer> |
resolveAclSupportedCapabilities(ServerSession session) |
protected Path |
resolveFile(String remotePath) |
protected NavigableMap<String,Object> |
resolveFileAttributes(Path path,
int flags,
boolean neverFollowSymLinks,
LinkOption... options) |
protected NavigableMap<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 String |
resolveNewlineValue(ServerSession session) |
protected Path |
resolveNormalizedLocation(String remotePath) |
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> |
resolveOpenSSHExtensions(ServerSession session) |
protected boolean |
resolvePathResolutionFollowLinks(int cmd,
String extension,
Path path) |
protected NavigableMap<String,Object> |
resolveReportedFileAttributes(Path file,
int flags,
LinkOption... options) |
protected abstract 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,
Path file,
String link) |
protected void |
sendPath(Buffer buffer,
int id,
Path f,
Map<String,?> attrs) |
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 |
sendStatus(Buffer buffer,
int id,
Throwable e,
int cmd,
Object... args)
Invoked when an exception was thrown due to the execution of some SFTP command
|
protected void |
setFileAccessControl(Path file,
List<AclEntry> acl,
LinkOption... options) |
protected void |
setFileAttribute(Path file,
String view,
String attribute,
Object value,
LinkOption... options) |
protected void |
setFileAttributes(Path file,
Map<String,?> attributes,
LinkOption... options) |
protected void |
setFileExtensions(Path file,
Map<String,byte[]> extensions,
LinkOption... options) |
protected void |
setFileOwnership(Path file,
String attribute,
Principal value,
LinkOption... options) |
protected void |
setFilePermissions(Path file,
Set<PosixFilePermission> perms,
LinkOption... options) |
protected void |
setFileRawViewAttribute(Path file,
String view,
String attribute,
Object value,
LinkOption... options) |
protected void |
setFileTime(Path file,
String view,
String attribute,
FileTime value,
LinkOption... options) |
protected <E extends IOException> |
signalOpenFailure(int id,
String pathValue,
Path path,
boolean isDir,
E thrown) |
protected <E extends IOException> |
signalRemovalPreConditionFailure(int id,
String pathValue,
Path path,
E thrown,
boolean isRemoveDirectory) |
protected GroupPrincipal |
toGroup(Path file,
GroupPrincipal name) |
protected UserPrincipal |
toUser(Path file,
UserPrincipal name) |
protected <H extends Handle> |
validateHandle(String handle,
Handle h,
Class<H> type)
Makes sure that the local handle is not null and of the specified type
|
Boolean |
validateParentExistWithNoSymlinksIfNeverFollowSymlinks(Path path,
boolean neverFollowSymLinks) |
protected Boolean |
validateProposedVersion(Buffer buffer,
int id,
String proposal) |
protected AbstractMap.SimpleImmutableEntry<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,
Map<String,Path> entries,
Buffer buffer,
int index,
Path f,
String shortName,
LinkOption... options) |
protected void |
writeDirEntry(ServerSession session,
int id,
Buffer buffer,
int index,
Path f,
String shortName,
SftpClient.Attributes attributes) |
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
getDefaultDirectory, getSession, getVersion
getSessionContext
getServerSession
public static final NavigableMap<String,OptionalFeature> DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
public static final List<AbstractOpenSSHExtensionParser.OpenSSHExtension> DEFAULT_OPEN_SSH_EXTENSIONS
public static final List<String> DEFAULT_OPEN_SSH_EXTENSIONS_NAMES
protected AbstractSftpSubsystemHelper(ChannelSession channelSession, SftpSubsystemConfigurator configurator)
public ChannelSession getServerChannelSession()
getServerChannelSession
in interface ServerChannelSessionHolder
public UnsupportedAttributePolicy getUnsupportedAttributePolicy()
getUnsupportedAttributePolicy
in interface SftpUnsupportedAttributePolicyProvider
UnsupportedAttributePolicy
to use if failed to access some local file attributespublic SftpFileSystemAccessor getFileSystemAccessor()
getFileSystemAccessor
in interface SftpFileSystemAccessorProvider
SftpFileSystemAccessor
to use for accessing files and directoriespublic SftpEventListener getSftpEventListenerProxy()
getSftpEventListenerProxy
in interface SftpEventListenerManager
public boolean addSftpEventListener(SftpEventListener listener)
SftpEventListenerManager
addSftpEventListener
in interface SftpEventListenerManager
listener
- The SftpEventListener
instance to add - never null
true
if listener is a previously un-registered onepublic boolean removeSftpEventListener(SftpEventListener listener)
SftpEventListenerManager
removeSftpEventListener
in interface SftpEventListenerManager
listener
- The SftpEventListener
instance to remove - never null
true
if listener is a (removed) registered onepublic SftpErrorStatusDataHandler getErrorStatusDataHandler()
getErrorStatusDataHandler
in interface SftpErrorStatusDataHandlerProvider
null
) SftpErrorStatusDataHandler
to use when generating failed commands error
messagesprotected Boolean validateProposedVersion(Buffer buffer, int id, String proposal) throws IOException
buffer
- The Buffer
holding the requestid
- The request idproposal
- 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 Map.Entry<Integer,String> checkVersionCompatibility(Buffer buffer, int id, int proposed, int failureOpcode) throws IOException
SftpModuleProperties.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 versions. null
if validation failed
and an appropriate status message was sentIOException
- If failed to send the failure status messageprotected void process(Buffer buffer) throws IOException
buffer
- the buffer to processIOException
- if anything wrong happensprotected void doProcess(Buffer buffer, int length, int type, int id) throws IOException
IOException
protected void doUnsupported(Buffer buffer, int length, int type, int id) throws IOException
IOException
protected abstract void doInit(Buffer buffer, int id) throws IOException
IOException
protected void doVersionSelect(Buffer buffer, int id) throws IOException
IOException
protected abstract void doVersionSelect(Buffer buffer, int id, String proposed) throws IOException
IOException
protected void doOpen(Buffer buffer, int id) throws IOException
IOException
protected abstract 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 <E extends IOException> E signalOpenFailure(int id, String pathValue, Path path, boolean isDir, E thrown) throws IOException
IOException
protected void doClose(Buffer buffer, int id) throws IOException
IOException
protected abstract void doClose(int id, String handle) throws IOException
IOException
protected void doRead(Buffer buffer, int id) throws IOException
IOException
protected abstract int doRead(int id, String handle, long offset, int length, byte[] data, int doff, AtomicReference<Boolean> eof) throws IOException
IOException
protected void doWrite(Buffer buffer, int id) throws IOException
IOException
protected abstract void doWrite(int id, String handle, long offset, int length, byte[] data, int doff, int remaining) throws IOException
IOException
protected void doLStat(Buffer buffer, int id) throws IOException
IOException
protected Map<String,Object> doLStat(int id, String path, int flags) throws IOException
IOException
protected void doSetStat(Buffer buffer, int id, String extension, int cmd, Boolean followLinks) throws IOException
IOException
protected void doSetStat(int id, String path, int cmd, String extension, Map<String,?> attrs, Boolean followLinks) throws IOException
IOException
protected void doFStat(Buffer buffer, int id) throws IOException
IOException
protected abstract Map<String,Object> doFStat(int id, String handle, int flags) throws IOException
IOException
protected void doFSetStat(Buffer buffer, int id) throws IOException
IOException
protected abstract void doFSetStat(int id, String handle, Map<String,?> attrs) throws IOException
IOException
protected void doOpenDir(Buffer buffer, int id) throws IOException
IOException
protected abstract String doOpenDir(int id, String path, Path p, LinkOption... options) throws IOException
IOException
protected abstract void doReadDir(Buffer buffer, int id) throws IOException
IOException
protected void doLink(Buffer buffer, int id) throws IOException
IOException
protected void doLink(int id, String targetPath, String linkPath, boolean symLink) throws IOException
IOException
protected void doSymLink(Buffer buffer, int id) throws IOException
IOException
protected void doSymLink(int id, String targetPath, String linkPath) throws IOException
IOException
protected abstract void createLink(int id, String existingPath, String linkPath, boolean symLink) throws IOException
IOException
protected void doOpenSSHHardLink(Buffer buffer, int id) throws IOException
IOException
protected void doOpenSSHLimits(Buffer buffer, int id) throws IOException
IOException
protected OpenSSHLimitsExtensionInfo getOpenSSHLimitsExtensionInfo(int id, ChannelSession channel) throws IOException
IOException
protected void doOpenSSHHardLink(int id, String srcFile, String dstFile) throws IOException
IOException
protected void doSpaceAvailable(Buffer buffer, int id) throws IOException
IOException
protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException
IOException
protected void doTextSeek(Buffer buffer, int id) throws IOException
IOException
protected abstract void doTextSeek(int id, String handle, long line) throws IOException
IOException
protected void doOpenSSHFsync(Buffer buffer, int id) throws IOException
IOException
protected abstract void doOpenSSHFsync(int id, String handle) throws IOException
IOException
protected void doCheckFileHash(Buffer buffer, int id, String targetType) throws IOException
IOException
protected void doCheckFileHash(int id, Path file, NamedFactory<? extends Digest> factory, long startOffset, long length, int blockSize, Buffer buffer) throws Exception
Exception
protected void doMD5Hash(Buffer buffer, int id, String targetType) throws IOException
IOException
protected abstract byte[] doMD5Hash(int id, String targetType, String target, long startOffset, long length, byte[] quickCheckHash) throws Exception
Exception
protected byte[] doMD5Hash(int id, Path path, long startOffset, long length, byte[] quickCheckHash) throws Exception
Exception
protected abstract void doCheckFileHash(int id, String targetType, String target, Collection<String> algos, long startOffset, long length, int blockSize, Buffer buffer) throws Exception
Exception
protected void doReadLink(Buffer buffer, int id) throws IOException
IOException
protected AbstractMap.SimpleImmutableEntry<Path,String> doReadLink(int id, String path) throws IOException
id
- Request identifierpath
- Referenced pathPath
and its referenced symbolic linkIOException
- If failed to resolve the requested dataprotected void doRename(Buffer buffer, int id) throws IOException
IOException
protected void doRename(int id, String oldPath, String newPath, int flags) throws IOException
IOException
protected void doRename(int id, String oldPath, String newPath, Collection<CopyOption> opts) throws IOException
IOException
protected void doPosixRename(Buffer buffer, int id) throws IOException
IOException
protected void doCopyData(Buffer buffer, int id) throws IOException
IOException
protected abstract void doCopyData(int id, String readHandle, long readOffset, long readLength, String writeHandle, long writeOffset) throws IOException
IOException
protected void doCopyFile(Buffer buffer, int id) throws IOException
IOException
protected void doCopyFile(int id, String srcFile, String dstFile, boolean overwriteDestination) throws IOException
IOException
protected void doCopyFile(int id, String srcFile, String dstFile, Collection<CopyOption> opts) throws IOException
IOException
protected void doBlock(Buffer buffer, int id) throws IOException
IOException
protected abstract void doBlock(int id, String handle, long offset, long length, int mask) throws IOException
IOException
protected void doUnblock(Buffer buffer, int id) throws IOException
IOException
protected abstract void doUnblock(int id, String handle, long offset, long length) throws IOException
IOException
protected void doStat(Buffer buffer, int id) throws IOException
IOException
protected Map<String,Object> doStat(int id, String path, int flags) throws IOException
IOException
protected void doRealPath(Buffer buffer, int id) throws IOException
IOException
protected AbstractMap.SimpleImmutableEntry<Path,Boolean> doRealPathV6(int id, String path, Collection<String> extraPaths, Path p, LinkOption... options) throws IOException
IOException
protected AbstractMap.SimpleImmutableEntry<Path,Boolean> doRealPathV345(int id, String path, Path p, LinkOption... options) throws IOException
IOException
protected AbstractMap.SimpleImmutableEntry<Path,Boolean> validateRealPath(int id, String path, Path f, LinkOption... options) throws IOException
id
- The request identifierpath
- The original pathf
- The resolve Path
options
- The LinkOption
s to use to verify file existence and accessAbstractMap.SimpleImmutableEntry
whose key is the absolute normalized
Path
and value is a Boolean
indicating its statusIOException
- If failed to validate the fileIoUtils.checkFileExists(Path, LinkOption...)
protected void doRemoveDirectory(Buffer buffer, int id) throws IOException
IOException
protected void doRemoveDirectory(int id, String path) throws IOException
IOException
protected void doRemove(int id, Path p, boolean isDirectory) throws IOException
SftpEventListener
id
- Deletion request IDp
- Path
to deleteisDirectory
- Whether the requested path represents a directory or a regular fileIOException
- If failed to deleteprotected void doMakeDirectory(Buffer buffer, int id) throws IOException
IOException
protected void doMakeDirectory(int id, String path, Map<String,?> attrs) throws IOException
IOException
protected void doRemove(Buffer buffer, int id) throws IOException
IOException
protected void doRemoveFile(int id, String path) throws IOException
IOException
protected <E extends IOException> E signalRemovalPreConditionFailure(int id, String pathValue, Path path, E thrown, boolean isRemoveDirectory) throws IOException
IOException
protected void doExtended(Buffer buffer, int id) throws IOException
IOException
protected void executeExtendedCommand(Buffer buffer, int id, String extension) throws IOException
buffer
- The command Buffer
id
- The request idextension
- The extension nameIOException
- If failed to execute the extensionprotected void doUnsupportedExtension(Buffer buffer, int id, String extension) throws IOException
IOException
protected int appendAclSupportedExtension(Buffer buffer, ServerSession session)
protected Collection<Integer> resolveAclSupportedCapabilities(ServerSession session)
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> appendOpenSSHExtensions(Buffer buffer, ServerSession session)
protected List<AbstractOpenSSHExtensionParser.OpenSSHExtension> resolveOpenSSHExtensions(ServerSession session)
protected Map<String,OptionalFeature> getSupportedClientExtensions(ServerSession session)
protected String appendVersionsExtension(Buffer buffer, String value, ServerSession session)
buffer
- The Buffer
to append tovalue
- The recommended value - ignored if null
/emptysession
- The ServerSession
for which this extension is addedSftpConstants.EXT_VERSIONS
protected String appendNewlineExtension(Buffer buffer, ServerSession session)
buffer
- The Buffer
to append tosession
- The ServerSession
for which this extension is addedSftpConstants.EXT_NEWLINE
,
resolveNewlineValue(ServerSession)
protected String resolveNewlineValue(ServerSession session)
protected Map<String,?> appendVendorIdExtension(Buffer buffer, Map<String,?> versionProperties, ServerSession session)
buffer
- The Buffer
to append toversionProperties
- The currently available version properties - ignored if null
/empty. The code
expects the following values:
groupId
- as the vendor nameartifactId
- as the product nameversion
- as the product versionsession
- The ServerSession
for which these properties are addedSftpConstants.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
IOException
protected void sendAttrs(Buffer buffer, int id, Map<String,?> attributes) throws IOException
IOException
protected void sendLink(Buffer buffer, int id, Path file, String link) throws IOException
IOException
protected void sendPath(Buffer buffer, int id, Path f, Map<String,?> attrs) throws IOException
IOException
protected int doReadDir(int id, String handle, DirectoryHandle dir, Buffer buffer, int maxSize, boolean followLinks) throws IOException
id
- Request idhandle
- The (opaque) handle assigned to this directorydir
- The DirectoryHandle
buffer
- The Buffer
to write the resultsmaxSize
- Max. buffer sizefollowLinks
- Whether to follow symbolic links when querying the directory contentsIOException
- If failed to generate an entryprotected void writeDirEntry(ServerSession session, int id, Buffer buffer, int index, Path f, String shortName, SftpClient.Attributes attributes) throws IOException
IOException
protected void writeDirEntry(int id, DirectoryHandle dir, Map<String,Path> entries, Buffer buffer, int index, Path f, String shortName, LinkOption... options) throws IOException
id
- Request iddir
- The DirectoryHandle
entries
- An in / out Map
for updating the written entry - key = short name, value = entry
Path
buffer
- The Buffer
to write the resultsindex
- Zero-based index of the entry to be writtenf
- The entry Path
shortName
- The entry short nameoptions
- The LinkOption
s to use for querying the entry-s attributesIOException
- If failed to generate the entry dataprotected String getLongName(Path f, String shortName, LinkOption... options) throws IOException
IOException
protected String getLongName(Path f, String shortName, boolean sendAttrs, LinkOption... options) throws IOException
IOException
protected String getLongName(Path f, String shortName, Map<String,?> attributes) throws IOException
IOException
protected String getLongName(Path f, String shortName, SftpClient.Attributes attributes) throws IOException
IOException
protected String getShortName(Path f) throws IOException
IOException
protected NavigableMap<String,Object> resolveFileAttributes(Path path, int flags, boolean neverFollowSymLinks, LinkOption... options) throws IOException
IOException
public Boolean checkSymlinkState(Path path, boolean neverFollowSymLinks, LinkOption[] options)
path
- the file to check for symlink presenceneverFollowSymLinks
- whether to never follow symlinks in the parent pathsoptions
- whether the file itself can be a symlinkpublic Boolean validateParentExistWithNoSymlinksIfNeverFollowSymlinks(Path path, boolean neverFollowSymLinks)
protected NavigableMap<String,Object> getAttributes(Path file, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> handleUnknownStatusFileAttributes(Path file, int flags, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> getAttributes(Path path, int flags, LinkOption... options) throws IOException
path
- The Path
location for the required attributesflags
- A mask of the original required attributes - ignored by the default implementationoptions
- The LinkOption
s to use in order to access the file if necessaryMap
of the retrieved attributesIOException
- If failed to access the fileresolveReportedFileAttributes(Path, int, LinkOption...)
protected NavigableMap<String,Object> resolveReportedFileAttributes(Path file, int flags, LinkOption... options) throws IOException
IOException
protected NavigableMap<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 LinkOption
s 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
clientSftpFileSystemAccessor.FILEATTRS_RESOLVERS
protected Object resolveMissingFileAttributeValue(Path file, String name, Object value, FileInfoExtractor<?> x, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> addMissingAttribute(Path file, NavigableMap<String,Object> current, String name, FileInfoExtractor<?> x, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> readFileAttributes(Path file, String view, LinkOption... options) throws IOException
IOException
protected NavigableMap<String,Object> handleReadFileAttributesException(Path file, String view, LinkOption[] options, IOException e) throws IOException
IOException
protected void doSetAttributes(int cmd, String extension, Path file, Map<String,?> attributes, boolean followLinks) throws IOException
IOException
protected LinkOption[] getPathResolutionLinkOption(int cmd, String extension, Path path) throws IOException
IOException
protected boolean resolvePathResolutionFollowLinks(int cmd, String extension, Path path) throws IOException
IOException
protected void setFileAttributes(Path file, Map<String,?> attributes, LinkOption... options) throws IOException
IOException
protected void handleSetFileAttributeFailure(Path file, String view, String attribute, Object value, Collection<String> unsupported, Exception e) throws IOException
IOException
protected void setFileAttribute(Path file, String view, String attribute, Object value, LinkOption... options) throws IOException
IOException
protected void setFileTime(Path file, String view, String attribute, FileTime value, LinkOption... options) throws IOException
IOException
protected void setFileRawViewAttribute(Path file, String view, String attribute, Object value, LinkOption... options) throws IOException
IOException
protected void setFileOwnership(Path file, String attribute, Principal value, LinkOption... options) throws IOException
IOException
protected void setFileExtensions(Path file, Map<String,byte[]> extensions, LinkOption... options) throws IOException
IOException
protected void setFilePermissions(Path file, Set<PosixFilePermission> perms, LinkOption... options) throws IOException
IOException
protected void setFileAccessControl(Path file, List<AclEntry> acl, LinkOption... options) throws IOException
IOException
protected void handleUnsupportedAttributes(Collection<String> attributes)
protected GroupPrincipal toGroup(Path file, GroupPrincipal name) throws IOException
IOException
protected UserPrincipal toUser(Path file, UserPrincipal name) throws IOException
IOException
protected void handleUserPrincipalLookupServiceException(Class<? extends Principal> principalType, String name, IOException e) throws IOException
IOException
protected Map<String,Object> readAttrs(Buffer buffer) throws IOException
IOException
protected <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 typeIOException
- If a generic exception occurredFileNotFoundException
- If the handle instance is null
InvalidHandleException
- If the handle instance is not of the expected typeprotected void sendStatus(Buffer buffer, int id, Throwable e, int cmd, Object... args) throws IOException
buffer
- A Buffer
to be used to build the status replyid
- Command identifiere
- Thrown exceptioncmd
- The command that was attemptedargs
- The relevant command arguments - Note: provided only for logging purposes and
subject to type and/or order change at any versionIOException
- If failed to build and send the status bufferprotected void sendStatus(Buffer buffer, int id, int substatus, String msg) throws IOException
IOException
protected void sendStatus(Buffer buffer, int id, int substatus, String msg, String lang) throws IOException
IOException
protected abstract void send(Buffer buffer) throws IOException
IOException
protected Path resolveNormalizedLocation(String remotePath) throws IOException, InvalidPathException
IOException
InvalidPathException
protected Path resolveFile(String remotePath) throws IOException, InvalidPathException
remotePath
- The remote path - separated by '/'Path
IOException
- If failed to resolve the local pathInvalidPathException
- If bad local path specificationCopyright © 2008–2024 The Apache Software Foundation. All rights reserved.