public class HostConfigEntry extends HostPatternsHolder implements MutableUserHolder
ALL_HOSTS_PATTERN, NEGATION_CHAR_PATTERN, NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM, NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM, PATTERN_CHARS, PORT_VALUE_DELIMITER, SINGLE_CHAR_PATTERN, WILDCARD_PATTERN| Constructor and Description |
|---|
HostConfigEntry() |
HostConfigEntry(String pattern,
String host,
int port,
String username) |
HostConfigEntry(String pattern,
String host,
int port,
String username,
String proxyJump) |
getPatterns, isHostMatch, isHostMatch, isHostMatch, isPortMatch, isSpecificHostPattern, isValidPatternChar, parsePatterns, parsePatterns, setPatterns, toPatternpublic static final String STD_CONFIG_FILENAME
public static final String HOST_CONFIG_PROP
public static final String MATCH_CONFIG_PROP
public static final String HOST_NAME_CONFIG_PROP
public static final String PORT_CONFIG_PROP
public static final String USER_CONFIG_PROP
public static final String PROXY_JUMP_CONFIG_PROP
public static final String IDENTITY_FILE_CONFIG_PROP
public static final String CERTIFICATE_FILE_CONFIG_PROP
public static final String EXCLUSIVE_IDENTITIES_CONFIG_PROP
public static final boolean DEFAULT_EXCLUSIVE_IDENTITIES
public static final String IDENTITY_AGENT
HostConfigEntry, the value of this
property is null, which means that a default SSH agent is to be used, if it
is running. Other values defined by OpenSSH are:
SSH_AUTH_SOCK
shall be used. If the environment variable is not set, no SSH agent is used.public static final NavigableSet<String> EXPLICIT_PROPERTIES
NavigableSet of the properties that receive special handlingpublic static final String MULTI_VALUE_SEPARATORS
public static final char PATH_MACRO_CHAR
public static final char LOCAL_HOME_MACRO
public static final char LOCAL_USER_MACRO
public static final char LOCAL_HOST_MACRO
public static final char REMOTE_HOST_MACRO
public static final char REMOTE_USER_MACRO
public static final char REMOTE_PORT_MACRO
protected String host
protected String hostName
protected int port
protected String username
protected String proxyJump
protected Boolean exclusiveIdentites
protected final Collection<String> identities
public void collate(HostConfigEntry that)
that - The HostConfigEntry to merge.public String getHost()
public void setHost(String host)
public void setHost(Collection<String> patterns)
public String getHostName()
public void setHostName(String hostName)
public int getPort()
public void setPort(int port)
public String getUsername()
getUsername in interface UsernameHoldernull/emptypublic void setUsername(String username)
setUsername in interface MutableUserHolderpublic String getProxyJump()
public void setProxyJump(String proxyJump)
public Collection<String> getIdentities()
null/emptypublic void addIdentity(Path path)
path - A Path to a file that contains an identity key - never nullpublic void addIdentity(String id)
id - The identity path to add - never nullpublic void setIdentities(Collection<String> identities)
public boolean isIdentitiesOnly()
true if must use only the identities in this entrypublic void setIdentitiesOnly(boolean identitiesOnly)
public Map<String,String> getProperties()
Map of extra properties that have been read - may be null/empty, or even contain some
values that have been parsed and set as members of the entry (e.g., host, port, etc.). Note:
multi-valued keys use a comma-separated list of valuespublic String getProperty(String name)
name - Property name - never null/emptynull if no such propertygetProperty(String, String)public String getProperty(String name, String defaultValue)
name - Property name - never null/emptydefaultValue - Default value to return if no such propertypublic void processProperty(String name, Collection<String> valsList)
name - Property name - never null/emptyvalsList - The available values for the propertyHOST_NAME_CONFIG_PROP,
PORT_CONFIG_PROP,
USER_CONFIG_PROP,
IDENTITY_FILE_CONFIG_PROPpublic String appendPropertyValue(String name, String value)
setProperty(String, String).name - Property name - never null/emptyvalue - The value to be appended - ignored if null/emptynull if no previous valuepublic String setProperty(String name, String value)
name - Property name - never null/emptyvalue - Property value - if null/empty then removeProperty(String) is callednull if no such namepublic String removeProperty(String name)
name - Property name - never null/emptynull if no such property namepublic void setProperties(Map<String,String> properties)
properties - The properties to set - if null then an empty map is effectively set. Note: it
is highly recommended to use a case insensitive key mapper.public <A extends Appendable> A append(A sb) throws IOException
IOExceptionpublic static <A extends Appendable> A appendNonEmptyPort(A sb, String name, int port) throws IOException
A - The Appendable typesb - The target appendername - The property name - never null/emptyport - The port value - ignored if non-positiveIOException - If failed to append the requested dataappendNonEmptyProperty(Appendable, String, Object)public static <A extends Appendable> A appendNonEmptyProperties(A sb, Map<String,?> props) throws IOException
EXPLICIT_PROPERTIES onesA - The Appendable typesb - The target appenderprops - The Map of properties - ignored if null/emptyIOException - If failed to append the requested dataappendNonEmptyProperty(Appendable, String, Object)public static <A extends Appendable> A appendNonEmptyProperty(A sb, String name, Object value) throws IOException
A - The Appendable typesb - The target appendername - The property name - never null/emptyvalue - The property value - ignored if null. Note: if the string representation of
the value contains any commas, they are assumed to indicate a multi-valued property which is
broken down to individual lines - one per value.IOException - If failed to append the requested dataappendNonEmptyValues(Appendable, String, Object...)public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Object... values) throws IOException
A - The Appendable typesb - The target appendername - The property name - never null/emptyvalues - The values to be added - one per line - ignored if null/emptyIOException - If failed to append the requested dataappendNonEmptyValues(Appendable, String, Collection)public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Collection<?> values) throws IOException
A - The Appendable typesb - The target appendername - The property name - never null/emptyvalues - The values to be added - one per line - ignored if null/emptyIOException - If failed to append the requested datapublic static List<HostConfigEntry> findMatchingEntries(String host, HostConfigEntry... entries)
host - The host name / address - ignored if null/emptyentries - The HostConfigEntry-ies to scan - ignored if null/emptyList of all the matching entriesHostPatternsHolder.isHostMatch(String, int)public static List<HostConfigEntry> findMatchingEntries(String host, Collection<? extends HostConfigEntry> entries)
host - The host name / address - ignored if null/emptyentries - The HostConfigEntry-ies to scan - ignored if null/emptyList of all the matching entriesHostPatternsHolder.isHostMatch(String, int)public static HostConfigEntryResolver toHostConfigEntryResolver(Collection<? extends HostConfigEntry> entries)
entries - The entries - ignored if null/emptyHostConfigEntryResolver wrapper using the entriespublic static List<HostConfigEntry> readHostConfigEntries(Path path, OpenOption... options) throws IOException
IOExceptionpublic static List<HostConfigEntry> readHostConfigEntries(URL url) throws IOException
IOExceptionpublic static List<HostConfigEntry> readHostConfigEntries(InputStream inStream, boolean okToClose) throws IOException
IOExceptionpublic static List<HostConfigEntry> readHostConfigEntries(Reader rdr, boolean okToClose) throws IOException
IOExceptionpublic static List<HostConfigEntry> readHostConfigEntries(BufferedReader rdr) throws IOException
rdr - The BufferedReader to useList of read HostConfigEntry-iesIOException - If failed to parse the read configurationpublic static void writeHostConfigEntries(Path path, Collection<? extends HostConfigEntry> entries, OpenOption... options) throws IOException
IOExceptionpublic static void writeHostConfigEntries(OutputStream outputStream, boolean okToClose, Collection<? extends HostConfigEntry> entries) throws IOException
IOExceptionpublic static <A extends Appendable> A appendHostConfigEntries(A sb, Collection<? extends HostConfigEntry> entries) throws IOException
IOExceptionpublic static List<String> parseConfigValue(String value)
value - The value - ignored if null/empty (after trimming)List of the encountered valuespublic static String resolveIdentityFilePath(String id, String host, int port, String username) throws IOException
IOExceptionCopyright © 2018–2024 The Apache Software Foundation. All rights reserved.