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.AttributeKeyused to store the client's proposalstatic final NavigableSet<String>static final DefaultClientKexExtensionHandlerstatic final AttributeRepository.AttributeKey<Map<KexProposalOption,String>> SessionAttributeRepository.AttributeKeyused to store the server's proposalFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhandleKexExtensionRequest(Session session, int index, int count, String name, byte[] data) Invoked byKexExtensionHandler.handleKexExtensionsMessage(Session, Buffer)in order to handle a specific extension.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.booleanisKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) intresolvePreferredSignaturePosition(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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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.AttributeKeyused to store the client's proposal -
SERVER_PROPOSAL_KEY
public static final AttributeRepository.AttributeKey<Map<KexProposalOption,String>> SERVER_PROPOSAL_KEYSessionAttributeRepository.AttributeKeyused 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:
isKexExtensionsAvailablein interfaceKexExtensionHandler- 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
public void handleKexInitProposal(Session session, boolean initiator, Map<KexProposalOption, String> proposal) throws IOExceptionDescription copied from interface:KexExtensionHandlerInvoked 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.- Specified by:
handleKexInitProposalin interfaceKexExtensionHandler- 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 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:KexExtensionHandlerInvoked byKexExtensionHandler.handleKexExtensionsMessage(Session, Buffer)in order to handle a specific extension.- Specified by:
handleKexExtensionRequestin interfaceKexExtensionHandler- 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:
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- TheSessionfor 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
-