use of com.jcraft.jsch.Proxy in project javautils by jiadongpo.
the class SFTPClient method setProxy.
public void setProxy(String host, String port, String user, String pass, String proxyType) throws Exception {
if (isEmpty(host) || toInt(port, 0) == 0) {
throw new Exception("Proxy server name must be set and server port must be greater than zero.");
}
Proxy proxy = null;
String proxyhost = host + ":" + port;
if (proxyType.equals(PROXY_TYPE_HTTP)) {
proxy = new ProxyHTTP(proxyhost);
if (!isEmpty(user)) {
((ProxyHTTP) proxy).setUserPasswd(user, pass);
}
} else if (proxyType.equals(PROXY_TYPE_SOCKS5)) {
proxy = new ProxySOCKS5(proxyhost);
if (!isEmpty(user)) {
((ProxySOCKS5) proxy).setUserPasswd(user, pass);
}
}
s.setProxy(proxy);
}
use of com.jcraft.jsch.Proxy in project javautils by jiadongpo.
the class SFTPClient method setProxy.
public void setProxy(String host, String port, String user, String pass, String proxyType) throws Exception {
if (isEmpty(host) || toInt(port, 0) == 0) {
throw new Exception("Proxy server name must be set and server port must be greater than zero.");
}
Proxy proxy = null;
String proxyhost = host + ":" + port;
if (proxyType.equals(PROXY_TYPE_HTTP)) {
proxy = new ProxyHTTP(proxyhost);
if (!isEmpty(user)) {
((ProxyHTTP) proxy).setUserPasswd(user, pass);
}
} else if (proxyType.equals(PROXY_TYPE_SOCKS5)) {
proxy = new ProxySOCKS5(proxyhost);
if (!isEmpty(user)) {
((ProxySOCKS5) proxy).setUserPasswd(user, pass);
}
}
s.setProxy(proxy);
}
use of com.jcraft.jsch.Proxy in project pentaho-kettle by pentaho.
the class SFTPClient method setProxy.
public void setProxy(String host, String port, String user, String pass, String proxyType) throws KettleJobException {
if (Utils.isEmpty(host) || Const.toInt(port, 0) == 0) {
throw new KettleJobException("Proxy server name must be set and server port must be greater than zero.");
}
Proxy proxy = null;
String proxyhost = host + ":" + port;
if (proxyType.equals(PROXY_TYPE_HTTP)) {
proxy = new ProxyHTTP(proxyhost);
if (!Utils.isEmpty(user)) {
((ProxyHTTP) proxy).setUserPasswd(user, pass);
}
} else if (proxyType.equals(PROXY_TYPE_SOCKS5)) {
proxy = new ProxySOCKS5(proxyhost);
if (!Utils.isEmpty(user)) {
((ProxySOCKS5) proxy).setUserPasswd(user, pass);
}
}
s.setProxy(proxy);
}
use of com.jcraft.jsch.Proxy in project javautils by jiadongpo.
the class SFTPClient method setProxy.
public void setProxy(String host, String port, String user, String pass, String proxyType) throws Exception {
if (isEmpty(host) || toInt(port, 0) == 0) {
throw new Exception("Proxy server name must be set and server port must be greater than zero.");
}
Proxy proxy = null;
String proxyhost = host + ":" + port;
if (proxyType.equals(PROXY_TYPE_HTTP)) {
proxy = new ProxyHTTP(proxyhost);
if (!isEmpty(user)) {
((ProxyHTTP) proxy).setUserPasswd(user, pass);
}
} else if (proxyType.equals(PROXY_TYPE_SOCKS5)) {
proxy = new ProxySOCKS5(proxyhost);
if (!isEmpty(user)) {
((ProxySOCKS5) proxy).setUserPasswd(user, pass);
}
}
s.setProxy(proxy);
}
use of com.jcraft.jsch.Proxy in project spring-integration by spring-projects.
the class ProxyTests method testFactoryBean.
@Test
public void testFactoryBean() throws Exception {
JschProxyFactoryBean proxyFactoryBean = new JschProxyFactoryBean(JschProxyFactoryBean.Type.SOCKS5, "localhost", 1080, "ftptest", "pass");
proxyFactoryBean.afterPropertiesSet();
Proxy proxy = proxyFactoryBean.getObject();
assertProxy(proxy, ProxySOCKS5.class);
proxyFactoryBean = new JschProxyFactoryBean(JschProxyFactoryBean.Type.SOCKS4, "localhost", 1080, "ftptest", "pass");
proxyFactoryBean.afterPropertiesSet();
proxy = proxyFactoryBean.getObject();
assertProxy(proxy, ProxySOCKS4.class);
proxyFactoryBean = new JschProxyFactoryBean(JschProxyFactoryBean.Type.HTTP, "localhost", 1080, "ftptest", "pass");
proxyFactoryBean.afterPropertiesSet();
proxy = proxyFactoryBean.getObject();
assertProxy(proxy, ProxyHTTP.class);
}
Aggregations