Interface KexExtensionHandler
- All Known Implementing Classes:
DefaultClientKexExtensionHandler
public interface KexExtensionHandler
Used to support RFC 8308
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Provides a hint as to the context in whichisKexExtensionsAvailable
is invokedstatic enum
The phase at whichsendKexExtensions
is invoked -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
handleKexCompressionMessage
(Session session, Buffer buffer) Parses theSSH_MSG_NEWCOMPRESS
message.default void
handleKexExtensionNegotiation
(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 boolean
handleKexExtensionRequest
(Session session, int index, int count, String name, byte[] data) Invoked byhandleKexExtensionsMessage(Session, Buffer)
in order to handle a specific extension.default boolean
handleKexExtensionsMessage
(Session session, Buffer buffer) Parses theSSH_MSG_EXT_INFO
message.default void
handleKexInitProposal
(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 boolean
isKexExtensionsAvailable
(Session session, KexExtensionHandler.AvailabilityPhase phase) default void
sendKexExtensions
(Session session, KexExtensionHandler.KexPhase phase) Invoked in order to allow the handler to send anSSH_MSG_EXT_INFO
message.
-
Method Details
-
isKexExtensionsAvailable
default boolean isKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) throws IOException - Parameters:
session
- TheSession
about to execute KEXphase
- TheKexExtensionHandler.AvailabilityPhase
hint as to why the query is being made- Returns:
true
whether 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 IOExceptionInvoked 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 ifisKexExtensionsAvailable
returnsfalse
for the session.- Parameters:
session
- TheSession
initiating or receiving the proposalinitiator
-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 before being sent or before being processed (if incoming)- Throws:
IOException
- 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 IOExceptionString> 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 ifisKexExtensionsAvailable
returnsfalse
for the session.- Parameters:
session
- TheSession
executing the negotiationoption
- The negotiatedKexProposalOption
nValue
- 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:
IOException
- If failed to handle the invocation
-
sendKexExtensions
default void sendKexExtensions(Session session, KexExtensionHandler.KexPhase phase) throws IOException Invoked in order to allow the handler to send anSSH_MSG_EXT_INFO
message. Note: this method is called only ifisKexExtensionsAvailable
returnstrue
for the session.- Parameters:
session
- TheSession
phase
- The phase at which the handler is invoked- Throws:
IOException
- If failed to handle the invocation- See Also:
-
handleKexExtensionsMessage
Parses theSSH_MSG_EXT_INFO
message. Note: this method is called regardless of whetherisKexExtensionsAvailable
returnstrue
for the session.- Parameters:
session
- TheSession
through which the message was receivedbuffer
- The message buffer- Returns:
true
if message handled - iffalse
thenSSH_MSG_UNIMPLEMENTED
will be generated- Throws:
IOException
- If failed to handle the message- See Also:
-
handleKexCompressionMessage
Parses theSSH_MSG_NEWCOMPRESS
message. Note: this method is called regardless of whetherisKexExtensionsAvailable
returnstrue
for the session.- Parameters:
session
- TheSession
through which the message was receivedbuffer
- The message buffer- Returns:
true
if message handled - iffalse
thenSSH_MSG_UNIMPLEMENTED
will be generated- Throws:
IOException
- If failed to handle the message- See Also:
-
handleKexExtensionRequest
default boolean handleKexExtensionRequest(Session session, int index, int count, String name, byte[] data) throws IOException Invoked byhandleKexExtensionsMessage(Session, Buffer)
in order to handle a specific extension.- Parameters:
session
- TheSession
through which the message was receivedindex
- The 0-based extension indexcount
- The total extensions in the messagename
- The extension namedata
- The extension data- Returns:
true
whether to proceed to the next extension or stop processing the rest- Throws:
IOException
- If failed to handle the extension
-