void substitute(String originalHostName, int port, String userName, String localUserName, File home) { int p = port >= 0 ? port : positive(getValue(SshConstants.PORT)); if (p < 0) { p = SshConstants.SSH_DEFAULT_PORT; : getValue(SshConstants.USER); if (u == null || u.isEmpty()) { u = localUserName; .get(SshConstants.IDENTITY_FILE); if (values != null) { values = substitute(values, "dhlru", r); //$NON-NLS-1$ values = replaceTilde(values, home); multiOptions.put(SshConstants.IDENTITY_FILE, values); values = substitute(values, "dhlru", r); //$NON-NLS-1$ values = replaceTilde(values, home); multiOptions.put(SshConstants.CERTIFICATE_FILE, values); .get(SshConstants.USER_KNOWN_HOSTS_FILE); if (values != null) { values = replaceTilde(values, home); listOptions.put(SshConstants.USER_KNOWN_HOSTS_FILE, values);
private void complete(String initialHostName, String localUserName) { hostName = entry.getValue(SshConstants.HOST_NAME); user = entry.getValue(SshConstants.USER); port = positive(entry.getValue(SshConstants.PORT)); connectionAttempts = positive( entry.getValue(SshConstants.CONNECTION_ATTEMPTS)); strictHostKeyChecking = entry .getValue(SshConstants.STRICT_HOST_KEY_CHECKING); batchMode = Boolean.valueOf(OpenSshConfigFile .flag(entry.getValue(SshConstants.BATCH_MODE))); preferredAuthentications = entry .getValue(SshConstants.PREFERRED_AUTHENTICATIONS); .getValues(SshConstants.IDENTITY_FILE); if (identityFiles != null && !identityFiles.isEmpty()) { identityFile = new File(identityFiles.get(0));
HostEntry defaults = new HostEntry(); current.add(defaults); entries.put(DEFAULT_NAME, defaults); c = new HostEntry(); entries.put(name, c); if (HostEntry.isListKey(keyword)) { List<String> args = validate(keyword, parseList(argValue)); for (HostEntry entry : current) { entry.setValue(keyword, args); entry.setValue(keyword, argValue);
void substitute(String originalHostName, int port, String userName, String localUserName, File home) { int p = port >= 0 ? port : positive(getValue(SshConstants.PORT)); if (p < 0) { p = SshConstants.SSH_DEFAULT_PORT; : getValue(SshConstants.USER); if (u == null || u.isEmpty()) { u = localUserName; .get(SshConstants.IDENTITY_FILE); if (values != null) { values = substitute(values, "dhlru", r); //$NON-NLS-1$ values = replaceTilde(values, home); multiOptions.put(SshConstants.IDENTITY_FILE, values); values = substitute(values, "dhlru", r); //$NON-NLS-1$ values = replaceTilde(values, home); multiOptions.put(SshConstants.CERTIFICATE_FILE, values); .get(SshConstants.USER_KNOWN_HOSTS_FILE); if (values != null) { values = replaceTilde(values, home); listOptions.put(SshConstants.USER_KNOWN_HOSTS_FILE, values);
HostEntry defaults = new HostEntry(); current.add(defaults); entries.put(DEFAULT_NAME, defaults); c = new HostEntry(); entries.put(name, c); if (HostEntry.isListKey(keyword)) { List<String> args = validate(keyword, parseList(argValue)); for (HostEntry entry : current) { entry.setValue(keyword, args); entry.setValue(keyword, argValue);
allOptions.putAll(entry.getOptions()); entry.getMultiValuedOptions().entrySet().stream() .forEach(e -> allOptions.put(e.getKey(), String.join(",", e.getValue()))); //$NON-NLS-1$ config.setProperties(allOptions); config.setMultiValuedOptions(entry.getMultiValuedOptions()); String hostName = entry.getValue(SshConstants.HOST_NAME); if (hostName == null || hostName.isEmpty()) { hostName = host; config.setHost(SshdSocketAddress.isIPv6Address(hostName) ? "" : hostName); //$NON-NLS-1$ String user = username != null && !username.isEmpty() ? username : entry.getValue(SshConstants.USER); if (user == null || user.isEmpty()) { user = configFile.getLocalUserName(); int p = port >= 0 ? port : positive(entry.getValue(SshConstants.PORT)); config.setPort(p >= 0 ? p : SshConstants.SSH_DEFAULT_PORT); config.setProperty(SshConstants.PORT, Integer.toString(config.getPort())); config.setIdentities(entry.getValues(SshConstants.IDENTITY_FILE)); config.setIdentitiesOnly( flag(entry.getValue(SshConstants.IDENTITIES_ONLY))); return config;
private void complete(String initialHostName, String localUserName) { hostName = entry.getValue(SshConstants.HOST_NAME); user = entry.getValue(SshConstants.USER); port = positive(entry.getValue(SshConstants.PORT)); connectionAttempts = positive( entry.getValue(SshConstants.CONNECTION_ATTEMPTS)); strictHostKeyChecking = entry .getValue(SshConstants.STRICT_HOST_KEY_CHECKING); batchMode = Boolean.valueOf(OpenSshConfigFile .flag(entry.getValue(SshConstants.BATCH_MODE))); preferredAuthentications = entry .getValue(SshConstants.PREFERRED_AUTHENTICATIONS); .getValues(SshConstants.IDENTITY_FILE); if (identityFiles != null && !identityFiles.isEmpty()) { identityFile = new File(identityFiles.get(0));
return h; HostEntry fullConfig = new HostEntry(); fullConfig.merge(cache.entries.get(DEFAULT_NAME)); for (Map.Entry<String, HostEntry> e : cache.entries.entrySet()) { String pattern = e.getKey(); if (isHostMatch(pattern, hostName)) { fullConfig.merge(e.getValue()); fullConfig.substitute(hostName, port, userName, localUserName, home); cache.hosts.put(cacheKey, fullConfig); return fullConfig;
@Override public String[] getValues(String key) { List<String> values = Host.this.entry .getValues(mapKey(key)); if (values == null) { return new String[0]; } return values.toArray(new String[0]); } };
@Override public String getValue(String key) { // See com.jcraft.jsch.OpenSSHConfig.MyConfig.getValue() // for this special case. if (key.equals("compression.s2c") //$NON-NLS-1$ || key.equals("compression.c2s")) { //$NON-NLS-1$ if (!OpenSshConfigFile.flag( Host.this.entry.getValue(mapKey(key)))) { return "none,zlib@openssh.com,zlib"; //$NON-NLS-1$ } return "zlib@openssh.com,zlib,none"; //$NON-NLS-1$ } return Host.this.entry.getValue(mapKey(key)); }
return h; HostEntry fullConfig = new HostEntry(); fullConfig.merge(cache.entries.get(DEFAULT_NAME)); for (Map.Entry<String, HostEntry> e : cache.entries.entrySet()) { String pattern = e.getKey(); if (isHostMatch(pattern, hostName)) { fullConfig.merge(e.getValue()); fullConfig.substitute(hostName, port, userName, localUserName, home); cache.hosts.put(cacheKey, fullConfig); return fullConfig;
@Override public String getValue(String key) { // See com.jcraft.jsch.OpenSSHConfig.MyConfig.getValue() // for this special case. if (key.equals("compression.s2c") //$NON-NLS-1$ || key.equals("compression.c2s")) { //$NON-NLS-1$ if (!OpenSshConfigFile.flag( Host.this.entry.getValue(mapKey(key)))) { return "none,zlib@openssh.com,zlib"; //$NON-NLS-1$ } return "zlib@openssh.com,zlib,none"; //$NON-NLS-1$ } return Host.this.entry.getValue(mapKey(key)); }
@Override public String[] getValues(String key) { List<String> values = Host.this.entry .getValues(mapKey(key)); if (values == null) { return new String[0]; } return values.toArray(new String[0]); } };