Interface PrivateKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
-
- Type Parameters:
PUB- Type ofPublicKeyPRV- 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
- Author:
- Apache MINA SSHD Project
-
-
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 PRVdecodePrivateKey(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData)default PRVdecodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte... keyData)default PRVdecodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length)default PRVdecodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, InputStream keyData)default StringencodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey)default booleanisPublicKeyRecoverySupported()default PUBrecoverPublicKey(PRV prvKey)Attempts to recover the public key given the private onedefault PrivateKeyresolve(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 Detail
-
resolve
default PrivateKey resolve(SessionContext session, String keyType, byte[] keyData) throws IOException, GeneralSecurityException
- Specified by:
resolvein interfacePrivateKeyEntryResolver- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).keyType- TheOpenSSHreported key typekeyData- TheOpenSSHencoded 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- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).passwordProvider- TheFilePasswordProviderto use in case the data is encrypted - may benullif no encrypted data is expectedkeyData- The key data bytes inOpenSSHformat (after BASE64 decoding) - ignored ifnull/empty- Returns:
- The decoded
PrivateKey- ornullif 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:
IOExceptionGeneralSecurityException
-
decodePrivateKey
default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException
- Throws:
IOExceptionGeneralSecurityException
-
decodePrivateKey
PRV decodePrivateKey(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException
- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).keyType- The reported / encode key typepasswordProvider- TheFilePasswordProviderto use in case the data is encrypted - may benullif 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- TheSecureByteArrayOutputStreamto write the data to.key- ThePrivateKey- may not benullpubKey- ThePublicKeybelonging to the private key - must be non-nullifpublic key recoveryis not supported- Returns:
- The key type value - one of the
KeyTypeNamesSupport.getSupportedKeyTypes()ornullif encoding not supported - Throws:
IOException- If failed to generate the encoding
-
isPublicKeyRecoverySupported
default boolean isPublicKeyRecoverySupported()
-
recoverPublicKey
default PUB recoverPublicKey(PRV prvKey) throws GeneralSecurityException
Attempts to recover the public key given the private one- Parameters:
prvKey- ThePrivateKey- Returns:
- The recovered
PublicKey-nullif cannot recover it - Throws:
GeneralSecurityException- If failed to generate the public key
-
-