Interface PrivateKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
- Type Parameters:
PUB
- Type ofPublicKey
PRV
- Type ofPrivateKey
- All Superinterfaces:
IdentityResourceLoader<PUB,
,PRV> KeyEntryResolver<PUB,
,PRV> KeyTypeNamesSupport
,PrivateKeyEntryResolver
- All Known Implementing Classes:
AbstractPrivateKeyEntryDecoder
,OpenSSHDSSPrivateKeyEntryDecoder
,OpenSSHECDSAPrivateKeyEntryDecoder
,OpenSSHEd25519PrivateKeyEntryDecoder
,OpenSSHRSAPrivateKeyDecoder
public interface PrivateKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
extends KeyEntryResolver<PUB,PRV>, PrivateKeyEntryResolver
-
Field Summary
Fields inherited from interface org.apache.sshd.common.config.keys.IdentityResourceLoader
MAX_BIGINT_OCTETS_COUNT
Fields inherited from interface org.apache.sshd.common.config.keys.PrivateKeyEntryResolver
FAILING, IGNORING
-
Method Summary
Modifier and TypeMethodDescriptiondecodePrivateKey
(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData) default PRV
decodePrivateKey
(SessionContext session, FilePasswordProvider passwordProvider, byte... keyData) default PRV
decodePrivateKey
(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length) default PRV
decodePrivateKey
(SessionContext session, FilePasswordProvider passwordProvider, InputStream keyData) default String
encodePrivateKey
(SecureByteArrayOutputStream s, PRV key, PUB pubKey) default boolean
default PUB
recoverPublicKey
(PRV prvKey) Attempts to recover the public key given the private onedefault PrivateKey
resolve
(SessionContext session, String keyType, byte[] keyData) Methods inherited from interface org.apache.sshd.common.config.keys.IdentityResourceLoader
getPrivateKeyType, getPublicKeyType
Methods inherited from interface org.apache.sshd.common.config.keys.KeyEntryResolver
cloneKeyPair, clonePrivateKey, clonePublicKey, generateKeyPair, getKeyFactoryInstance, getKeyPairGenerator
Methods inherited from interface org.apache.sshd.common.config.keys.KeyTypeNamesSupport
getSupportedKeyTypes
-
Method Details
-
resolve
default PrivateKey resolve(SessionContext session, String keyType, byte[] keyData) throws IOException, GeneralSecurityException - Specified by:
resolve
in interfacePrivateKeyEntryResolver
- 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 data- Returns:
- The extracted
PrivateKey
- ignored ifnull
- Throws:
IOException
- If failed to parse the key dataGeneralSecurityException
- If failed to generate the key
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte... keyData) throws IOException, GeneralSecurityException - Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).passwordProvider
- TheFilePasswordProvider
to use in case the data is encrypted - may benull
if no encrypted data is expectedkeyData
- The key data bytes inOpenSSH
format (after BASE64 decoding) - ignored ifnull
/empty- Returns:
- The decoded
PrivateKey
- ornull
if no data - Throws:
IOException
- If failed to decode the keyGeneralSecurityException
- If failed to generate the key
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException - Throws:
IOException
GeneralSecurityException
-
decodePrivateKey
PRV decodePrivateKey(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException - 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
- The reported / encode key typepasswordProvider
- TheFilePasswordProvider
to use in case the data is encrypted - may benull
if no encrypted data is expectedkeyData
- The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types- Returns:
- The decoded
PrivateKey
- Throws:
IOException
- If failed to read from the data streamGeneralSecurityException
- If failed to generate the key
-
encodePrivateKey
default String encodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey) throws IOException - Parameters:
s
- TheSecureByteArrayOutputStream
to write the data to.key
- ThePrivateKey
- may not benull
pubKey
- ThePublicKey
belonging to the private key - must be non-null
ifpublic key recovery
is not supported- Returns:
- The key type value - one of the
KeyTypeNamesSupport.getSupportedKeyTypes()
ornull
if encoding not supported - Throws:
IOException
- If failed to generate the encoding
-
isPublicKeyRecoverySupported
default boolean isPublicKeyRecoverySupported() -
recoverPublicKey
Attempts to recover the public key given the private one- Parameters:
prvKey
- ThePrivateKey
- Returns:
- The recovered
PublicKey
-null
if cannot recover it - Throws:
GeneralSecurityException
- If failed to generate the public key
-