Interface SftpEventListener
-
- All Superinterfaces:
java.util.EventListener
,SshdEventListener
- All Known Implementing Classes:
AbstractSftpEventListenerAdapter
public interface SftpEventListener extends SshdEventListener
Can be used register for SFTP events. Note: it does not expose the entire set of available SFTP commands and responses (e.g., no reports for initialization, extensions, parameters re-negotiation, etc...);
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default void
blocked(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask, java.lang.Throwable thrown)
Called after blocking a file sectiondefault void
blocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask)
Called prior to blocking a file sectiondefault void
closed(ServerSession session, java.lang.String remoteHandle, Handle localHandle, java.lang.Throwable thrown)
Specified file / directory has been closeddefault void
closing(ServerSession session, java.lang.String remoteHandle, Handle localHandle)
Specified file / directory about to be closeddefault void
created(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs, java.lang.Throwable thrown)
Called after creating a directorydefault void
creating(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs)
Called prior to creating a directorydefault void
destroying(ServerSession session)
Called when subsystem is destroyed since it was closeddefault void
exiting(ServerSession session, Handle handle)
Called when subsystem is exiting due to being destroyeddefault void
initialized(ServerSession session, int version)
Called when the SFTP protocol has been initializeddefault void
linked(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink, java.lang.Throwable thrown)
Called after creating a linkdefault void
linking(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink)
Called prior to creating a linkdefault void
modifiedAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs, java.lang.Throwable thrown)
Called after modifying the attributes of a file / directorydefault void
modifyingAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs)
Called prior to modifying the attributes of a file / directorydefault void
moved(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts, java.lang.Throwable thrown)
Called after renaming a file / directorydefault void
moving(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts)
Called prior to renaming a file / directorydefault void
open(ServerSession session, java.lang.String remoteHandle, Handle localHandle)
Specified file / directory has been openeddefault void
openFailed(ServerSession session, java.lang.String remotePath, java.nio.file.Path localPath, boolean isDirectory, java.lang.Throwable thrown)
Specified file / directory could not be opened - Note: this call may occur withoutopening(ServerSession, String, Handle)
ever having been calleddefault void
opening(ServerSession session, java.lang.String remoteHandle, Handle localHandle)
Specified file / directory is being openeddefault void
read(ServerSession session, java.lang.String remoteHandle, DirectoryHandle localHandle, java.util.Map<java.lang.String,java.nio.file.Path> entries)
Result of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the responsedefault void
read(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, java.lang.Throwable thrown)
Result of reading from a filedefault void
reading(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)
Preparing to read from a filedefault void
removed(ServerSession session, java.nio.file.Path path, boolean isDirectory, java.lang.Throwable thrown)
Called after a file has been removeddefault void
removing(ServerSession session, java.nio.file.Path path, boolean isDirectory)
Called prior to removing a filedefault void
unblocked(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, java.lang.Throwable thrown)
Called prior to un-blocking a file sectiondefault void
unblocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length)
Called prior to un-blocking a file sectionstatic <L extends SftpEventListener>
LvalidateListener(L listener)
default void
writing(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)
Preparing to write to filedefault void
written(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, java.lang.Throwable thrown)
Finished to writing to file
-
-
-
Method Detail
-
initialized
default void initialized(ServerSession session, int version) throws java.io.IOException
Called when the SFTP protocol has been initialized- Parameters:
session
- TheServerSession
through which the request was handledversion
- The negotiated SFTP version- Throws:
java.io.IOException
- If failed to handle the call
-
exiting
default void exiting(ServerSession session, Handle handle) throws java.io.IOException
Called when subsystem is exiting due to being destroyed- Parameters:
session
- The associatedServerSession
handle
- The file / directoryHandle
being closed due to the exit- Throws:
java.io.IOException
- If failed to handle the call
-
destroying
default void destroying(ServerSession session) throws java.io.IOException
Called when subsystem is destroyed since it was closed- Parameters:
session
- The associatedServerSession
- Throws:
java.io.IOException
- If failed to handle the call
-
opening
default void opening(ServerSession session, java.lang.String remoteHandle, Handle localHandle) throws java.io.IOException
Specified file / directory is being opened- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the file / directorylocalHandle
- The associated file / directoryHandle
- Throws:
java.io.IOException
- If failed to handle the call
-
open
default void open(ServerSession session, java.lang.String remoteHandle, Handle localHandle) throws java.io.IOException
Specified file / directory has been opened- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the file / directorylocalHandle
- The associated file / directoryHandle
- Throws:
java.io.IOException
- If failed to handle the call
-
openFailed
default void openFailed(ServerSession session, java.lang.String remotePath, java.nio.file.Path localPath, boolean isDirectory, java.lang.Throwable thrown) throws java.io.IOException
Specified file / directory could not be opened - Note: this call may occur withoutopening(ServerSession, String, Handle)
ever having been called- Parameters:
session
- TheServerSession
through which the request was handledremotePath
- The path that was specified in the commandlocalPath
- The matching resolved local pathisDirectory
- Whether this was a folder or a filethrown
- Non-null
reason for the failure- Throws:
java.io.IOException
- If failed to handle the call
-
read
default void read(ServerSession session, java.lang.String remoteHandle, DirectoryHandle localHandle, java.util.Map<java.lang.String,java.nio.file.Path> entries) throws java.io.IOException
Result of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the response- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the directorylocalHandle
- The associatedDirectoryHandle
entries
- AMap
of the listed entries - key = short name, value =Path
of the sub-entry- Throws:
java.io.IOException
- If failed to handle the call
-
reading
default void reading(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws java.io.IOException
Preparing to read from a file- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file from which to readdata
- Buffer holding the read datadataOffset
- Offset of read data in bufferdataLen
- Requested read length- Throws:
java.io.IOException
- If failed to handle the call
-
read
default void read(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, java.lang.Throwable thrown) throws java.io.IOException
Result of reading from a file- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file from which to readdata
- Buffer holding the read datadataOffset
- Offset of read data in bufferdataLen
- Requested read lengthreadLen
- Actual read length - negative if thrown exception providedthrown
- Non-null
if read failed due to this exception- Throws:
java.io.IOException
- If failed to handle the call
-
writing
default void writing(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws java.io.IOException
Preparing to write to file- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file to which to writedata
- Buffer holding the written datadataOffset
- Offset of write data in bufferdataLen
- Requested write length- Throws:
java.io.IOException
- If failed to handle the call
-
written
default void written(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, java.lang.Throwable thrown) throws java.io.IOException
Finished to writing to file- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file to which to writedata
- Buffer holding the written datadataOffset
- Offset of write data in bufferdataLen
- Requested write lengththrown
- The reason for failing to write -null
if successful- Throws:
java.io.IOException
- If failed to handle the call
-
blocking
default void blocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask) throws java.io.IOException
Called prior to blocking a file section- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file for lockinglength
- Section size for lockingmask
- Lock mask flags - seeSSH_FXP_BLOCK
message- Throws:
java.io.IOException
- If failed to handle the call- See Also:
blocked(ServerSession, String, FileHandle, long, long, int, Throwable)
-
blocked
default void blocked(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, int mask, java.lang.Throwable thrown) throws java.io.IOException
Called after blocking a file section- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file for lockinglength
- Section size for lockingmask
- Lock mask flags - seeSSH_FXP_BLOCK
messagethrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
unblocking
default void unblocking(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length) throws java.io.IOException
Called prior to un-blocking a file section- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file for un-lockinglength
- Section size for un-locking- Throws:
java.io.IOException
- If failed to handle the call
-
unblocked
default void unblocked(ServerSession session, java.lang.String remoteHandle, FileHandle localHandle, long offset, long length, java.lang.Throwable thrown) throws java.io.IOException
Called prior to un-blocking a file section- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the filelocalHandle
- The associatedFileHandle
offset
- Offset in file for un-lockinglength
- Section size for un-lockingthrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
closing
default void closing(ServerSession session, java.lang.String remoteHandle, Handle localHandle) throws java.io.IOException
Specified file / directory about to be closed- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the file / directorylocalHandle
- The associated file / directoryHandle
- Throws:
java.io.IOException
- If failed to handle the call
-
closed
default void closed(ServerSession session, java.lang.String remoteHandle, Handle localHandle, java.lang.Throwable thrown) throws java.io.IOException
Specified file / directory has been closed- Parameters:
session
- TheServerSession
through which the request was handledremoteHandle
- The (opaque) assigned handle for the file / directorylocalHandle
- The associated file / directoryHandle
thrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
creating
default void creating(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
Called prior to creating a directory- Parameters:
session
- TheServerSession
through which the request was handledpath
- DirectoryPath
to be createdattrs
- Requested associated attributes to set- Throws:
java.io.IOException
- If failed to handle the call- See Also:
created(ServerSession, Path, Map, Throwable)
-
created
default void created(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs, java.lang.Throwable thrown) throws java.io.IOException
Called after creating a directory- Parameters:
session
- TheServerSession
through which the request was handledpath
- DirectoryPath
to be createdattrs
- Requested associated attributes to setthrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
moving
default void moving(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts) throws java.io.IOException
Called prior to renaming a file / directory- Parameters:
session
- TheServerSession
through which the request was handledsrcPath
- The sourcePath
dstPath
- The targetPath
opts
- The resolved renaming options- Throws:
java.io.IOException
- If failed to handle the call- See Also:
moved(ServerSession, Path, Path, Collection, Throwable)
-
moved
default void moved(ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts, java.lang.Throwable thrown) throws java.io.IOException
Called after renaming a file / directory- Parameters:
session
- TheServerSession
through which the request was handledsrcPath
- The sourcePath
dstPath
- The targetPath
opts
- The resolved renaming optionsthrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
removing
default void removing(ServerSession session, java.nio.file.Path path, boolean isDirectory) throws java.io.IOException
Called prior to removing a file- Parameters:
session
- TheServerSession
through which the request was handledpath
- ThePath
about to be removedisDirectory
- Whether this is a folder or a file- Throws:
java.io.IOException
- If failed to handle the call- See Also:
removed(ServerSession, Path, boolean, Throwable)
-
removed
default void removed(ServerSession session, java.nio.file.Path path, boolean isDirectory, java.lang.Throwable thrown) throws java.io.IOException
Called after a file has been removed- Parameters:
session
- TheServerSession
through which the request was handledpath
- ThePath
to be removedisDirectory
- Whether this was a folder or a filethrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
linking
default void linking(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink) throws java.io.IOException
Called prior to creating a link- Parameters:
session
- TheServerSession
through which the request was handledsource
- The sourcePath
target
- The targetPath
symLink
-true
= symbolic link- Throws:
java.io.IOException
- If failed to handle the call- See Also:
linked(ServerSession, Path, Path, boolean, Throwable)
-
linked
default void linked(ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink, java.lang.Throwable thrown) throws java.io.IOException
Called after creating a link- Parameters:
session
- TheServerSession
through which the request was handledsource
- The sourcePath
target
- The targetPath
symLink
-true
= symbolic linkthrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
modifyingAttributes
default void modifyingAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs) throws java.io.IOException
Called prior to modifying the attributes of a file / directory- Parameters:
session
- TheServerSession
through which the request was handledpath
- The file / directoryPath
to be modifiedattrs
- The attributesMap
- names and values depend on the O/S, view, type, etc...- Throws:
java.io.IOException
- If failed to handle the call- See Also:
modifiedAttributes(ServerSession, Path, Map, Throwable)
-
modifiedAttributes
default void modifiedAttributes(ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,?> attrs, java.lang.Throwable thrown) throws java.io.IOException
Called after modifying the attributes of a file / directory- Parameters:
session
- TheServerSession
through which the request was handledpath
- The file / directoryPath
to be modifiedattrs
- The attributesMap
- names and values depend on the O/S, view, type, etc...thrown
- If not-null
then the reason for the failure to execute- Throws:
java.io.IOException
- If failed to handle the call
-
validateListener
static <L extends SftpEventListener> L validateListener(L listener)
-
-