Class DefaultServerKexExtensionHandler
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.kex.extension.DefaultServerKexExtensionHandler
-
- All Implemented Interfaces:
KexExtensionHandler
public class DefaultServerKexExtensionHandler extends AbstractLoggingBean implements KexExtensionHandler
A basic default implementation of a server-sideKexExtensionHandler
handling theServerSignatureAlgorithms
KEX extension.- See Also:
- RFC 8308
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandler
KexExtensionHandler.AvailabilityPhase, KexExtensionHandler.KexPhase
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeRepository.AttributeKey<java.lang.Boolean>
CLIENT_REQUESTED_EXT_INFO
SessionAttributeRepository.AttributeKey
storing whether the client requested to get the EXT_INFO message.static AttributeRepository.AttributeKey<java.lang.Boolean>
EXT_INFO_SENT_AT_NEWKEYS
SessionAttributeRepository.AttributeKey
storing whether the server sent an EXT_INFO message atKexExtensionHandler.KexPhase.NEWKEYS
.static DefaultServerKexExtensionHandler
INSTANCE
Default singleton instance.-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description DefaultServerKexExtensionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collectExtensions(Session session, KexExtensionHandler.KexPhase phase, java.util.function.BiConsumer<java.lang.String,java.lang.Object> marshaller)
Collects extension info records, handing them off to the givenmarshaller
for writing into anKexExtensions.SSH_MSG_EXT_INFO
message.void
handleKexInitProposal(Session session, boolean initiator, java.util.Map<KexProposalOption,java.lang.String> proposal)
Invoked when a peer is ready to send the KEX options proposal or has received such a proposal.void
sendKexExtensions(Session session, KexExtensionHandler.KexPhase phase)
Invoked in order to allow the handler to send anSSH_MSG_EXT_INFO
message.-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandler
handleKexCompressionMessage, handleKexExtensionNegotiation, handleKexExtensionRequest, handleKexExtensionsMessage, isKexExtensionsAvailable
-
-
-
-
Field Detail
-
INSTANCE
public static final DefaultServerKexExtensionHandler INSTANCE
Default singleton instance.
-
CLIENT_REQUESTED_EXT_INFO
public static final AttributeRepository.AttributeKey<java.lang.Boolean> CLIENT_REQUESTED_EXT_INFO
SessionAttributeRepository.AttributeKey
storing whether the client requested to get the EXT_INFO message. Possible values are:null
- Unknown. We have not yet received the client's KEX proposal. Do not send the message.
Boolean.TRUE
- We have received the client's KEX proposal, and the client has requested to get the EXT_INFO message.
Boolean.FALSE
- We have received the client's KEX proposal, and the client did not request to get the EXT_INFO message. Do not send the message.
-
EXT_INFO_SENT_AT_NEWKEYS
public static final AttributeRepository.AttributeKey<java.lang.Boolean> EXT_INFO_SENT_AT_NEWKEYS
SessionAttributeRepository.AttributeKey
storing whether the server sent an EXT_INFO message atKexExtensionHandler.KexPhase.NEWKEYS
. A server is supposed to send the message at that point only on the very first NEWKEYS message. Possible values are:null
orBoolean.FALSE
- The EXT_INFO message at
KexExtensionHandler.KexPhase.NEWKEYS
was not done yet. Boolean.TRUE
- The EXT_INFO message at
KexExtensionHandler.KexPhase.NEWKEYS
was done.
-
-
Method Detail
-
handleKexInitProposal
public void handleKexInitProposal(Session session, boolean initiator, java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.lang.Exception
Description copied from interface:KexExtensionHandler
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 ifisKexExtensionsAvailable
returnsfalse
for the session.- Specified by:
handleKexInitProposal
in interfaceKexExtensionHandler
- 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 it before being sent or before being processed (if incoming)- Throws:
java.lang.Exception
- If failed to handle the request
-
sendKexExtensions
public void sendKexExtensions(Session session, KexExtensionHandler.KexPhase phase) throws java.lang.Exception
Description copied from interface:KexExtensionHandler
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.- Specified by:
sendKexExtensions
in interfaceKexExtensionHandler
- Parameters:
session
- TheSession
phase
- The phase at which the handler is invoked- Throws:
java.lang.Exception
- If failed to handle the invocation- See Also:
- RFC-8308 - section 2.4
-
collectExtensions
public void collectExtensions(Session session, KexExtensionHandler.KexPhase phase, java.util.function.BiConsumer<java.lang.String,java.lang.Object> marshaller)
Collects extension info records, handing them off to the givenmarshaller
for writing into anKexExtensions.SSH_MSG_EXT_INFO
message.This default implementation marshals a
ServerSignatureAlgorithms
extension if thephase
isKexExtensionHandler.KexPhase.NEWKEYS
.- Parameters:
session
-Session
to send the KEX extension information forphase
-KexExtensionHandler.KexPhase
of the SSH protocolmarshaller
-BiConsumer
writing the extensions into an SSH message
-
-