Class TtyCommand

java.lang.Object
org.aesh.terminal.ssh.TtyCommand
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.sshd.server.channel.ChannelDataReceiver, org.apache.sshd.server.channel.ChannelSessionAware, org.apache.sshd.server.command.AsyncCommand, org.apache.sshd.server.command.AsyncCommandErrorStreamAware, org.apache.sshd.server.command.AsyncCommandInputStreamAware, org.apache.sshd.server.command.AsyncCommandOutputStreamAware, org.apache.sshd.server.command.AsyncCommandStreamsAware, org.apache.sshd.server.command.Command, org.apache.sshd.server.command.CommandDirectErrorStreamAware, org.apache.sshd.server.command.CommandDirectInputStreamAware, org.apache.sshd.server.command.CommandDirectOutputStreamAware, org.apache.sshd.server.command.CommandDirectStreamsAware, org.apache.sshd.server.command.CommandLifecycle

public class TtyCommand extends Object implements org.apache.sshd.server.command.AsyncCommand, org.apache.sshd.server.channel.ChannelDataReceiver, org.apache.sshd.server.channel.ChannelSessionAware
SSH command implementation that handles TTY connections and data transfer.
Author:
Julien Viet
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.sshd.server.channel.ChannelSession
    The SSH channel session associated with this command.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TtyCommand(Charset defaultCharset, Consumer<Connection> handler)
    Creates a new TtyCommand with the specified charset and connection handler.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    int
    data(org.apache.sshd.server.channel.ChannelSession channel, byte[] buf, int start, int len)
     
    void
    destroy(org.apache.sshd.server.channel.ChannelSession channelSession)
     
    protected void
    Executes a task asynchronously using the SSH session's executor service.
    protected void
    schedule(Runnable task, long delay, TimeUnit unit)
    Schedules a task for delayed execution using the SSH session's executor service.
    void
    setChannelSession(org.apache.sshd.server.channel.ChannelSession session)
     
    void
     
    void
    setExitCallback(org.apache.sshd.server.ExitCallback callback)
     
    void
     
    void
    setIoErrorStream(org.apache.sshd.common.io.IoOutputStream err)
     
    void
    setIoInputStream(org.apache.sshd.common.io.IoInputStream in)
     
    void
    setIoOutputStream(org.apache.sshd.common.io.IoOutputStream out)
     
    void
     
    void
    start(org.apache.sshd.server.channel.ChannelSession channelSession, org.apache.sshd.server.Environment env)
     
    void
    updateSize(org.apache.sshd.server.Environment env)
    Updates the terminal size from the SSH environment variables.

    Methods inherited from class Object

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

    • session

      protected org.apache.sshd.server.channel.ChannelSession session
      The SSH channel session associated with this command.
  • Constructor Details

    • TtyCommand

      public TtyCommand(Charset defaultCharset, Consumer<Connection> handler)
      Creates a new TtyCommand with the specified charset and connection handler.
      Parameters:
      defaultCharset - the default character set for encoding/decoding
      handler - the consumer that handles new connections
  • Method Details

    • data

      public int data(org.apache.sshd.server.channel.ChannelSession channel, byte[] buf, int start, int len) throws IOException
      Specified by:
      data in interface org.apache.sshd.server.channel.ChannelDataReceiver
      Throws:
      IOException
    • setChannelSession

      public void setChannelSession(org.apache.sshd.server.channel.ChannelSession session)
      Specified by:
      setChannelSession in interface org.apache.sshd.server.channel.ChannelSessionAware
    • setInputStream

      public void setInputStream(InputStream in)
      Specified by:
      setInputStream in interface org.apache.sshd.server.command.CommandDirectInputStreamAware
    • setOutputStream

      public void setOutputStream(OutputStream out)
      Specified by:
      setOutputStream in interface org.apache.sshd.server.command.CommandDirectOutputStreamAware
    • setErrorStream

      public void setErrorStream(OutputStream err)
      Specified by:
      setErrorStream in interface org.apache.sshd.server.command.CommandDirectErrorStreamAware
    • setIoInputStream

      public void setIoInputStream(org.apache.sshd.common.io.IoInputStream in)
      Specified by:
      setIoInputStream in interface org.apache.sshd.server.command.AsyncCommandInputStreamAware
    • setIoOutputStream

      public void setIoOutputStream(org.apache.sshd.common.io.IoOutputStream out)
      Specified by:
      setIoOutputStream in interface org.apache.sshd.server.command.AsyncCommandOutputStreamAware
    • setIoErrorStream

      public void setIoErrorStream(org.apache.sshd.common.io.IoOutputStream err)
      Specified by:
      setIoErrorStream in interface org.apache.sshd.server.command.AsyncCommandErrorStreamAware
    • setExitCallback

      public void setExitCallback(org.apache.sshd.server.ExitCallback callback)
      Specified by:
      setExitCallback in interface org.apache.sshd.server.command.Command
    • start

      public void start(org.apache.sshd.server.channel.ChannelSession channelSession, org.apache.sshd.server.Environment env) throws IOException
      Specified by:
      start in interface org.apache.sshd.server.command.CommandLifecycle
      Throws:
      IOException
    • updateSize

      public void updateSize(org.apache.sshd.server.Environment env)
      Updates the terminal size from the SSH environment variables.
      Parameters:
      env - the SSH environment containing size information
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • destroy

      public void destroy(org.apache.sshd.server.channel.ChannelSession channelSession) throws Exception
      Specified by:
      destroy in interface org.apache.sshd.server.command.CommandLifecycle
      Throws:
      Exception
    • execute

      protected void execute(Runnable task)
      Executes a task asynchronously using the SSH session's executor service.
      Parameters:
      task - the task to execute
    • schedule

      protected void schedule(Runnable task, long delay, TimeUnit unit)
      Schedules a task for delayed execution using the SSH session's executor service.
      Parameters:
      task - the task to schedule
      delay - the delay before execution
      unit - the time unit for the delay