if (proxyServer.getType().equals(SshProxyServerDetails.Type.HTTP)) { ProxyHTTP proxy = new ProxyHTTP(proxyServer.getHostname(), proxyServer.getPort()); proxy.setUserPasswd(proxyServer.getUsername(), new String(proxyServer.getPassword())); session.setProxy(proxy); } else if (proxyServer.getType().equals(SshProxyServerDetails.Type.SOCKS4)) { ProxySOCKS4 proxy = new ProxySOCKS4(proxyServer.getHostname(), proxyServer.getPort()); proxy.setUserPasswd(proxyServer.getUsername(), new String(proxyServer.getPassword())); session.setProxy(proxy); } else if (proxyServer.getType().equals(SshProxyServerDetails.Type.SOCKS5)) { ProxySOCKS5 proxy = new ProxySOCKS5(proxyServer.getHostname(), proxyServer.getPort()); proxy.setUserPasswd(proxyServer.getUsername(), new String(proxyServer.getPassword())); session.setProxy(proxy);
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 (proxyServer != null) { connection = new Connection(hostname, port, new HTTPProxyData( proxyServer.getHostname(), proxyServer.getPort(), proxyServer.getUsername(), new String( proxyServer.getPassword()))); } else { connection = new Connection(hostname, port);