/** * Get a value from a configuration object, returning a default value if it * does not exist. This method will also look for the same property in the * current system properties. * * @param configuration configuration object * @param name name of configuration * @param defaultValue * @return value */ public static String getConfigurationValue(SshConfiguration configuration, String name, String defaultValue) { String val = configuration == null ? null : configuration.getProperties().getProperty(name); if (val == null) { val = System.getProperty(SshConfiguration.CFG_KNOWN_HOSTS_PATH); } if (val == null) { val = defaultValue; } return val; }
/** * Get a value from a configuration object, returning a default value if it * does not exist. This method will also look for the same property in the * current system properties. * * @param configuration configuration object * @param name name of configuration * @param defaultValue * @return value */ public static String getConfigurationValue(SshConfiguration configuration, String name, String defaultValue) { String val = configuration == null ? null : configuration.getProperties().getProperty(name); if (val == null) { val = System.getProperty(SshConfiguration.CFG_KNOWN_HOSTS_PATH); } if (val == null) { val = defaultValue; } return val; }
public final SshHostKey[] getKeysForHost(String host, String type) { // Look up first using the plain text hostname SshHostKey[] hk = doGetKeysForHost(host, type); if (hk == null) { // Now try a reverse look up if ("true".equals(configuration.getProperties().getProperty(SshConfiguration.CFG_KNOWN_HOSTS_REVERSE_DNS, "true"))) { try { InetAddress addr = InetAddress.getByName(host); hk = doGetKeysForHost(addr.getHostName(), type); if (hk == null) { hk = doGetKeysForHost(addr.getCanonicalHostName(), type); } if (hk == null) { hk = doGetKeysForHost(addr.getHostAddress(), type); } } catch (UnknownHostException uhe) { } } } return hk == null ? new SshHostKey[0] : hk; }
public final SshHostKey[] getKeysForHost(String host, String type) { // Look up first using the plain text hostname SshHostKey[] hk = doGetKeysForHost(host, type); if (hk == null) { // Now try a reverse look up if ("true".equals(configuration.getProperties().getProperty(SshConfiguration.CFG_KNOWN_HOSTS_REVERSE_DNS, "true"))) { try { InetAddress addr = InetAddress.getByName(host); hk = doGetKeysForHost(addr.getHostName(), type); if (hk == null) { hk = doGetKeysForHost(addr.getCanonicalHostName(), type); } if (hk == null) { hk = doGetKeysForHost(addr.getHostAddress(), type); } } catch (UnknownHostException uhe) { } } } return hk == null ? new SshHostKey[0] : hk; }
public void onOpen() throws SshException { try { in = channel.getInputStream(); out = channel.getOutputStream(); ext = channel.getExtInputStream(); channel.connect(Integer.parseInt(configuration.getProperties().getProperty(JschSshProvider.CFG_CHANNEL_CONNECT_TIMEOUT, "3000"))); } catch (Exception e) { throw new SshException("Failed to connect channel.", e); } onChannelOpen(); }
SshConfiguration configuration = getConfiguration(); try { session.connect(Integer.parseInt(configuration.getProperties().getProperty(JschSshProvider.CFG_SESSION_CONNECT_TIMEOUT, "30000"))); authenticated = true;
public final void onOpen() throws SshException { if (!Util.nullOrTrimmedBlank(configuration.getX11Host())) { boolean singleConnection = Boolean.parseBoolean(configuration.getProperties().getProperty( GanymedSshProvider.CFG_SINGLE_X11_CONNECTION, "false")); try { session.requestX11Forwarding(configuration.getX11Host(), configuration.getX11Port(), configuration.getX11Cookie(), singleConnection); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } } onChannelOpen(); }