Class SimpleAccessControlSftpEventListener

  • All Implemented Interfaces:
    java.util.EventListener, org.apache.sshd.common.util.SshdEventListener, org.apache.sshd.sftp.server.SftpEventListener

    public abstract class SimpleAccessControlSftpEventListener
    extends org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
    Provides a simple access control by making a distinction between methods that provide information - including reading data - and those that modify it
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void blocking​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.FileHandle localHandle, long offset, long length, int mask)  
      void creating​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,​?> attrs)  
      protected abstract boolean isAccessAllowed​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath)  
      protected boolean isAccessAllowed​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.Handle localHandle)  
      protected abstract boolean isModificationAllowed​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, java.nio.file.Path localPath)  
      void linking​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path source, java.nio.file.Path target, boolean symLink)  
      void modifyingAttributes​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path path, java.util.Map<java.lang.String,​?> attrs)  
      void moving​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path srcPath, java.nio.file.Path dstPath, java.util.Collection<java.nio.file.CopyOption> opts)  
      void opening​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.Handle localHandle)  
      void readEntries​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.DirectoryHandle localHandle, java.util.Map<java.lang.String,​java.nio.file.Path> entries)  
      void reading​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)  
      void removed​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path path, boolean isDirectory, java.lang.Throwable thrown)  
      void removing​(org.apache.sshd.server.session.ServerSession session, java.nio.file.Path path, boolean isDirectory)  
      void unblocking​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.FileHandle localHandle, long offset, long length)  
      void writing​(org.apache.sshd.server.session.ServerSession session, java.lang.String remoteHandle, org.apache.sshd.sftp.server.FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen)  
      • Methods inherited from class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter

        blocked, closed, closing, created, destroying, exiting, initialized, linked, modifiedAttributes, moved, open, openFailed, read, readingEntries, receivedExtension, unblocked, written
      • 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.sftp.server.SftpEventListener

        received
    • Constructor Detail

      • SimpleAccessControlSftpEventListener

        protected SimpleAccessControlSftpEventListener()
    • Method Detail

      • opening

        public void opening​(org.apache.sshd.server.session.ServerSession session,
                            java.lang.String remoteHandle,
                            org.apache.sshd.sftp.server.Handle localHandle)
                     throws java.io.IOException
        Specified by:
        opening in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        opening in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • readEntries

        public void readEntries​(org.apache.sshd.server.session.ServerSession session,
                                java.lang.String remoteHandle,
                                org.apache.sshd.sftp.server.DirectoryHandle localHandle,
                                java.util.Map<java.lang.String,​java.nio.file.Path> entries)
                         throws java.io.IOException
        Specified by:
        readEntries in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        readEntries in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • reading

        public void reading​(org.apache.sshd.server.session.ServerSession session,
                            java.lang.String remoteHandle,
                            org.apache.sshd.sftp.server.FileHandle localHandle,
                            long offset,
                            byte[] data,
                            int dataOffset,
                            int dataLen)
                     throws java.io.IOException
        Specified by:
        reading in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        reading in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • isAccessAllowed

        protected boolean isAccessAllowed​(org.apache.sshd.server.session.ServerSession session,
                                          java.lang.String remoteHandle,
                                          org.apache.sshd.sftp.server.Handle localHandle)
                                   throws java.io.IOException
        Parameters:
        session - The ServerSession throw which the request was made
        remoteHandle - The remote handle value
        localHandle - The local handle
        Returns:
        true if allowed to access the handle
        Throws:
        java.io.IOException - If failed to handle the call
      • isAccessAllowed

        protected abstract boolean isAccessAllowed​(org.apache.sshd.server.session.ServerSession session,
                                                   java.lang.String remoteHandle,
                                                   java.nio.file.Path localPath)
                                            throws java.io.IOException
        Parameters:
        session - The ServerSession throw which the request was made
        remoteHandle - The remote handle value
        localPath - The local Path
        Returns:
        true if allowed to access the path
        Throws:
        java.io.IOException - If failed to handle the call
      • writing

        public void writing​(org.apache.sshd.server.session.ServerSession session,
                            java.lang.String remoteHandle,
                            org.apache.sshd.sftp.server.FileHandle localHandle,
                            long offset,
                            byte[] data,
                            int dataOffset,
                            int dataLen)
                     throws java.io.IOException
        Specified by:
        writing in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        writing in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • blocking

        public void blocking​(org.apache.sshd.server.session.ServerSession session,
                             java.lang.String remoteHandle,
                             org.apache.sshd.sftp.server.FileHandle localHandle,
                             long offset,
                             long length,
                             int mask)
                      throws java.io.IOException
        Specified by:
        blocking in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        blocking in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • unblocking

        public void unblocking​(org.apache.sshd.server.session.ServerSession session,
                               java.lang.String remoteHandle,
                               org.apache.sshd.sftp.server.FileHandle localHandle,
                               long offset,
                               long length)
                        throws java.io.IOException
        Specified by:
        unblocking in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        unblocking in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • creating

        public void creating​(org.apache.sshd.server.session.ServerSession session,
                             java.nio.file.Path path,
                             java.util.Map<java.lang.String,​?> attrs)
                      throws java.io.IOException
        Specified by:
        creating in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        creating in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • moving

        public void moving​(org.apache.sshd.server.session.ServerSession session,
                           java.nio.file.Path srcPath,
                           java.nio.file.Path dstPath,
                           java.util.Collection<java.nio.file.CopyOption> opts)
                    throws java.io.IOException
        Specified by:
        moving in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        moving in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • removing

        public void removing​(org.apache.sshd.server.session.ServerSession session,
                             java.nio.file.Path path,
                             boolean isDirectory)
                      throws java.io.IOException
        Specified by:
        removing in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        removing in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • removed

        public void removed​(org.apache.sshd.server.session.ServerSession session,
                            java.nio.file.Path path,
                            boolean isDirectory,
                            java.lang.Throwable thrown)
                     throws java.io.IOException
        Specified by:
        removed in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        removed in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • linking

        public void linking​(org.apache.sshd.server.session.ServerSession session,
                            java.nio.file.Path source,
                            java.nio.file.Path target,
                            boolean symLink)
                     throws java.io.IOException
        Specified by:
        linking in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        linking in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • modifyingAttributes

        public void modifyingAttributes​(org.apache.sshd.server.session.ServerSession session,
                                        java.nio.file.Path path,
                                        java.util.Map<java.lang.String,​?> attrs)
                                 throws java.io.IOException
        Specified by:
        modifyingAttributes in interface org.apache.sshd.sftp.server.SftpEventListener
        Overrides:
        modifyingAttributes in class org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
        Throws:
        java.io.IOException
      • isModificationAllowed

        protected abstract boolean isModificationAllowed​(org.apache.sshd.server.session.ServerSession session,
                                                         java.lang.String remoteHandle,
                                                         java.nio.file.Path localPath)
                                                  throws java.io.IOException
        Parameters:
        session - The ServerSession throw which the request was made
        remoteHandle - The remote handle value
        localPath - The local Path
        Returns:
        true if allowed to modify the path
        Throws:
        java.io.IOException - If failed to handle the call