Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindbright.ssh2
Class SSH2FTPOverSFTP

    java.lang.Object
      com.mindbright.ssh2.SSH2FTPOverSFTP

All Implemented Interfaces:
  FTPServerEventHandler

Direct Known Subclasses:
  FTPToSFTPProxy

public class SSH2FTPOverSFTP
extends java.lang.Object
implements FTPServerEventHandler

Implements a proxy which proxies between an ftp client and an sftp server.

Field Summary
`protected SSH2Connection` | `connection` The `SSH2Connection` to use
`protected FTPServer` | `ftp` FTP server instance
`protected SSH2SFTPClient` | `sftp` SFTP client instance

Constructor Summary
`protected` | `SSH2FTPOverSFTP(java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, java.lang.String identity, boolean needPassword)`
`` | `SSH2FTPOverSFTP(SSH2Connection connection, java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, boolean remoteIsWindows, java.lang.String identity)`
`` | `SSH2FTPOverSFTP(SSH2Connection connection, java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, java.lang.String identity)`

Method Summary
`void` | `abort()`
`void` | `changeDirectory(java.lang.String dir)` Change current directory on the server.
`void` | `chmod(int mod, java.lang.String file)` Modify the file permissions.
`void` | `delete(java.lang.String file)` Delete the given file.
`protected void` | `initFTP(java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, boolean remoteIsWindows, java.lang.String identity, boolean needPassword)` Initialize the FTP server portion of this class.
`protected void` | `initFTP(java.io.InputStream ftpInput, java.io.OutputStream ftpOutput, java.lang.String identity, boolean needPassword)` Initialize the FTP server portion of this class.
`protected void` | `initSFTP(SSH2Connection connection)` Connect this instance with an `SSH2Connection` which is connected to the server we want to transfer files to/from.
`boolean` | `isPlainFile(java.lang.String file)` Check if the name refers to a normal file as opposed to for example a directory.
`void` | `list(java.lang.String path, java.io.OutputStream data)` Lists the names of the files and directories in the given directory.
`boolean` | `login(java.lang.String user, java.lang.String pass)` Login to server.
`void` | `mkdir(java.lang.String dir)` Create a new directory.
`long` | `modTime(java.lang.String file)` Find out when a file was last modified.
`void` | `nameList(java.lang.String path, java.io.OutputStream data)` Lists the contents of the given directory.
`java.lang.String` | `pwd()` Get the current working directory.
`void` | `quit()` Close the ftp session.
`void` | `renameFrom(java.lang.String from)` The first step in a rename operation.
`void` | `renameTo(java.lang.String to)` The second step in the rename operation.
`void` | `retrieve(java.lang.String file, java.io.OutputStream data, boolean binary)` Retrieve a file from the server.
`void` | `rmdir(java.lang.String dir)` Remove the given directory.
`long` | `size(java.lang.String file)` Get the size of a file.
`void` | `store(java.lang.String file, java.io.InputStream data, boolean binary)` Store a file on the server.
`java.lang.String` | `system()` Get the type of system the server is running.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### connection

    protected SSH2Connection connection

  The `SSH2Connection` to use

### sftp

    protected SSH2SFTPClient sftp

  SFTP client instance

### ftp

    protected FTPServer ftp

  FTP server instance

Constructor Detail

### SSH2FTPOverSFTP

    protected SSH2FTPOverSFTP(java.io.InputStream ftpInput,
                              java.io.OutputStream ftpOutput,
                              java.lang.String identity,
                              boolean needPassword)

### SSH2FTPOverSFTP

    public SSH2FTPOverSFTP(SSH2Connection connection,
                           java.io.InputStream ftpInput,
                           java.io.OutputStream ftpOutput,
                           java.lang.String identity)
                    throws SSH2SFTP.SFTPException

### SSH2FTPOverSFTP

    public SSH2FTPOverSFTP(SSH2Connection connection,
                           java.io.InputStream ftpInput,
                           java.io.OutputStream ftpOutput,
                           boolean remoteIsWindows,
                           java.lang.String identity)
                    throws SSH2SFTP.SFTPException

Method Detail

### initSFTP

    protected void initSFTP(SSH2Connection connection)
                     throws SSH2SFTP.SFTPException

  Connect this instance with an `SSH2Connection` which is connected to the server we want to transfer files to/from.

  Parameters:
    `connection` - Established connection to the server.
  Throws:
    `SSH2SFTP.SFTPException`

### initFTP

    protected void initFTP(java.io.InputStream ftpInput,
                           java.io.OutputStream ftpOutput,
                           java.lang.String identity,
                           boolean needPassword)

  Initialize the FTP server portion of this class.

  Parameters:
    `ftpInput` - The ftp command input stream.
    `ftpOutput` - The ftp command output stream.
    `identity` - Username to log in as
    `needPassword` - Tells the instance if it should request a password or not from the user. The actual password the user then gives is ignored.

### initFTP

    protected void initFTP(java.io.InputStream ftpInput,
                           java.io.OutputStream ftpOutput,
                           boolean remoteIsWindows,
                           java.lang.String identity,
                           boolean needPassword)

  Initialize the FTP server portion of this class.

  Parameters:
    `ftpInput` - The ftp command input stream.
    `ftpOutput` - The ftp command output stream.
    `remoteIsWindows` - Whether remote system is a Windows system or not.
    `identity` - Username to log in as
    `needPassword` - Tells the instance if it should request a password or not from the user. The actual password the user then gives is ignored.

### login

    public boolean login(java.lang.String user,
                         java.lang.String pass)

  Login to server. This is actually a null operation for this class since the user is already authenticated as part of the SSH connection.

  Specified by:
    `login` in interface `FTPServerEventHandler`
  Parameters:
    `user` - Username to login as.
    `pass` - Password.
  Returns:
    true if the login was successful.

### quit

    public void quit()

  Description copied from interface: `FTPServerEventHandler`
  Close the ftp session.

  Specified by:
    `quit` in interface `FTPServerEventHandler`

### isPlainFile

    public boolean isPlainFile(java.lang.String file)

  Description copied from interface: `FTPServerEventHandler`
  Check if the name refers to a normal file as opposed to for example a directory.

  Specified by:
    `isPlainFile` in interface `FTPServerEventHandler`
  Parameters:
    `file` - The name of the file.
  Returns:
    True if the name refers to a plain file.

### changeDirectory

    public void changeDirectory(java.lang.String dir)
                         throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Change current directory on the server.

  Specified by:
    `changeDirectory` in interface `FTPServerEventHandler`
  Parameters:
    `dir` - Name of new directory
  Throws:
    `FTPException`

### renameFrom

    public void renameFrom(java.lang.String from)
                    throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  The first step in a rename operation. Specifies which file to rename. Must be folloed by a call to `renameTo`.

  Specified by:
    `renameFrom` in interface `FTPServerEventHandler`
  Parameters:
    `from` - The name of the file to rename.
  Throws:
    `FTPException`

### renameTo

    public void renameTo(java.lang.String to)
                  throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  The second step in the rename operation. Specifies the new name of the file. Must be preceeded by a call to `renameFrom`

  Specified by:
    `renameTo` in interface `FTPServerEventHandler`
  Parameters:
    `to` - The new name of the file.
  Throws:
    `FTPException`

### delete

    public void delete(java.lang.String file)
                throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Delete the given file.

  Specified by:
    `delete` in interface `FTPServerEventHandler`
  Parameters:
    `file` - Name of the file to delete.
  Throws:
    `FTPException`

### rmdir

    public void rmdir(java.lang.String dir)
               throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Remove the given directory.

  Specified by:
    `rmdir` in interface `FTPServerEventHandler`
  Parameters:
    `dir` - Directory to remove.
  Throws:
    `FTPException`

### mkdir

    public void mkdir(java.lang.String dir)
               throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Create a new directory.

  Specified by:
    `mkdir` in interface `FTPServerEventHandler`
  Parameters:
    `dir` - Name of directory to create.
  Throws:
    `FTPException`

### chmod

    public void chmod(int mod,
                      java.lang.String file)
               throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Modify the file permissions.

  Specified by:
    `chmod` in interface `FTPServerEventHandler`
  Parameters:
    `mod` - New file permissions.
    `file` - Name of file to modify.
  Throws:
    `FTPException`

### pwd

    public java.lang.String pwd()

  Description copied from interface: `FTPServerEventHandler`
  Get the current working directory.

  Specified by:
    `pwd` in interface `FTPServerEventHandler`
  Returns:
    The path to the current working directory.

### system

    public java.lang.String system()

  Description copied from interface: `FTPServerEventHandler`
  Get the type of system the server is running.

  Specified by:
    `system` in interface `FTPServerEventHandler`
  Returns:
    A string describing the system.

### modTime

    public long modTime(java.lang.String file)
                 throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Find out when a file was last modified.

  Specified by:
    `modTime` in interface `FTPServerEventHandler`
  Parameters:
    `file` - Name of file to investigate.
  Returns:
    The timestamp of the file.
  Throws:
    `FTPException`

### size

    public long size(java.lang.String file)
              throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Get the size of a file.

  Specified by:
    `size` in interface `FTPServerEventHandler`
  Parameters:
    `file` - Name of file to get the size of.
  Returns:
    The size of the file.
  Throws:
    `FTPException`

### store

    public void store(java.lang.String file,
                      java.io.InputStream data,
                      boolean binary)
               throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Store a file on the server. Line endings are translated into the proper form for non-binary files.

  Specified by:
    `store` in interface `FTPServerEventHandler`
  Parameters:
    `file` - Name to store file as.
    `data` - Stream from which the contents of the file is read.
    `binary` - Controls the translating of line endings.
  Throws:
    `FTPException`

### retrieve

    public void retrieve(java.lang.String file,
                         java.io.OutputStream data,
                         boolean binary)
                  throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Retrieve a file from the server. Line endings are translated into the proper form for non-binary files.

  Specified by:
    `retrieve` in interface `FTPServerEventHandler`
  Parameters:
    `file` - Name of file to retrieve.
    `data` - Stream to which the file content is written.
    `binary` - Controls the translating of line endings.
  Throws:
    `FTPException`

### list

    public void list(java.lang.String path,
                     java.io.OutputStream data)
              throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Lists the names of the files and directories in the given directory. The difference between this function and `nameList` is that the latter appends a trailing '/' to directory names.

  Specified by:
    `list` in interface `FTPServerEventHandler`
  Parameters:
    `path` - Directory to list the contens of.
    `data` - Stream to write the results to.
  Throws:
    `FTPException`

### nameList

    public void nameList(java.lang.String path,
                         java.io.OutputStream data)
                  throws FTPException

  Description copied from interface: `FTPServerEventHandler`
  Lists the contents of the given directory. The difference between this function and `list` is that the this appends a trailing '/' to directory names.

  Specified by:
    `nameList` in interface `FTPServerEventHandler`
  Parameters:
    `path` - Directory to list the contens of.
    `data` - Stream to write the results to.
  Throws:
    `FTPException`

### abort

    public void abort()

  Specified by:
    `abort` in interface `FTPServerEventHandler`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD