Class SshTransport

All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
TransportGitSsh, TransportSftp

public abstract class SshTransport extends TcpTransport
The base class for transports that use SSH protocol. This class allows customizing SSH connection settings.
  • Field Details

  • Constructor Details

    • SshTransport

      protected SshTransport(Repository local, URIish uri)
      Create a new transport instance.
      Parameters:
      local - the repository this instance will fetch into, or push out of. This must be the repository passed to Transport.open(Repository, URIish).
      uri - the URI used to access the remote repository. This must be the URI passed to Transport.open(Repository, URIish).
    • SshTransport

      protected SshTransport(URIish uri)
      Create a new transport instance without a local repository.
      Parameters:
      uri - the URI used to access the remote repository. This must be the URI passed to Transport.open(URIish).
      Since:
      3.5
  • Method Details

    • setSshSessionFactory

      public void setSshSessionFactory(SshSessionFactory factory)
      Set SSH session factory instead of the default one for this instance of the transport.
      Parameters:
      factory - a factory to set, must not be null
      Throws:
      IllegalStateException - if session has been already created.
    • getSshSessionFactory

      public SshSessionFactory getSshSessionFactory()
      Get the SSH session factory
      Returns:
      the SSH session factory that will be used for creating SSH sessions
    • getSession

      protected RemoteSession getSession() throws TransportException
      Get the default SSH session
      Returns:
      a remote session
      Throws:
      TransportException - in case of error with opening SSH session
    • close

      public void close()

      Close any resources used by this transport.

      If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

      AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class Transport