KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jsch > core > IJSchService


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jsch.core;
12
13 import org.eclipse.core.net.proxy.IProxyData;
14 import org.eclipse.core.runtime.IProgressMonitor;
15
16 import com.jcraft.jsch.*;
17
18 /**
19  * A service whose purpose is to ensure that all the JSch preferences are properly pushed into JSch
20  * before a {@link Session} is created. The service is registered as
21  * an OSGi service. Clients can obtain an instance of the service from their bundle context
22  * or from a service tracker.
23  * @since 1.0
24  */

25 public interface IJSchService{
26
27   /**
28    * Create a {@link Session} that can be used to make SSH2 connections. This method ensures that
29    * all preferences are properly propagated into JSch before creating the session and also
30    * ensures that the session uses the appropriate proxy settings.
31    * <p>
32    * Calling this method does not connect the session (see {@link #connect(Session, int, IProgressMonitor)}, if connection
33    * throws an exception, clients should check to see if the session is still connected (see {@link Session#isConnected()}.
34    * If it is, they should call {@link Session#disconnect()}.
35    *
36    * @param host the host name
37    * @param port the port or -1 if the default port is to be used
38    * @param username the user name or <code>null</code> if there is no user name or the user name is not known
39    
40    * @return the created session
41    * @throws JSchException if errors occur
42    */

43   public abstract Session createSession(String JavaDoc host, int port, String JavaDoc username)
44       throws JSchException;
45
46   /**
47    * Connect the session using a responsive socket factory. The timeout value is used
48    * for socket creation only. Clients that desire a timeout on the session must
49    * call {@link Session#setTimeout(int)}. If session connection fails due to an exception,
50    * the session will be disconnected by this method.
51    *
52    * @param session the session to be connected
53    * @param timeout
54    * a timeout in milliseconds
55    * @param monitor
56    * a progress monitor or <code>null</code> if progress and
57    * cancelation is not desired
58    * @throws JSchException if an exception occurs connecting the session.
59    */

60   public abstract void connect(Session session, int timeout,
61       IProgressMonitor monitor) throws JSchException;
62
63   /**
64    * Return the proxy that should be used to connect to the given host or <code>null</code>
65    * if no proxy is specified for the host.
66    * @param host the host
67    * @param proxyType the proxy type (either {@link IProxyData#HTTPS_PROXY_TYPE} or {@link IProxyData#SOCKS_PROXY_TYPE})
68    * @return the proxy that should be used to connect to the given host or <code>null</code>
69    * if no proxy is specified for the host
70    */

71   public abstract Proxy getProxyForHost(String JavaDoc host, String JavaDoc proxyType);
72   
73   /**
74    * Connect to the given host and port using the given proxy.
75    * This method calls {@link Proxy#connect(SocketFactory, String, int, int)}
76    * and provides a {@link SocketFactory} that responds to cancelation.
77    * @param proxy the proxy
78    * @param host the host name
79    * @param port the port
80    * @param timeout
81    * a timeout in milliseconds
82    * @param monitor
83    * a progress monitor or <code>null</code> if progress and
84    * cancelation is not desired
85    * @throws JSchException
86    */

87   public abstract void connect(Proxy proxy, String JavaDoc host, int port, int timeout,
88       IProgressMonitor monitor) throws JSchException;
89
90 }
Popular Tags