public void doSupportsConfiguration(SshConfiguration configuration) { try { Class.forName("com.jcraft.jsch.JSch", false, getClass().getClassLoader()); } catch (ClassNotFoundException cnfe) { throw new UnsupportedOperationException("JSch is not on the CLASSPATH"); } if (configuration != null && configuration.getProtocolVersion() == SshConfiguration.SSH1_ONLY) { throw new UnsupportedOperationException("SSH1 is not supported."); } }
public int getRemoteProtocolVersion() { if (!isConnected()) { throw new IllegalStateException("Not connected"); } // TODO get the actual remote version return getConfiguration().getProtocolVersion() == SshConfiguration.SSH1_OR_SSH2 ? 2 : getConfiguration() .getProtocolVersion(); }
public void doSupportsConfiguration(SshConfiguration configuration) { try { Class.forName("ch.ethz.ssh2.Connection", false, getClass().getClassLoader()); } catch (ClassNotFoundException cnfe) { SshConfiguration.getLogger().log(Level.INFO, "Could not find Ganymed class ch.ethz.ssh2.Connection."); throw new UnsupportedOperationException("Ganymed is not on the CLASSPATH"); } if (configuration != null && configuration.getProtocolVersion() == SshConfiguration.SSH1_ONLY) { SshConfiguration.getLogger().log(Level.INFO, "Ganymed does not support SSH1, not usable."); throw new UnsupportedOperationException("SSH1 is not supported."); } }
static void dumpClientInfo(SshClient client) { System.out.println("Provider: " + client.getProvider().getClass().getName()); System.out.println("Client: " + client.getClass().getName()); System.out.println("Capabilities: " + client.getProvider().getCapabilities()); int protocolVersion = client.getConfiguration().getProtocolVersion(); System.out.println("Ciphers: " + client.getProvider().getSupportedCiphers(protocolVersion)); if (protocolVersion != SshConfiguration.SSH1_ONLY) { System.out.println("MAC: " + client.getProvider().getSupportedMAC()); System.out.println("Compression: " + client.getProvider().getSupportedCompression()); System.out.println("Key Exchange: " + client.getProvider().getSupportedKeyExchange()); System.out.println("Public Key: " + client.getProvider().getSupportedPublicKey()); } }
private void checkDefaultConfiguration(SshConfiguration configuration) { if (configuration == null) { if (supportsDefaultConfiguration) { return; } else { throw new UnsupportedOperationException("Default configuration is not supported. You must supply a configuration."); } } configuration.providerHasCapabilities(this); check(configuration.getPreferredClientToServerCipher(), getSupportedCiphers(configuration.getProtocolVersion())); check(configuration.getPreferredServerToClientCipher(), getSupportedCiphers(configuration.getProtocolVersion())); check(configuration.getPreferredClientToServerMAC(), getSupportedMAC()); check(configuration.getPreferredServerToClientMAC(), getSupportedMAC()); check(configuration.getPreferredClientToServerCompression(), getSupportedCompression()); check(configuration.getPreferredServerToClientCompression(), getSupportedCompression()); if (configuration.getProxyServer() != null) { SshProxyServerDetails proxy = configuration.getProxyServer(); if (proxy.getType().equals(SshProxyServerDetails.Type.HTTP) && !getCapabilities().contains(Capability.HTTP_PROXY)) { throw new UnsupportedOperationException("HTTP proxy is not supported."); } if (proxy.getType().equals(SshProxyServerDetails.Type.SOCKS4) && !getCapabilities().contains(Capability.SOCKS4_PROXY)) { throw new UnsupportedOperationException("SOCKS4 proxy is not supported."); } if (proxy.getType().equals(SshProxyServerDetails.Type.SOCKS5) && !getCapabilities().contains(Capability.SOCKS5_PROXY)) { throw new UnsupportedOperationException("SOCKS5 proxy is not supported."); } } }
private void checkDefaultConfiguration(SshConfiguration configuration) { if (configuration == null) { if (supportsDefaultConfiguration) { return; } else { throw new UnsupportedOperationException("Default configuration is not supported. You must supply a configuration."); } } configuration.providerHasCapabilities(this); check(configuration.getPreferredClientToServerCipher(), getSupportedCiphers(configuration.getProtocolVersion())); check(configuration.getPreferredServerToClientCipher(), getSupportedCiphers(configuration.getProtocolVersion())); check(configuration.getPreferredClientToServerMAC(), getSupportedMAC()); check(configuration.getPreferredServerToClientMAC(), getSupportedMAC()); check(configuration.getPreferredClientToServerCompression(), getSupportedCompression()); check(configuration.getPreferredServerToClientCompression(), getSupportedCompression()); if (configuration.getProxyServer() != null) { SshProxyServerDetails proxy = configuration.getProxyServer(); if (proxy.getType().equals(SshProxyServerDetails.Type.HTTP) && !getCapabilities().contains(Capability.HTTP_PROXY)) { throw new UnsupportedOperationException("HTTP proxy is not supported."); } if (proxy.getType().equals(SshProxyServerDetails.Type.SOCKS4) && !getCapabilities().contains(Capability.SOCKS4_PROXY)) { throw new UnsupportedOperationException("SOCKS4 proxy is not supported."); } if (proxy.getType().equals(SshProxyServerDetails.Type.SOCKS5) && !getCapabilities().contains(Capability.SOCKS5_PROXY)) { throw new UnsupportedOperationException("SOCKS5 proxy is not supported."); } } }
if (configuration.getProtocolVersion() == SshConfiguration.SSH1_ONLY) { throw new SshException(SshException.UNSUPPORTED_PROTOCOL_VERSION, "Ganymed only supports SSH2, yet SSH1 only was request.");
new IntByReference(configuration.getProtocolVersion() == SshConfiguration.SSH2_ONLY ? 0 : 1).getPointer()); library.ssh_options_set(libSshSession, SshLibrary.ssh_options_e.SSH_OPTIONS_SSH2, new IntByReference(configuration.getProtocolVersion() == SshConfiguration.SSH1_ONLY ? 0 : 1).getPointer());