Class SshUtil

java.lang.Object
org.dellroad.jct.ssh.SshUtil

public final class SshUtil extends Object
Utility methods relating to Apache MINA SSHD.
  • Method Summary

    Modifier and Type
    Method
    Description
    inferCharacterEncoding(org.apache.sshd.server.Environment env)
    Attempt to infer the character encoding associated with an SSH connection.
    inferLocale(org.apache.sshd.server.Environment env)
    Attempt to infer the locale associated with an SSH connection.
    static Optional<org.jline.terminal.Terminal.Signal>
    mapSignalToTerminal(org.apache.sshd.server.Signal signal)
    Map SSH channel signal to the corresponding Terminal signal, if able.
    static Optional<org.apache.sshd.server.Signal>
    mapTerminalToSignal(org.jline.terminal.Terminal.Signal signal)
    Map Terminal signal to the corresponding SSH channel signal.
    static void
    updateAttributesFromEnvironment(org.jline.terminal.Attributes attr, org.apache.sshd.server.Environment env)
    Update Terminal attributes based on the given SSH connection.
    static boolean
    updateSize(org.jline.terminal.Terminal terminal, org.apache.sshd.server.Environment env)
    Update Terminal window size based on SSH environment variables.

    Methods inherited from class java.lang.Object

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

    • mapSignalToTerminal

      public static Optional<org.jline.terminal.Terminal.Signal> mapSignalToTerminal(org.apache.sshd.server.Signal signal)
      Map SSH channel signal to the corresponding Terminal signal, if able.
      Parameters:
      signal - SSH channel signal
      Returns:
      corresponding Terminal signal, if known
      Throws:
      IllegalArgumentException - if signal is null
    • mapTerminalToSignal

      public static Optional<org.apache.sshd.server.Signal> mapTerminalToSignal(org.jline.terminal.Terminal.Signal signal)
      Map Terminal signal to the corresponding SSH channel signal.
      Parameters:
      signal - Terminal signal
      Returns:
      corresponding SSH channel signal, if known
      Throws:
      IllegalArgumentException - if signal is null
    • inferCharacterEncoding

      public static Optional<Charset> inferCharacterEncoding(org.apache.sshd.server.Environment env)
      Attempt to infer the character encoding associated with an SSH connection.
      Parameters:
      env - SSH environment
      Returns:
      character encoding, if known
      Throws:
      IllegalArgumentException - if env is null
    • inferLocale

      public static Optional<Locale> inferLocale(org.apache.sshd.server.Environment env)
      Attempt to infer the locale associated with an SSH connection.
      Parameters:
      env - SSH environment
      Returns:
      local, if known
      Throws:
      IllegalArgumentException - if env is null
    • updateAttributesFromEnvironment

      public static void updateAttributesFromEnvironment(org.jline.terminal.Attributes attr, org.apache.sshd.server.Environment env)
      Update Terminal attributes based on the given SSH connection.
      Parameters:
      attr - terminal attributes
      env - SSH connection info
      Throws:
      IllegalArgumentException - if either parameter is null
    • updateSize

      public static boolean updateSize(org.jline.terminal.Terminal terminal, org.apache.sshd.server.Environment env)
      Update Terminal window size based on SSH environment variables.
      Parameters:
      terminal - the terminal to update
      env - SSH connection info
      Returns:
      true if size was successfully updated
      Throws:
      IllegalArgumentException - if either parameter is null