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
Fields Modifier and Type Field Description static AttributeRepository.AttributeKey<java.util.Map<KexProposalOption,java.lang.String>>
CLIENT_PROPOSAL_KEY
SessionAttributeRepository.AttributeKey
used to store the client's proposalstatic java.util.NavigableSet<java.lang.String>
DEFAULT_EXTRA_SIGNATURES
static DefaultClientKexExtensionHandler
INSTANCE
static AttributeRepository.AttributeKey<java.util.Map<KexProposalOption,java.lang.String>>
SERVER_PROPOSAL_KEY
SessionAttributeRepository.AttributeKey
used to store the server's proposal-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description DefaultClientKexExtensionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
handleKexExtensionRequest(Session session, int index, int count, java.lang.String name, byte[] data)
Invoked byKexExtensionHandler.handleKexExtensionsMessage(Session, Buffer)
in order to handle a specific extension.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.boolean
isKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase)
int
resolvePreferredSignaturePosition(Session session, java.util.List<? extends NamedFactory<Signature>> factories, NamedFactory<Signature> factory)
java.util.List<NamedFactory<Signature>>
resolveRequestedSignatureFactories(Session session, java.util.Collection<java.lang.String> extraAlgos)
NamedFactory<Signature>
resolveRequestedSignatureFactory(Session session, java.lang.String name)
java.util.List<NamedFactory<Signature>>
resolveUpdatedSignatureFactories(Session session, java.util.List<NamedFactory<Signature>> available, java.util.Collection<java.lang.String> extraAlgos)
Checks if the extra signature algorithms are already included in the available ones, and adds the extra ones (if supported).java.util.List<NamedFactory<Signature>>
updateAvailableSignatureFactories(Session session, java.util.Collection<java.lang.String> extraAlgos)
java.util.List<NamedFactory<Signature>>
updateAvailableSignatureFactories(Session session, java.util.List<NamedFactory<Signature>> available, java.util.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 Detail
-
CLIENT_PROPOSAL_KEY
public static final AttributeRepository.AttributeKey<java.util.Map<KexProposalOption,java.lang.String>> CLIENT_PROPOSAL_KEY
SessionAttributeRepository.AttributeKey
used to store the client's proposal
-
SERVER_PROPOSAL_KEY
public static final AttributeRepository.AttributeKey<java.util.Map<KexProposalOption,java.lang.String>> SERVER_PROPOSAL_KEY
SessionAttributeRepository.AttributeKey
used to store the server's proposal
-
DEFAULT_EXTRA_SIGNATURES
public static final java.util.NavigableSet<java.lang.String> DEFAULT_EXTRA_SIGNATURES
-
INSTANCE
public static final DefaultClientKexExtensionHandler INSTANCE
-
-
Method Detail
-
isKexExtensionsAvailable
public boolean isKexExtensionsAvailable(Session session, KexExtensionHandler.AvailabilityPhase phase) throws java.io.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:
java.io.IOException
- If failed to process the request
-
handleKexInitProposal
public void handleKexInitProposal(Session session, boolean initiator, java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.io.IOException
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 before being sent or before being processed (if incoming)- Throws:
java.io.IOException
- If failed to handle the request
-
handleKexExtensionRequest
public boolean handleKexExtensionRequest(Session session, int index, int count, java.lang.String name, byte[] data) throws java.io.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:
java.io.IOException
- If failed to handle the extension
-
updateAvailableSignatureFactories
public java.util.List<NamedFactory<Signature>> updateAvailableSignatureFactories(Session session, java.util.Collection<java.lang.String> extraAlgos) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveUpdatedSignatureFactories
public java.util.List<NamedFactory<Signature>> resolveUpdatedSignatureFactories(Session session, java.util.List<NamedFactory<Signature>> available, java.util.Collection<java.lang.String> extraAlgos) throws java.io.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:
java.io.IOException
- If failed to resolve the factories
-
updateAvailableSignatureFactories
public java.util.List<NamedFactory<Signature>> updateAvailableSignatureFactories(Session session, java.util.List<NamedFactory<Signature>> available, java.util.Collection<? extends NamedFactory<Signature>> toAdd) throws java.io.IOException
- Throws:
java.io.IOException
-
resolvePreferredSignaturePosition
public int resolvePreferredSignaturePosition(Session session, java.util.List<? extends NamedFactory<Signature>> factories, NamedFactory<Signature> factory) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveRequestedSignatureFactories
public java.util.List<NamedFactory<Signature>> resolveRequestedSignatureFactories(Session session, java.util.Collection<java.lang.String> extraAlgos) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveRequestedSignatureFactory
public NamedFactory<Signature> resolveRequestedSignatureFactory(Session session, java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
-