1 11 package org.eclipse.team.internal.ccvs.ssh; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.io.OutputStream ; 16 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; 19 import org.eclipse.team.internal.ccvs.core.IServerConnection; 20 import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; 21 22 public class SSHServerConnection implements IServerConnection { 23 24 private static final String INVOKE_SVR_CMD = "cvs server"; 27 private static final int DEFAULT_PORT = 22; 28 29 private ICVSRepositoryLocation location; 31 32 private String password; 34 35 InputStream inputStream; 37 38 OutputStream outputStream; 40 41 Client client; 43 44 public SSHServerConnection(ICVSRepositoryLocation location, String password) { 45 if (password == null) { 46 password = ""; } 48 this.location = location; 49 this.password = password; 50 } 51 52 public void close() throws IOException { 53 client.disconnect(); 54 } 55 59 public InputStream getInputStream() { 60 return inputStream; 61 } 62 66 public OutputStream getOutputStream() { 67 return outputStream; 68 } 69 70 75 public void open(IProgressMonitor monitor) throws IOException , CVSAuthenticationException { 76 monitor.subTask(CVSSSHMessages.SSHServerConnection_authenticating); 77 monitor.worked(1); 78 String hostname = location.getHost(); 79 String username = location.getUsername(); 80 int port = location.getPort(); 81 if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) 82 port = DEFAULT_PORT; 83 client = new Client(hostname, port, username, password, INVOKE_SVR_CMD, location.getTimeout()); 85 client.connect(monitor); 86 inputStream = client.getInputStream(); 87 outputStream = client.getOutputStream(); 88 } 89 } 90 | Popular Tags |