Interface SftpEventListener

All Superinterfaces:
EventListener, org.apache.sshd.common.util.SshdEventListener
All Known Implementing Classes:
AbstractSftpEventListenerAdapter

public interface SftpEventListener extends org.apache.sshd.common.util.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...);
Author:
Apache MINA SSHD Project
  • Method Details

    • received

      default void received(ServerSession session, int type, int id) throws IOException
      Called when a SFTP request has been received before it is processed.
      Parameters:
      session - The ServerSession through which the request was received
      type - The request type; one of the SSH_FXP_* constants from SftpConstants
      id - The id received with the request
      Throws:
      IOException - If the request shall generate an error response. Throwing an exception for type = SftpConstants.SSH_FXP_INIT closes the session.
    • receivedExtension

      default void receivedExtension(ServerSession session, String extension, int id) throws IOException
      Called when a SFTP extension request SftpConstants.SSH_FXP_EXTENDED has been received before it is processed.
      Parameters:
      session - The ServerSession through which the request was received
      extension - The extension request received; one of the SSH_EXT_* constants from SftpConstants
      id - The id received with the request
      Throws:
      IOException - If the request shall generate an error response.
    • initialized

      default void initialized(ServerSession session, int version) throws IOException
      Called when the SFTP protocol has been initialized
      Parameters:
      session - The ServerSession through which the request was handled
      version - The negotiated SFTP version
      Throws:
      IOException - If failed to handle the call
    • exiting

      default void exiting(ServerSession session, Handle handle) throws IOException
      Called when subsystem is exiting due to being destroyed
      Parameters:
      session - The associated ServerSession
      handle - The file / directory Handle being closed due to the exit
      Throws:
      IOException - If failed to handle the call
    • destroying

      default void destroying(ServerSession session) throws IOException
      Called when subsystem is destroyed since it was closed
      Parameters:
      session - The associated ServerSession
      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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file / directory
      localHandle - The associated file / directory Handle
      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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file / directory
      localHandle - The associated file / directory Handle
      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 without opening(ServerSession, String, Handle) ever having been called
      Parameters:
      session - The ServerSession through which the request was handled
      remotePath - The path that was specified in the command
      localPath - The matching resolved local path
      isDirectory - Whether this was a folder or a file
      thrown - Non-null reason 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the directory
      localHandle - The associated DirectoryHandle
      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 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the directory
      localHandle - The associated DirectoryHandle
      entries - A Map of the listed entries - key = short name, value = Path of 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file from which to read
      data - Buffer holding the read data
      dataOffset - Offset of read data in buffer
      dataLen - 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file from which to read
      data - Buffer holding the read data
      dataOffset - Offset of read data in buffer
      dataLen - Requested read length
      readLen - Actual read length - negative if thrown exception provided
      thrown - Non-null if 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file to which to write
      data - Buffer holding the written data
      dataOffset - Offset of write data in buffer
      dataLen - 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file to which to write
      data - Buffer holding the written data
      dataOffset - Offset of write data in buffer
      dataLen - Requested write length
      thrown - The reason for failing to write - null if 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file for locking
      length - Section size for locking
      mask - Lock mask flags - see SSH_FXP_BLOCK message
      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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file for locking
      length - Section size for locking
      mask - Lock mask flags - see SSH_FXP_BLOCK message
      thrown - If not-null then 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file for un-locking
      length - 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file
      localHandle - The associated FileHandle
      offset - Offset in file for un-locking
      length - Section size for un-locking
      thrown - If not-null then 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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file / directory
      localHandle - The associated file / directory Handle
      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 - The ServerSession through which the request was handled
      remoteHandle - The (opaque) assigned handle for the file / directory
      localHandle - The associated file / directory Handle
      thrown - If not-null then the reason for the failure to execute
      Throws:
      IOException - If failed to handle the call
    • creating

      default void creating(ServerSession session, Path path, Map<String,?> attrs) throws IOException
      Called prior to creating a directory
      Parameters:
      session - The ServerSession through which the request was handled
      path - Directory Path to be created
      attrs - 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 IOException
      Called after creating a directory
      Parameters:
      session - The ServerSession through which the request was handled
      path - Directory Path to be created
      attrs - Requested associated attributes to set
      thrown - If not-null then 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 - The ServerSession through which the request was handled
      srcPath - The source Path
      dstPath - The target Path
      opts - 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 - The ServerSession through which the request was handled
      srcPath - The source Path
      dstPath - The target Path
      opts - The resolved renaming options
      thrown - If not-null then the reason for the failure to execute
      Throws:
      IOException - If failed to handle the call
    • removing

      default void removing(ServerSession session, Path path, boolean isDirectory) throws IOException
      Called prior to removing a file
      Parameters:
      session - The ServerSession through which the request was handled
      path - The Path about to be removed
      isDirectory - 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 - The ServerSession through which the request was handled
      path - The Path to be removed
      isDirectory - Whether this was a folder or a file
      thrown - If not-null then 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 - The ServerSession through which the request was handled
      source - The source Path
      target - The target Path
      symLink - 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 - The ServerSession through which the request was handled
      source - The source Path
      target - The target Path
      symLink - true = symbolic link
      thrown - If not-null then 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 IOException
      Called prior to modifying the attributes of a file / directory
      Parameters:
      session - The ServerSession through which the request was handled
      path - The file / directory Path to be modified
      attrs - The attributes Map - 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 IOException
      Called after modifying the attributes of a file / directory
      Parameters:
      session - The ServerSession through which the request was handled
      path - The file / directory Path to be modified
      attrs - The attributes Map - names and values depend on the O/S, view, type, etc...
      thrown - If not-null then the reason for the failure to execute
      Throws:
      IOException - If failed to handle the call
    • validateListener

      static <L extends SftpEventListener> L validateListener(L listener)