Top Description Fields Constructors Methods
org.apache.sshd.common.kex.extension

public final Class KexExtensions

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.AbstractMap.SimpleImmutableEntry, .ArrayList, .Collection, .Collections, .List, .Map, .NavigableMap, .NavigableSet, .Objects, .TreeMap, java.util.function.Function, .Predicate, java.util.stream.Collectors, .Stream, org.apache.sshd.common.NamedResource, org.apache.sshd.common.kex.extension.parser.DelayCompression, .Elevation, .NoFlowControl, .ServerSignatureAlgorithms, org.apache.sshd.common.util.GenericUtils, .MapEntryUtils, .Readable, .ValidateUtils, org.apache.sshd.common.util.buffer.Buffer

Provides some helpers for RFC 8308
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final String
private static final NavigableMap<String, KexExtensionParser<?>>
EXTENSION_PARSERS

A case insensitive map of all the default known KexExtensionParser where key=the extension name

public static final Predicate<String>
public static final String
public static final byte
public static final byte
public static final 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.

public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static KexExtensionParser<?>

Returns:

The registered KexExtensionParser for the (case insensitive) extension name - null if no match found
getRegisteredExtensionParser
(String
The (never null/empty) extension name
name
)

public static NavigableSet<String>

Returns:

A case insensitive copy of the currently registered KexExtensionParsers names
getRegisteredExtensionParserNames
()

public static List<Map.Entry<String, ?>>

Returns:

A List of key/value "pairs" where key=the extension name, value=the parsed value using the matching registered KexExtensionParser. If no such parser found then the raw value bytes are set as the extension value.
parseExtensions
(Buffer
The Buffer containing the message
buffer
)

Attempts to parse an SSH_MSG_EXT_INFO message

public static void
putExtensions(Collection<? extends Map.Entry<String, ?>>
A Collection of key/value "pairs" where key=the extension name, value=the extension value

Note

if a registered KexExtensionParser 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 another Readable (e.g., another Buffer) or a ByteBuffer.

exts
,
Buffer
The target Buffer - assumed to already contain the SSH_MSG_EXT_INFO opcode
buffer
)

Creates an SSH_MSG_EXT_INFO message using the provided extensions.

public static KexExtensionParser<?>

Returns:

The replaced parser for the named extension (case insensitive) - null if no previous parser registered for this extension
registerExtensionParser
(KexExtensionParser<?>
The (never null) parser to register
parser
)

Registers a KexExtensionParser for a named extension

public static KexExtensionParser<?>

Returns:

The removed KexExtensionParser for the (case insensitive) extension name - null if no match found
unregisterExtensionParser
(String
The (never null/empty) extension name
name
)

Registers KexExtensionParser for a named extension

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLIENT_KEX_EXTENSIONback to summary
public static final String CLIENT_KEX_EXTENSION
EXTENSION_PARSERSback to summary
private static final NavigableMap<String, KexExtensionParser<?>> EXTENSION_PARSERS

A case insensitive map of all the default known KexExtensionParser where key=the extension name

IS_KEX_EXTENSION_SIGNALback to summary
public static final Predicate<String> IS_KEX_EXTENSION_SIGNAL
SERVER_KEX_EXTENSIONback to summary
public static final String SERVER_KEX_EXTENSION
SSH_MSG_EXT_INFOback to summary
public static final byte SSH_MSG_EXT_INFO
SSH_MSG_NEWCOMPRESSback to summary
public static final byte SSH_MSG_NEWCOMPRESS
STRICT_KEX_CLIENT_EXTENSIONback to summary
public static final 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.

See Also
OpenSSH PROTOCOL - 1.9 transport: strict key exchange extension
STRICT_KEX_SERVER_EXTENSIONback to summary
public static final String STRICT_KEX_SERVER_EXTENSION

Constructor Detail

KexExtensionsback to summary
private KexExtensions()

Method Detail

getRegisteredExtensionParserback to summary
public static KexExtensionParser<?> getRegisteredExtensionParser(String name)
Parameters
name:String

The (never null/empty) extension name

Returns:KexExtensionParser<?>

The registered KexExtensionParser for the (case insensitive) extension name - null if no match found

getRegisteredExtensionParserNamesback to summary
public static NavigableSet<String> getRegisteredExtensionParserNames()
Returns:NavigableSet<String>

A case insensitive copy of the currently registered KexExtensionParsers names

parseExtensionsback to summary
public static List<Map.Entry<String, ?>> parseExtensions(Buffer buffer) throws IOException

Attempts to parse an SSH_MSG_EXT_INFO message

Parameters
buffer:Buffer

The Buffer containing the message

Returns:List<Map.Entry<String, ?>>

A List of key/value "pairs" where key=the extension name, value=the parsed value using the matching registered KexExtensionParser. If no such parser found then the raw value bytes are set as the extension value.

Exceptions
IOException:
If failed to parse one of the extensions
See Also
RFC-8308 - section 2.3
putExtensionsback to summary
public static void putExtensions(Collection<? extends Map.Entry<String, ?>> exts, Buffer buffer) throws IOException

Creates an SSH_MSG_EXT_INFO message using the provided extensions.

Parameters
exts:Collection<? extends Map.Entry<String, ?>>

A Collection of key/value "pairs" where key=the extension name, value=the extension value

Note

if a registered KexExtensionParser 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 another Readable (e.g., another Buffer) or a ByteBuffer.

buffer:Buffer

The target Buffer - assumed to already contain the SSH_MSG_EXT_INFO opcode

Exceptions
IOException:
If failed to encode
registerExtensionParserback to summary
public static KexExtensionParser<?> registerExtensionParser(KexExtensionParser<?> parser)

Registers a KexExtensionParser for a named extension

Parameters
parser:KexExtensionParser<?>

The (never null) parser to register

Returns:KexExtensionParser<?>

The replaced parser for the named extension (case insensitive) - null if no previous parser registered for this extension

unregisterExtensionParserback to summary
public static KexExtensionParser<?> unregisterExtensionParser(String name)

Registers KexExtensionParser for a named extension

Parameters
name:String

The (never null/empty) extension name

Returns:KexExtensionParser<?>

The removed KexExtensionParser for the (case insensitive) extension name - null if no match found