Class OpenSSHRSAPrivateKeyDecoder
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.config.keys.impl.AbstractIdentityResourceLoader<PUB,PRV>
-
- org.apache.sshd.common.config.keys.impl.AbstractKeyEntryResolver<PUB,PRV>
-
- org.apache.sshd.common.config.keys.impl.AbstractPrivateKeyEntryDecoder<RSAPublicKey,RSAPrivateKey>
-
- org.apache.sshd.common.config.keys.loader.openssh.OpenSSHRSAPrivateKeyDecoder
-
- All Implemented Interfaces:
IdentityResourceLoader<RSAPublicKey,RSAPrivateKey>
,KeyEntryResolver<RSAPublicKey,RSAPrivateKey>
,KeyTypeNamesSupport
,PrivateKeyEntryDecoder<RSAPublicKey,RSAPrivateKey>
,PrivateKeyEntryResolver
public class OpenSSHRSAPrivateKeyDecoder extends AbstractPrivateKeyEntryDecoder<RSAPublicKey,RSAPrivateKey>
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static BigInteger
DEFAULT_PUBLIC_EXPONENT
static OpenSSHRSAPrivateKeyDecoder
INSTANCE
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
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
-
-
Constructor Summary
Constructors Constructor Description OpenSSHRSAPrivateKeyDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RSAPrivateKey
clonePrivateKey(RSAPrivateKey key)
RSAPublicKey
clonePublicKey(RSAPublicKey key)
RSAPrivateKey
decodePrivateKey(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData)
KeyFactory
getKeyFactoryInstance()
KeyPairGenerator
getKeyPairGenerator()
boolean
isPublicKeyRecoverySupported()
RSAPublicKey
recoverPublicKey(RSAPrivateKey privateKey)
Attempts to recover the public key given the private one-
Methods inherited from class org.apache.sshd.common.config.keys.impl.AbstractKeyEntryResolver
generatePrivateKey, generatePublicKey, toString
-
Methods inherited from class org.apache.sshd.common.config.keys.impl.AbstractIdentityResourceLoader
getPrivateKeyType, getPublicKeyType, getSupportedKeyTypes
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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, generateKeyPair
-
Methods inherited from interface org.apache.sshd.common.config.keys.KeyTypeNamesSupport
getSupportedKeyTypes
-
Methods inherited from interface org.apache.sshd.common.config.keys.PrivateKeyEntryDecoder
decodePrivateKey, decodePrivateKey, decodePrivateKey, encodePrivateKey, resolve
-
-
-
-
Field Detail
-
DEFAULT_PUBLIC_EXPONENT
public static final BigInteger DEFAULT_PUBLIC_EXPONENT
-
INSTANCE
public static final OpenSSHRSAPrivateKeyDecoder INSTANCE
-
-
Method Detail
-
decodePrivateKey
public RSAPrivateKey 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
-
isPublicKeyRecoverySupported
public boolean isPublicKeyRecoverySupported()
-
recoverPublicKey
public RSAPublicKey recoverPublicKey(RSAPrivateKey privateKey) throws GeneralSecurityException
Description copied from interface:PrivateKeyEntryDecoder
Attempts to recover the public key given the private one- Parameters:
privateKey
- ThePrivateKey
- Returns:
- The recovered
PublicKey
-null
if cannot recover it - Throws:
GeneralSecurityException
- If failed to generate the public key
-
clonePublicKey
public RSAPublicKey clonePublicKey(RSAPublicKey key) throws GeneralSecurityException
- Parameters:
key
- ThePublicKey
to clone - ignored ifnull
- Returns:
- The cloned key (or
null
if no original key) - Throws:
GeneralSecurityException
- If failed to clone the key
-
clonePrivateKey
public RSAPrivateKey clonePrivateKey(RSAPrivateKey key) throws GeneralSecurityException
- Parameters:
key
- ThePrivateKey
to clone - ignored ifnull
- Returns:
- The cloned key (or
null
if no original key) - Throws:
GeneralSecurityException
- If failed to clone the key
-
getKeyPairGenerator
public KeyPairGenerator getKeyPairGenerator() throws GeneralSecurityException
- Returns:
- A
KeyPairGenerator
suitable for this decoder - Throws:
GeneralSecurityException
- If failed to create the generator
-
getKeyFactoryInstance
public KeyFactory getKeyFactoryInstance() throws GeneralSecurityException
- Returns:
- A
KeyFactory
suitable for the specific decoder type - Throws:
GeneralSecurityException
- If failed to create one
-
-