Package org.apache.sshd.sftp.server
Class AbstractSftpSubsystemHelper
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.sftp.server.AbstractSftpSubsystemHelper
-
- All Implemented Interfaces:
SessionContextHolder,SessionHolder<ServerSession>,ServerChannelSessionHolder,ServerSessionHolder,SftpErrorStatusDataHandlerProvider,SftpEventListenerManager,SftpFileSystemAccessorProvider,SftpSubsystemEnvironment,SftpSubsystemProxy,SftpUnsupportedAttributePolicyProvider
- Direct Known Subclasses:
SftpSubsystem
public abstract class AbstractSftpSubsystemHelper extends AbstractLoggingBean implements SftpSubsystemProxy
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelSessionchannelSessionstatic java.util.Set<java.lang.Integer>DEFAULT_ACL_SUPPORTED_MASKstatic java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>DEFAULT_OPEN_SSH_EXTENSIONSstatic java.util.List<java.lang.String>DEFAULT_OPEN_SSH_EXTENSIONS_NAMESstatic java.util.NavigableMap<java.lang.String,OptionalFeature>DEFAULT_SUPPORTED_CLIENT_EXTENSIONSThe default reported supported client extensions (case insensitive)private SftpErrorStatusDataHandlererrorStatusDataHandlerprivate SftpFileSystemAccessorfileSystemAccessorprivate SftpEventListenersftpEventListenerProxyprivate java.util.Collection<SftpEventListener>sftpEventListenersprivate UnsupportedAttributePolicyunsupportedAttributePolicy-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.sftp.server.SftpSubsystemEnvironment
ALL_SFTP_IMPL, HIGHER_SFTP_IMPL, LOWER_SFTP_IMPL, SUPPORTED_SFTP_VERSIONS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSftpSubsystemHelper(ChannelSession channelSession, SftpSubsystemConfigurator configurator)
-
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)booleanaddSftpEventListener(SftpEventListener listener)Register a listener instanceprotected intappendAclSupportedExtension(Buffer buffer, ServerSession session)protected voidappendExtensions(Buffer buffer, java.lang.String supportedVersions)protected java.lang.StringappendNewlineExtension(Buffer buffer, ServerSession session)Appends the "newline" extension to the buffer.protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>appendOpenSSHExtensions(Buffer buffer, ServerSession session)protected voidappendSupported2Extension(Buffer buffer, java.util.Collection<java.lang.String> extras)Appends the "supported2" extension to the buffer.protected voidappendSupportedExtension(Buffer buffer, java.util.Collection<java.lang.String> extras)Appends the "supported" extension to the buffer.protected java.util.Map<java.lang.String,?>appendVendorIdExtension(Buffer buffer, java.util.Map<java.lang.String,?> versionProperties, ServerSession session)Appends the "vendor-id" extension to the buffer.protected java.lang.StringappendVersionsExtension(Buffer buffer, java.lang.String value, ServerSession session)Appends the "versions" extension to the buffer.java.lang.BooleancheckSymlinkState(java.nio.file.Path path, boolean neverFollowSymLinks, java.nio.file.LinkOption[] options)A utility function to validate that the directories leading up to a file are not symlinksprotected 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 voidcreateLink(int id, java.lang.String existingPath, java.lang.String linkPath, boolean symLink)protected abstract voiddoBlock(int id, java.lang.String handle, long offset, long length, int mask)protected voiddoBlock(Buffer buffer, int id)protected abstract voiddoCheckFileHash(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 voiddoCheckFileHash(int id, java.nio.file.Path file, NamedFactory<? extends Digest> factory, long startOffset, long length, int blockSize, Buffer buffer)protected voiddoCheckFileHash(Buffer buffer, int id, java.lang.String targetType)protected abstract voiddoClose(int id, java.lang.String handle)protected voiddoClose(Buffer buffer, int id)protected abstract voiddoCopyData(int id, java.lang.String readHandle, long readOffset, long readLength, java.lang.String writeHandle, long writeOffset)protected voiddoCopyData(Buffer buffer, int id)protected voiddoCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, boolean overwriteDestination)protected voiddoCopyFile(int id, java.lang.String srcFile, java.lang.String dstFile, java.util.Collection<java.nio.file.CopyOption> opts)protected voiddoCopyFile(Buffer buffer, int id)protected voiddoExtended(Buffer buffer, int id)protected abstract voiddoFSetStat(int id, java.lang.String handle, java.util.Map<java.lang.String,?> attrs)protected voiddoFSetStat(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 voiddoFStat(Buffer buffer, int id)protected abstract voiddoInit(Buffer buffer, int id)protected voiddoLink(int id, java.lang.String targetPath, java.lang.String linkPath, boolean symLink)protected voiddoLink(Buffer buffer, int id)protected java.util.Map<java.lang.String,java.lang.Object>doLStat(int id, java.lang.String path, int flags)protected voiddoLStat(Buffer buffer, int id)protected voiddoMakeDirectory(int id, java.lang.String path, java.util.Map<java.lang.String,?> attrs)protected voiddoMakeDirectory(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 voiddoMD5Hash(Buffer buffer, int id, java.lang.String targetType)protected abstract java.lang.StringdoOpen(int id, java.lang.String path, int pflags, int access, java.util.Map<java.lang.String,java.lang.Object> attrs)protected voiddoOpen(Buffer buffer, int id)protected abstract java.lang.StringdoOpenDir(int id, java.lang.String path, java.nio.file.Path p, java.nio.file.LinkOption... options)protected voiddoOpenDir(Buffer buffer, int id)protected abstract voiddoOpenSSHFsync(int id, java.lang.String handle)protected voiddoOpenSSHFsync(Buffer buffer, int id)protected voiddoOpenSSHHardLink(int id, java.lang.String srcFile, java.lang.String dstFile)protected voiddoOpenSSHHardLink(Buffer buffer, int id)protected voiddoOpenSSHLimits(Buffer buffer, int id)protected voiddoPosixRename(Buffer buffer, int id)protected voiddoProcess(Buffer buffer, int length, int type, int id)protected abstract intdoRead(int id, java.lang.String handle, long offset, int length, byte[] data, int doff, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eof)protected voiddoRead(Buffer buffer, int id)protected intdoReadDir(int id, java.lang.String handle, DirectoryHandle dir, Buffer buffer, int maxSize, boolean followLinks)protected abstract voiddoReadDir(Buffer buffer, int id)protected java.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.String>doReadLink(int id, java.lang.String path)protected voiddoReadLink(Buffer buffer, int id)protected voiddoRealPath(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 voiddoRemove(int id, java.nio.file.Path p, boolean isDirectory)Called when need to delete a file / directory - also informs theSftpEventListenerprotected voiddoRemove(Buffer buffer, int id)protected voiddoRemoveDirectory(int id, java.lang.String path)protected voiddoRemoveDirectory(Buffer buffer, int id)protected voiddoRemoveFile(int id, java.lang.String path)protected voiddoRename(int id, java.lang.String oldPath, java.lang.String newPath, int flags)protected voiddoRename(int id, java.lang.String oldPath, java.lang.String newPath, java.util.Collection<java.nio.file.CopyOption> opts)protected voiddoRename(Buffer buffer, int id)protected voiddoSetAttributes(int cmd, java.lang.String extension, java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, boolean followLinks)protected voiddoSetStat(int id, java.lang.String path, int cmd, java.lang.String extension, java.util.Map<java.lang.String,?> attrs, java.lang.Boolean followLinks)protected voiddoSetStat(Buffer buffer, int id, java.lang.String extension, int cmd, java.lang.Boolean followLinks)protected SpaceAvailableExtensionInfodoSpaceAvailable(int id, java.lang.String path)protected voiddoSpaceAvailable(Buffer buffer, int id)protected java.util.Map<java.lang.String,java.lang.Object>doStat(int id, java.lang.String path, int flags)protected voiddoStat(Buffer buffer, int id)protected voiddoSymLink(int id, java.lang.String targetPath, java.lang.String linkPath)protected voiddoSymLink(Buffer buffer, int id)protected abstract voiddoTextSeek(int id, java.lang.String handle, long line)protected voiddoTextSeek(Buffer buffer, int id)protected abstract voiddoUnblock(int id, java.lang.String handle, long offset, long length)protected voiddoUnblock(Buffer buffer, int id)protected voiddoUnsupported(Buffer buffer, int length, int type, int id)protected voiddoUnsupportedExtension(Buffer buffer, int id, java.lang.String extension)protected voiddoVersionSelect(Buffer buffer, int id)protected abstract voiddoVersionSelect(Buffer buffer, int id, java.lang.String proposed)protected abstract voiddoWrite(int id, java.lang.String handle, long offset, int length, byte[] data, int doff, int remaining)protected voiddoWrite(Buffer buffer, int id)protected voidexecuteExtendedCommand(Buffer buffer, int id, java.lang.String extension)protected java.util.NavigableMap<java.lang.String,java.lang.Object>getAttributes(java.nio.file.Path path, 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)SftpErrorStatusDataHandlergetErrorStatusDataHandler()SftpFileSystemAccessorgetFileSystemAccessor()protected java.lang.StringgetLongName(java.nio.file.Path f, java.lang.String shortName, boolean sendAttrs, java.nio.file.LinkOption... options)protected java.lang.StringgetLongName(java.nio.file.Path f, java.lang.String shortName, java.nio.file.LinkOption... options)protected java.lang.StringgetLongName(java.nio.file.Path f, java.lang.String shortName, java.util.Map<java.lang.String,?> attributes)protected java.lang.StringgetLongName(java.nio.file.Path f, java.lang.String shortName, SftpClient.Attributes attributes)protected OpenSSHLimitsExtensionInfogetOpenSSHLimitsExtensionInfo(int id, ChannelSession channel)protected java.nio.file.LinkOption[]getPathResolutionLinkOption(int cmd, java.lang.String extension, java.nio.file.Path path)ChannelSessiongetServerChannelSession()SftpEventListenergetSftpEventListenerProxy()protected java.lang.StringgetShortName(java.nio.file.Path f)protected java.util.Map<java.lang.String,OptionalFeature>getSupportedClientExtensions(ServerSession session)UnsupportedAttributePolicygetUnsupportedAttributePolicy()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 voidhandleSetFileAttributeFailure(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 voidhandleUnsupportedAttributes(java.util.Collection<java.lang.String> attributes)protected voidhandleUserPrincipalLookupServiceException(java.lang.Class<? extends java.security.Principal> principalType, java.lang.String name, java.io.IOException e)protected java.nio.file.Pathnormalize(java.nio.file.Path f)protected abstract BufferprepareReply(Buffer buffer)protected voidprocess(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)booleanremoveSftpEventListener(SftpEventListener listener)Remove a listener instanceprotected java.util.Collection<java.lang.Integer>resolveAclSupportedCapabilities(ServerSession session)protected java.nio.file.PathresolveFile(java.lang.String remotePath)protected java.util.NavigableMap<java.lang.String,java.lang.Object>resolveFileAttributes(java.nio.file.Path path, int flags, boolean neverFollowSymLinks, 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.ObjectresolveMissingFileAttributeValue(java.nio.file.Path file, java.lang.String name, java.lang.Object value, FileInfoExtractor<?> x, java.nio.file.LinkOption... options)protected java.lang.StringresolveNewlineValue(ServerSession session)protected java.nio.file.PathresolveNormalizedLocation(java.lang.String remotePath)protected java.util.List<AbstractOpenSSHExtensionParser.OpenSSHExtension>resolveOpenSSHExtensions(ServerSession session)protected booleanresolvePathResolutionFollowLinks(int cmd, java.lang.String extension, java.nio.file.Path path)protected java.util.NavigableMap<java.lang.String,java.lang.Object>resolveReportedFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options)protected abstract voidsend(Buffer buffer)protected voidsendAttrs(Buffer buffer, int id, java.util.Map<java.lang.String,?> attributes)protected voidsendHandle(Buffer buffer, int id, java.lang.String handle)protected voidsendLink(Buffer buffer, int id, java.nio.file.Path file, java.lang.String link)protected voidsendPath(Buffer buffer, int id, java.nio.file.Path f, java.util.Map<java.lang.String,?> attrs)protected voidsendStatus(Buffer buffer, int id, int substatus, java.lang.String msg)protected voidsendStatus(Buffer buffer, int id, int substatus, java.lang.String msg, java.lang.String lang)protected voidsendStatus(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 voidsetFileAccessControl(java.nio.file.Path file, java.util.List<java.nio.file.attribute.AclEntry> acl, java.nio.file.LinkOption... options)protected voidsetFileAttribute(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options)protected voidsetFileAttributes(java.nio.file.Path file, java.util.Map<java.lang.String,?> attributes, java.nio.file.LinkOption... options)protected voidsetFileExtensions(java.nio.file.Path file, java.util.Map<java.lang.String,byte[]> extensions, java.nio.file.LinkOption... options)protected voidsetFileOwnership(java.nio.file.Path file, java.lang.String attribute, java.security.Principal value, java.nio.file.LinkOption... options)protected voidsetFilePermissions(java.nio.file.Path file, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.nio.file.LinkOption... options)protected voidsetFileRawViewAttribute(java.nio.file.Path file, java.lang.String view, java.lang.String attribute, java.lang.Object value, java.nio.file.LinkOption... options)protected voidsetFileTime(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.GroupPrincipaltoGroup(java.nio.file.Path file, java.nio.file.attribute.GroupPrincipal name)protected java.nio.file.attribute.UserPrincipaltoUser(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 typejava.lang.BooleanvalidateParentExistWithNoSymlinksIfNeverFollowSymlinks(java.nio.file.Path path, boolean neverFollowSymLinks)protected java.lang.BooleanvalidateProposedVersion(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 voidwriteAttrs(Buffer buffer, java.util.Map<java.lang.String,?> attributes)protected voidwriteDirEntry(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)protected voidwriteDirEntry(ServerSession session, int id, Buffer buffer, int index, java.nio.file.Path f, java.lang.String shortName, SftpClient.Attributes attributes)-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
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.sftp.server.SftpSubsystemEnvironment
getDefaultDirectory, getSession, getVersion
-
-
-
-
Field Detail
-
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)
-
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
-
DEFAULT_ACL_SUPPORTED_MASK
public static final java.util.Set<java.lang.Integer> DEFAULT_ACL_SUPPORTED_MASK
-
channelSession
private final ChannelSession channelSession
-
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(ChannelSession channelSession, SftpSubsystemConfigurator configurator)
-
-
Method Detail
-
getServerChannelSession
public ChannelSession getServerChannelSession()
- Specified by:
getServerChannelSessionin interfaceServerChannelSessionHolder
-
getUnsupportedAttributePolicy
public UnsupportedAttributePolicy getUnsupportedAttributePolicy()
- Specified by:
getUnsupportedAttributePolicyin interfaceSftpUnsupportedAttributePolicyProvider- Returns:
- The
UnsupportedAttributePolicyto use if failed to access some local file attributes
-
getFileSystemAccessor
public SftpFileSystemAccessor getFileSystemAccessor()
- Specified by:
getFileSystemAccessorin interfaceSftpFileSystemAccessorProvider- Returns:
- The
SftpFileSystemAccessorto use for accessing files and directories
-
getSftpEventListenerProxy
public SftpEventListener getSftpEventListenerProxy()
- Specified by:
getSftpEventListenerProxyin 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:SftpEventListenerManagerRegister a listener instance- Specified by:
addSftpEventListenerin interfaceSftpEventListenerManager- Parameters:
listener- TheSftpEventListenerinstance to add - nevernull- Returns:
trueif listener is a previously un-registered one
-
removeSftpEventListener
public boolean removeSftpEventListener(SftpEventListener listener)
Description copied from interface:SftpEventListenerManagerRemove a listener instance- Specified by:
removeSftpEventListenerin interfaceSftpEventListenerManager- Parameters:
listener- TheSftpEventListenerinstance to remove - nevernull- Returns:
trueif listener is a (removed) registered one
-
getErrorStatusDataHandler
public SftpErrorStatusDataHandler getErrorStatusDataHandler()
- Specified by:
getErrorStatusDataHandlerin interfaceSftpErrorStatusDataHandlerProvider- Returns:
- The (never
null)SftpErrorStatusDataHandlerto use when generating failed commands error messages
-
validateProposedVersion
protected java.lang.Boolean validateProposedVersion(Buffer buffer, int id, java.lang.String proposal) throws java.io.IOException
- Parameters:
buffer- TheBufferholding the requestid- The request idproposal- The proposed value- Returns:
- A
Booleanindicating whether to accept/reject the proposal. Ifnullthen 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 theSftpModuleProperties.SFTP_VERSIONproperty, then it is used to validate the proposed value- Parameters:
buffer- TheBuffercontaining 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
Stringof comma separated values representing all the supported versions.nullif 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_XXXflagsaccess- Access mode flags - seeACE4_XXXflagsattrs- 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, java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> eof) 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
-
doOpenSSHLimits
protected void doOpenSSHLimits(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
getOpenSSHLimitsExtensionInfo
protected OpenSSHLimitsExtensionInfo getOpenSSHLimitsExtensionInfo(int id, ChannelSession channel) 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.util.AbstractMap.SimpleImmutableEntry<java.nio.file.Path,java.lang.String> doReadLink(int id, java.lang.String path) throws java.io.IOException- Parameters:
id- Request identifierpath- Referenced path- Returns:
- A "pair" containing the local link
Pathand its referenced symbolic link - Throws:
java.io.IOException- If failed to resolve the requested data
-
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
-
doPosixRename
protected void doPosixRename(Buffer buffer, int id) 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 resolvePathoptions- TheLinkOptions to use to verify file existence and access- Returns:
- A
AbstractMap.SimpleImmutableEntrywhose key is the absolute normalizedPathand value is aBooleanindicating 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) throws java.io.IOException- Throws:
java.io.IOException
-
doRemove
protected void doRemove(int id, java.nio.file.Path p, boolean isDirectory) throws java.io.IOExceptionCalled when need to delete a file / directory - also informs theSftpEventListener- Parameters:
id- Deletion request IDp-Pathto 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) throws java.io.IOException- Throws:
java.io.IOException
-
doRemove
protected void doRemove(Buffer buffer, int id) throws java.io.IOException
- Throws:
java.io.IOException
-
doRemoveFile
protected void doRemoveFile(int id, java.lang.String path) 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 commandBufferid- 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 java.lang.String 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- TheBufferto append tovalue- The recommended value - ignored ifnull/emptysession- TheServerSessionfor which this extension is added- Returns:
- The apended value
- See Also:
SftpConstants.EXT_VERSIONS
-
appendNewlineExtension
protected java.lang.String 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- TheBufferto append tosession- TheServerSessionfor which this extension is added- Returns:
- The appended value
- See Also:
SftpConstants.EXT_NEWLINE,resolveNewlineValue(ServerSession)
-
resolveNewlineValue
protected java.lang.String resolveNewlineValue(ServerSession session)
-
appendVendorIdExtension
protected java.util.Map<java.lang.String,?> 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- TheBufferto 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- TheServerSessionfor which these properties are added- Returns:
- The version properties
- 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- TheBufferto 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- TheBufferto 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.nio.file.Path file, 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, boolean followLinks) throws java.io.IOException- Parameters:
id- Request idhandle- The (opaque) handle assigned to this directorydir- TheDirectoryHandlebuffer- TheBufferto write the resultsmaxSize- Max. buffer sizefollowLinks- Whether to follow symbolic links when querying the directory contents- Returns:
- Number of written entries
- Throws:
java.io.IOException- If failed to generate an entry
-
writeDirEntry
protected void writeDirEntry(ServerSession session, int id, Buffer buffer, int index, java.nio.file.Path f, java.lang.String shortName, SftpClient.Attributes attributes) throws java.io.IOException
- Throws:
java.io.IOException
-
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- TheDirectoryHandleentries- An in / outMapfor updating the written entry - key = short name, value = entryPathbuffer- TheBufferto write the resultsindex- Zero-based index of the entry to be writtenf- The entryPathshortName- The entry short nameoptions- TheLinkOptions 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
-
getLongName
protected java.lang.String getLongName(java.nio.file.Path f, java.lang.String shortName, SftpClient.Attributes 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 path, int flags, boolean neverFollowSymLinks, java.nio.file.LinkOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
checkSymlinkState
public java.lang.Boolean checkSymlinkState(java.nio.file.Path path, boolean neverFollowSymLinks, java.nio.file.LinkOption[] options)A utility function to validate that the directories leading up to a file are not symlinks- Parameters:
path- the file to check for symlink presenceneverFollowSymLinks- whether to never follow symlinks in the parent pathsoptions- whether the file itself can be a symlink- Returns:
- whether there are symlinks in the path to this file, or null if unknown
-
validateParentExistWithNoSymlinksIfNeverFollowSymlinks
public java.lang.Boolean validateParentExistWithNoSymlinksIfNeverFollowSymlinks(java.nio.file.Path path, boolean neverFollowSymLinks)
-
writeAttrs
protected void writeAttrs(Buffer buffer, java.util.Map<java.lang.String,?> attributes)
-
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 path, int flags, java.nio.file.LinkOption... options) throws java.io.IOException- Parameters:
path- ThePathlocation for the required attributesflags- A mask of the original required attributes - ignored by the default implementationoptions- TheLinkOptions to use in order to access the file if necessary- Returns:
- A
Mapof the retrieved attributes - Throws:
java.io.IOException- If failed to access the file- See Also:
resolveReportedFileAttributes(Path, int, LinkOption...)
-
resolveReportedFileAttributes
protected java.util.NavigableMap<java.lang.String,java.lang.Object> resolveReportedFileAttributes(java.nio.file.Path file, int flags, java.nio.file.LinkOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
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.IOExceptionCalled 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- ThePathlocation for the required attributesflags- A mask of the original required attributes - ignored by the default implementationcurrent- TheMapof attributes already retrieved - may benull/empty and/or unmodifiableoptions- TheLinkOptions to use in order to access the file if necessary- Returns:
- A
Mapof 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-nullvalue - 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(int cmd, java.lang.String extension, 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
-
setFileRawViewAttribute
protected void setFileRawViewAttribute(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
-
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 resolvedHandleinstancetype- The expected handle type- Returns:
- The cast type
- Throws:
java.io.IOException- If a generic exception occurredjava.io.FileNotFoundException- If the handle instance isnullInvalidHandleException- 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- ABufferto 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.IOExceptionjava.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
-
-