Class MappedKeyPairProvider
- java.lang.Object
-
- org.apache.sshd.common.keyprovider.MappedKeyPairProvider
-
- All Implemented Interfaces:
KeyIdentityProvider
,KeyPairProvider
public class MappedKeyPairProvider extends java.lang.Object implements KeyPairProvider
Holds aMap
ofString
->KeyPair
where the map key is the type and value is the associatedKeyPair
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Function<java.util.Map<java.lang.String,java.security.KeyPair>,KeyPairProvider>
MAP_TO_KEY_PAIR_PROVIDER
Transforms aMap
ofString
->KeyPair
to aKeyPairProvider
where map key is the type and value is the associatedKeyPair
private java.util.Map<java.lang.String,java.security.KeyPair>
pairsMap
-
Fields inherited from interface org.apache.sshd.common.keyprovider.KeyIdentityProvider
EMPTY_KEYS_PROVIDER
-
Fields inherited from interface org.apache.sshd.common.keyprovider.KeyPairProvider
ECDSA_SHA2_NISTP256, ECDSA_SHA2_NISTP384, ECDSA_SHA2_NISTP521, EMPTY_KEYPAIR_PROVIDER, SSH_DSS, SSH_DSS_CERT, SSH_ECDSA_SHA2_NISTP256_CERT, SSH_ECDSA_SHA2_NISTP384_CERT, SSH_ECDSA_SHA2_NISTP521_CERT, SSH_ED25519, SSH_ED25519_CERT, SSH_RSA, SSH_RSA_CERT
-
-
Constructor Summary
Constructors Constructor Description MappedKeyPairProvider(java.security.KeyPair... pairs)
MappedKeyPairProvider(java.util.Collection<? extends java.security.KeyPair> pairs)
MappedKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> pairsMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<java.lang.String>
getKeyTypes(SessionContext session)
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}".java.lang.Iterable<java.security.KeyPair>
loadKeys(SessionContext session)
Load available keys.static java.util.Map<java.lang.String,java.security.KeyPair>
mapUniquePairs(java.util.Collection<? extends java.security.KeyPair> pairs)
java.lang.String
toString()
-
-
-
Field Detail
-
MAP_TO_KEY_PAIR_PROVIDER
public static final java.util.function.Function<java.util.Map<java.lang.String,java.security.KeyPair>,KeyPairProvider> MAP_TO_KEY_PAIR_PROVIDER
Transforms aMap
ofString
->KeyPair
to aKeyPairProvider
where map key is the type and value is the associatedKeyPair
-
pairsMap
private final java.util.Map<java.lang.String,java.security.KeyPair> pairsMap
-
-
Constructor Detail
-
MappedKeyPairProvider
public MappedKeyPairProvider(java.security.KeyPair... pairs)
-
MappedKeyPairProvider
public MappedKeyPairProvider(java.util.Collection<? extends java.security.KeyPair> pairs)
-
MappedKeyPairProvider
public MappedKeyPairProvider(java.util.Map<java.lang.String,java.security.KeyPair> pairsMap)
-
-
Method Detail
-
loadKeys
public java.lang.Iterable<java.security.KeyPair> loadKeys(SessionContext session)
Description copied from interface:KeyIdentityProvider
Load available keys.- Specified by:
loadKeys
in interfaceKeyIdentityProvider
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).- Returns:
- an
Iterable
instance of available keys - ignored ifnull
-
loadKey
public java.security.KeyPair loadKey(SessionContext session, java.lang.String type)
Description copied from interface:KeyPairProvider
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
- Specified by:
loadKey
in interfaceKeyPairProvider
- 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
-
getKeyTypes
public java.lang.Iterable<java.lang.String> getKeyTypes(SessionContext session)
- Specified by:
getKeyTypes
in interfaceKeyPairProvider
- 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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
mapUniquePairs
public static java.util.Map<java.lang.String,java.security.KeyPair> mapUniquePairs(java.util.Collection<? extends java.security.KeyPair> pairs)
-
-