Class Ssh2PublicKeyEntryDecoder
java.lang.Object
org.apache.sshd.common.config.keys.loader.ssh2.Ssh2PublicKeyEntryDecoder
- All Implemented Interfaces:
KeyTypeNamesSupport
,PublicKeyEntryResolver
,PublicKeyRawDataDecoder<PublicKey>
,PublicKeyRawDataReader<PublicKey>
public class Ssh2PublicKeyEntryDecoder
extends Object
implements PublicKeyRawDataDecoder<PublicKey>, PublicKeyEntryResolver, PublicKeyRawDataReader<PublicKey>, KeyTypeNamesSupport
Decodes a public key file encoded according to The Secure Shell (SSH)
Public Key File Format
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final char
According to RFC-4716 section 3.3:static final Ssh2PublicKeyEntryDecoder
static final NavigableSet<String>
Fields inherited from interface org.apache.sshd.common.config.keys.PublicKeyEntryResolver
FAILING, IGNORING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodePublicKey
(SessionContext session, String keyType, InputStream keyData, Map<String, String> headers) decodePublicKeyByType
(SessionContext session, String keyType, InputStream keyData, Map<String, String> headers) readPublicKey
(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, byte[] dataBytes, Map<String, String> headers) readPublicKey
(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, List<String> lines, Map<String, String> headers) readPublicKey
(SessionContext session, NamedResource resourceKey, List<String> lines) separateDataLinesFromHeaders
(SessionContext session, NamedResource resourceKey, String startLine, String endLine, List<String> lines) 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.config.keys.PublicKeyRawDataDecoder
decodePublicKey, decodePublicKey
Methods inherited from interface org.apache.sshd.common.config.keys.PublicKeyRawDataReader
readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey, readPublicKey
-
Field Details
-
SUPPORTED_KEY_TYPES
-
BEGIN_MARKER
- See Also:
-
START_MARKERS
-
END_MARKER
- See Also:
-
STOP_MARKERS
-
HEADER_CONTINUATION_INDICATOR
public static final char HEADER_CONTINUATION_INDICATORAccording to RFC-4716 section 3.3:A line is continued if the last character in the line is a "\". If the last character of a line is a "\", then the logical contents of the line are formed by removing the "\" and the line termination characters, and appending the contents of the next line.
- See Also:
-
INSTANCE
-
-
Constructor Details
-
Ssh2PublicKeyEntryDecoder
public Ssh2PublicKeyEntryDecoder()
-
-
Method Details
-
getSupportedKeyTypes
- Specified by:
getSupportedKeyTypes
in interfaceKeyTypeNamesSupport
- Returns:
- The case insensitive
NavigableSet
ofOpenSSH
key type names that are supported by this decoder - e.g.,ssh-rsa, ssh-dss, ecdsa-sha2-nistp384
. This is not a single name - e.g., ECDSA keys have several curve names. Caveat: this collection may be un-modifiable...
-
resolve
public PublicKey resolve(SessionContext session, String keyType, byte[] keyData, Map<String, String> headers) throws IOException, GeneralSecurityException- Specified by:
resolve
in interfacePublicKeyEntryResolver
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).keyType
- TheOpenSSH
reported key typekeyData
- TheOpenSSH
encoded key dataheaders
- Any headers that may have been available when data was read- Returns:
- The extracted
PublicKey
- ignored ifnull
- Throws:
IOException
- If failed to parse the key dataGeneralSecurityException
- If failed to generate the key
-
decodePublicKey
public PublicKey decodePublicKey(SessionContext session, String keyType, InputStream keyData, Map<String, String> headers) throws IOException, GeneralSecurityException- Specified by:
decodePublicKey
in interfacePublicKeyRawDataDecoder<PublicKey>
- Parameters:
session
- TheSessionContext
for invoking this command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).keyType
- The reported / encode key typekeyData
- The key data bytes stream positioned after the key type decoding and making sure it is one of the supported typesheaders
- Any headers that may have been available when data was read- Returns:
- The decoded
PublicKey
- Throws:
IOException
- If failed to read from the data streamGeneralSecurityException
- If failed to generate the key
-
decodePublicKeyByType
public PublicKey decodePublicKeyByType(SessionContext session, String keyType, InputStream keyData, Map<String, String> headers) throws IOException, GeneralSecurityException- Specified by:
decodePublicKeyByType
in interfacePublicKeyRawDataDecoder<PublicKey>
- Throws:
IOException
GeneralSecurityException
-
readPublicKey
public PublicKey readPublicKey(SessionContext session, NamedResource resourceKey, List<String> lines) throws IOException, GeneralSecurityException - Specified by:
readPublicKey
in interfacePublicKeyRawDataReader<PublicKey>
- Throws:
IOException
GeneralSecurityException
-
readPublicKey
public PublicKey readPublicKey(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, List<String> lines, Map<String, String> headers) throws IOException, GeneralSecurityException- Throws:
IOException
GeneralSecurityException
-
readPublicKey
public PublicKey readPublicKey(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, byte[] dataBytes, Map<String, String> headers) throws IOException, GeneralSecurityException- Throws:
IOException
GeneralSecurityException
-
separateDataLinesFromHeaders
protected Map.Entry<Map<String,String>, separateDataLinesFromHeadersList<String>> (SessionContext session, NamedResource resourceKey, String startLine, String endLine, List<String> lines) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-