Package org.apache.sshd.sftp.server
Interface SftpEventListener
- All Superinterfaces:
EventListener,SshdEventListener
- All Known Implementing Classes:
AbstractSftpEventListenerAdapter
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
Modifier and TypeMethodDescriptiondefault voidblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask, Throwable thrown) Called after blocking a file sectiondefault voidblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask) Called prior to blocking a file sectiondefault voidclosed(ServerSession session, String remoteHandle, Handle localHandle, Throwable thrown) Specified file / directory has been closeddefault voidclosing(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory about to be closeddefault voidCalled after creating a directorydefault voidcreating(ServerSession session, Path path, Map<String, ?> attrs) Called prior to creating a directorydefault voiddestroying(ServerSession session) Called when subsystem is destroyed since it was closeddefault voidexiting(ServerSession session, Handle handle) Called when subsystem is exiting due to being destroyeddefault voidinitialized(ServerSession session, int version) Called when the SFTP protocol has been initializeddefault voidlinked(ServerSession session, Path source, Path target, boolean symLink, Throwable thrown) Called after creating a linkdefault voidlinking(ServerSession session, Path source, Path target, boolean symLink) Called prior to creating a linkdefault voidmodifiedAttributes(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) Called after modifying the attributes of a file / directorydefault voidmodifyingAttributes(ServerSession session, Path path, Map<String, ?> attrs) Called prior to modifying the attributes of a file / directorydefault voidmoved(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown) Called after renaming a file / directorydefault voidmoving(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts) Called prior to renaming a file / directorydefault voidopen(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory has been openeddefault voidopenFailed(ServerSession session, String remotePath, Path localPath, boolean isDirectory, Throwable thrown) Specified file / directory could not be opened - Note: this call may occur withoutopening(ServerSession, String, Handle)ever having been calleddefault voidopening(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory is being openeddefault voidread(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) Result of reading from a filedefault voidreadEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle, Map<String, 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 voidreading(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) Preparing to read from a filedefault voidreadingEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle) About to read entries from a directory - Note: might not be the 1st time it is called for the directory in case several iterations are required in order to go through all the entries in the directorydefault voidreceived(ServerSession session, int type, int id) Called when a SFTP request has been received before it is processed.default voidreceivedExtension(ServerSession session, String extension, int id) Called when a SFTP extension requestSftpConstants.SSH_FXP_EXTENDEDhas been received before it is processed.default voidremoved(ServerSession session, Path path, boolean isDirectory, Throwable thrown) Called after a file has been removeddefault voidremoving(ServerSession session, Path path, boolean isDirectory) Called prior to removing a filedefault voidunblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown) Called prior to un-blocking a file sectiondefault voidunblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length) Called prior to un-blocking a file sectionstatic <L extends SftpEventListener>
LvalidateListener(L listener) default voidwriting(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) Preparing to write to filedefault voidwritten(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) Finished to writing to file
-
Method Details
-
received
Called when a SFTP request has been received before it is processed.- Parameters:
session- TheServerSessionthrough which the request was receivedtype- The request type; one of theSSH_FXP_*constants fromSftpConstantsid- The id received with the request- Throws:
IOException- If the request shall generate an error response. Throwing an exception fortype =SftpConstants.SSH_FXP_INITcloses the session.
-
receivedExtension
Called when a SFTP extension requestSftpConstants.SSH_FXP_EXTENDEDhas been received before it is processed.- Parameters:
session- TheServerSessionthrough which the request was receivedextension- The extension request received; one of theSSH_EXT_*constants fromSftpConstantsid- The id received with the request- Throws:
IOException- If the request shall generate an error response.
-
initialized
Called when the SFTP protocol has been initialized- Parameters:
session- TheServerSessionthrough which the request was handledversion- The negotiated SFTP version- Throws:
IOException- If failed to handle the call
-
exiting
Called when subsystem is exiting due to being destroyed- Parameters:
session- The associatedServerSessionhandle- The file / directoryHandlebeing closed due to the exit- Throws:
IOException- If failed to handle the call
-
destroying
Called when subsystem is destroyed since it was closed- Parameters:
session- The associatedServerSession- Throws:
IOException- If failed to handle the call
-
opening
default void opening(ServerSession session, String remoteHandle, Handle localHandle) throws IOException Specified file / directory is being opened- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
open
default void open(ServerSession session, String remoteHandle, Handle localHandle) throws IOException Specified file / directory has been opened- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
openFailed
default void openFailed(ServerSession session, String remotePath, Path localPath, boolean isDirectory, Throwable thrown) throws IOException Specified file / directory could not be opened - Note: this call may occur withoutopening(ServerSession, String, Handle)ever having been called- Parameters:
session- TheServerSessionthrough 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-nullreason for the failure- Throws:
IOException- If failed to handle the call
-
readingEntries
default void readingEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle) throws IOException About to read entries from a directory - Note: might not be the 1st time it is called for the directory in case several iterations are required in order to go through all the entries in the directory- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the directorylocalHandle- The associatedDirectoryHandle- Throws:
IOException- If failed to handle the call- See Also:
-
readEntries
default void readEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle, Map<String, Path> entries) throws IOExceptionResult 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- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the directorylocalHandle- The associatedDirectoryHandleentries- AMapof the listed entries - key = short name, value =Pathof the sub-entry- Throws:
IOException- If failed to handle the call
-
reading
default void reading(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws IOException Preparing to read from a file- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file from which to readdata- Buffer holding the read datadataOffset- Offset of read data in bufferdataLen- Requested read length- Throws:
IOException- If failed to handle the call
-
read
default void read(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) throws IOException Result of reading from a file- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- 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-nullif read failed due to this exception- Throws:
IOException- If failed to handle the call
-
writing
default void writing(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws IOException Preparing to write to file- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file to which to writedata- Buffer holding the written datadataOffset- Offset of write data in bufferdataLen- Requested write length- Throws:
IOException- If failed to handle the call
-
written
default void written(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) throws IOException Finished to writing to file- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- 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 -nullif successful- Throws:
IOException- If failed to handle the call
-
blocking
default void blocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask) throws IOException Called prior to blocking a file section- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for lockinglength- Section size for lockingmask- Lock mask flags - seeSSH_FXP_BLOCKmessage- Throws:
IOException- If failed to handle the call- See Also:
-
blocked
default void blocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask, Throwable thrown) throws IOException Called after blocking a file section- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for lockinglength- Section size for lockingmask- Lock mask flags - seeSSH_FXP_BLOCKmessagethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
unblocking
default void unblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length) throws IOException Called prior to un-blocking a file section- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for un-lockinglength- Section size for un-locking- Throws:
IOException- If failed to handle the call
-
unblocked
default void unblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown) throws IOException Called prior to un-blocking a file section- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for un-lockinglength- Section size for un-lockingthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
closing
default void closing(ServerSession session, String remoteHandle, Handle localHandle) throws IOException Specified file / directory about to be closed- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
closed
default void closed(ServerSession session, String remoteHandle, Handle localHandle, Throwable thrown) throws IOException Specified file / directory has been closed- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandlethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
creating
Called prior to creating a directory- Parameters:
session- TheServerSessionthrough which the request was handledpath- DirectoryPathto be createdattrs- Requested associated attributes to set- Throws:
IOException- If failed to handle the call- See Also:
-
created
default void created(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) throws IOExceptionCalled after creating a directory- Parameters:
session- TheServerSessionthrough which the request was handledpath- DirectoryPathto be createdattrs- Requested associated attributes to setthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
moving
default void moving(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts) throws IOException Called prior to renaming a file / directory- Parameters:
session- TheServerSessionthrough which the request was handledsrcPath- The sourcePathdstPath- The targetPathopts- The resolved renaming options- Throws:
IOException- If failed to handle the call- See Also:
-
moved
default void moved(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown) throws IOException Called after renaming a file / directory- Parameters:
session- TheServerSessionthrough which the request was handledsrcPath- The sourcePathdstPath- The targetPathopts- The resolved renaming optionsthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
removing
Called prior to removing a file- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathabout to be removedisDirectory- Whether this is a folder or a file- Throws:
IOException- If failed to handle the call- See Also:
-
removed
default void removed(ServerSession session, Path path, boolean isDirectory, Throwable thrown) throws IOException Called after a file has been removed- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathto be removedisDirectory- Whether this was a folder or a filethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
linking
default void linking(ServerSession session, Path source, Path target, boolean symLink) throws IOException Called prior to creating a link- Parameters:
session- TheServerSessionthrough which the request was handledsource- The sourcePathtarget- The targetPathsymLink-true= symbolic link- Throws:
IOException- If failed to handle the call- See Also:
-
linked
default void linked(ServerSession session, Path source, Path target, boolean symLink, Throwable thrown) throws IOException Called after creating a link- Parameters:
session- TheServerSessionthrough which the request was handledsource- The sourcePathtarget- The targetPathsymLink-true= symbolic linkthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
modifyingAttributes
default void modifyingAttributes(ServerSession session, Path path, Map<String, ?> attrs) throws IOExceptionCalled prior to modifying the attributes of a file / directory- Parameters:
session- TheServerSessionthrough which the request was handledpath- The file / directoryPathto be modifiedattrs- The attributesMap- names and values depend on the O/S, view, type, etc...- Throws:
IOException- If failed to handle the call- See Also:
-
modifiedAttributes
default void modifiedAttributes(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) throws IOExceptionCalled after modifying the attributes of a file / directory- Parameters:
session- TheServerSessionthrough which the request was handledpath- The file / directoryPathto be modifiedattrs- The attributesMap- names and values depend on the O/S, view, type, etc...thrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
validateListener
-