Skip to main content
summaryrefslogtreecommitdiffstats
blob: c7c1b6f6957c30466019868f0b3edc40764fc011 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.eclipse.team.internal.ccvs.ssh2;

/*
 * (c) Copyright IBM Corp. 2000, 2003.
 * All Rights Reserved.
 */

import java.io.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IServerConnection;
import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
import org.eclipse.team.internal.ccvs.ssh.SSHPlugin;

import com.jcraft.jsch.*;

public class SSH2ServerConnection implements IServerConnection {

	// command to start remote cvs in server mode
	private static final String INVOKE_SVR_CMD = "cvs server"; //$NON-NLS-1$
	
	// cvs format for the repository (e.g. :extssh:user@host:/home/cvs/repo)
	private ICVSRepositoryLocation location;
	// password for user specified in repository location string
	private String password;
	
	private ChannelExec channel;
	private InputStream inputStream;
	private OutputStream outputStream;

	protected SSH2ServerConnection(ICVSRepositoryLocation location, String password) {
		this.location = location;
		this.password = password;
	}

	public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
		ConnectionProgressMonitor innerMonitor = new ConnectionProgressMonitor(monitor);
		Session session = SSHPlugin.getPlugin().getPool().getSession(location, password, innerMonitor);
		channel=(ChannelExec) session.openChannel("exec");
		((ChannelExec)channel).setCommand(INVOKE_SVR_CMD);
		channel.connect();
		inputStream = channel.getInputStream();
		outputStream = channel.getOutputStream();
	}



	/**
	 * @see org.eclipse.team.internal.ccvs.core.IServerConnection#close()
	 */
	public void close() throws IOException {
		channel.close();
	}

	/**
	 * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getInputStream()
	 */
	public InputStream getInputStream() {
		return inputStream;
	}

	/**
	 * @see org.eclipse.team.internal.ccvs.core.IServerConnection#getOutputStream()
	 */
	public OutputStream getOutputStream() {
		return outputStream;
	}

}

Back to the top