Class KexExtensions
java.lang.Object
org.apache.sshd.common.kex.extension.KexExtensions
Provides some helpers for RFC 8308
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
private static final NavigableMap<String,
KexExtensionParser<?>> A case insensitive map of all the default knownKexExtensionParser
where key=the extension namestatic final String
static final byte
static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KexExtensionParser<?>
static NavigableSet<String>
parseExtensions
(Buffer buffer) Attempts to parse anSSH_MSG_EXT_INFO
messagestatic void
putExtensions
(Collection<? extends Map.Entry<String, ?>> exts, Buffer buffer) Creates anSSH_MSG_EXT_INFO
message using the provided extensions.static KexExtensionParser<?>
registerExtensionParser
(KexExtensionParser<?> parser) Registers aKexExtensionParser
for a named extensionstatic KexExtensionParser<?>
RegistersKexExtensionParser
for a named extension
-
Field Details
-
SSH_MSG_EXT_INFO
public static final byte SSH_MSG_EXT_INFO- See Also:
-
SSH_MSG_NEWCOMPRESS
public static final byte SSH_MSG_NEWCOMPRESS- See Also:
-
CLIENT_KEX_EXTENSION
- See Also:
-
SERVER_KEX_EXTENSION
- See Also:
-
IS_KEX_EXTENSION_SIGNAL
-
EXTENSION_PARSERS
A case insensitive map of all the default knownKexExtensionParser
where key=the extension name
-
-
Constructor Details
-
KexExtensions
private KexExtensions()
-
-
Method Details
-
getRegisteredExtensionParserNames
- Returns:
- A case insensitive copy of the currently registered
KexExtensionParser
s names
-
getRegisteredExtensionParser
- Parameters:
name
- The (nevernull
/empty) extension name- Returns:
- The registered
KexExtensionParser
for the (case insensitive) extension name -null
if no match found
-
registerExtensionParser
Registers aKexExtensionParser
for a named extension- Parameters:
parser
- The (nevernull
) parser to register- Returns:
- The replaced parser for the named extension (case insensitive) -
null
if no previous parser registered for this extension
-
unregisterExtensionParser
RegistersKexExtensionParser
for a named extension- Parameters:
name
- The (nevernull
/empty) extension name- Returns:
- The removed
KexExtensionParser
for the (case insensitive) extension name -null
if no match found
-
parseExtensions
Attempts to parse anSSH_MSG_EXT_INFO
message- Parameters:
buffer
- TheBuffer
containing the message- Returns:
- A
List
of 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:
-
putExtensions
public static void putExtensions(Collection<? extends Map.Entry<String, ?>> exts, Buffer buffer) throws IOExceptionCreates anSSH_MSG_EXT_INFO
message using the provided extensions.- Parameters:
exts
- ACollection
of key/value "pairs" where key=the extension name, value=the extension value. Note: if a registeredKexExtensionParser
exists 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_INFO
opcode- Throws:
IOException
- If failed to encode
-