Interface KeyIdentityProvider
-
- All Known Subinterfaces:
AuthenticationIdentitiesProvider,KeyPairProvider
- All Known Implementing Classes:
AbstractGeneratorHostKeyProvider,AbstractKeyPairProvider,AbstractResourceKeyPairProvider,BouncyCastleGeneratorHostKeyProvider,BuiltinClientIdentitiesWatcher,ClassLoadableResourceKeyPairProvider,ClientIdentitiesWatcher,DefaultClientIdentitiesWatcher,FileKeyPairProvider,LazyClientKeyIdentityProvider,MappedKeyPairProvider,MultiKeyIdentityProvider,SimpleGeneratorHostKeyProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface KeyIdentityProvider
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static KeyIdentityProviderEMPTY_KEYS_PROVIDERAn "empty" implementation ofKeyIdentityProviderthat returns an empty group of key pairs
-
Method Summary
-
-
-
Field Detail
-
EMPTY_KEYS_PROVIDER
static final KeyIdentityProvider EMPTY_KEYS_PROVIDER
An "empty" implementation ofKeyIdentityProviderthat returns an empty group of key pairs
-
-
Method Detail
-
loadKeys
Iterable<KeyPair> loadKeys(SessionContext session) throws IOException, GeneralSecurityException
Load available keys.- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).- Returns:
- an
Iterableinstance of available keys - ignored ifnull - Throws:
IOException- If failed to read/parse the keys dataGeneralSecurityException- If failed to generate the keys
-
isEmpty
static boolean isEmpty(KeyIdentityProvider provider)
- Parameters:
provider- TheKeyIdentityProviderinstance to verify- Returns:
trueif instance isnullor theEMPTY_KEYS_PROVIDER
-
resolveKeyIdentityProvider
static KeyIdentityProvider resolveKeyIdentityProvider(KeyIdentityProvider identities, KeyIdentityProvider keys)
Creates a "unified"
KeyIdentityProviderout of 2 possible ones as follows:- If both are
nullthen returnnull. - If either one is
null/emptythen use the non-nullone. - If both are the same instance then use the instance.
- Otherwise, returns a wrapper that groups both providers.
- Parameters:
identities- The registered key pair identitieskeys- The extra available key pairs- Returns:
- The resolved provider
- See Also:
multiProvider(KeyIdentityProvider...)
- If both are
-
multiProvider
static KeyIdentityProvider multiProvider(KeyIdentityProvider... providers)
Wraps a group ofKeyIdentityProviderinto a single one- Parameters:
providers- The providers - ignored ifnull/empty (i.e., returnsEMPTY_KEYS_PROVIDER)- Returns:
- The wrapping provider
- See Also:
multiProvider(Collection)
-
multiProvider
static KeyIdentityProvider multiProvider(Collection<? extends KeyIdentityProvider> providers)
Wraps a group ofKeyIdentityProviderinto a single one- Parameters:
providers- The providers - ignored ifnull/empty (i.e., returnsEMPTY_KEYS_PROVIDER)- Returns:
- The wrapping provider
- See Also:
MultiKeyIdentityProvider
-
iterableOf
static Iterable<KeyPair> iterableOf(SessionContext session, Collection<? extends KeyIdentityProvider> providers)
- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).providers- The group of providers - ignored ifnull/empty (i.e., returns an empty iterable instance)- Returns:
- The wrapping iterable
-
wrapKeyPairs
static KeyIdentityProvider wrapKeyPairs(KeyPair... pairs)
Wraps a group ofKeyPairs into aKeyIdentityProvider- Parameters:
pairs- The key pairs - ignored ifnull/empty (i.e., returnsEMPTY_KEYS_PROVIDER).- Returns:
- The provider wrapper
-
wrapKeyPairs
static KeyIdentityProvider wrapKeyPairs(Iterable<KeyPair> pairs)
Wraps a group ofKeyPairs into aKeyIdentityProvider- Parameters:
pairs- The key pairsIterable- ignored ifnull(i.e., returnsEMPTY_KEYS_PROVIDER).- Returns:
- The provider wrapper
-
exhaustCurrentIdentities
static KeyPair exhaustCurrentIdentities(Iterator<? extends KeyPair> ids)
Attempts to find the first non-nullKeyPair- Parameters:
ids- TheIterator- ignored ifnullor no next element available- Returns:
- The first non-
nullkey pair found in the iterator -nullif all elements exhausted without such an entry
-
-