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 ); }
this.session.setProxy(new ProxyHTTP(proxyHost, proxyPort));
jschSession.setProxy(this.proxy);
@Override public Session newSession() throws JSchException { Session session = jsch.getSession( username, hostname, port ); if ( config != null ) { for ( String key : config.keySet() ) { session.setConfig( key, config.get( key ) ); } } if ( proxy != null ) { session.setProxy( proxy ); } if ( password != null ) { session.setPassword( password ); } if ( userInfo != null ) { session.setUserInfo( userInfo ); } return session; }
JSch jsch = new JSch(); Properties properties = new Properties(); properties.setProperty("StrictHostKeyChecking", "no"); if (privKeyFile != null) jsch.addIdentity(privKeyFile, password); Session session = jsch.getSession(username, host, port); session.setTimeout(timeout); session.setConfig(properties); if (proxy != null) session.setProxy(proxy); if (privKeyFile == null && password != null) session.setPassword(password); session.connect(); ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); channel.connect();
@Override public Session newSession() throws JSchException { Session session = jsch.getSession( username, hostname, port ); if ( config != null ) { for ( String key : config.keySet() ) { session.setConfig( key, config.get( key ) ); } } if ( proxy != null ) { session.setProxy( proxy ); } if ( password != null ) { session.setPassword( password ); } if ( userInfo != null ) { session.setUserInfo( userInfo ); } return session; }
@Override public Session create() throws Exception { JSch jsch = new JSch(); session = jsch .getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (sessionTimeout != 0) session.setTimeout(sessionTimeout); if (loginCredentials.getPrivateKey() == null) { session.setPassword(loginCredentials.getPassword()); } else { checkArgument(!loginCredentials.getPrivateKey().contains("Proc-Type: 4,ENCRYPTED"), "JschSshClientModule does not support private keys that require a passphrase"); byte[] privateKey = loginCredentials.getPrivateKey().getBytes(); jsch.addIdentity(loginCredentials.getUser(), privateKey, null, emptyPassPhrase); } java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); if (proxy.isPresent()) session.setProxy(proxy.get()); session.connect(connectTimeout); return session; }
@Override public Session create() throws Exception { JSch jsch = new JSch(); session = jsch .getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (sessionTimeout != 0) session.setTimeout(sessionTimeout); if (loginCredentials.hasUnencryptedPrivateKey()) { byte[] privateKey = loginCredentials.getOptionalPrivateKey().get().getBytes(); jsch.addIdentity(loginCredentials.getUser(), privateKey, null, emptyPassPhrase); } else if (loginCredentials.getOptionalPassword().isPresent()) { session.setPassword(loginCredentials.getOptionalPassword().orNull()); } else if (agentConnector.isPresent()) { JSch.setConfig("PreferredAuthentications", "publickey"); jsch.setIdentityRepository(new RemoteIdentityRepository(agentConnector.get())); } java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); if (proxy.isPresent()) session.setProxy(proxy.get()); session.connect(connectTimeout); return session; }
public static void setProxy(Session session){ Proxy proxy=getProxyForHost(session.getHost(), IProxyData.SOCKS_PROXY_TYPE); if(proxy==null) proxy=getProxyForHost(session.getHost(), IProxyData. HTTPS_PROXY_TYPE); if(proxy!=null) session.setProxy(proxy); }
@Override public Session create() throws Exception { JSch jsch = new JSch(); session = jsch .getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (sessionTimeout != 0) session.setTimeout(sessionTimeout); if (loginCredentials.hasUnencryptedPrivateKey()) { byte[] privateKey = loginCredentials.getOptionalPrivateKey().get().getBytes(); jsch.addIdentity(loginCredentials.getUser(), privateKey, null, emptyPassPhrase); } else if (loginCredentials.getOptionalPassword().isPresent()) { session.setPassword(loginCredentials.getOptionalPassword().orNull()); } else if (agentConnector.isPresent()) { JSch.setConfig("PreferredAuthentications", "publickey"); jsch.setIdentityRepository(new RemoteIdentityRepository(agentConnector.get())); } java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); if (proxy.isPresent()) session.setProxy(proxy.get()); session.connect(connectTimeout); return session; }
public static void setProxy(Session session){ Proxy proxy=getProxyForHost(session.getHost(), IProxyData.SOCKS_PROXY_TYPE); if(proxy==null) proxy=getProxyForHost(session.getHost(), IProxyData. HTTPS_PROXY_TYPE); if(proxy!=null) session.setProxy(proxy); }
jschSession.setProxy(this.proxy);
this.session.setProxy(new ProxyHTTP(proxyHost, proxyPort));
session.setUserInfo(userInfo); if (config.isSshOverHttpProxy() || config.isSshOverHttpsProxy()) { session.setProxy(buildProxy(config));
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);
proxyHTTP.setUserPasswd(user.getProxyUser(), user.getProxySecurityPswd()); session.setProxy(proxyHTTP);
void initialize(Session session) throws IOException { if (containsKey(PROXY)) { Proxy proxy = FileSystemProviderSupport.getValue(this, PROXY, Proxy.class, null); session.setProxy(proxy);