Class OpenSSHECDSAPrivateKeyEntryDecoder
- 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<java.security.interfaces.ECPublicKey,java.security.interfaces.ECPrivateKey>
-
- org.apache.sshd.common.config.keys.loader.openssh.OpenSSHECDSAPrivateKeyEntryDecoder
-
- All Implemented Interfaces:
IdentityResourceLoader<java.security.interfaces.ECPublicKey,java.security.interfaces.ECPrivateKey>
,KeyEntryResolver<java.security.interfaces.ECPublicKey,java.security.interfaces.ECPrivateKey>
,KeyTypeNamesSupport
,PrivateKeyEntryDecoder<java.security.interfaces.ECPublicKey,java.security.interfaces.ECPrivateKey>
,PrivateKeyEntryResolver
public class OpenSSHECDSAPrivateKeyEntryDecoder extends AbstractPrivateKeyEntryDecoder<java.security.interfaces.ECPublicKey,java.security.interfaces.ECPrivateKey>
-
-
Field Summary
Fields Modifier and Type Field Description static OpenSSHECDSAPrivateKeyEntryDecoder
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 OpenSSHECDSAPrivateKeyEntryDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.interfaces.ECPrivateKey
clonePrivateKey(java.security.interfaces.ECPrivateKey key)
java.security.interfaces.ECPublicKey
clonePublicKey(java.security.interfaces.ECPublicKey key)
java.security.interfaces.ECPrivateKey
decodePrivateKey(SessionContext session, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.InputStream keyData)
java.lang.String
encodePrivateKey(java.io.OutputStream s, java.security.interfaces.ECPrivateKey key)
Encodes thePrivateKey
using theOpenSSH
format - same one used by thedecodePublicKey
method(s)java.security.KeyPair
generateKeyPair(int keySize)
java.security.KeyFactory
getKeyFactoryInstance()
java.security.KeyPairGenerator
getKeyPairGenerator()
java.security.interfaces.ECPublicKey
recoverPublicKey(java.security.interfaces.ECPrivateKey prvKey)
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
-
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, isPublicKeyRecoverySupported, resolve
-
-
-
-
Field Detail
-
INSTANCE
public static final OpenSSHECDSAPrivateKeyEntryDecoder INSTANCE
-
-
Method Detail
-
decodePrivateKey
public java.security.interfaces.ECPrivateKey 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
public java.lang.String encodePrivateKey(java.io.OutputStream s, java.security.interfaces.ECPrivateKey key) throws java.io.IOException
Description copied from interface:PrivateKeyEntryDecoder
Encodes thePrivateKey
using theOpenSSH
format - same one used by thedecodePublicKey
method(s)- Parameters:
s
- TheOutputStream
to write the data tokey
- ThePrivateKey
- may not benull
- 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
-
recoverPublicKey
public java.security.interfaces.ECPublicKey recoverPublicKey(java.security.interfaces.ECPrivateKey prvKey) throws java.security.GeneralSecurityException
Description copied from interface:PrivateKeyEntryDecoder
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
-
clonePublicKey
public java.security.interfaces.ECPublicKey clonePublicKey(java.security.interfaces.ECPublicKey key) throws java.security.GeneralSecurityException
- Parameters:
key
- ThePublicKey
to clone - ignored ifnull
- Returns:
- The cloned key (or
null
if no original key) - Throws:
java.security.GeneralSecurityException
- If failed to clone the key
-
clonePrivateKey
public java.security.interfaces.ECPrivateKey clonePrivateKey(java.security.interfaces.ECPrivateKey key) throws java.security.GeneralSecurityException
- Parameters:
key
- ThePrivateKey
to clone - ignored ifnull
- Returns:
- The cloned key (or
null
if no original key) - Throws:
java.security.GeneralSecurityException
- If failed to clone the key
-
getKeyFactoryInstance
public java.security.KeyFactory getKeyFactoryInstance() throws java.security.GeneralSecurityException
- Returns:
- A
KeyFactory
suitable for the specific decoder type - Throws:
java.security.GeneralSecurityException
- If failed to create one
-
generateKeyPair
public java.security.KeyPair generateKeyPair(int keySize) throws java.security.GeneralSecurityException
- Parameters:
keySize
- Key size in bits- Returns:
- A
KeyPair
with the specified key size - Throws:
java.security.GeneralSecurityException
- if unable to generate the pair
-
getKeyPairGenerator
public java.security.KeyPairGenerator getKeyPairGenerator() throws java.security.GeneralSecurityException
- Returns:
- A
KeyPairGenerator
suitable for this decoder - Throws:
java.security.GeneralSecurityException
- If failed to create the generator
-
-