java.lang.Object
org.apache.ivy.plugins.repository.ssh.Scp

public class Scp extends Object
This class is using the scp client to transfer data and information for the repository.

It is based on the SCPClient from the ganymed ssh library from Christian Plattner, released under a BSD style license.

To minimize the dependency to the ssh library and because we needed some additional functionality, we decided to copy'n'paste the single class rather than to inherit or delegate it somehow.

Nevertheless credit should go to the original author.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Scp(com.jcraft.jsch.Session session)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    get(String remoteFile, OutputStream localTarget)
    Download a file from the remote server into an OutputStream
    void
    get(String remoteFile, String localTarget)
    Download a file from the remote server to a local file.
    getFileinfo(String remoteFile)
    Initiates an SCP sequence but stops after getting fileinformation header
    void
    put(String localFile, String remoteTargetDir, String remoteTargetName, String mode)
    Copy a local file to a remote site, uses the specified mode when creating the file on the remote side.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Scp

      public Scp(com.jcraft.jsch.Session session)
  • Method Details

    • put

      public void put(String localFile, String remoteTargetDir, String remoteTargetName, String mode) throws IOException, RemoteScpException
      Copy a local file to a remote site, uses the specified mode when creating the file on the remote side.
      Parameters:
      localFile - Path and name of local file. Must be absolute.
      remoteTargetDir - Remote target directory where the file has to end up (optional)
      remoteTargetName - file name to use on the target system
      mode - a four digit string (e.g., 0644, see "man chmod", "man open")
      Throws:
      IOException - in case of network problems
      RemoteScpException - in case of problems on the target system (connection ok)
    • get

      public void get(String remoteFile, String localTarget) throws IOException, RemoteScpException
      Download a file from the remote server to a local file.
      Parameters:
      remoteFile - Path and name of the remote file.
      localTarget - Local file where to store the data. Must be absolute.
      Throws:
      IOException - in case of network problems
      RemoteScpException - in case of problems on the target system (connection ok)
    • get

      public void get(String remoteFile, OutputStream localTarget) throws IOException, RemoteScpException
      Download a file from the remote server into an OutputStream
      Parameters:
      remoteFile - Path and name of the remote file.
      localTarget - OutputStream to store the data.
      Throws:
      IOException - in case of network problems
      RemoteScpException - in case of problems on the target system (connection ok)
    • getFileinfo

      public Scp.FileInfo getFileinfo(String remoteFile) throws IOException, RemoteScpException
      Initiates an SCP sequence but stops after getting fileinformation header
      Parameters:
      remoteFile - to get information for
      Returns:
      the file information got
      Throws:
      IOException - in case of network problems
      RemoteScpException - in case of problems on the target system (connection ok)