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.StringECDSA_SHA2_NISTP256SSH identifier for EC keys in NIST curve P-256static java.lang.StringECDSA_SHA2_NISTP384SSH identifier for EC keys in NIST curve P-384static java.lang.StringECDSA_SHA2_NISTP521SSH identifier for EC keys in NIST curve P-521static KeyPairProviderEMPTY_KEYPAIR_PROVIDERAKeyPairProviderthat has no keysstatic java.lang.StringSSH_DSSSSH identifier for DSA keysstatic java.lang.StringSSH_DSS_CERTstatic java.lang.StringSSH_ECDSA_SHA2_NISTP256_CERTstatic java.lang.StringSSH_ECDSA_SHA2_NISTP384_CERTstatic java.lang.StringSSH_ECDSA_SHA2_NISTP521_CERTstatic java.lang.StringSSH_ED25519SSH identifier for ED25519 elliptic curve keysstatic java.lang.StringSSH_ED25519_CERTstatic java.lang.StringSSH_RSASSH identifier for RSA keysstatic java.lang.StringSSH_RSA_CERTSSH 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.KeyPairloadKey(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 KeyPairProviderwrap(java.lang.Iterable<java.security.KeyPair> pairs)Wrap the providedKeyPairs into aKeyPairProviderstatic KeyPairProviderwrap(java.security.KeyPair... pairs)Wrap the providedKeyPairs 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
AKeyPairProviderthat 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- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool).type- the type of key to load- Returns:
- a valid key pair or
nullif 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- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool).- Returns:
- The available
Iterablekey 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 providedKeyPairs 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 providedKeyPairs into aKeyPairProvider- Parameters:
pairs- The available pairsIterable- ignored ifnull(i.e., returnsEMPTY_KEYPAIR_PROVIDER)- Returns:
- The provider wrapper
-
-