Package ch.ethz.ssh2

Examples of ch.ethz.ssh2.HTTPProxyData


      return s;
    }

    if (proxyData instanceof HTTPProxyData)
    {
      HTTPProxyData pd = (HTTPProxyData) proxyData;

      /* At the moment, we only support HTTP proxies */

      InetAddress addr = createInetAddress(pd.proxyHost);
      Socket s = new Socket();
View Full Code Here


       * (the above text is based partially on the OpenSSH man page)
       */

      /* You can create as many of them as you want */
     
      LocalPortForwarder lpf1 = conn.createLocalPortForwarder(8080, "www.ethz.ch", 80);
     
      /* Now simply point your webbrowser to 127.0.0.1:8080 */
      /* (on the host where you execute this program)                         */

      /* ===== OK, now let's establish some remote port forwardings ===== */
     
      /* Example Port Forwarding: -R 127.0.0.1:8080:www.ganymed.ethz.ch:80 (OpenSSH notation)
       *
       * Specifies that the port 127.0.0.1:8080 on the remote server is to be forwarded to the
       * given host and port on the local side.  This works by allocating a socket to listen to port
       * 8080 on the remote side (the ssh server), and whenever a connection is made to this port, the
       * connection is forwarded over the secure channel, and a connection is made to
       * www.ganymed.ethz.ch:80 by the Ganymed SSH-2 library.
       *
       * (the above text is based partially on the OpenSSH man page)
       */

      /* You can create as many of them as you want */
     
      conn.requestRemotePortForwarding("127.0.0.1", 8080, "www.ganymed.ethz.ch", 80);

      /* Now, on the ssh server, if you connect to 127.0.0.1:8080, then the connection is forwarded
       * through the secure tunnel to the library, which in turn will forward the connection
       * to www.ganymed.ethz.ch:80. */

      /* Sleep a bit... (30 seconds) */
      sleepSomeTime(30000);

      /* Stop accepting remote connections that are being forwarded to www.ganymed.ethz.ch:80 */

      conn.cancelRemotePortForwarding(8080);

      /* Sleep a bit... (20 seconds) */
      sleepSomeTime(20000);

      /* Stop accepting connections on 127.0.0.1:8080 that are being forwarded to www.ethz.ch:80 */

      lpf1.close();
     
      /* Close the connection */

      conn.close();

 
View Full Code Here

    public void testWithGanymede() throws Exception {
        // begin client config
        final Connection conn = new Connection("localhost", port);
        conn.connect(null, 5000, 0);
        conn.authenticateWithPassword("sshd", "sshd");
        final SCPClient scp_client = new SCPClient(conn);
        final Properties props = new Properties();
        props.setProperty("test", "test-passed");
        File f = new File("target/scp/gan");
        Utils.deleteRecursive(f);
        f.mkdirs();
        assertTrue(f.exists());

        String name = "test.properties";
        scp_client.put(toBytes(props, ""), name, "target/scp/gan");
        assertTrue(new File(f, name).exists());
        assertTrue(new File(f, name).delete());

        name = "test2.properties";
        scp_client.put(toBytes(props, ""), name, "target/scp/gan");
        assertTrue(new File(f, name).exists());
        assertTrue(new File(f, name).delete());

        assertTrue(f.delete());
        conn.close();
View Full Code Here

    public void testWithGanymede() throws Exception {
        // begin client config
        final Connection conn = new Connection("localhost", port);
        conn.connect(null, 5000, 0);
        conn.authenticateWithPassword("sshd", "sshd");
        final SCPClient scp_client = new SCPClient(conn);
        final Properties props = new Properties();
        props.setProperty("test", "test-passed");
        File f = new File("target/scp/gan");
        Utils.deleteRecursive(f);
        f.mkdirs();
        assertTrue(f.exists());

        String name = "test.properties";
        scp_client.put(toBytes(props, ""), name, "target/scp/gan");
        assertTrue(new File(f, name).exists());
        assertTrue(new File(f, name).delete());

        name = "test2.properties";
        scp_client.put(toBytes(props, ""), name, "target/scp/gan");
        assertTrue(new File(f, name).exists());
        assertTrue(new File(f, name).delete());

        assertTrue(f.delete());
        conn.close();
View Full Code Here

    public void testWithGanymede() throws Exception {
        // begin client config
        final Connection conn = new Connection("localhost", port);
        conn.connect(null, 5000, 0);
        conn.authenticateWithPassword("sshd", "sshd");
        final SCPClient scp_client = new SCPClient(conn);
        final Properties props = new Properties();
        props.setProperty("test", "test-passed");
        File f = new File("target/scp/gan");
        scp_client.put(toBytes(props, ""), "test.properties", "target/scp/gan");
        assertTrue(f.exists());
        scp_client.put(toBytes(props, ""), "test2.properties", "target/scp/gan");
        assertTrue(f.exists());
        f.delete();
        conn.close();
    }
View Full Code Here

    }
  }

  private SFTPv3Client FtpClient() throws Exception {
    if (sftpClient == null) {
      sftpClient = new SFTPv3Client(this.getSshConnection());
    }
    return sftpClient;
  }
View Full Code Here

   * @throws Exception
   */
  protected boolean sshFileExists(SFTPv3Client psftpClient, String filename) {

    try {
      SFTPv3FileAttributes attributes = psftpClient.stat(filename);

      if (attributes != null) {
        return (attributes.isRegularFile() || attributes.isDirectory());
      }
      else {
        return false;
      }

View Full Code Here

   * @throws Exception
   */
  protected int sshFilePermissions(SFTPv3Client psftpClient, String filename) {

    try {
      SFTPv3FileAttributes attributes = psftpClient.stat(filename);

      if (attributes != null) {
        return attributes.permissions.intValue();
      }
      else {
View Full Code Here

  public SFTPv3FileHandle getFileHandle(final String pstrFileName, final Integer pintPermissions) throws Exception {

    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::setFilePermissions";

    SFTPv3FileAttributes attr = new SFTPv3FileAttributes();
    attr.permissions = pintPermissions;
    SFTPv3FileHandle fileHandle = this.FtpClient().createFileTruncate(pstrFileName, attr);
    return fileHandle;
  } // private void setFilePermissions
View Full Code Here

  public void setFilePermissions(final String pstrFileName, final Integer pintPermissions) throws Exception {

    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::setFilePermissions";

    SFTPv3FileAttributes attr = new SFTPv3FileAttributes();
    attr.permissions = pintPermissions;
    @SuppressWarnings("unused")
    SFTPv3FileHandle fileHandle = this.FtpClient().createFileTruncate(pstrFileName, attr);
  } // private void setFilePermissions
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.HTTPProxyData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.