public Replacer(String host, int port, String user, String localUserName, File home) { replacements.put(Character.valueOf('%'), "%"); //$NON-NLS-1$ replacements.put(Character.valueOf('d'), home.getPath()); replacements.put(Character.valueOf('h'), host); String localhost = SystemReader.getInstance().getHostname(); replacements.put(Character.valueOf('l'), localhost); int period = localhost.indexOf('.'); if (period > 0) { localhost = localhost.substring(0, period); } replacements.put(Character.valueOf('L'), localhost); replacements.put(Character.valueOf('n'), host); replacements.put(Character.valueOf('p'), Integer.toString(port)); replacements.put(Character.valueOf('r'), user == null ? "" : user); //$NON-NLS-1$ replacements.put(Character.valueOf('u'), localUserName); replacements.put(Character.valueOf('C'), substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put(Character.valueOf('T'), "NONE"); //$NON-NLS-1$ }
u = localUserName; Replacer r = new Replacer(originalHostName, p, u, localUserName, home); if (options != null) { options.put(SshConstants.HOST_NAME, originalHostName); } else { hostName = r.substitute(hostName, "h"); //$NON-NLS-1$ options.put(SshConstants.HOST_NAME, hostName); r.update('h', hostName); value = r.substitute(value, "dhlru"); //$NON-NLS-1$ value = toFile(value, home).getPath(); options.put(SshConstants.IDENTITY_AGENT, value); value = r.substitute(value, "ChLlnpru"); //$NON-NLS-1$ value = toFile(value, home).getPath(); options.put(SshConstants.CONTROL_PATH, value); value = r.substitute(value, "CdhlnprTu"); //$NON-NLS-1$ options.put(SshConstants.LOCAL_COMMAND, value); value = r.substitute(value, "Cdhlnpru"); //$NON-NLS-1$ options.put(SshConstants.REMOTE_COMMAND, value); value = r.substitute(value, "hpr"); //$NON-NLS-1$ options.put(SshConstants.PROXY_COMMAND, value);
public Replacer(String host, int port, String user, String localUserName, File home) { replacements.put(Character.valueOf('%'), "%"); //$NON-NLS-1$ replacements.put(Character.valueOf('d'), home.getPath()); replacements.put(Character.valueOf('h'), host); String localhost = SystemReader.getInstance().getHostname(); replacements.put(Character.valueOf('l'), localhost); int period = localhost.indexOf('.'); if (period > 0) { localhost = localhost.substring(0, period); } replacements.put(Character.valueOf('L'), localhost); replacements.put(Character.valueOf('n'), host); replacements.put(Character.valueOf('p'), Integer.toString(port)); replacements.put(Character.valueOf('r'), user == null ? "" : user); //$NON-NLS-1$ replacements.put(Character.valueOf('u'), localUserName); replacements.put(Character.valueOf('C'), substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put(Character.valueOf('T'), "NONE"); //$NON-NLS-1$ }
public void update(char key, String value) { replacements.put(Character.valueOf(key), value); if ("lhpr".indexOf(key) >= 0) { //$NON-NLS-1$ replacements.put(Character.valueOf('C'), substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$ } }
private List<String> substitute(List<String> values, String allowed, Replacer r) { List<String> result = new ArrayList<>(values.size()); for (String value : values) { result.add(r.substitute(value, allowed)); } return result; }
u = localUserName; Replacer r = new Replacer(originalHostName, p, u, localUserName, home); if (options != null) { options.put(SshConstants.HOST_NAME, originalHostName); } else { hostName = r.substitute(hostName, "h"); //$NON-NLS-1$ options.put(SshConstants.HOST_NAME, hostName); r.update('h', hostName); value = r.substitute(value, "dhlru"); //$NON-NLS-1$ value = toFile(value, home).getPath(); options.put(SshConstants.IDENTITY_AGENT, value); value = r.substitute(value, "ChLlnpru"); //$NON-NLS-1$ value = toFile(value, home).getPath(); options.put(SshConstants.CONTROL_PATH, value); value = r.substitute(value, "CdhlnprTu"); //$NON-NLS-1$ options.put(SshConstants.LOCAL_COMMAND, value); value = r.substitute(value, "Cdhlnpru"); //$NON-NLS-1$ options.put(SshConstants.REMOTE_COMMAND, value); value = r.substitute(value, "hpr"); //$NON-NLS-1$ options.put(SshConstants.PROXY_COMMAND, value);
private List<String> substitute(List<String> values, String allowed, Replacer r) { List<String> result = new ArrayList<>(values.size()); for (String value : values) { result.add(r.substitute(value, allowed)); } return result; }
public void update(char key, String value) { replacements.put(Character.valueOf(key), value); if ("lhpr".indexOf(key) >= 0) { //$NON-NLS-1$ replacements.put(Character.valueOf('C'), substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$ } }