Interface PrivateKeyEntryDecoder<PUB extends java.security.PublicKey,PRV extends java.security.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 java.security.PublicKey,PRV extends java.security.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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description PRV
decodePrivateKey(SessionContext session, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.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, java.io.InputStream keyData)
default java.lang.String
encodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey)
Encodes thePrivateKey
using theOpenSSH
format - same one used by thedecodePublicKey
method(s)default boolean
isPublicKeyRecoverySupported()
default PUB
recoverPublicKey(PRV prvKey)
Attempts to recover the public key given the private onedefault java.security.PrivateKey
resolve(SessionContext session, java.lang.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 Detail
-
resolve
default java.security.PrivateKey resolve(SessionContext session, java.lang.String keyType, byte[] keyData) throws java.io.IOException, java.security.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:
java.io.IOException
- If failed to parse the key datajava.security.GeneralSecurityException
- If failed to generate the key
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte... keyData) throws java.io.IOException, java.security.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:
java.io.IOException
- If failed to decode the keyjava.security.GeneralSecurityException
- If failed to generate the key
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length) throws java.io.IOException, java.security.GeneralSecurityException
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, java.io.InputStream keyData) throws java.io.IOException, java.security.GeneralSecurityException
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
decodePrivateKey
PRV decodePrivateKey(SessionContext session, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.InputStream keyData) throws java.io.IOException, java.security.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:
java.io.IOException
- If failed to read from the data streamjava.security.GeneralSecurityException
- If failed to generate the key
-
encodePrivateKey
default java.lang.String encodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey) throws java.io.IOException
Encodes thePrivateKey
using theOpenSSH
format - same one used by thedecodePublicKey
method(s)- 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:
java.io.IOException
- If failed to generate the encoding
-
isPublicKeyRecoverySupported
default boolean isPublicKeyRecoverySupported()
-
recoverPublicKey
default PUB recoverPublicKey(PRV prvKey) throws java.security.GeneralSecurityException
Attempts to recover the public key given the private one- Parameters:
prvKey
- ThePrivateKey
- Returns:
- The recovered
PublicKey
-null
if cannot recover it - Throws:
java.security.GeneralSecurityException
- If failed to generate the public key
-
-