Class SftpStreamProxy

  • All Implemented Interfaces:
    com.jcraft.jsch.Proxy

    public class SftpStreamProxy
    extends java.lang.Object
    implements com.jcraft.jsch.Proxy
    Stream based proxy for JSch.

    Use a command on the proxy that will forward the SSH stream to the target host and port.

    Since:
    2.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BASH_TCP_COMMAND
      Command format using bash built-in TCP stream.
      static java.lang.String NETCAT_COMMAND
      Command format using netcat command.
    • Constructor Summary

      Constructors 
      Constructor Description
      SftpStreamProxy​(java.lang.String commandFormat, java.lang.String proxyUser, java.lang.String proxyHost, int proxyPort, java.lang.String proxyPassword, FileSystemOptions proxyOptions)
      Creates a stream proxy.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void connect​(com.jcraft.jsch.SocketFactory socketFactory, java.lang.String targetHost, int targetPort, int timeout)  
      java.io.InputStream getInputStream()  
      java.io.OutputStream getOutputStream()  
      java.net.Socket getSocket()  
      • Methods inherited from class java.lang.Object

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

      • SftpStreamProxy

        public SftpStreamProxy​(java.lang.String commandFormat,
                               java.lang.String proxyUser,
                               java.lang.String proxyHost,
                               int proxyPort,
                               java.lang.String proxyPassword,
                               FileSystemOptions proxyOptions)
        Creates a stream proxy.
        Parameters:
        commandFormat - A format string that will be used to create the command to execute on the proxy host using String.format(String, Object...). Two parameters are given to the format command, the target host name (String) and port (Integer).
        proxyUser - The proxy user
        proxyPassword - The proxy password
        proxyHost - The proxy host
        proxyPort - The port to connect to on the proxy
        proxyOptions - Options used when connecting to the proxy
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface com.jcraft.jsch.Proxy
      • connect

        public void connect​(com.jcraft.jsch.SocketFactory socketFactory,
                            java.lang.String targetHost,
                            int targetPort,
                            int timeout)
                     throws java.lang.Exception
        Specified by:
        connect in interface com.jcraft.jsch.Proxy
        Throws:
        java.lang.Exception
      • getInputStream

        public java.io.InputStream getInputStream()
        Specified by:
        getInputStream in interface com.jcraft.jsch.Proxy
      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Specified by:
        getOutputStream in interface com.jcraft.jsch.Proxy
      • getSocket

        public java.net.Socket getSocket()
        Specified by:
        getSocket in interface com.jcraft.jsch.Proxy