Class SshSession

java.lang.Object
org.qubership.atp.mia.repo.impl.SshSession

public class SshSession extends Object
  • Constructor Details

    • SshSession

      public SshSession(Server server, CommonConfiguration configuration)
      Creates details for ssh session, which used when opening Channel and Session.
      Parameters:
      server - with credentials
      configuration - used to get SshRsaFilePath field of CommonConfiguration.
  • Method Details

    • openChannel

      public com.jcraft.jsch.Channel openChannel(ChannelType channelType)
      Opens Channel, don't requires already opened Session, because does it itself.
      Parameters:
      channelType - type of channel depends on ssh operation, check ChannelType.
      Returns:
      opened channel or throw error.
    • closeChannel

      public void closeChannel(com.jcraft.jsch.Channel channel)
      Close channel.
      Parameters:
      channel - channel
    • createSession

      public void createSession(int retryCount)
      Creates jschSession.
      Parameters:
      retryCount - pass 1 to make retry amount equal to this.retries.
    • isConnected

      public boolean isConnected()
      Is session connected.
      Returns:
      true or false.
    • getProperties

      @NonNull public ConnectionProps getProperties()
      Properties with ssh information, such as host, port etc.
      Returns:
      ssh connection properties.
    • disconnect

      public boolean disconnect()
      Disconnects ssh session if it was connected.
    • isExecuting

      public boolean isExecuting()
    • isSame

      public boolean isSame(Server server, CommonConfiguration configuration)
      Checks that properties not changed since connection store. It helps to avoid situations when connection is old, while configuration updated.
      Parameters:
      server - server.
      configuration - only check sshRsaFilePath field of CommonConfiguration.
      Returns:
      false if not the same.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object