com.ssh.sft
Class Sft
java.lang.Object
com.ssh.sft.SftLib
com.ssh.sft.SftBase
com.ssh.sft.Sft
- All Implemented Interfaces:
- SftLibConstants
- public class Sft
- extends com.ssh.sft.SftBase
The Secure File Transfer service. The SFT service allows manipulation of files and directory hierarchies in remote hosts. The SSH Tectia Server needs to be running on the remote hosts, and the SSH Tectia Broker needs to be running on the local host under the same user ID as the Java process that uses the SFT Service.
Constructor Summary |
Sft() Creates a new instance of the SFT service. |
Sft(String broker_addr, Authenticator authenticator) Creates a new instance of the SFT service. |
Sft
public Sft()
- Creates a new instance of the SFT service. It will be the same as calling Sft(null, null).
Sft
public Sft(String broker_addr,
Authenticator authenticator)
- Creates a new instance of the SFT service. The authenticator is used to authenticate new SSH connections that the service needs to open.
- Parameters:
broker_addr
- the broker_address to connect (set to null to connect to default broker)authenticator
- the authenticator to use. In windows, if set to null, ssh-broker-gui will be the authenticator.
getLocation
public Location getLocation(URI uri)
throws SftException
- Returns the
Location
of a given file. This call will open a Session
if needed, (if there is a session already open to the same host, it will reuse that given session). If broker does not have a connection to the server, connects to the server first. In this case, the authenticator may be called before returning. - Parameters:
uri
- the URI where the remote file is specified. - Returns:
- the
Location
object of the remote file - Throws:
SftException
openFile
public File openFile(URI uri)
throws SftException
- Returns the
File
pointed by the URI. It is the same as calling 'getLocation(uri).getFile()'. - Parameters:
uri
- the URI where the remote file is specified. - Returns:
- the
File
who represents the remote file. - Throws:
SftException
openSession
public Session openSession(URI uri)
throws SftException
- Opens a new SFTP session using the username, host and port specified in the URI. It does not reuse already existing SFTP sessions. If necessary, connects to the server first. In this case, the authenticator may be called before returning. It uses the broker_address and the authenticator providen to the constructor of the
Sft
. - Parameters:
uri
- the URI where username, host and port is specified. - Returns:
- the new SFTP
Session
. - Throws:
SftException
openLocalSession
public Session openLocalSession()
throws SftException
- Opens an SFTP session to the local host as the current user. No authentication is required. It is the same as opening a session with an URI without specifying username, host and port.
- Returns:
- the new SFTP
Session
. - Throws:
SftException