1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

[259367][telnet][api] Allow the ITelnetSessionProvider to configure Telnet options before logging in

This commit is contained in:
Martin Oberhuber 2008-12-19 14:12:06 +00:00
parent 67258abee6
commit f304881272
4 changed files with 69 additions and 42 deletions

View file

@ -2,11 +2,11 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.connectorservice.telnet;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.2.0.qualifier
Bundle-Activator: org.eclipse.rse.internal.connectorservice.telnet.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.rse.services.telnet;bundle-version="[1.1.0,2.0.0)",
org.eclipse.rse.services.telnet;bundle-version="[1.2.0,2.0.0)",
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",

View file

@ -151,10 +151,10 @@ public class TelnetConnectorService extends StandardConnectorService implements
public TelnetClient makeNewTelnetClient(IProgressMonitor monitor ) throws Exception {
TelnetClient client = new TelnetClient();
return makeNewTelnetClient(client, monitor);
return loginTelnetClient(client, monitor);
}
public TelnetClient makeNewTelnetClient(TelnetClient client, IProgressMonitor monitor ) throws Exception {
public TelnetClient loginTelnetClient(TelnetClient client, IProgressMonitor monitor) throws SystemMessageException {
String host = getHostName();
String user = getUserId();
String password = ""; //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -20,24 +20,51 @@ package org.eclipse.rse.internal.services.telnet;
import org.apache.commons.net.telnet.TelnetClient;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
public interface ITelnetSessionProvider {
/**
* Create a new Commons.Net TelnetClient.
* Create a new Commons.Net TelnetClient, and authenticate it with the
* remote.
*
* @param monitor progress monitor
* @return a new Commons.Net TelnetClient for the given connection, already authenticated
* @return a new Commons.Net TelnetClient for the given connection, already
* authenticated
* @throws Exception in case of any error
*/
public TelnetClient makeNewTelnetClient(IProgressMonitor monitor) throws Exception ;
/**
* Initialize a new Commons.Net TelnetClient with a given ptyType.
* Authenticate an existing Commons.Net TelnetClient connection with the
* remote, using the credentials known to RSE. Depending on configuration
* options, this may answer the remote "login:" and "password:" prompts to
* come up with an authenticated client.
*
* By passing in a pre-existing TelnetClient instance, this method allows
* for fine-tuning the TelnetClient options such as ECHO handling through
* the Commons.Net APIs before using RSE to authenticate the client.
*
* Example:
*
* <pre>
* TelnetClient client = new TelnetClient(&quot;vt100&quot;);
* client.addOptionHandler(new EchoOptionHandler(false, true, true, true));
* client = fSessionProvider.loginTelnetClient(client, new NullProgressMonitor());
* </pre>
*
* @param client telnet client already created
* @param monitor progress monitor
* @return authenticated client for the given connection
* @throws Exception in case of any error
* @return authenticated client for the given connection, or
* <code>null</code> in case the user cancelled the login through
* the progress monitor. The passed-in client is disconnected in
* this case.
* @throws SystemMessageException in case of an error while authenticating
* (such as timeout, communications error, or failure matching
* expected prompt). The passed-in TelnetClient remains
* connected in this case.
* @since 1.2
*/
public TelnetClient makeNewTelnetClient(TelnetClient client, IProgressMonitor monitor) throws Exception ;
public TelnetClient loginTelnetClient(TelnetClient client, IProgressMonitor monitor) throws SystemMessageException;
}

View file

@ -99,7 +99,7 @@ public class TelnetTerminalShell extends AbstractTerminalShell {
true, true, true));
fTelnetClient.addOptionHandler(new TerminalTypeOptionHandler(
ptyType, true, true, true, true));
fTelnetClient = fSessionProvider.makeNewTelnetClient(fTelnetClient,
fTelnetClient = fSessionProvider.loginTelnetClient(fTelnetClient,
new NullProgressMonitor());
fOutputStream = fTelnetClient.getOutputStream();
if (onUNIX)