Search in sources :

Example 1 with ProxyHTTP

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);
}
Also used : Proxy(com.jcraft.jsch.Proxy) ProxySOCKS5(com.jcraft.jsch.ProxySOCKS5) ProxyHTTP(com.jcraft.jsch.ProxyHTTP) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) SftpException(com.jcraft.jsch.SftpException) JSchException(com.jcraft.jsch.JSchException)

Example 2 with ProxyHTTP

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);
}
Also used : Proxy(com.jcraft.jsch.Proxy) ProxySOCKS5(com.jcraft.jsch.ProxySOCKS5) ProxyHTTP(com.jcraft.jsch.ProxyHTTP) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) SftpException(com.jcraft.jsch.SftpException) JSchException(com.jcraft.jsch.JSchException)

Example 3 with ProxyHTTP

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);
    }
}
Also used : ProxySOCKS4(com.jcraft.jsch.ProxySOCKS4) ProxySOCKS5(com.jcraft.jsch.ProxySOCKS5) ProxyHTTP(com.jcraft.jsch.ProxyHTTP)

Example 4 with ProxyHTTP

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;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) ProxyHTTP(com.jcraft.jsch.ProxyHTTP)

Example 5 with ProxyHTTP

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;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) ProxyHTTP(com.jcraft.jsch.ProxyHTTP)

Aggregations

ProxyHTTP (com.jcraft.jsch.ProxyHTTP)8 ProxySOCKS5 (com.jcraft.jsch.ProxySOCKS5)5 JSchException (com.jcraft.jsch.JSchException)4 Proxy (com.jcraft.jsch.Proxy)4 SftpException (com.jcraft.jsch.SftpException)3 IOException (java.io.IOException)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 JndiRegistry (org.apache.camel.impl.JndiRegistry)2 JSch (com.jcraft.jsch.JSch)1 ProxySOCKS4 (com.jcraft.jsch.ProxySOCKS4)1 UserInfo (com.jcraft.jsch.UserInfo)1 FileBasedHelperException (org.apache.gobblin.source.extractor.filebased.FileBasedHelperException)1 KettleJobException (org.pentaho.di.core.exception.KettleJobException)1