Package org.eclipse.jsch.core
Interface IJSchService
public interface IJSchService
A service whose purpose is to ensure that all the JSch preferences are properly pushed into JSch
before a
Session is created. The service is registered as
an OSGi service. Clients can obtain an instance of the service from their bundle context
or from a service tracker.
This interface is not intended to be implemented by clients.- Since:
- 1.0
- Restriction:
-
Method Summary
Modifier and TypeMethodDescriptionvoidconnect(com.jcraft.jsch.Proxy proxy, String host, int port, int timeout, IProgressMonitor monitor) Connect to the given host and port using the given proxy.voidconnect(com.jcraft.jsch.Session session, int timeout, IProgressMonitor monitor) Connect the session using a responsive socket factory.com.jcraft.jsch.SessioncreateSession(String host, int port, String username) Create aSessionthat can be used to make SSH2 connections.com.jcraft.jsch.SessioncreateSession(IJSchLocation location, com.jcraft.jsch.UserInfo uinfo) Create aSessionthat can be used to make SSH2 connections.com.jcraft.jsch.JSchgetJSch()Get the singleton instance of JSch allocated in jsch.core plug-in internally.getLocation(String user, String host, int port) Get the IJSchLocation according to given user name, host name and port number.com.jcraft.jsch.ProxygetProxyForHost(String host, String proxyType) Return the proxy that should be used to connect to the given host ornullif no proxy is specified for the host.
-
Method Details
-
createSession
com.jcraft.jsch.Session createSession(String host, int port, String username) throws com.jcraft.jsch.JSchException Create aSessionthat can be used to make SSH2 connections. This method ensures that all preferences are properly propagated into JSch before creating the session and also ensures that the session uses the appropriate proxy settings.Calling this method does not connect the session (see
connect(Session, int, IProgressMonitor), if connection throws an exception, clients should check to see if the session is still connected (seeSession.isConnected(). If it is, they should callSession.disconnect().- Parameters:
host- the host nameport- the port or -1 if the default port is to be usedusername- the user name ornullif there is no user name or the user name is not known- Returns:
- the created session
- Throws:
com.jcraft.jsch.JSchException- if errors occur
-
createSession
com.jcraft.jsch.Session createSession(IJSchLocation location, com.jcraft.jsch.UserInfo uinfo) throws com.jcraft.jsch.JSchException Create aSessionthat can be used to make SSH2 connections. This method ensures that all preferences are properly propagated into JSch before creating the session and also ensures that the session uses the appropriate proxy settings.Calling this method does not connect the session (see
connect(Session, int, IProgressMonitor), if connection throws an exception, clients should check to see if the session is still connected (seeSession.isConnected(). If it is, they should callSession.disconnect().- Parameters:
location- the location which corresponds to user@host:portuinfo- an instance ofUserInfoornullif the internal UserInfo implementation should be used.- Returns:
- the created session
- Throws:
com.jcraft.jsch.JSchException- if errors occur- Since:
- 1.1
-
connect
void connect(com.jcraft.jsch.Session session, int timeout, IProgressMonitor monitor) throws com.jcraft.jsch.JSchException Connect the session using a responsive socket factory. The timeout value is used for socket creation only. Clients that desire a timeout on the session must callSession.setTimeout(int). If session connection fails due to an exception, the session will be disconnected by this method.- Parameters:
session- the session to be connectedtimeout- a timeout in millisecondsmonitor- a progress monitor ornullif progress and cancelation is not desired- Throws:
com.jcraft.jsch.JSchException- if an exception occurs connecting the session.
-
getProxyForHost
Return the proxy that should be used to connect to the given host ornullif no proxy is specified for the host.- Parameters:
host- the hostproxyType- the proxy type (eitherIProxyData.HTTPS_PROXY_TYPEorIProxyData.SOCKS_PROXY_TYPE)- Returns:
- the proxy that should be used to connect to the given host or
nullif no proxy is specified for the host
-
connect
void connect(com.jcraft.jsch.Proxy proxy, String host, int port, int timeout, IProgressMonitor monitor) throws com.jcraft.jsch.JSchException Connect to the given host and port using the given proxy. This method callsProxy.connect(SocketFactory, String, int, int)and provides aSocketFactorythat responds to cancelation.- Parameters:
proxy- the proxyhost- the host nameport- the porttimeout- a timeout in millisecondsmonitor- a progress monitor ornullif progress and cancelation is not desired- Throws:
com.jcraft.jsch.JSchException- if errors occur
-
getLocation
Get the IJSchLocation according to given user name, host name and port number.- Parameters:
user- user name for ssh2 connectionhost- host name for ssh2 connectionport- port number for ssh2 connection- Returns:
- the created IJSchLocation
- Since:
- 1.1
-
getJSch
com.jcraft.jsch.JSch getJSch()Get the singleton instance of JSch allocated in jsch.core plug-in internally.- Returns:
- the singleton instance of JSch.
- Since:
- 1.1
-