Class DefaultClientKexExtensionHandler
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.kex.extension.DefaultClientKexExtensionHandler
- All Implemented Interfaces:
KexExtensionHandler
public class DefaultClientKexExtensionHandler
extends AbstractLoggingBean
implements KexExtensionHandler
Detects if the server sends a
"server-sig-algs" and updates the client
session by adding the "rsa-sha2-256/512" signature
factories (if not already added).
Note: experimental - used for development purposes and as an example
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandler
KexExtensionHandler.AvailabilityPhase, KexExtensionHandler.KexPhase
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AttributeRepository.AttributeKey<Map<KexProposalOption,
String>> SessionAttributeRepository.AttributeKey
used to store the client's proposalstatic final NavigableSet<String>
static final DefaultClientKexExtensionHandler
static final AttributeRepository.AttributeKey<Map<KexProposalOption,
String>> SessionAttributeRepository.AttributeKey
used to store the server's proposalFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
handleKexExtensionRequest
(Session session, int index, int count, String name, byte[] data) Invoked byKexExtensionHandler.handleKexExtensionsMessage(Session, Buffer)
in order to handle a specific extension.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.boolean
isKexExtensionsAvailable
(Session session, KexExtensionHandler.AvailabilityPhase phase) int
resolvePreferredSignaturePosition
(Session session, List<? extends NamedFactory<Signature>> factories, NamedFactory<Signature> factory) resolveRequestedSignatureFactories
(Session session, Collection<String> extraAlgos) resolveRequestedSignatureFactory
(Session session, String name) resolveUpdatedSignatureFactories
(Session session, List<NamedFactory<Signature>> available, Collection<String> extraAlgos) Checks if the extra signature algorithms are already included in the available ones, and adds the extra ones (if supported).updateAvailableSignatureFactories
(Session session, Collection<String> extraAlgos) updateAvailableSignatureFactories
(Session session, List<NamedFactory<Signature>> available, Collection<? extends NamedFactory<Signature>> toAdd) 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, handleKexExtensionsMessage, sendKexExtensions
-
Field Details
-
CLIENT_PROPOSAL_KEY
public static final AttributeRepository.AttributeKey<Map<KexProposalOption,String>> CLIENT_PROPOSAL_KEYSessionAttributeRepository.AttributeKey
used to store the client's proposal -
SERVER_PROPOSAL_KEY
public static final AttributeRepository.AttributeKey<Map<KexProposalOption,String>> SERVER_PROPOSAL_KEYSessionAttributeRepository.AttributeKey
used to store the server's proposal -
DEFAULT_EXTRA_SIGNATURES
-
INSTANCE
-
-
Constructor Details
-
DefaultClientKexExtensionHandler
public DefaultClientKexExtensionHandler()
-
-
Method Details
-
isKexExtensionsAvailable
public boolean isKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) throws IOException - Specified by:
isKexExtensionsAvailable
in interfaceKexExtensionHandler
- 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
public void handleKexInitProposal(Session session, boolean initiator, Map<KexProposalOption, String> proposal) throws IOExceptionDescription 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 before being sent or before being processed (if incoming)- Throws:
IOException
- If failed to handle the request
-
handleKexExtensionRequest
public boolean handleKexExtensionRequest(Session session, int index, int count, String name, byte[] data) throws IOException Description copied from interface:KexExtensionHandler
Invoked byKexExtensionHandler.handleKexExtensionsMessage(Session, Buffer)
in order to handle a specific extension.- Specified by:
handleKexExtensionRequest
in interfaceKexExtensionHandler
- 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
-
updateAvailableSignatureFactories
public List<NamedFactory<Signature>> updateAvailableSignatureFactories(Session session, Collection<String> extraAlgos) throws IOException - Throws:
IOException
-
resolveUpdatedSignatureFactories
public List<NamedFactory<Signature>> resolveUpdatedSignatureFactories(Session session, List<NamedFactory<Signature>> available, Collection<String> extraAlgos) throws IOException Checks if the extra signature algorithms are already included in the available ones, and adds the extra ones (if supported).- Parameters:
session
- TheSession
for which the resolution occursavailable
- The available signature factoriesextraAlgos
- The extra requested signatures - ignored ifnull
/empty- Returns:
- The resolved signature factories - same as input if nothing added
- Throws:
IOException
- If failed to resolve the factories
-
updateAvailableSignatureFactories
public List<NamedFactory<Signature>> updateAvailableSignatureFactories(Session session, List<NamedFactory<Signature>> available, Collection<? extends NamedFactory<Signature>> toAdd) throws IOException - Throws:
IOException
-
resolvePreferredSignaturePosition
public int resolvePreferredSignaturePosition(Session session, List<? extends NamedFactory<Signature>> factories, NamedFactory<Signature> factory) throws IOException - Throws:
IOException
-
resolveRequestedSignatureFactories
public List<NamedFactory<Signature>> resolveRequestedSignatureFactories(Session session, Collection<String> extraAlgos) throws IOException - Throws:
IOException
-
resolveRequestedSignatureFactory
public NamedFactory<Signature> resolveRequestedSignatureFactory(Session session, String name) throws IOException - Throws:
IOException
-