Class KexExtensions
- java.lang.Object
-
- org.apache.sshd.common.kex.extension.KexExtensions
-
public final class KexExtensions extends java.lang.ObjectProvides some helpers for RFC 8308
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLIENT_KEX_EXTENSIONprivate static java.util.NavigableMap<java.lang.String,KexExtensionParser<?>>EXTENSION_PARSERSA case insensitive map of all the default knownKexExtensionParserwhere key=the extension namestatic java.util.function.Predicate<java.lang.String>IS_KEX_EXTENSION_SIGNALstatic java.lang.StringSERVER_KEX_EXTENSIONstatic byteSSH_MSG_EXT_INFOstatic byteSSH_MSG_NEWCOMPRESSstatic java.lang.StringSTRICT_KEX_CLIENT_EXTENSIONReminder: These pseudo-algorithms are only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored if they are present in subsequent SSH2_MSG_KEXINIT packets.static java.lang.StringSTRICT_KEX_SERVER_EXTENSION
-
Constructor Summary
Constructors Modifier Constructor Description privateKexExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KexExtensionParser<?>getRegisteredExtensionParser(java.lang.String name)static java.util.NavigableSet<java.lang.String>getRegisteredExtensionParserNames()static java.util.List<java.util.Map.Entry<java.lang.String,?>>parseExtensions(Buffer buffer)Attempts to parse anSSH_MSG_EXT_INFOmessagestatic voidputExtensions(java.util.Collection<? extends java.util.Map.Entry<java.lang.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(java.lang.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 java.lang.String CLIENT_KEX_EXTENSION
- See Also:
- Constant Field Values
-
SERVER_KEX_EXTENSION
public static final java.lang.String SERVER_KEX_EXTENSION
- See Also:
- Constant Field Values
-
IS_KEX_EXTENSION_SIGNAL
public static final java.util.function.Predicate<java.lang.String> IS_KEX_EXTENSION_SIGNAL
-
STRICT_KEX_CLIENT_EXTENSION
public static final java.lang.String STRICT_KEX_CLIENT_EXTENSION
Reminder: These pseudo-algorithms are only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored if they are present in subsequent SSH2_MSG_KEXINIT packets. Note: these values are appended to the initial proposals and removed if received before proceeding with the standard KEX proposals negotiation.
-
STRICT_KEX_SERVER_EXTENSION
public static final java.lang.String STRICT_KEX_SERVER_EXTENSION
- See Also:
- Constant Field Values
-
EXTENSION_PARSERS
private static final java.util.NavigableMap<java.lang.String,KexExtensionParser<?>> EXTENSION_PARSERS
A case insensitive map of all the default knownKexExtensionParserwhere key=the extension name
-
-
Method Detail
-
getRegisteredExtensionParserNames
public static java.util.NavigableSet<java.lang.String> getRegisteredExtensionParserNames()
- Returns:
- A case insensitive copy of the currently registered
KexExtensionParsers names
-
getRegisteredExtensionParser
public static KexExtensionParser<?> getRegisteredExtensionParser(java.lang.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(java.lang.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 java.util.List<java.util.Map.Entry<java.lang.String,?>> parseExtensions(Buffer buffer) throws java.io.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:
java.io.IOException- If failed to parse one of the extensions- See Also:
- RFC-8308 - section 2.3
-
putExtensions
public static void putExtensions(java.util.Collection<? extends java.util.Map.Entry<java.lang.String,?>> exts, Buffer buffer) throws java.io.IOExceptionCreates 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:
java.io.IOException- If failed to encode
-
-