use of com.jcraft.jsch.ProxyHTTP 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.ProxyHTTP 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.ProxyHTTP in project spring-integration by spring-projects.
the class JschProxyFactoryBean method createInstance.
@Override
protected Proxy createInstance() throws Exception {
switch(this.type) {
case SOCKS5:
ProxySOCKS5 socks5proxy = new ProxySOCKS5(this.host, this.port);
socks5proxy.setUserPasswd(this.user, this.password);
return socks5proxy;
case SOCKS4:
ProxySOCKS4 socks4proxy = new ProxySOCKS4(this.host, this.port);
socks4proxy.setUserPasswd(this.user, this.password);
return socks4proxy;
case HTTP:
ProxyHTTP httpProxy = new ProxyHTTP(this.host, this.port);
httpProxy.setUserPasswd(this.user, this.password);
return httpProxy;
default:
throw new IllegalArgumentException("Invalid type:" + this.type);
}
}
use of com.jcraft.jsch.ProxyHTTP in project camel by apache.
the class SftpSimpleConsumeThroughProxyTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
final ProxyHTTP proxyHTTP = new ProxyHTTP("localhost", proxyPort);
proxyHTTP.setUserPasswd("user", "password");
jndi.bind("proxy", proxyHTTP);
return jndi;
}
use of com.jcraft.jsch.ProxyHTTP in project camel by apache.
the class SftpSimpleProduceThroughProxyTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
final ProxyHTTP proxyHTTP = new ProxyHTTP("localhost", proxyPort);
proxyHTTP.setUserPasswd("user", "password");
jndi.bind("proxy", proxyHTTP);
return jndi;
}
Aggregations