Class KexExtensions
- java.lang.Object
-
- org.apache.sshd.common.kex.extension.KexExtensions
-
public final class KexExtensions extends Object
Provides some helpers for RFC 8308- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLIENT_KEX_EXTENSIONstatic Predicate<String>IS_KEX_EXTENSION_SIGNALstatic StringSERVER_KEX_EXTENSIONstatic byteSSH_MSG_EXT_INFOstatic byteSSH_MSG_NEWCOMPRESS
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KexExtensionParser<?>getRegisteredExtensionParser(String name)static NavigableSet<String>getRegisteredExtensionParserNames()static List<Map.Entry<String,?>>parseExtensions(Buffer buffer)Attempts to parse anSSH_MSG_EXT_INFOmessagestatic voidputExtensions(Collection<? extends Map.Entry<String,?>> exts, Buffer buffer)Creates anSSH_MSG_EXT_INFOmessage using the provided extensions.static KexExtensionParser<?>registerExtensionParser(KexExtensionParser<?> parser)Registers aKexExtensionParserfor a named extensionstatic KexExtensionParser<?>unregisterExtensionParser(String name)RegistersKexExtensionParserfor a named extension
-
-
-
Field Detail
-
SSH_MSG_EXT_INFO
public static final byte SSH_MSG_EXT_INFO
- See Also:
- Constant Field Values
-
SSH_MSG_NEWCOMPRESS
public static final byte SSH_MSG_NEWCOMPRESS
- See Also:
- Constant Field Values
-
CLIENT_KEX_EXTENSION
public static final String CLIENT_KEX_EXTENSION
- See Also:
- Constant Field Values
-
SERVER_KEX_EXTENSION
public static final String SERVER_KEX_EXTENSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRegisteredExtensionParserNames
public static NavigableSet<String> getRegisteredExtensionParserNames()
- Returns:
- A case insensitive copy of the currently registered
KexExtensionParsers names
-
getRegisteredExtensionParser
public static KexExtensionParser<?> getRegisteredExtensionParser(String name)
- Parameters:
name- The (nevernull/empty) extension name- Returns:
- The registered
KexExtensionParserfor the (case insensitive) extension name -nullif no match found
-
registerExtensionParser
public static KexExtensionParser<?> registerExtensionParser(KexExtensionParser<?> parser)
Registers aKexExtensionParserfor a named extension- Parameters:
parser- The (nevernull) parser to register- Returns:
- The replaced parser for the named extension (case insensitive) -
nullif no previous parser registered for this extension
-
unregisterExtensionParser
public static KexExtensionParser<?> unregisterExtensionParser(String name)
RegistersKexExtensionParserfor a named extension- Parameters:
name- The (nevernull/empty) extension name- Returns:
- The removed
KexExtensionParserfor the (case insensitive) extension name -nullif no match found
-
parseExtensions
public static List<Map.Entry<String,?>> parseExtensions(Buffer buffer) throws IOException
Attempts to parse anSSH_MSG_EXT_INFOmessage- Parameters:
buffer- TheBuffercontaining the message- Returns:
- A
Listof key/value "pairs" where key=the extension name, value=the parsed value using the matching registeredKexExtensionParser. If no such parser found then the raw value bytes are set as the extension value. - Throws:
IOException- If failed to parse one of the extensions- See Also:
- RFC-8308 - section 2.3
-
putExtensions
public static void putExtensions(Collection<? extends Map.Entry<String,?>> exts, Buffer buffer) throws IOException
Creates anSSH_MSG_EXT_INFOmessage using the provided extensions.- Parameters:
exts- ACollectionof key/value "pairs" where key=the extension name, value=the extension value. Note: if a registeredKexExtensionParserexists for the name, then it is assumed that the value is of the correct type. If no registered parser found the value is assumed to be either the encoded value as an array of bytes or as anotherReadable(e.g., anotherBuffer) or aByteBuffer.buffer- The targetBuffer- assumed to already contain theSSH_MSG_EXT_INFOopcode- Throws:
IOException- If failed to encode
-
-