Search in sources :

Example 1 with ProxySOCKS5

use of com.jcraft.jsch.ProxySOCKS5 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 ProxySOCKS5

use of com.jcraft.jsch.ProxySOCKS5 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 ProxySOCKS5

use of com.jcraft.jsch.ProxySOCKS5 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 ProxySOCKS5

use of com.jcraft.jsch.ProxySOCKS5 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);
}
Also used : Proxy(com.jcraft.jsch.Proxy) ProxySOCKS5(com.jcraft.jsch.ProxySOCKS5) ProxyHTTP(com.jcraft.jsch.ProxyHTTP) KettleJobException(org.pentaho.di.core.exception.KettleJobException)

Example 5 with ProxySOCKS5

use of com.jcraft.jsch.ProxySOCKS5 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)

Aggregations

ProxyHTTP (com.jcraft.jsch.ProxyHTTP)5 ProxySOCKS5 (com.jcraft.jsch.ProxySOCKS5)5 Proxy (com.jcraft.jsch.Proxy)4 JSchException (com.jcraft.jsch.JSchException)3 SftpException (com.jcraft.jsch.SftpException)3 IOException (java.io.IOException)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 ProxySOCKS4 (com.jcraft.jsch.ProxySOCKS4)1 KettleJobException (org.pentaho.di.core.exception.KettleJobException)1