Class OpenSshConfigFile.HostEntry

java.lang.Object
org.eclipse.jgit.internal.transport.ssh.OpenSshConfigFile.HostEntry
All Implemented Interfaces:
SshConfigStore.HostConfig
Enclosing class:
OpenSshConfigFile

public static class OpenSshConfigFile.HostEntry extends Object implements SshConfigStore.HostConfig
A host entry from the ssh config file. Any merging of global values and of several matching host entries, %-substitutions, and ~ replacement have all been done.
  • Field Details

    • MULTI_KEYS

      private static final Set<String> MULTI_KEYS
      Keys that can be specified multiple times, building up a list. (I.e., those are the keys that do not follow the general rule of "first occurrence wins".)
    • LIST_KEYS

      private static final Set<String> LIST_KEYS
      Keys that take a whitespace-separated list of elements as argument. Because the dequote-handling is different, we must handle those in the parser. There are a few other keys that take comma-separated lists as arguments, but for the parser those are single arguments that must be quoted if they contain whitespace, and taking them apart is the responsibility of the user of those keys.
    • ALIASES

      private static final Map<String,String> ALIASES
      OpenSSH has renamed some config keys. This maps old names to new names.
    • options

      private Map<String,String> options
    • multiOptions

      private Map<String,List<String>> multiOptions
    • listOptions

      private Map<String,List<String>> listOptions
    • patterns

      private final List<String> patterns
  • Constructor Details

    • HostEntry

      public HostEntry()
      Constructor used to build the merged entry; never matches anything
    • HostEntry

      public HostEntry(List<String> patterns)
      Parameters:
      patterns - to be used in matching against host name.
  • Method Details

    • matches

      boolean matches(String hostName)
    • toKey

      private static String toKey(String key)
    • getValue

      public String getValue(String key)
      Retrieves the value of a single-valued key, or the first if the key has multiple values. Keys are case-insensitive, so getValue("HostName") == getValue("HOSTNAME").
      Specified by:
      getValue in interface SshConfigStore.HostConfig
      Parameters:
      key - to get the value of
      Returns:
      the value, or null if none
    • getValues

      public List<String> getValues(String key)
      Retrieves the values of a multi or list-valued key. Keys are case-insensitive, so getValue("HostName") == getValue("HOSTNAME").
      Specified by:
      getValues in interface SshConfigStore.HostConfig
      Parameters:
      key - to get the values of
      Returns:
      a possibly empty list of values
    • setValue

      public void setValue(String key, String value)
      Sets the value of a single-valued key if it not set yet, or adds a value to a multi-valued key. If the value is null, the key is removed altogether, whether it is single-, list-, or multi-valued.
      Parameters:
      key - to modify
      value - to set or add
    • setValue

      public void setValue(String key, List<String> values)
      Sets the values of a multi- or list-valued key.
      Parameters:
      key - to set
      values - a non-empty list of values
    • isListKey

      public static boolean isListKey(String key)
      Does the key take a whitespace-separated list of values?
      Parameters:
      key - to check
      Returns:
      true if the key is a list-valued key.
    • merge

      void merge(OpenSshConfigFile.HostEntry entry)
    • substitute

      private List<String> substitute(List<String> values, String allowed, OpenSshConfigFile.Replacer r, boolean withEnv)
    • replaceTilde

      private List<String> replaceTilde(List<String> values, File home)
    • substitute

      void substitute(String originalHostName, int port, String userName, String localUserName, File home, boolean fillDefaults)
    • getOptions

      @NonNull public Map<String,String> getOptions()
      Retrieves an unmodifiable map of all single-valued options, with case-insensitive lookup by keys.
      Specified by:
      getOptions in interface SshConfigStore.HostConfig
      Returns:
      all single-valued options
    • getMultiValuedOptions

      @NonNull public Map<String,List<String>> getMultiValuedOptions()
      Retrieves an unmodifiable map of all multi-valued options, with case-insensitive lookup by keys.
      Specified by:
      getMultiValuedOptions in interface SshConfigStore.HostConfig
      Returns:
      all multi-valued options
    • toString

      public String toString()
      Overrides:
      toString in class Object