当前位置: 首页>>代码示例>>Java>>正文


Java Connection.setProxyData方法代码示例

本文整理汇总了Java中com.trilead.ssh2.Connection.setProxyData方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.setProxyData方法的具体用法?Java Connection.setProxyData怎么用?Java Connection.setProxyData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.trilead.ssh2.Connection的用法示例。


在下文中一共展示了Connection.setProxyData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private Connection getConnection(String servername,int serverport,
		String proxyhost,int proxyport,String proxyusername,String proxypassword)
{
	/* Create a connection instance */

	Connection conn = new Connection(servername,serverport);

	/* We want to connect through a HTTP proxy */
	if(usehttpproxy)
	{
		conn.setProxyData(new HTTPProxyData(proxyhost, proxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(useBasicAuthentication)
		{
			conn.setProxyData(new HTTPProxyData(proxyhost, proxyport, proxyusername, proxypassword));
		}
	}
	
	return conn;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:23,代码来源:JobEntrySSH2GET.java

示例2: getConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private Connection getConnection(String servername,int serverpassword,
		String proxyhost,int proxyport,String proxyusername,String proxypassword)
{
	/* Create a connection instance */

	Connection connnect = new Connection(servername,serverpassword);

	/* We want to connect through a HTTP proxy */
	if(usehttpproxy)
	{
		connnect.setProxyData(new HTTPProxyData(proxyhost, proxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(useBasicAuthentication)
		{
			connnect.setProxyData(new HTTPProxyData(proxyhost, proxyport, proxyusername, proxypassword));
		}
	}
	
	return connnect;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:23,代码来源:JobEntrySSH2PUT.java

示例3: getConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private Connection getConnection(String servername,int serverport,
		String proxyhost,int proxyport,String proxyusername,String proxypassword)
{
	/* Create a connection instance */

	Connection connect = new Connection(servername,serverport);

	/* We want to connect through a HTTP proxy */
	if(usehttpproxy)
	{
		connect.setProxyData(new HTTPProxyData(proxyhost, proxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(useBasicAuthentication)
		{
			connect.setProxyData(new HTTPProxyData(proxyhost, proxyport, proxyusername, proxypassword));
		}
	}
	
	return connect;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:JobEntrySSH2PUT.java

示例4: getConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private Connection getConnection( String servername, int serverport, String proxyhost, int proxyport,
  String proxyusername, String proxypassword ) {
  /* Create a connection instance */

  Connection conn = new Connection( servername, serverport );

  /* We want to connect through a HTTP proxy */
  if ( usehttpproxy ) {
    conn.setProxyData( new HTTPProxyData( proxyhost, proxyport ) );

    /* Now connect */
    // if the proxy requires basic authentication:
    if ( useBasicAuthentication ) {
      conn.setProxyData( new HTTPProxyData( proxyhost, proxyport, proxyusername, proxypassword ) );
    }
  }

  return conn;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:JobEntrySSH2GET.java

示例5: getConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private Connection getConnection( String servername, int serverport, String proxyhost, int proxyport,
  String proxyusername, String proxypassword ) {
  /* Create a connection instance */

  Connection connect = new Connection( servername, serverport );

  /* We want to connect through a HTTP proxy */
  if ( usehttpproxy ) {
    connect.setProxyData( new HTTPProxyData( proxyhost, proxyport ) );

    /* Now connect */
    // if the proxy requires basic authentication:
    if ( useBasicAuthentication ) {
      connect.setProxyData( new HTTPProxyData( proxyhost, proxyport, proxyusername, proxypassword ) );
    }
  }

  return connect;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:JobEntrySSH2PUT.java

示例6: openConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
public static Connection openConnection(final ConnectionSettings connectionSettings, final SshAuthentication authentication)
  throws AuthenticationException, IOException {
  final int port = connectionSettings.getPort() == -1 ? SSH_DEFAULT_PORT : connectionSettings.getPort();
  final Connection connection = new Connection(connectionSettings.getHostName(), port);
  final ProxyData proxy = SshProxyFactory.createAndRegister(connectionSettings);
  if (proxy != null) {
    connection.setProxyData(proxy);
  }
  connection.connect(null, connectionSettings.getConnectionTimeout(), connectionSettings.getConnectionTimeout());
  authentication.authenticate(connection);
  //HTTPProxyException
  return connection;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SshConnectionUtils.java

示例7: main

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
public static void main(String[] args)
{
	String hostname = "my-ssh-server";
	String username = "joe";
	String password = "joespass";

	String proxyHost = "192.168.1.1";
	int proxyPort = 3128; // default port used by squid
	
	try
	{
		/* Create a connection instance */

		Connection conn = new Connection(hostname);

		/* We want to connect through a HTTP proxy */
		
		conn.setProxyData(new HTTPProxyData(proxyHost, proxyPort));
		
		// if the proxy requires basic authentication:
		// conn.setProxyData(new HTTPProxyData(proxyHost, proxyPort, "username", "secret"));
		
		/* Now connect (through the proxy) */

		conn.connect();

		/* Authenticate.
		 * If you get an IOException saying something like
		 * "Authentication method password not supported by the server at this stage."
		 * then please check the FAQ.
		 */

		boolean isAuthenticated = conn.authenticateWithPassword(username, password);

		if (isAuthenticated == false)
			throw new IOException("Authentication failed.");

		/* Create a session */

		Session sess = conn.openSession();

		sess.execCommand("uname -a && date && uptime && who");

		System.out.println("Here is some information about the remote host:");

		/* 
		 * This basic example does not handle stderr, which is sometimes dangerous
		 * (please read the FAQ).
		 */

		InputStream stdout = new StreamGobbler(sess.getStdout());

		BufferedReader br = new BufferedReader(new InputStreamReader(stdout));

		while (true)
		{
			String line = br.readLine();
			if (line == null)
				break;
			System.out.println(line);
		}

		/* Show exit status, if available (otherwise "null") */

		System.out.println("ExitCode: " + sess.getExitStatus());

		/* Close this session */

		sess.close();

		/* Close the connection */

		conn.close();

	}
	catch (IOException e)
	{
		e.printStackTrace(System.err);
		System.exit(2);
	}
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:82,代码来源:BasicWithHTTPProxy.java

示例8: SSHConnect

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private void SSHConnect(LogWriter log,String realservername, String realserverpassword, int realserverport,
		String realUsername, String realPassword,
		String realproxyhost,String realproxyusername, String realproxypassword, int realproxyport,
		String realkeyFilename, String realkeyPass) throws Exception
{
	
	/* Create a connection instance */

	Connection conn = new Connection(realservername,realserverport);

	/* We want to connect through a HTTP proxy */
	if(useproxy)
	{
		conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(!Const.isEmpty(realproxyusername) || !Const.isEmpty(realproxypassword))
		{
			conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport, realproxyusername, realproxypassword));
		}
	}
	
	
	if(timeout>0)
	{
		// Use timeout
		conn.connect(null,0,timeout*1000);	
		
	}else
	{
		// Cache Host Key
		conn.connect();
	}
	
	// Authenticate

	boolean isAuthenticated = false;
	if(publicpublickey)
	{
		isAuthenticated=conn.authenticateWithPublicKey(realUsername, new File(keyFilename), realkeyPass);
	}else
	{
		isAuthenticated=conn.authenticateWithPassword(realUsername, realserverpassword);
	}

	if(!isAuthenticated) throw new Exception("Can not connect to ");
	
	sshclient = new SFTPv3Client(conn);
	
	
	
	
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:55,代码来源:JobEntryFTPDelete.java

示例9: SSHConnect

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private void SSHConnect(String realservername, String realserverpassword, int realserverport,
		String realUsername, String realPassword,
		String realproxyhost,String realproxyusername, String realproxypassword, int realproxyport,
		String realkeyFilename, String realkeyPass) throws Exception
{
	
	/* Create a connection instance */

	Connection conn = new Connection(realservername,realserverport);

	/* We want to connect through a HTTP proxy */
	if(useproxy)
	{
		conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(!Const.isEmpty(realproxyusername) || !Const.isEmpty(realproxypassword))
		{
			conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport, realproxyusername, realproxypassword));
		}
	}
	
	
	if(timeout>0)
	{
		// Use timeout
		conn.connect(null,0,timeout*1000);	
		
	}else
	{
		// Cache Host Key
		conn.connect();
	}
	
	// Authenticate

	boolean isAuthenticated = false;
	if(publicpublickey)
	{
		isAuthenticated=conn.authenticateWithPublicKey(realUsername, new File(keyFilename), realkeyPass);
	}else
	{
		isAuthenticated=conn.authenticateWithPassword(realUsername, realserverpassword);
	}

	if(!isAuthenticated) throw new Exception("Can not connect to ");
	
	sshclient = new SFTPv3Client(conn);
	
	
	
	
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:55,代码来源:JobEntryFTPDelete.java

示例10: SSHConnect

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private void SSHConnect(String realservername, String realserverpassword, int realserverport,
		String realUsername, String realPassword,
		String realproxyhost,String realproxyusername, String realproxypassword, int realproxyport,
		String realkeyFilename, String realkeyPass) throws Exception
{
	
	/* Create a connection instance */

	Connection conn = new Connection(realservername,realserverport);

	/* We want to connect through a HTTP proxy */
	if(useproxy)
	{
		conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport));
	
		/* Now connect */
		// if the proxy requires basic authentication:
		if(!Const.isEmpty(realproxyusername) || !Const.isEmpty(realproxypassword))
		{
			conn.setProxyData(new HTTPProxyData(realproxyhost, realproxyport, realproxyusername, realproxypassword));
		}
	}
	
	
	if(timeout>0)
	{
		// Use timeout
		conn.connect(null,0,timeout*1000);	
		
	}else
	{
		// Cache Host Key
		conn.connect();
	}
	
	// Authenticate

	boolean isAuthenticated = false;
	if(publicpublickey)
	{
		isAuthenticated=conn.authenticateWithPublicKey(realUsername, new File(realkeyFilename), realkeyPass);
	}else
	{
		isAuthenticated=conn.authenticateWithPassword(realUsername, realserverpassword);
	}

	if(!isAuthenticated) throw new Exception("Can not connect to ");
	
	sshclient = new SFTPv3Client(conn);
	
	
	
	
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:55,代码来源:JobEntryFTPDelete.java

示例11: SSHConnect

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
private void SSHConnect( String realservername, String realserverpassword, int realserverport,
  String realUsername, String realPassword, String realproxyhost, String realproxyusername,
  String realproxypassword, int realproxyport, String realkeyFilename, String realkeyPass ) throws Exception {

  /* Create a connection instance */

  Connection conn = new Connection( realservername, realserverport );

  /* We want to connect through a HTTP proxy */
  if ( useproxy ) {
    conn.setProxyData( new HTTPProxyData( realproxyhost, realproxyport ) );

    /* Now connect */
    // if the proxy requires basic authentication:
    if ( !Utils.isEmpty( realproxyusername ) || !Utils.isEmpty( realproxypassword ) ) {
      conn
        .setProxyData( new HTTPProxyData( realproxyhost, realproxyport, realproxyusername, realproxypassword ) );
    }
  }

  if ( timeout > 0 ) {
    // Use timeout
    conn.connect( null, 0, timeout * 1000 );

  } else {
    // Cache Host Key
    conn.connect();
  }

  // Authenticate

  boolean isAuthenticated = false;
  if ( publicpublickey ) {
    isAuthenticated = conn.authenticateWithPublicKey( realUsername, new File( realkeyFilename ), realkeyPass );
  } else {
    isAuthenticated = conn.authenticateWithPassword( realUsername, realserverpassword );
  }

  if ( !isAuthenticated ) {
    throw new Exception( "Can not connect to " );
  }

  sshclient = new SFTPv3Client( conn );

}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:46,代码来源:JobEntryFTPDelete.java

示例12: OpenConnection

import com.trilead.ssh2.Connection; //导入方法依赖的package包/类
public static Connection OpenConnection( String serveur, int port, String username, String password,
    boolean useKey, String keyFilename, String passPhrase, int timeOut, VariableSpace space, String proxyhost,
    int proxyport, String proxyusername, String proxypassword ) throws KettleException {
  Connection conn = null;
  char[] content = null;
  boolean isAuthenticated = false;
  try {
    // perform some checks
    if ( useKey ) {
      if ( Utils.isEmpty( keyFilename ) ) {
        throw new KettleException( BaseMessages.getString( SSHMeta.PKG, "SSH.Error.PrivateKeyFileMissing" ) );
      }
      FileObject keyFileObject = KettleVFS.getFileObject( keyFilename );

      if ( !keyFileObject.exists() ) {
        throw new KettleException( BaseMessages.getString( SSHMeta.PKG, "SSH.Error.PrivateKeyNotExist", keyFilename ) );
      }

      FileContent keyFileContent = keyFileObject.getContent();

      CharArrayWriter charArrayWriter = new CharArrayWriter( (int) keyFileContent.getSize() );

      try ( InputStream in = keyFileContent.getInputStream() ) {
        IOUtils.copy( in, charArrayWriter );
      }

      content = charArrayWriter.toCharArray();
    }
    // Create a new connection
    conn = createConnection( serveur, port );

    /* We want to connect through a HTTP proxy */
    if ( !Utils.isEmpty( proxyhost ) ) {
      /* Now connect */
      // if the proxy requires basic authentication:
      if ( !Utils.isEmpty( proxyusername ) ) {
        conn.setProxyData( new HTTPProxyData( proxyhost, proxyport, proxyusername, proxypassword ) );
      } else {
        conn.setProxyData( new HTTPProxyData( proxyhost, proxyport ) );
      }
    }

    // and connect
    if ( timeOut == 0 ) {
      conn.connect();
    } else {
      conn.connect( null, 0, timeOut * 1000 );
    }
    // authenticate
    if ( useKey ) {
      isAuthenticated =
        conn.authenticateWithPublicKey( username, content, space.environmentSubstitute( passPhrase ) );
    } else {
      isAuthenticated = conn.authenticateWithPassword( username, password );
    }
    if ( isAuthenticated == false ) {
      throw new KettleException( BaseMessages.getString( SSHMeta.PKG, "SSH.Error.AuthenticationFailed", username ) );
    }
  } catch ( Exception e ) {
    // Something wrong happened
    // do not forget to disconnect if connected
    if ( conn != null ) {
      conn.close();
    }
    throw new KettleException( BaseMessages.getString( SSHMeta.PKG, "SSH.Error.ErrorConnecting", serveur, username ), e );
  }
  return conn;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:69,代码来源:SSHData.java


注:本文中的com.trilead.ssh2.Connection.setProxyData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。