Interface KexExtensionHandler

    • Method Detail

      • handleKexInitProposal

        default void handleKexInitProposal​(Session session,
                                           boolean initiator,
                                           Map<KexProposalOption,​String> proposal)
                                    throws Exception
        Invoked when a peer is ready to send the KEX options proposal or has received such a proposal. Note: this method is called during the negotiation phase even if isKexExtensionsAvailable returns false for the session.
        Parameters:
        session - The Session initiating or receiving the proposal
        initiator - true if the proposal is about to be sent, false if this is a proposal received from the peer.
        proposal - The proposal contents - Caveat emptor: the proposal is modifiable i.e., the handler can modify it before being sent or before being processed (if incoming)
        Throws:
        Exception - If failed to handle the request
      • handleKexExtensionNegotiation

        default void handleKexExtensionNegotiation​(Session session,
                                                   KexProposalOption option,
                                                   String nValue,
                                                   Map<KexProposalOption,​String> c2sOptions,
                                                   String cValue,
                                                   Map<KexProposalOption,​String> s2cOptions,
                                                   String sValue)
                                            throws Exception
        Invoked during the KEX negotiation phase to inform about option being negotiated. Note: this method is called during the negotiation phase even if isKexExtensionsAvailable returns false for the session.
        Parameters:
        session - The Session executing the negotiation
        option - The negotiated KexProposalOption
        nValue - The negotiated option value (may be null/empty).
        c2sOptions - The client proposals
        cValue - The client-side value for the option (may be null/empty).
        s2cOptions - The server proposals
        sValue - The server-side value for the option (may be null/empty).
        Throws:
        Exception - If failed to handle the invocation
      • sendKexExtensions

        default void sendKexExtensions​(Session session,
                                       KexExtensionHandler.KexPhase phase)
                                throws Exception
        Invoked in order to allow the handler to send an SSH_MSG_EXT_INFO message. Note: this method is called only if isKexExtensionsAvailable returns true for the session.
        Parameters:
        session - The Session
        phase - The phase at which the handler is invoked
        Throws:
        Exception - If failed to handle the invocation
        See Also:
        RFC-8308 - section 2.4
      • handleKexExtensionsMessage

        default boolean handleKexExtensionsMessage​(Session session,
                                                   Buffer buffer)
                                            throws Exception
        Parses the SSH_MSG_EXT_INFO message. Note: this method is called regardless of whether isKexExtensionsAvailable returns true for the session.
        Parameters:
        session - The Session through which the message was received
        buffer - The message buffer
        Returns:
        true if message handled - if false then SSH_MSG_UNIMPLEMENTED will be generated
        Throws:
        Exception - If failed to handle the message
        See Also:
        RFC-8308 - section 2.3, handleKexExtensionRequest(Session, int, int, String, byte[])
      • handleKexCompressionMessage

        default boolean handleKexCompressionMessage​(Session session,
                                                    Buffer buffer)
                                             throws Exception
        Parses the SSH_MSG_NEWCOMPRESS message. Note: this method is called regardless of whether isKexExtensionsAvailable returns true for the session.
        Parameters:
        session - The Session through which the message was received
        buffer - The message buffer
        Returns:
        true if message handled - if false then SSH_MSG_UNIMPLEMENTED will be generated
        Throws:
        Exception - If failed to handle the message
        See Also:
        RFC-8308 - section 3.2
      • handleKexExtensionRequest

        default boolean handleKexExtensionRequest​(Session session,
                                                  int index,
                                                  int count,
                                                  String name,
                                                  byte[] data)
                                           throws Exception
        Invoked by handleKexExtensionsMessage(Session, Buffer) in order to handle a specific extension.
        Parameters:
        session - The Session through which the message was received
        index - The 0-based extension index
        count - The total extensions in the message
        name - The extension name
        data - The extension data
        Returns:
        true whether to proceed to the next extension or stop processing the rest
        Throws:
        Exception - If failed to handle the extension