Class MinaFileSystemAccessor

java.lang.Object
ecmwf.common.ssh.MinaFileSystemAccessor
All Implemented Interfaces:
org.apache.sshd.sftp.server.SftpFileSystemAccessor

public class MinaFileSystemAccessor extends Object implements org.apache.sshd.sftp.server.SftpFileSystemAccessor
Author:
Apache MINA SSHD Project
  • Constructor Details

    • MinaFileSystemAccessor

      public MinaFileSystemAccessor()
  • Method Details

    • closeFilesystem

      public void closeFilesystem()
      Close all files open.
    • resolveLocalFilePath

      public Path resolveLocalFilePath(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path rootDir, String remotePath) throws IOException, InvalidPathException
      Invoked in order to resolve remote file paths reference by the client into ones accessible by the server
      Specified by:
      resolveLocalFilePath in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Parameters:
      subsystem - The SFTP subsystem instance that manages the session
      rootDir - The default root directory used to resolve relative paths - a.k.a. the chroot location
      remotePath - The remote path - separated by '/'
      Returns:
      The local Path
      Throws:
      IOException - If failed to resolve the local path
      InvalidPathException - If bad local path specification
      See Also:
      • SftpSubsystemEnvironment#getDefaultDirectory()
    • resolveReportedFileAttributes

      public NavigableMap<String,Object> resolveReportedFileAttributes(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, int flags, NavigableMap<String,Object> attrs, LinkOption... options) throws IOException
      Specified by:
      resolveReportedFileAttributes in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • applyExtensionFileAttributes

      public void applyExtensionFileAttributes(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, Map<String,byte[]> extensions, LinkOption... options) throws IOException
      Specified by:
      applyExtensionFileAttributes in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • putRemoteFileName

      public void putRemoteFileName(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path path, org.apache.sshd.common.util.buffer.Buffer buf, String name, boolean shortName) throws IOException
      Specified by:
      putRemoteFileName in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • openFile

      public SeekableByteChannel openFile(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.FileHandle fileHandle, Path file, String handle, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
      Specified by:
      openFile in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • tryLock

      public FileLock tryLock(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.FileHandle fileHandle, Path file, String handle, Channel channel, long position, long size, boolean shared) throws IOException
      Specified by:
      tryLock in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • syncFileData

      public void syncFileData(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.FileHandle fileHandle, Path file, String handle, Channel channel) throws IOException
      Specified by:
      syncFileData in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • closeFile

      public void closeFile(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.FileHandle fileHandle, Path file, String handle, Channel channel, Set<? extends OpenOption> options) throws IOException
      Called to inform the accessor that it should close the file
      Specified by:
      closeFile in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Parameters:
      subsystem - The SFTP subsystem instance that manages the session
      fileHandle - The FileHandle representing the created channel - may be null if not invoked within the context of such a handle (special cases)
      file - The requested local file Path - same one returned by resolveLocalFilePath
      handle - The assigned file handle through which the remote peer references this file
      channel - The original Channel that was returned by openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)
      options - The original options used to open the channel
      Throws:
      IOException - If failed to execute the request
    • openDirectory

      public DirectoryStream<Path> openDirectory(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.DirectoryHandle dirHandle, Path dir, String handle, LinkOption... linkOptions) throws IOException
      Called when a new directory stream is requested
      Specified by:
      openDirectory in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Parameters:
      subsystem - The SFTP subsystem instance that manages the session
      dirHandle - The DirectoryHandle representing the stream
      dir - The requested local directory Path - same one returned by resolveLocalFilePath
      handle - The assigned directory handle through which the remote peer references this directory
      linkOptions - The LinkOptions - OK if null/empty.
      Returns:
      The opened DirectoryStream
      Throws:
      IOException - If failed to open
    • closeDirectory

      public void closeDirectory(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, org.apache.sshd.sftp.server.DirectoryHandle dirHandle, Path dir, String handle, DirectoryStream<Path> ds) throws IOException
      Called when a directory stream is no longer required
      Specified by:
      closeDirectory in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Parameters:
      subsystem - The SFTP subsystem instance that manages the session
      dirHandle - The DirectoryHandle representing the stream - may be null if not invoked within the context of such a handle (special cases)
      dir - The requested local directory Path - same one returned by resolveLocalFilePath
      handle - The assigned directory handle through which the remote peer references this directory
      ds - The disposed DirectoryStream
      Throws:
      IOException - If failed to open
    • readFileAttributes

      public Map<String,?> readFileAttributes(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, String view, LinkOption... options) throws IOException
      Specified by:
      readFileAttributes in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • setFileAttribute

      public void setFileAttribute(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, String view, String attribute, Object value, LinkOption... options) throws IOException
      Specified by:
      setFileAttribute in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • setFileOwner

      public void setFileOwner(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options) throws IOException
      Specified by:
      setFileOwner in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • setGroupOwner

      public void setGroupOwner(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options) throws IOException
      Specified by:
      setGroupOwner in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • setFilePermissions

      public void setFilePermissions(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, Set<PosixFilePermission> perms, LinkOption... options) throws IOException
      Specified by:
      setFilePermissions in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • setFileAccessControl

      public void setFileAccessControl(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path file, List<AclEntry> acl, LinkOption... options) throws IOException
      Specified by:
      setFileAccessControl in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • createDirectory

      public void createDirectory(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path path) throws IOException
      Specified by:
      createDirectory in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • createLink

      public void createLink(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path link, Path existing, boolean symLink) throws IOException
      Specified by:
      createLink in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • renameFile

      public void renameFile(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path oldPath, Path newPath, Collection<CopyOption> opts) throws IOException
      Specified by:
      renameFile in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • copyFile

      public void copyFile(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path src, Path dst, Collection<CopyOption> opts) throws IOException
      Specified by:
      copyFile in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • removeFile

      public void removeFile(org.apache.sshd.sftp.server.SftpSubsystemProxy subsystem, Path path, boolean isDirectory) throws IOException
      Specified by:
      removeFile in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor
      Throws:
      IOException
    • noFollow

      public boolean noFollow(Collection<?> opts)
      Specified by:
      noFollow in interface org.apache.sshd.sftp.server.SftpFileSystemAccessor