Interface KexExtensionHandler
- All Known Implementing Classes:
DefaultClientKexExtensionHandler,DefaultServerKexExtensionHandler
public interface KexExtensionHandler
Used to support RFC 8308
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumProvides a hint as to the context in whichisKexExtensionsAvailableis invokedstatic enumThe phase at whichsendKexExtensionsis invoked -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanhandleKexCompressionMessage(Session session, Buffer buffer) Parses theSSH_MSG_NEWCOMPRESSmessage.default voidhandleKexExtensionNegotiation(Session session, KexProposalOption option, String nValue, Map<KexProposalOption, String> c2sOptions, String cValue, Map<KexProposalOption, String> s2cOptions, String sValue) Invoked during the KEX negotiation phase to inform about option being negotiated.default booleanhandleKexExtensionRequest(Session session, int index, int count, String name, byte[] data) Invoked byhandleKexExtensionsMessage(Session, Buffer)in order to handle a specific extension.default booleanhandleKexExtensionsMessage(Session session, Buffer buffer) Parses theSSH_MSG_EXT_INFOmessage.default voidhandleKexInitProposal(Session session, boolean initiator, Map<KexProposalOption, String> proposal) Invoked when a peer is ready to send the KEX options proposal or has received such a proposal.default booleanisKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) default voidsendKexExtensions(Session session, KexExtensionHandler.KexPhase phase) Invoked in order to allow the handler to send anSSH_MSG_EXT_INFOmessage.
-
Method Details
-
isKexExtensionsAvailable
default boolean isKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) throws IOException - Parameters:
session- TheSessionabout to execute KEXphase- TheKexExtensionHandler.AvailabilityPhasehint as to why the query is being made- Returns:
truewhether to KEX extensions are supported/allowed for the session- Throws:
IOException- If failed to process the request
-
handleKexInitProposal
default void handleKexInitProposal(Session session, boolean initiator, Map<KexProposalOption, String> proposal) throws ExceptionInvoked 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 ifisKexExtensionsAvailablereturnsfalsefor the session.- Parameters:
session- TheSessioninitiating or receiving the proposalinitiator-trueif the proposal is about to be sent,falseif 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, throws ExceptionString> s2cOptions, String sValue) Invoked during the KEX negotiation phase to inform about option being negotiated. Note: this method is called during the negotiation phase even ifisKexExtensionsAvailablereturnsfalsefor the session.- Parameters:
session- TheSessionexecuting the negotiationoption- The negotiatedKexProposalOptionnValue- The negotiated option value (may benull/empty).c2sOptions- The client proposalscValue- The client-side value for the option (may benull/empty).s2cOptions- The server proposalssValue- The server-side value for the option (may benull/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 anSSH_MSG_EXT_INFOmessage. Note: this method is called only ifisKexExtensionsAvailablereturnstruefor the session. -
handleKexExtensionsMessage
Parses theSSH_MSG_EXT_INFOmessage. Note: this method is called regardless of whetherisKexExtensionsAvailablereturnstruefor the session. -
handleKexCompressionMessage
Parses theSSH_MSG_NEWCOMPRESSmessage. Note: this method is called regardless of whetherisKexExtensionsAvailablereturnstruefor the session. -
handleKexExtensionRequest
default boolean handleKexExtensionRequest(Session session, int index, int count, String name, byte[] data) throws Exception Invoked byhandleKexExtensionsMessage(Session, Buffer)in order to handle a specific extension.- Parameters:
session- TheSessionthrough which the message was receivedindex- The 0-based extension indexcount- The total extensions in the messagename- The extension namedata- The extension data- Returns:
truewhether to proceed to the next extension or stop processing the rest- Throws:
Exception- If failed to handle the extension
-