Class AbstractSftpSubsystemHelper
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.server.subsystem.sftp.AbstractSftpSubsystemHelper
-
- All Implemented Interfaces:
SessionContextHolder
,SessionHolder<ServerSession>
,ServerSessionHolder
,SftpEventListenerManager
,SftpSubsystemEnvironment
- Direct Known Subclasses:
SftpSubsystem
public abstract class AbstractSftpSubsystemHelper extends AbstractLoggingBean implements SftpEventListenerManager, SftpSubsystemEnvironment
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACL_SUPPORTED_MASK_PROP
Comma separate list ofSSH_ACL_CAP_xxx
names - where name can be without the prefix.static java.lang.String
AUTO_FOLLOW_LINKS
Whether to automatically follow symbolic links when resolving pathsstatic java.lang.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.static java.util.Set<java.lang.Integer>
DEFAULT_ACL_SUPPORTED_MASK
static boolean
DEFAULT_AUTO_FOLLOW_LINKS
Default value of "sftp-auto-follow-links"static int
DEFAULT_MAX_READDATA_PACKET_LENGTH
static java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>
DEFAULT_OPEN_SSH_EXTENSIONS
static java.util.List<java.lang.String>
DEFAULT_OPEN_SSH_EXTENSIONS_NAMES
static java.util.NavigableMap<java.lang.String,OptionalFeature>
DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
The default reported supported client extensions (case insensitive)private SftpErrorStatusDataHandler
errorStatusDataHandler
private SftpFileSystemAccessor
fileSystemAccessor
static java.lang.String
MAX_READDATA_PACKET_LENGTH_PROP
Force the use of a max.static java.lang.String
NEWLINE_VALUE
Property that can be used to set the reported NL value.static java.lang.String
OPENSSH_EXTENSIONS_PROP
Comma-separated list of whichOpenSSH
extensions are reported and what version is reported for each - format:name=version
.private SftpEventListener
sftpEventListenerProxy
private java.util.Collection<SftpEventListener>
sftpEventListeners
private UnsupportedAttributePolicy
unsupportedAttributePolicy
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.server.subsystem.sftp.SftpSubsystemEnvironment
ALL_SFTP_IMPL, HIGHER_SFTP_IMPL, LOWER_SFTP_IMPL, SFTP_VERSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSftpSubsystemHelper(UnsupportedAttributePolicy policy, SftpFileSystemAccessor accessor, SftpErrorStatusDataHandler handler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.NavigableMap<java.lang.String,java.lang.Object>
addMissingAttribute(java.nio.file.Path file, java.util.NavigableMap<java.lang.String,java.lang.Object> current, java.lang.String name, FileInfoExtractor<?> x, java.nio.file.LinkOption... options)
boolean
addSftpEventListener(SftpEventListener listener)
Register a listener instanceprotected int
appendAclSupportedExtension(Buffer buffer, ServerSession session)
protected void
appendExtensions(Buffer buffer, java.lang.String supportedVersions)
protected void
appendNewlineExtension(Buffer buffer, ServerSession session)
Appends the "newline" extension to the buffer.protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>
appendOpenSSHExtensions(Buffer buffer, ServerSession session)
protected void
appendSupported2Extension(Buffer buffer, java.util.Collection<java.lang.String> extras)
Appends the "supported2" extension to the buffer.protected void
appendSupportedExtension(Buffer buffer, java.util.Collection<java.lang.String> extras)
Appends the "supported" extension to the buffer.protected void
appendVendorIdExtension(Buffer buffer, java.util.Map<java.lang.String,?> versionProperties, ServerSession session)
Appends the "vendor-id" extension to the buffer.protected void
appendVersionsExtension(Buffer buffer, java.lang.String value, ServerSession session)
Appends the "versions" extension to the buffer.protected java.util.Map.Entry<java.lang.Integer,java.lang.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, java.lang.String existingPath, java.lang.String linkPath, boolean symLink)
protected abstract void
doBlock(int id, java.lang.String handle, long offset, long length, int mask)
protected void
doBlock(Buffer buffer, int id)
protected abstract void
doCheckFileHash(int id, java.lang.String targetType, java.lang.String target, java.util.Collection<java.lang.String> algos, long startOffset, long length, int blockSize, Buffer buffer)
protected void
doCheckFileHash(int id, java.nio.file.Path file, NamedFactory<? extends Digest> factory, long startOffset, long length, int blockSize, Buffer buffer)
protected void
doCheckFileHash(Buffer buffer, int id, java.lang.String targetType)
protected abstract void
doClose(int id, java.lang.String handle)
protected void
doClose(Buffer buffer, int id)
protected abstract void
doCopyData(int id, java.lang.String readHandle, long readOffset, long readLength, java.lang.String writeHandle, long writeOffset)
protected void
doCopyData(Buffer buffer, int id)
protected void
doCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, boolean overwriteDestination)
protected void
doCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, java.util.Collection<java.nio.file.CopyOption> opts)
protected void
doCopyFile(Buffer buffer, int id)
protected void
doExtended(Buffer buffer, int id)
protected abstract void
doFSetStat(int id, java.lang.String handle, java.util.Map<java.lang.String,?> attrs)
protected void
doFSetStat(Buffer buffer, int id)
protected abstract java.util.Map<java.lang.String,java.lang.Object>
doFStat(int id, java.lang.String handle, int flags)
protected void
doFStat(Buffer buffer, int id)
protected abstract void
doInit(Buffer buffer, int id)
protected void
doLink(int id, java.lang.String targetPath, java.lang.String linkPath, boolean symLink)
protected void
doLink(Buffer buffer, int id)
protected java.util.Map<java.lang.String,java.lang.Object>
doLStat(int id, java.lang.String path, int flags)
protected void
doLStat(Buffer buffer, int id)
protected void
doMakeDirectory(int id, java.lang.String path, java.util.Map<java.lang.String,?> attrs, java.nio.file.LinkOption... options)
protected void
doMakeDirectory(Buffer buffer, int id)
protected abstract byte[]
doMD5Hash(int id, java.lang.String targetType, java.lang.String target, long startOffset, long length, byte[] quickCheckHash)
protected byte[]
doMD5Hash(int id, java.nio.file.Path path, long startOffset, long length, byte[] quickCheckHash)
protected void
doMD5Hash(Buffer buffer, int id, java.lang.String targetType)
protected abstract java.lang.String
doOpen(int id, java.lang.String path, int pflags, int access, java.util.Map<java.lang.String,java.lang.Object> attrs)
protected void
doOpen(Buffer buffer, int id)
protected abstract java.lang.String
doOpenDir(int id, java.lang.String path, java.nio.file.Path p, java.nio.file.LinkOption... options)
protected void
doOpenDir(Buffer buffer, int id)
protected abstract void
doOpenSSHFsync(int id, java.lang.String handle)
protected void
doOpenSSHFsync(Buffer buffer, int id)
protected void
doOpenSSHHardLink(int id, java.lang.String srcFile, java.lang.String dstFile)
protected void
doOpenSSHHardLink(Buffer buffer, int id)
protected void
doProcess(Buffer buffer, int length, int type, int id)
protected abstract int
doRead(int id, java.lang.String handle, long offset, int length, byte[] data, int doff)
protected void
doRead(Buffer buffer, int id)
protected int
doReadDir(int id, java.lang.String handle, DirectoryHandle dir, Buffer buffer, int maxSize, java.nio.file.LinkOption... options)
protected abstract void
doReadDir(Buffer buffer, int id)
protected java.lang.String
doReadLink(int id, java.lang.String path)
protected void
doReadLink(Buffer buffer, int id)
protected void
doRealPath(Buffer buffer, int id)
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean>
doRealPathV345(int id, java.lang.String path, java.nio.file.Path p, java.nio.file.LinkOption... options)
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean>
doRealPathV6(int id, java.lang.String path, java.util.Collection<java.lang.String> extraPaths, java.nio.file.Path p, java.nio.file.LinkOption... options)
protected void
doRemove(int id, java.lang.String path, java.nio.file.LinkOption... options)
protected void
doRemove(int id, java.nio.file.Path p, boolean isDirectory)
Called when need to delete a file / directory - also informs theSftpEventListener
protected void
doRemove(Buffer buffer, int id)
protected void
doRemoveDirectory(int id, java.lang.String path, java.nio.file.LinkOption... options)
protected void
doRemoveDirectory(Buffer buffer, int id)
protected void
doRename(int id, java.lang.String oldPath, java.lang.String newPath, int flags)
protected void
doRename(int id, java.lang.String oldPath, java.lang.String newPath, java.util.Collection<java.nio.file.CopyOption> opts)
protected void
doRename(Buffer buffer, int id)
protected void
doSetAttributes(java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, boolean followLinks)
protected void
doSetStat(int id, java.lang.String path, int cmd, java.lang.String extension, java.util.Map<java.lang.String,?> attrs, java.lang.Boolean followLinks)
protected void
doSetStat(Buffer buffer, int id, java.lang.String extension, int cmd, java.lang.Boolean followLinks)
protected SpaceAvailableExtensionInfo
doSpaceAvailable(int id, java.lang.String path)
protected void
doSpaceAvailable(Buffer buffer, int id)
protected java.util.Map<java.lang.String,java.lang.Object>
doStat(int id, java.lang.String path, int flags)
protected void
doStat(Buffer buffer, int id)
protected void
doSymLink(int id, java.lang.String targetPath, java.lang.String linkPath)
protected void
doSymLink(Buffer buffer, int id)
protected abstract void
doTextSeek(int id, java.lang.String handle, long line)
protected void
doTextSeek(Buffer buffer, int id)
protected abstract void
doUnblock(int id, java.lang.String handle, long offset, long length)
protected void
doUnblock(Buffer buffer, int id)
protected void
doUnsupported(Buffer buffer, int length, int type, int id)
protected void
doUnsupportedExtension(Buffer buffer, int id, java.lang.String extension)
protected void
doVersionSelect(Buffer buffer, int id)
protected abstract void
doVersionSelect(Buffer buffer, int id, java.lang.String proposed)
protected abstract void
doWrite(int id, java.lang.String handle, long offset, int length, byte[] data, int doff, int remaining)
protected void
doWrite(Buffer buffer, int id)
protected void
executeExtendedCommand(Buffer buffer, int id, java.lang.String extension)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
getAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
getAttributes(java.nio.file.Path file, java.nio.file.LinkOption... options)
SftpErrorStatusDataHandler
getErrorStatusDataHandler()
SftpFileSystemAccessor
getFileSystemAccessor()
protected java.lang.String
getLongName(java.nio.file.Path f, java.lang.String shortName, boolean sendAttrs, java.nio.file.LinkOption... options)
protected java.lang.String
getLongName(java.nio.file.Path f, java.lang.String shortName, java.nio.file.LinkOption... options)
protected java.lang.String
getLongName(java.nio.file.Path f, java.lang.String shortName, java.util.Map<java.lang.String,?> attributes)
protected java.nio.file.LinkOption[]
getPathResolutionLinkOption(int cmd, java.lang.String extension, java.nio.file.Path path)
SftpEventListener
getSftpEventListenerProxy()
protected java.lang.String
getShortName(java.nio.file.Path f)
protected java.util.Map<java.lang.String,OptionalFeature>
getSupportedClientExtensions(ServerSession session)
UnsupportedAttributePolicy
getUnsupportedAttributePolicy()
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
handleReadFileAttributesException(java.nio.file.Path file, java.lang.String view, java.nio.file.LinkOption[] options, java.io.IOException e)
protected void
handleSetFileAttributeFailure(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.util.Collection<java.lang.String> unsupported, java.lang.Exception e)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
handleUnknownStatusFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options)
protected void
handleUnsupportedAttributes(java.util.Collection<java.lang.String> attributes)
protected void
handleUserPrincipalLookupServiceException(java.lang.Class<? extends java.security.Principal> principalType, java.lang.String name, java.io.IOException e)
protected java.nio.file.Path
normalize(java.nio.file.Path f)
protected abstract Buffer
prepareReply(Buffer buffer)
protected void
process(Buffer buffer)
Process an SFTP command.protected java.util.Map<java.lang.String,java.lang.Object>
readAttrs(Buffer buffer)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
readFileAttributes(java.nio.file.Path file, java.lang.String view, java.nio.file.LinkOption... options)
boolean
removeSftpEventListener(SftpEventListener listener)
Remove a listener instanceprotected java.util.Collection<java.lang.Integer>
resolveAclSupportedCapabilities(ServerSession session)
protected java.nio.file.Path
resolveFile(java.lang.String remotePath)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
resolveFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options)
protected java.util.NavigableMap<java.lang.String,java.lang.Object>
resolveMissingFileAttributes(java.nio.file.Path file, int flags, java.util.Map<java.lang.String,java.lang.Object> current, java.nio.file.LinkOption... options)
Called bygetAttributes(Path, int, LinkOption...)
in order to complete any attributes that could not be retrieved via the supported file system views.protected java.lang.Object
resolveMissingFileAttributeValue(java.nio.file.Path file, java.lang.String name, java.lang.Object value, FileInfoExtractor<?> x, java.nio.file.LinkOption... options)
protected java.lang.String
resolveNewlineValue(ServerSession session)
protected java.nio.file.Path
resolveNormalizedLocation(java.lang.String remotePath)
protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>
resolveOpenSSHExtensions(ServerSession session)
protected boolean
resolvePathResolutionFollowLinks(int cmd, java.lang.String extension, java.nio.file.Path path)
protected abstract void
send(Buffer buffer)
protected void
sendAttrs(Buffer buffer, int id, java.util.Map<java.lang.String,?> attributes)
protected void
sendHandle(Buffer buffer, int id, java.lang.String handle)
protected void
sendLink(Buffer buffer, int id, java.lang.String link)
protected void
sendPath(Buffer buffer, int id, java.nio.file.Path f, java.util.Map<java.lang.String,?> attrs)
protected void
sendStatus(Buffer buffer, int id, int substatus, java.lang.String msg)
protected void
sendStatus(Buffer buffer, int id, int substatus, java.lang.String msg, java.lang.String lang)
protected void
sendStatus(Buffer buffer, int id, java.lang.Throwable e, int cmd, java.lang.Object... args)
Invoked when an exception was thrown due to the execution of some SFTP commandprotected void
setFileAccessControl(java.nio.file.Path file, java.util.List<java.nio.file.attribute.AclEntry> acl, java.nio.file.LinkOption... options)
protected void
setFileAttribute(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options)
protected void
setFileAttributes(java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, java.nio.file.LinkOption... options)
protected void
setFileExtensions(java.nio.file.Path file, java.util.Map<java.lang.String,byte[]> extensions, java.nio.file.LinkOption... options)
protected void
setFileOwnership(java.nio.file.Path file, java.lang.String attribute, java.security.Principal value, java.nio.file.LinkOption... options)
protected void
setFilePermissions(java.nio.file.Path file, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.nio.file.LinkOption... options)
protected void
setFileTime(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.nio.file.attribute.FileTime value, java.nio.file.LinkOption... options)
protected <E extends java.io.IOException>
EsignalOpenFailure(int id, java.lang.String pathValue, java.nio.file.Path path, boolean isDir, E thrown)
protected <E extends java.io.IOException>
EsignalRemovalPreConditionFailure(int id, java.lang.String pathValue, java.nio.file.Path path, E thrown, boolean isRemoveDirectory)
protected java.nio.file.attribute.GroupPrincipal
toGroup(java.nio.file.Path file, java.nio.file.attribute.GroupPrincipal name)
protected java.nio.file.attribute.UserPrincipal
toUser(java.nio.file.Path file, java.nio.file.attribute.UserPrincipal name)
protected <H extends Handle>
HvalidateHandle(java.lang.String handle, Handle h, java.lang.Class<H> type)
Makes sure that the local handle is not null and of the specified typeprotected java.lang.Boolean
validateProposedVersion(Buffer buffer, int id, java.lang.String proposal)
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean>
validateRealPath(int id, java.lang.String path, java.nio.file.Path f, java.nio.file.LinkOption... options)
protected void
writeAttrs(Buffer buffer, java.util.Map<java.lang.String,?> attributes)
protected void
writeDirEntry(int id, DirectoryHandle dir, java.util.Map<java.lang.String,java.nio.file.Path> entries, Buffer buffer, int index, java.nio.file.Path f, java.lang.String shortName, java.nio.file.LinkOption... options)
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.server.session.ServerSessionHolder
getServerSession
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
Methods inherited from interface org.apache.sshd.server.subsystem.sftp.SftpSubsystemEnvironment
getDefaultDirectory, getSession, getVersion
-
-
-
-
Field Detail
-
AUTO_FOLLOW_LINKS
public static final java.lang.String AUTO_FOLLOW_LINKS
Whether to automatically follow symbolic links when resolving paths- See Also:
DEFAULT_AUTO_FOLLOW_LINKS
, Constant Field Values
-
DEFAULT_AUTO_FOLLOW_LINKS
public static final boolean DEFAULT_AUTO_FOLLOW_LINKS
Default value of "sftp-auto-follow-links"- See Also:
- Constant Field Values
-
CLIENT_EXTENSIONS_PROP
public static final java.lang.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. Note: requires overriding theexecuteExtendedCommand(Buffer, int, String)
command accordingly. If empty string is set then no server extensions are reported
-
DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
public static final java.util.NavigableMap<java.lang.String,OptionalFeature> DEFAULT_SUPPORTED_CLIENT_EXTENSIONS
The default reported supported client extensions (case insensitive)
-
OPENSSH_EXTENSIONS_PROP
public static final java.lang.String OPENSSH_EXTENSIONS_PROP
Comma-separated list of whichOpenSSH
extensions are reported and what version is reported for each - format:name=version
. If empty value set, then no such extensions are reported. Otherwise, theDEFAULT_OPEN_SSH_EXTENSIONS
are used- See Also:
- Constant Field Values
-
DEFAULT_OPEN_SSH_EXTENSIONS
public static final java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension> DEFAULT_OPEN_SSH_EXTENSIONS
-
DEFAULT_OPEN_SSH_EXTENSIONS_NAMES
public static final java.util.List<java.lang.String> DEFAULT_OPEN_SSH_EXTENSIONS_NAMES
-
ACL_SUPPORTED_MASK_PROP
public static final java.lang.String ACL_SUPPORTED_MASK_PROP
Comma separate list ofSSH_ACL_CAP_xxx
names - where name can be without the prefix. If not defined thenDEFAULT_ACL_SUPPORTED_MASK
is used- See Also:
- Constant Field Values
-
DEFAULT_ACL_SUPPORTED_MASK
public static final java.util.Set<java.lang.Integer> DEFAULT_ACL_SUPPORTED_MASK
-
NEWLINE_VALUE
public static final java.lang.String NEWLINE_VALUE
Property that can be used to set the reported NL value. If not set, thenIoUtils.EOL
is used- See Also:
- Constant Field Values
-
MAX_READDATA_PACKET_LENGTH_PROP
public static final java.lang.String MAX_READDATA_PACKET_LENGTH_PROP
Force the use of a max. packet length fordoRead(Buffer, int)
protection against malicious packets
-
DEFAULT_MAX_READDATA_PACKET_LENGTH
public static final int DEFAULT_MAX_READDATA_PACKET_LENGTH
- See Also:
- Constant Field Values
-
unsupportedAttributePolicy
private final UnsupportedAttributePolicy unsupportedAttributePolicy
-
sftpEventListeners
private final java.util.Collection<SftpEventListener> sftpEventListeners
-
sftpEventListenerProxy
private final SftpEventListener sftpEventListenerProxy
-
fileSystemAccessor
private final SftpFileSystemAccessor fileSystemAccessor
-
errorStatusDataHandler
private final SftpErrorStatusDataHandler errorStatusDataHandler
-
-
Constructor Detail
-
AbstractSftpSubsystemHelper
protected AbstractSftpSubsystemHelper(UnsupportedAttributePolicy policy, SftpFileSystemAccessor accessor, SftpErrorStatusDataHandler handler)
-
-
Method Detail
-
getUnsupportedAttributePolicy
public UnsupportedAttributePolicy getUnsupportedAttributePolicy()
- Specified by:
getUnsupportedAttributePolicy
in interfaceSftpSubsystemEnvironment
- Returns:
- The selected behavior in case some unsupported attributes are requested
-
getFileSystemAccessor
public SftpFileSystemAccessor getFileSystemAccessor()
- Specified by:
getFileSystemAccessor
in interfaceSftpSubsystemEnvironment
- Returns:
- The
SftpFileSystemAccessor
used to access effective server-side paths
-
getSftpEventListenerProxy
public SftpEventListener getSftpEventListenerProxy()
- Specified by:
getSftpEventListenerProxy
in interfaceSftpEventListenerManager
- Returns:
- An instance representing all the currently registered listeners. Any method invocation is replicated to the actually registered listeners
-
addSftpEventListener
public boolean addSftpEventListener(SftpEventListener listener)
Description copied from interface:SftpEventListenerManager
Register a listener instance- Specified by:
addSftpEventListener
in interfaceSftpEventListenerManager
- Parameters:
listener
- TheSftpEventListener
instance to add - nevernull
- Returns:
true
if listener is a previously un-registered one
-
removeSftpEventListener
public boolean removeSftpEventListener(SftpEventListener listener)
Description copied from interface:SftpEventListenerManager
Remove a listener instance- Specified by:
removeSftpEventListener
in interfaceSftpEventListenerManager
- Parameters:
listener
- TheSftpEventListener
instance to remove - nevernull
- Returns:
true
if listener is a (removed) registered one
-
getErrorStatusDataHandler
public SftpErrorStatusDataHandler getErrorStatusDataHandler()
-
validateProposedVersion
protected java.lang.Boolean validateProposedVersion(Buffer buffer, int id, java.lang.String proposal) throws java.io.IOException
- Parameters:
buffer
- TheBuffer
holding the requestid
- The request idproposal
- The proposed value- Returns:
- A
Boolean
indicating whether to accept/reject the proposal. Ifnull
then rejection response has been sent, otherwise and appropriate response is generated - Throws:
java.io.IOException
- If failed send an independent rejection response
-
checkVersionCompatibility
protected java.util.Map.Entry<java.lang.Integer,java.lang.String> checkVersionCompatibility(Buffer buffer, int id, int proposed, int failureOpcode) throws java.io.IOException
Checks if a proposed version is within supported range. Note: if the user forced a specific value via theSftpSubsystemEnvironment.SFTP_VERSION
property, then it is used to validate the proposed value- Parameters:
buffer
- TheBuffer
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 fails- Returns:
- A "pair" whose key is the negotiated version and value a
String
of comma separated values representing all the supported versions.null
if validation failed and an appropriate status message was sent - Throws:
java.io.IOException
- If failed to send the failure status message
-
process
protected void process(Buffer buffer) throws java.io.IOException
Process an SFTP command. If the command throws an exception, the channel will be closed.- Parameters:
buffer
- the buffer to process- Throws:
java.io.IOException
- if anything wrong happens
-
doProcess
protected void doProcess(Buffer buffer, int length, int type, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doUnsupported
protected void doUnsupported(Buffer buffer, int length, int type, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doInit
protected abstract void doInit(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doVersionSelect
protected void doVersionSelect(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doVersionSelect
protected abstract void doVersionSelect(Buffer buffer, int id, java.lang.String proposed) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpen
protected void doOpen(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpen
protected abstract java.lang.String doOpen(int id, java.lang.String path, int pflags, int access, java.util.Map<java.lang.String,java.lang.Object> attrs) throws java.io.IOException
- Parameters:
id
- Request idpath
- Pathpflags
- Open mode flags - seeSSH_FXF_XXX
flagsaccess
- Access mode flags - seeACE4_XXX
flagsattrs
- Requested attributes- Returns:
- The assigned (opaque) handle
- Throws:
java.io.IOException
- if failed to execute
-
signalOpenFailure
protected <E extends java.io.IOException> E signalOpenFailure(int id, java.lang.String pathValue, java.nio.file.Path path, boolean isDir, E thrown) throws java.io.IOException
- Throws:
java.io.IOException
-
doClose
protected void doClose(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doClose
protected abstract void doClose(int id, java.lang.String handle) throws java.io.IOException
- Throws:
java.io.IOException
-
doRead
protected void doRead(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRead
protected abstract int doRead(int id, java.lang.String handle, long offset, int length, byte[] data, int doff) throws java.io.IOException
- Throws:
java.io.IOException
-
doWrite
protected void doWrite(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doWrite
protected abstract void doWrite(int id, java.lang.String handle, long offset, int length, byte[] data, int doff, int remaining) throws java.io.IOException
- Throws:
java.io.IOException
-
doLStat
protected void doLStat(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doLStat
protected java.util.Map<java.lang.String,java.lang.Object> doLStat(int id, java.lang.String path, int flags) throws java.io.IOException
- Throws:
java.io.IOException
-
doSetStat
protected void doSetStat(Buffer buffer, int id, java.lang.String extension, int cmd, java.lang.Boolean followLinks) throws java.io.IOException
- Throws:
java.io.IOException
-
doSetStat
protected void doSetStat(int id, java.lang.String path, int cmd, java.lang.String extension, java.util.Map<java.lang.String,?> attrs, java.lang.Boolean followLinks) throws java.io.IOException
- Throws:
java.io.IOException
-
doFStat
protected void doFStat(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doFStat
protected abstract java.util.Map<java.lang.String,java.lang.Object> doFStat(int id, java.lang.String handle, int flags) throws java.io.IOException
- Throws:
java.io.IOException
-
doFSetStat
protected void doFSetStat(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doFSetStat
protected abstract void doFSetStat(int id, java.lang.String handle, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenDir
protected void doOpenDir(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenDir
protected abstract java.lang.String doOpenDir(int id, java.lang.String path, java.nio.file.Path p, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
doReadDir
protected abstract void doReadDir(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doLink
protected void doLink(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doLink
protected void doLink(int id, java.lang.String targetPath, java.lang.String linkPath, boolean symLink) throws java.io.IOException
- Throws:
java.io.IOException
-
doSymLink
protected void doSymLink(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doSymLink
protected void doSymLink(int id, java.lang.String targetPath, java.lang.String linkPath) throws java.io.IOException
- Throws:
java.io.IOException
-
createLink
protected abstract void createLink(int id, java.lang.String existingPath, java.lang.String linkPath, boolean symLink) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenSSHHardLink
protected void doOpenSSHHardLink(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenSSHHardLink
protected void doOpenSSHHardLink(int id, java.lang.String srcFile, java.lang.String dstFile) throws java.io.IOException
- Throws:
java.io.IOException
-
doSpaceAvailable
protected void doSpaceAvailable(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doSpaceAvailable
protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
doTextSeek
protected void doTextSeek(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doTextSeek
protected abstract void doTextSeek(int id, java.lang.String handle, long line) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenSSHFsync
protected void doOpenSSHFsync(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doOpenSSHFsync
protected abstract void doOpenSSHFsync(int id, java.lang.String handle) throws java.io.IOException
- Throws:
java.io.IOException
-
doCheckFileHash
protected void doCheckFileHash(Buffer buffer, int id, java.lang.String targetType) throws java.io.IOException
- Throws:
java.io.IOException
-
doCheckFileHash
protected void doCheckFileHash(int id, java.nio.file.Path file, NamedFactory<? extends Digest> factory, long startOffset, long length, int blockSize, Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doMD5Hash
protected void doMD5Hash(Buffer buffer, int id, java.lang.String targetType) throws java.io.IOException
- Throws:
java.io.IOException
-
doMD5Hash
protected abstract byte[] doMD5Hash(int id, java.lang.String targetType, java.lang.String target, long startOffset, long length, byte[] quickCheckHash) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doMD5Hash
protected byte[] doMD5Hash(int id, java.nio.file.Path path, long startOffset, long length, byte[] quickCheckHash) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doCheckFileHash
protected abstract void doCheckFileHash(int id, java.lang.String targetType, java.lang.String target, java.util.Collection<java.lang.String> algos, long startOffset, long length, int blockSize, Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doReadLink
protected void doReadLink(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doReadLink
protected java.lang.String doReadLink(int id, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
doRename
protected void doRename(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRename
protected void doRename(int id, java.lang.String oldPath, java.lang.String newPath, int flags) throws java.io.IOException
- Throws:
java.io.IOException
-
doRename
protected void doRename(int id, java.lang.String oldPath, java.lang.String newPath, java.util.Collection<java.nio.file.CopyOption> opts) throws java.io.IOException
- Throws:
java.io.IOException
-
doCopyData
protected void doCopyData(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doCopyData
protected abstract void doCopyData(int id, java.lang.String readHandle, long readOffset, long readLength, java.lang.String writeHandle, long writeOffset) throws java.io.IOException
- Throws:
java.io.IOException
-
doCopyFile
protected void doCopyFile(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doCopyFile
protected void doCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, boolean overwriteDestination) throws java.io.IOException
- Throws:
java.io.IOException
-
doCopyFile
protected void doCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, java.util.Collection<java.nio.file.CopyOption> opts) throws java.io.IOException
- Throws:
java.io.IOException
-
doBlock
protected void doBlock(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doBlock
protected abstract void doBlock(int id, java.lang.String handle, long offset, long length, int mask) throws java.io.IOException
- Throws:
java.io.IOException
-
doUnblock
protected void doUnblock(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doUnblock
protected abstract void doUnblock(int id, java.lang.String handle, long offset, long length) throws java.io.IOException
- Throws:
java.io.IOException
-
doStat
protected void doStat(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doStat
protected java.util.Map<java.lang.String,java.lang.Object> doStat(int id, java.lang.String path, int flags) throws java.io.IOException
- Throws:
java.io.IOException
-
doRealPath
protected void doRealPath(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRealPathV6
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean> doRealPathV6(int id, java.lang.String path, java.util.Collection<java.lang.String> extraPaths, java.nio.file.Path p, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
doRealPathV345
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean> doRealPathV345(int id, java.lang.String path, java.nio.file.Path p, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
validateRealPath
protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.Boolean> validateRealPath(int id, java.lang.String path, java.nio.file.Path f, java.nio.file.LinkOption... options) throws java.io.IOException
- Parameters:
id
- The request identifierpath
- The original pathf
- The resolvePath
options
- TheLinkOption
s to use to verify file existence and access- Returns:
- A
AbstractMap.SimpleImmutableEntry
whose key is the absolute normalizedPath
and value is aBoolean
indicating its status - Throws:
java.io.IOException
- If failed to validate the file- See Also:
IoUtils.checkFileExists(Path, LinkOption...)
-
doRemoveDirectory
protected void doRemoveDirectory(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRemoveDirectory
protected void doRemoveDirectory(int id, java.lang.String path, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
doRemove
protected void doRemove(int id, java.nio.file.Path p, boolean isDirectory) throws java.io.IOException
Called when need to delete a file / directory - also informs theSftpEventListener
- Parameters:
id
- Deletion request IDp
-Path
to deleteisDirectory
- Whether the requested path represents a directory or a regular file- Throws:
java.io.IOException
- If failed to delete
-
doMakeDirectory
protected void doMakeDirectory(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doMakeDirectory
protected void doMakeDirectory(int id, java.lang.String path, java.util.Map<java.lang.String,?> attrs, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
doRemove
protected void doRemove(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRemove
protected void doRemove(int id, java.lang.String path, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
signalRemovalPreConditionFailure
protected <E extends java.io.IOException> E signalRemovalPreConditionFailure(int id, java.lang.String pathValue, java.nio.file.Path path, E thrown, boolean isRemoveDirectory) throws java.io.IOException
- Throws:
java.io.IOException
-
doExtended
protected void doExtended(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
executeExtendedCommand
protected void executeExtendedCommand(Buffer buffer, int id, java.lang.String extension) throws java.io.IOException
- Parameters:
buffer
- The commandBuffer
id
- The request idextension
- The extension name- Throws:
java.io.IOException
- If failed to execute the extension
-
doUnsupportedExtension
protected void doUnsupportedExtension(Buffer buffer, int id, java.lang.String extension) throws java.io.IOException
- Throws:
java.io.IOException
-
appendExtensions
protected void appendExtensions(Buffer buffer, java.lang.String supportedVersions)
-
appendAclSupportedExtension
protected int appendAclSupportedExtension(Buffer buffer, ServerSession session)
-
resolveAclSupportedCapabilities
protected java.util.Collection<java.lang.Integer> resolveAclSupportedCapabilities(ServerSession session)
-
appendOpenSSHExtensions
protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension> appendOpenSSHExtensions(Buffer buffer, ServerSession session)
-
resolveOpenSSHExtensions
protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension> resolveOpenSSHExtensions(ServerSession session)
-
getSupportedClientExtensions
protected java.util.Map<java.lang.String,OptionalFeature> getSupportedClientExtensions(ServerSession session)
-
appendVersionsExtension
protected void appendVersionsExtension(Buffer buffer, java.lang.String value, ServerSession session)
Appends the "versions" extension to the buffer. Note: if overriding this method make sure you either do not append anything or use the correct extension name- Parameters:
buffer
- TheBuffer
to append tovalue
- The recommended value - ignored ifnull
/emptysession
- TheServerSession
for which this extension is added- See Also:
SftpConstants.EXT_VERSIONS
-
appendNewlineExtension
protected void appendNewlineExtension(Buffer buffer, ServerSession session)
Appends the "newline" extension to the buffer. Note: if overriding this method make sure you either do not append anything or use the correct extension name- Parameters:
buffer
- TheBuffer
to append tosession
- TheServerSession
for which this extension is added- See Also:
SftpConstants.EXT_NEWLINE
,resolveNewlineValue(ServerSession)
-
resolveNewlineValue
protected java.lang.String resolveNewlineValue(ServerSession session)
-
appendVendorIdExtension
protected void appendVendorIdExtension(Buffer buffer, java.util.Map<java.lang.String,?> versionProperties, ServerSession session)
Appends the "vendor-id" extension to the buffer. Note: if overriding this method make sure you either do not append anything or use the correct extension name- Parameters:
buffer
- TheBuffer
to append toversionProperties
- The currently available version properties - ignored ifnull
/empty. The code expects the following values:groupId
- as the vendor nameartifactId
- as the product nameversion
- as the product version
session
- TheServerSession
for which these properties are added- See Also:
SftpConstants.EXT_VENDOR_ID
, DRAFT 09 - section 4.4
-
appendSupportedExtension
protected void appendSupportedExtension(Buffer buffer, java.util.Collection<java.lang.String> extras)
Appends the "supported" extension to the buffer. Note: if overriding this method make sure you either do not append anything or use the correct extension name- Parameters:
buffer
- TheBuffer
to append toextras
- The extra extensions that are available and can be reported - may benull
/empty
-
appendSupported2Extension
protected void appendSupported2Extension(Buffer buffer, java.util.Collection<java.lang.String> extras)
Appends the "supported2" extension to the buffer. Note: if overriding this method make sure you either do not append anything or use the correct extension name- Parameters:
buffer
- TheBuffer
to append toextras
- The extra extensions that are available and can be reported - may benull
/empty- See Also:
SftpConstants.EXT_SUPPORTED
, DRAFT 13 section 5.4
-
sendHandle
protected void sendHandle(Buffer buffer, int id, java.lang.String handle) throws java.io.IOException
- Throws:
java.io.IOException
-
sendAttrs
protected void sendAttrs(Buffer buffer, int id, java.util.Map<java.lang.String,?> attributes) throws java.io.IOException
- Throws:
java.io.IOException
-
sendLink
protected void sendLink(Buffer buffer, int id, java.lang.String link) throws java.io.IOException
- Throws:
java.io.IOException
-
sendPath
protected void sendPath(Buffer buffer, int id, java.nio.file.Path f, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
- Throws:
java.io.IOException
-
doReadDir
protected int doReadDir(int id, java.lang.String handle, DirectoryHandle dir, Buffer buffer, int maxSize, java.nio.file.LinkOption... options) throws java.io.IOException
- Parameters:
id
- Request idhandle
- The (opaque) handle assigned to this directorydir
- TheDirectoryHandle
buffer
- TheBuffer
to write the resultsmaxSize
- Max. buffer sizeoptions
- TheLinkOption
-s to use when querying the directory contents- Returns:
- Number of written entries
- Throws:
java.io.IOException
- If failed to generate an entry
-
writeDirEntry
protected void writeDirEntry(int id, DirectoryHandle dir, java.util.Map<java.lang.String,java.nio.file.Path> entries, Buffer buffer, int index, java.nio.file.Path f, java.lang.String shortName, java.nio.file.LinkOption... options) throws java.io.IOException
- Parameters:
id
- Request iddir
- TheDirectoryHandle
entries
- An in / outMap
for updating the written entry - key = short name, value = entryPath
buffer
- TheBuffer
to write the resultsindex
- Zero-based index of the entry to be writtenf
- The entryPath
shortName
- The entry short nameoptions
- TheLinkOption
s to use for querying the entry-s attributes- Throws:
java.io.IOException
- If failed to generate the entry data
-
getLongName
protected java.lang.String getLongName(java.nio.file.Path f, java.lang.String shortName, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
getLongName
protected java.lang.String getLongName(java.nio.file.Path f, java.lang.String shortName, boolean sendAttrs, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
getLongName
protected java.lang.String getLongName(java.nio.file.Path f, java.lang.String shortName, java.util.Map<java.lang.String,?> attributes) throws java.io.IOException
- Throws:
java.io.IOException
-
getShortName
protected java.lang.String getShortName(java.nio.file.Path f) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveFileAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> resolveFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAttrs
protected void writeAttrs(Buffer buffer, java.util.Map<java.lang.String,?> attributes) throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> getAttributes(java.nio.file.Path file, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
handleUnknownStatusFileAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> handleUnknownStatusFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
getAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> getAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options) throws java.io.IOException
- Parameters:
file
- ThePath
location for the required attributesflags
- A mask of the original required attributes - ignored by the default implementationoptions
- TheLinkOption
s to use in order to access the file if necessary- Returns:
- A
Map
of the retrieved attributes - Throws:
java.io.IOException
- If failed to access the file- See Also:
resolveMissingFileAttributes(Path, int, Map, LinkOption...)
-
resolveMissingFileAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> resolveMissingFileAttributes(java.nio.file.Path file, int flags, java.util.Map<java.lang.String,java.lang.Object> current, java.nio.file.LinkOption... options) throws java.io.IOException
Called bygetAttributes(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 them- Parameters:
file
- ThePath
location for the required attributesflags
- A mask of the original required attributes - ignored by the default implementationcurrent
- TheMap
of attributes already retrieved - may benull
/empty and/or unmodifiableoptions
- TheLinkOption
s to use in order to access the file if necessary- Returns:
- A
Map
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
value - Throws:
java.io.IOException
- If failed to access the attributes - in which case an error is returned to the SFTP client- See Also:
SftpFileSystemAccessor.FILEATTRS_RESOLVERS
-
resolveMissingFileAttributeValue
protected java.lang.Object resolveMissingFileAttributeValue(java.nio.file.Path file, java.lang.String name, java.lang.Object value, FileInfoExtractor<?> x, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
addMissingAttribute
protected java.util.NavigableMap<java.lang.String,java.lang.Object> addMissingAttribute(java.nio.file.Path file, java.util.NavigableMap<java.lang.String,java.lang.Object> current, java.lang.String name, FileInfoExtractor<?> x, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
readFileAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> readFileAttributes(java.nio.file.Path file, java.lang.String view, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
handleReadFileAttributesException
protected java.util.NavigableMap<java.lang.String,java.lang.Object> handleReadFileAttributesException(java.nio.file.Path file, java.lang.String view, java.nio.file.LinkOption[] options, java.io.IOException e) throws java.io.IOException
- Throws:
java.io.IOException
-
doSetAttributes
protected void doSetAttributes(java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, boolean followLinks) throws java.io.IOException
- Throws:
java.io.IOException
-
getPathResolutionLinkOption
protected java.nio.file.LinkOption[] getPathResolutionLinkOption(int cmd, java.lang.String extension, java.nio.file.Path path) throws java.io.IOException
- Throws:
java.io.IOException
-
resolvePathResolutionFollowLinks
protected boolean resolvePathResolutionFollowLinks(int cmd, java.lang.String extension, java.nio.file.Path path) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileAttributes
protected void setFileAttributes(java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
handleSetFileAttributeFailure
protected void handleSetFileAttributeFailure(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.util.Collection<java.lang.String> unsupported, java.lang.Exception e) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileAttribute
protected void setFileAttribute(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileTime
protected void setFileTime(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.nio.file.attribute.FileTime value, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileOwnership
protected void setFileOwnership(java.nio.file.Path file, java.lang.String attribute, java.security.Principal value, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileExtensions
protected void setFileExtensions(java.nio.file.Path file, java.util.Map<java.lang.String,byte[]> extensions, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
setFilePermissions
protected void setFilePermissions(java.nio.file.Path file, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
setFileAccessControl
protected void setFileAccessControl(java.nio.file.Path file, java.util.List<java.nio.file.attribute.AclEntry> acl, java.nio.file.LinkOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
handleUnsupportedAttributes
protected void handleUnsupportedAttributes(java.util.Collection<java.lang.String> attributes)
-
toGroup
protected java.nio.file.attribute.GroupPrincipal toGroup(java.nio.file.Path file, java.nio.file.attribute.GroupPrincipal name) throws java.io.IOException
- Throws:
java.io.IOException
-
toUser
protected java.nio.file.attribute.UserPrincipal toUser(java.nio.file.Path file, java.nio.file.attribute.UserPrincipal name) throws java.io.IOException
- Throws:
java.io.IOException
-
handleUserPrincipalLookupServiceException
protected void handleUserPrincipalLookupServiceException(java.lang.Class<? extends java.security.Principal> principalType, java.lang.String name, java.io.IOException e) throws java.io.IOException
- Throws:
java.io.IOException
-
readAttrs
protected java.util.Map<java.lang.String,java.lang.Object> readAttrs(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
validateHandle
protected <H extends Handle> H validateHandle(java.lang.String handle, Handle h, java.lang.Class<H> type) throws java.io.IOException
Makes sure that the local handle is not null and of the specified type- Type Parameters:
H
- The generic handle type- Parameters:
handle
- The original handle idh
- The resolvedHandle
instancetype
- The expected handle type- Returns:
- The cast type
- Throws:
java.io.IOException
- If a generic exception occurredjava.io.FileNotFoundException
- If the handle instance isnull
InvalidHandleException
- If the handle instance is not of the expected type
-
sendStatus
protected void sendStatus(Buffer buffer, int id, java.lang.Throwable e, int cmd, java.lang.Object... args) throws java.io.IOException
Invoked when an exception was thrown due to the execution of some SFTP command- Parameters:
buffer
- ABuffer
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 version- Throws:
java.io.IOException
- If failed to build and send the status buffer
-
sendStatus
protected void sendStatus(Buffer buffer, int id, int substatus, java.lang.String msg) throws java.io.IOException
- Throws:
java.io.IOException
-
sendStatus
protected void sendStatus(Buffer buffer, int id, int substatus, java.lang.String msg, java.lang.String lang) throws java.io.IOException
- Throws:
java.io.IOException
-
send
protected abstract void send(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveNormalizedLocation
protected java.nio.file.Path resolveNormalizedLocation(java.lang.String remotePath) throws java.io.IOException, java.nio.file.InvalidPathException
- Throws:
java.io.IOException
java.nio.file.InvalidPathException
-
normalize
protected java.nio.file.Path normalize(java.nio.file.Path f)
-
resolveFile
protected java.nio.file.Path resolveFile(java.lang.String remotePath) throws java.io.IOException, java.nio.file.InvalidPathException
- Parameters:
remotePath
- The remote path - separated by '/'- Returns:
- The local
Path
- Throws:
java.io.IOException
- If failed to resolve the local pathjava.nio.file.InvalidPathException
- If bad local path specification
-
-