Class MappedKeyPairProvider

  • All Implemented Interfaces:
    KeyIdentityProvider, KeyPairProvider

    public class MappedKeyPairProvider
    extends java.lang.Object
    implements KeyPairProvider
    Holds a Map of String->KeyPair where the map key is the type and value is the associated KeyPair
    • 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 a Map of String->KeyPair to a KeyPairProvider where map key is the type and value is the associated KeyPair
      • 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 interface KeyIdentityProvider
        Parameters:
        session - The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
        Returns:
        an Iterable instance of available keys - ignored if null
      • 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, return null
        Specified by:
        loadKey in interface KeyPairProvider
        Parameters:
        session - The SessionContext for invoking this load command - may be null 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 interface KeyPairProvider
        Parameters:
        session - The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool).
        Returns:
        The available Iterable key types - never null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • mapUniquePairs

        public static java.util.Map<java.lang.String,​java.security.KeyPair> mapUniquePairs​(java.util.Collection<? extends java.security.KeyPair> pairs)