Class ChannelSession

    • Constructor Detail

      • ChannelSession

        public ChannelSession()
      • ChannelSession

        public ChannelSession​(java.util.Collection<? extends RequestHandler<Channel>> handlers)
    • Method Detail

      • handleWindowAdjust

        public void handleWindowAdjust​(Buffer buffer)
                                throws java.io.IOException
        Description copied from interface: Channel
        Invoked when SSH_MSG_CHANNEL_WINDOW_ADJUST received
        Specified by:
        handleWindowAdjust in interface Channel
        Overrides:
        handleWindowAdjust in class AbstractChannel
        Parameters:
        buffer - The rest of the message data Buffer after decoding the channel identifiers
        Throws:
        java.io.IOException - If failed to handle the message
      • closeImmediately0

        protected void closeImmediately0()
      • handleEof

        public void handleEof()
                       throws java.io.IOException
        Description copied from interface: Channel
        Invoked when SSH_MSG_CHANNEL_EOF received
        Specified by:
        handleEof in interface Channel
        Overrides:
        handleEof in class AbstractChannel
        Throws:
        java.io.IOException - If failed to handle the message
      • doWriteData

        protected void doWriteData​(byte[] data,
                                   int off,
                                   long len)
                            throws java.io.IOException
        Specified by:
        doWriteData in class AbstractChannel
        Throws:
        java.io.IOException
      • doWriteExtendedData

        protected void doWriteExtendedData​(byte[] data,
                                           int off,
                                           long len)
                                    throws java.io.IOException
        Specified by:
        doWriteExtendedData in class AbstractChannel
        Throws:
        java.io.IOException
      • handleInternalRequest

        protected RequestHandler.Result handleInternalRequest​(java.lang.String requestType,
                                                              boolean wantReply,
                                                              Buffer buffer)
                                                       throws java.io.IOException
        Description copied from class: AbstractChannel
        Called by AbstractChannel.handleUnknownChannelRequest(String, boolean, Buffer) in order to allow channel request handling if none of the registered handlers processed the request - last chance.
        Overrides:
        handleInternalRequest in class AbstractChannel
        Parameters:
        requestType - The request type
        wantReply - Whether reply is requested
        buffer - The Buffer containing extra request-specific data
        Returns:
        The handling result - if null or Unsupported and reply is required then a failure message will be sent
        Throws:
        java.io.IOException - If failed to process the request internally
      • handleEnv

        protected RequestHandler.Result handleEnv​(Buffer buffer,
                                                  boolean wantReply)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • handlePtyReq

        protected RequestHandler.Result handlePtyReq​(Buffer buffer,
                                                     boolean wantReply)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • handleWindowChange

        protected RequestHandler.Result handleWindowChange​(Buffer buffer,
                                                           boolean wantReply)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • handleSignal

        protected RequestHandler.Result handleSignal​(Buffer buffer,
                                                     boolean wantReply)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • handleBreak

        protected RequestHandler.Result handleBreak​(Buffer buffer,
                                                    boolean wantReply)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • handleShell

        protected RequestHandler.Result handleShell​(java.lang.String request,
                                                    Buffer buffer,
                                                    boolean wantReply)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • handleExec

        protected RequestHandler.Result handleExec​(java.lang.String request,
                                                   Buffer buffer,
                                                   boolean wantReply)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • handleSubsystem

        protected RequestHandler.Result handleSubsystem​(java.lang.String request,
                                                        Buffer buffer,
                                                        boolean wantReply)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • prepareChannelCommand

        protected RequestHandler.Result prepareChannelCommand​(java.lang.String request,
                                                              Command cmd)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • setExtendedDataWriter

        public void setExtendedDataWriter​(ChannelDataReceiver extendedDataWriter)
        A special ChannelDataReceiver that can be used to receive data sent as "extended" - usually STDERR. Note: by default any such data sent to the channel session causes an exception, but specific implementations may choose to register such a receiver (e.g., for custom usage of the STDERR stream). A good place in the code to register such a writer would be in commands that also implement ChannelSessionAware.
        Parameters:
        extendedDataWriter - The ChannelDataReceiver.
      • prepareCommand

        protected Command prepareCommand​(java.lang.String requestType,
                                         Command command)
                                  throws java.io.IOException
        Called by prepareChannelCommand(String, Command) in order to set up the command's streams, session, file-system, exit callback, etc..
        Parameters:
        requestType - The request that caused the command to be created
        command - The created Command - may be null
        Returns:
        The updated command instance - if null then the request that initially caused the creation of the command is failed and the original command (if any) destroyed (eventually). Note: if a different command instance than the input one is returned, then it is up to the implementor to take care of the wrapping or destruction of the original command instance.
        Throws:
        java.io.IOException - If failed to prepare the command
      • getPtyModeValue

        protected int getPtyModeValue​(PtyMode mode)
      • handleAgentForwarding

        protected RequestHandler.Result handleAgentForwarding​(java.lang.String requestType,
                                                              Buffer buffer,
                                                              boolean wantReply)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • handleX11Forwarding

        protected RequestHandler.Result handleX11Forwarding​(java.lang.String requestType,
                                                            Buffer buffer,
                                                            boolean wantReply)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • addEnvVariable

        protected void addEnvVariable​(java.lang.String name,
                                      java.lang.String value)
      • closeShell

        protected void closeShell​(int exitValue)
                           throws java.io.IOException
        Throws:
        java.io.IOException