Class MinaScpFileOpener

java.lang.Object
ecmwf.common.ssh.MinaScpFileOpener
All Implemented Interfaces:
org.apache.sshd.scp.common.ScpFileOpener

public final class MinaScpFileOpener extends Object implements org.apache.sshd.scp.common.ScpFileOpener
SCP file-opener that routes all I/O through the virtual ECPDS user session. This enables SCP downloads and uploads via the same backend as SFTP, using UserSession.getProxySocketInput(String, long) and UserSession.getProxySocketOutput(String, long, int) for streaming, and UserSession.getFileListElement(String) for metadata.
  • Constructor Details

    • MinaScpFileOpener

      public MinaScpFileOpener()
  • Method Details

    • resolveLocalPath

      public Path resolveLocalPath(org.apache.sshd.common.session.Session session, FileSystem fileSystem, String path) throws IOException
      Resolves the SCP command path to a NIO Path. The returned path is always absolute and is used only as a virtual-path carrier — it is never opened on the real local filesystem.
      Specified by:
      resolveLocalPath in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • sendAsDirectory

      public boolean sendAsDirectory(org.apache.sshd.common.session.Session session, Path path, LinkOption... options) throws IOException
      Specified by:
      sendAsDirectory in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • sendAsRegularFile

      public boolean sendAsRegularFile(org.apache.sshd.common.session.Session session, Path path, LinkOption... options) throws IOException
      Specified by:
      sendAsRegularFile in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • getLocalBasicFileAttributes

      public BasicFileAttributes getLocalBasicFileAttributes(org.apache.sshd.common.session.Session session, Path path, LinkOption... options) throws IOException
      Specified by:
      getLocalBasicFileAttributes in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • getLocalFilePermissions

      public Set<PosixFilePermission> getLocalFilePermissions(org.apache.sshd.common.session.Session session, Path path, LinkOption... options) throws IOException
      Specified by:
      getLocalFilePermissions in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • getLocalFolderChildren

      public DirectoryStream<Path> getLocalFolderChildren(org.apache.sshd.common.session.Session session, Path path) throws IOException
      Returns the virtual children of a directory. Uses UserSession.getFileList(String) to enumerate entries and maps each name to a child path under path.
      Specified by:
      getLocalFolderChildren in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • getMatchingFilesToSend

      public Iterable<Path> getMatchingFilesToSend(org.apache.sshd.common.session.Session session, Path path, String pattern) throws IOException
      Returns virtual paths whose names match pattern inside the directory at path. If path points to a regular file, returns it directly.
      Specified by:
      getMatchingFilesToSend in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • resolveIncomingFilePath

      public Path resolveIncomingFilePath(org.apache.sshd.common.session.Session session, Path path, String name, boolean recursive, Set<PosixFilePermission> perms, org.apache.sshd.scp.common.helpers.ScpTimestampCommandDetails time) throws IOException
      Resolves the incoming target path for an SCP upload. If the target path is an existing virtual directory the uploaded file is placed inside it (as path/name); otherwise the file is created at path directly.
      Specified by:
      resolveIncomingFilePath in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • resolveIncomingReceiveLocation

      public Path resolveIncomingReceiveLocation(org.apache.sshd.common.session.Session session, Path path, boolean recursive, boolean shouldBeDir, boolean preserve) throws IOException
      Resolves the root receive location for an SCP upload. Returns path unchanged; directory creation, if needed, is handled by the backend.
      Specified by:
      resolveIncomingReceiveLocation in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • openRead

      public InputStream openRead(org.apache.sshd.common.session.Session session, Path file, long size, Set<PosixFilePermission> permissions, OpenOption... options) throws IOException
      Specified by:
      openRead in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • openWrite

      public OutputStream openWrite(org.apache.sshd.common.session.Session session, Path file, long size, Set<PosixFilePermission> permissions, OpenOption... options) throws IOException
      Specified by:
      openWrite in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • createScpSourceStreamResolver

      public org.apache.sshd.scp.common.ScpSourceStreamResolver createScpSourceStreamResolver(org.apache.sshd.common.session.Session session, Path path) throws IOException
      Specified by:
      createScpSourceStreamResolver in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException
    • createScpTargetStreamResolver

      public org.apache.sshd.scp.common.ScpTargetStreamResolver createScpTargetStreamResolver(org.apache.sshd.common.session.Session session, Path path) throws IOException
      Specified by:
      createScpTargetStreamResolver in interface org.apache.sshd.scp.common.ScpFileOpener
      Throws:
      IOException