Interface KeyPairProvider
-
- All Superinterfaces:
KeyIdentityProvider
- All Known Implementing Classes:
AbstractGeneratorHostKeyProvider
,AbstractKeyPairProvider
,AbstractResourceKeyPairProvider
,BouncyCastleGeneratorHostKeyProvider
,BuiltinClientIdentitiesWatcher
,ClassLoadableResourceKeyPairProvider
,ClientIdentitiesWatcher
,DefaultClientIdentitiesWatcher
,FileKeyPairProvider
,MappedKeyPairProvider
,SimpleGeneratorHostKeyProvider
public interface KeyPairProvider extends KeyIdentityProvider
Provider for key pairs. This provider is used on the server side to provide the host key, or on the client side to provide the user key.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ECDSA_SHA2_NISTP256
SSH identifier for EC keys in NIST curve P-256static java.lang.String
ECDSA_SHA2_NISTP384
SSH identifier for EC keys in NIST curve P-384static java.lang.String
ECDSA_SHA2_NISTP521
SSH identifier for EC keys in NIST curve P-521static KeyPairProvider
EMPTY_KEYPAIR_PROVIDER
AKeyPairProvider
that has no keysstatic java.lang.String
SSH_DSS
SSH identifier for DSA keysstatic java.lang.String
SSH_DSS_CERT
static java.lang.String
SSH_ECDSA_SHA2_NISTP256_CERT
static java.lang.String
SSH_ECDSA_SHA2_NISTP384_CERT
static java.lang.String
SSH_ECDSA_SHA2_NISTP521_CERT
static java.lang.String
SSH_ED25519
SSH identifier for ED25519 elliptic curve keysstatic java.lang.String
SSH_ED25519_CERT
static java.lang.String
SSH_RSA
SSH identifier for RSA keysstatic java.lang.String
SSH_RSA_CERT
SSH identifier for openssh cert keys-
Fields inherited from interface org.apache.sshd.common.keyprovider.KeyIdentityProvider
EMPTY_KEYS_PROVIDER
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default java.lang.Iterable<java.lang.String>
getKeyTypes(SessionContext session)
default java.security.KeyPair
loadKey(SessionContext session, java.lang.String type)
Load a key of the specified type which can be "ssh-rsa", "ssh-dss", or "ecdsa-sha2-nistp{256,384,521}".static KeyPairProvider
wrap(java.lang.Iterable<java.security.KeyPair> pairs)
Wrap the providedKeyPair
s into aKeyPairProvider
static KeyPairProvider
wrap(java.security.KeyPair... pairs)
Wrap the providedKeyPair
s into aKeyPairProvider
-
Methods inherited from interface org.apache.sshd.common.keyprovider.KeyIdentityProvider
loadKeys
-
-
-
-
Field Detail
-
SSH_RSA
static final java.lang.String SSH_RSA
SSH identifier for RSA keys- See Also:
- Constant Field Values
-
SSH_DSS
static final java.lang.String SSH_DSS
SSH identifier for DSA keys- See Also:
- Constant Field Values
-
SSH_ED25519
static final java.lang.String SSH_ED25519
SSH identifier for ED25519 elliptic curve keys- See Also:
- Constant Field Values
-
ECDSA_SHA2_NISTP256
static final java.lang.String ECDSA_SHA2_NISTP256
SSH identifier for EC keys in NIST curve P-256
-
ECDSA_SHA2_NISTP384
static final java.lang.String ECDSA_SHA2_NISTP384
SSH identifier for EC keys in NIST curve P-384
-
ECDSA_SHA2_NISTP521
static final java.lang.String ECDSA_SHA2_NISTP521
SSH identifier for EC keys in NIST curve P-521
-
SSH_RSA_CERT
static final java.lang.String SSH_RSA_CERT
SSH identifier for openssh cert keys- See Also:
- Constant Field Values
-
SSH_DSS_CERT
static final java.lang.String SSH_DSS_CERT
- See Also:
- Constant Field Values
-
SSH_ED25519_CERT
static final java.lang.String SSH_ED25519_CERT
- See Also:
- Constant Field Values
-
SSH_ECDSA_SHA2_NISTP256_CERT
static final java.lang.String SSH_ECDSA_SHA2_NISTP256_CERT
- See Also:
- Constant Field Values
-
SSH_ECDSA_SHA2_NISTP384_CERT
static final java.lang.String SSH_ECDSA_SHA2_NISTP384_CERT
- See Also:
- Constant Field Values
-
SSH_ECDSA_SHA2_NISTP521_CERT
static final java.lang.String SSH_ECDSA_SHA2_NISTP521_CERT
- See Also:
- Constant Field Values
-
EMPTY_KEYPAIR_PROVIDER
static final KeyPairProvider EMPTY_KEYPAIR_PROVIDER
AKeyPairProvider
that has no keys
-
-
Method Detail
-
loadKey
default java.security.KeyPair loadKey(SessionContext session, java.lang.String type) throws java.io.IOException, java.security.GeneralSecurityException
Load a key of the specified type which can be "ssh-rsa", "ssh-dss", or "ecdsa-sha2-nistp{256,384,521}". If there is no key of this type, returnnull
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool).type
- the type of key to load- Returns:
- a valid key pair or
null
if this type of key is not available - Throws:
java.io.IOException
- If failed to read/parse the keys datajava.security.GeneralSecurityException
- If failed to generate the keys
-
getKeyTypes
default java.lang.Iterable<java.lang.String> getKeyTypes(SessionContext session) 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).- Returns:
- The available
Iterable
key types - nevernull
- Throws:
java.io.IOException
- If failed to read/parse the keys datajava.security.GeneralSecurityException
- If failed to generate the keys
-
wrap
static KeyPairProvider wrap(java.security.KeyPair... pairs)
Wrap the providedKeyPair
s into aKeyPairProvider
- Parameters:
pairs
- The available pairs - ignored ifnull
/empty (i.e., returnsEMPTY_KEYPAIR_PROVIDER
)- Returns:
- The provider wrapper
- See Also:
wrap(Iterable)
-
wrap
static KeyPairProvider wrap(java.lang.Iterable<java.security.KeyPair> pairs)
Wrap the providedKeyPair
s into aKeyPairProvider
- Parameters:
pairs
- The available pairsIterable
- ignored ifnull
(i.e., returnsEMPTY_KEYPAIR_PROVIDER
)- Returns:
- The provider wrapper
-
-