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:
parent
67258abee6
commit
f304881272
4 changed files with 69 additions and 42 deletions
|
@ -2,11 +2,11 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.rse.connectorservice.telnet;singleton:=true
|
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-Activator: org.eclipse.rse.internal.connectorservice.telnet.Activator
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
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.services;bundle-version="[3.0.0,4.0.0)",
|
||||||
org.eclipse.rse.core;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)",
|
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||||
* David Dykstal (IBM) - [168977] refactoring IConnectorService and ServerLauncher hierarchies
|
* David Dykstal (IBM) - [168977] refactoring IConnectorService and ServerLauncher hierarchies
|
||||||
* Sheldon D'souza (Celunite) - adapted from SshConnectorService
|
* Sheldon D'souza (Celunite) - adapted from SshConnectorService
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [178606] fix endless loop in readUntil()
|
* Martin Oberhuber (Wind River) - [178606] fix endless loop in readUntil()
|
||||||
* Sheldon D'souza (Celunite) - [186536] login and password should be configurable
|
* Sheldon D'souza (Celunite) - [186536] login and password should be configurable
|
||||||
* Sheldon D'souza (Celunite) - [186570] handle invalid user id and password more gracefully
|
* Sheldon D'souza (Celunite) - [186570] handle invalid user id and password more gracefully
|
||||||
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
|
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
|
||||||
* Sheldon D'souza (Celunite) - [187301] support multiple telnet shells
|
* Sheldon D'souza (Celunite) - [187301] support multiple telnet shells
|
||||||
* Sheldon D'souza (Celunite) - [194464] fix create multiple telnet shells quickly
|
* Sheldon D'souza (Celunite) - [194464] fix create multiple telnet shells quickly
|
||||||
* Martin Oberhuber (Wind River) - [186761] make the port setting configurable
|
* Martin Oberhuber (Wind River) - [186761] make the port setting configurable
|
||||||
|
@ -94,7 +94,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
* Return the telnet property set, and fill it with default values if it has
|
* Return the telnet property set, and fill it with default values if it has
|
||||||
* not been created yet. Extenders may override in order to set different
|
* not been created yet. Extenders may override in order to set different
|
||||||
* default values.
|
* default values.
|
||||||
*
|
*
|
||||||
* @return a property set holding properties understood by the telnet
|
* @return a property set holding properties understood by the telnet
|
||||||
* connector service.
|
* connector service.
|
||||||
*/
|
*/
|
||||||
|
@ -106,9 +106,9 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
telnetSet.addProperty(PROPERTY_LOGIN_REQUIRED,
|
telnetSet.addProperty(PROPERTY_LOGIN_REQUIRED,
|
||||||
"true", PropertyType.getEnumPropertyType(new String[] { "true", "false" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"true", PropertyType.getEnumPropertyType(new String[] { "true", "false" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
telnetSet.addProperty(PROPERTY_LOGIN_PROMPT,
|
telnetSet.addProperty(PROPERTY_LOGIN_PROMPT,
|
||||||
"ogin: ", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
"ogin: ", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
||||||
telnetSet.addProperty(PROPERTY_PASSWORD_PROMPT,
|
telnetSet.addProperty(PROPERTY_PASSWORD_PROMPT,
|
||||||
"assword: ", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
"assword: ", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
||||||
telnetSet.addProperty(PROPERTY_COMMAND_PROMPT,
|
telnetSet.addProperty(PROPERTY_COMMAND_PROMPT,
|
||||||
"$", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
"$", PropertyType.getStringPropertyType()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -151,10 +151,10 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
|
|
||||||
public TelnetClient makeNewTelnetClient(IProgressMonitor monitor ) throws Exception {
|
public TelnetClient makeNewTelnetClient(IProgressMonitor monitor ) throws Exception {
|
||||||
TelnetClient client = new TelnetClient();
|
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 host = getHostName();
|
||||||
String user = getUserId();
|
String user = getUserId();
|
||||||
String password = ""; //$NON-NLS-1$
|
String password = ""; //$NON-NLS-1$
|
||||||
|
@ -213,14 +213,14 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
//from the remote side with the SystemMessageException for user diagnostics
|
//from the remote side with the SystemMessageException for user diagnostics
|
||||||
SystemMessage msg;
|
SystemMessage msg;
|
||||||
if (nestedException!=null) {
|
if (nestedException!=null) {
|
||||||
msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ICommonMessageIds.MSG_EXCEPTION_OCCURRED,
|
ICommonMessageIds.MSG_EXCEPTION_OCCURRED,
|
||||||
IStatus.ERROR,
|
IStatus.ERROR,
|
||||||
CommonMessages.MSG_EXCEPTION_OCCURRED, nestedException);
|
CommonMessages.MSG_EXCEPTION_OCCURRED, nestedException);
|
||||||
} else {
|
} else {
|
||||||
msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ICommonMessageIds.MSG_COMM_AUTH_FAILED,
|
ICommonMessageIds.MSG_COMM_AUTH_FAILED,
|
||||||
IStatus.ERROR,
|
IStatus.ERROR,
|
||||||
CommonMessages.MSG_COMM_AUTH_FAILED,
|
CommonMessages.MSG_COMM_AUTH_FAILED,
|
||||||
NLS.bind(CommonMessages.MSG_COMM_AUTH_FAILED_DETAILS, getHost().getAliasName()));
|
NLS.bind(CommonMessages.MSG_COMM_AUTH_FAILED_DETAILS, getHost().getAliasName()));
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
* Handle session-lost events. This is generic for any sort of connector
|
* Handle session-lost events. This is generic for any sort of connector
|
||||||
* service. Most of this is extracted from dstore's
|
* service. Most of this is extracted from dstore's
|
||||||
* ConnectionStatusListener.
|
* ConnectionStatusListener.
|
||||||
*
|
*
|
||||||
* TODO should be refactored to make it generally available, and allow
|
* TODO should be refactored to make it generally available, and allow
|
||||||
* dstore to derive from it.
|
* dstore to derive from it.
|
||||||
*/
|
*/
|
||||||
|
@ -371,11 +371,11 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
// TODO allow users to reconnect from this dialog
|
// TODO allow users to reconnect from this dialog
|
||||||
// SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST);
|
// SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST);
|
||||||
|
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ICommonMessageIds.MSG_CONNECT_CANCELLED,
|
ICommonMessageIds.MSG_CONNECT_CANCELLED,
|
||||||
IStatus.CANCEL,
|
IStatus.CANCEL,
|
||||||
NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, _connection.getHost().getAliasName()));
|
NLS.bind(CommonMessages.MSG_CONNECT_CANCELLED, _connection.getHost().getAliasName()));
|
||||||
|
|
||||||
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
try {
|
try {
|
||||||
|
@ -489,11 +489,11 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
*/
|
*/
|
||||||
protected void showDisconnectErrorMessage(Shell shell, String hostName,
|
protected void showDisconnectErrorMessage(Shell shell, String hostName,
|
||||||
int port, Exception exc) {
|
int port, Exception exc) {
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ICommonMessageIds.MSG_DISCONNECT_FAILED,
|
ICommonMessageIds.MSG_DISCONNECT_FAILED,
|
||||||
IStatus.ERROR,
|
IStatus.ERROR,
|
||||||
NLS.bind(CommonMessages.MSG_DISCONNECT_FAILED, hostName), exc);
|
NLS.bind(CommonMessages.MSG_DISCONNECT_FAILED, hostName), exc);
|
||||||
|
|
||||||
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,msg);
|
SystemMessageDialog msgDlg = new SystemMessageDialog(shell,msg);
|
||||||
msgDlg.setException(exc);
|
msgDlg.setException(exc);
|
||||||
msgDlg.open();
|
msgDlg.open();
|
||||||
|
@ -505,7 +505,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
*/
|
*/
|
||||||
protected void showDisconnectCancelledMessage(Shell shell,
|
protected void showDisconnectCancelledMessage(Shell shell,
|
||||||
String hostName, int port) {
|
String hostName, int port) {
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ICommonMessageIds.MSG_DISCONNECT_CANCELLED,
|
ICommonMessageIds.MSG_DISCONNECT_CANCELLED,
|
||||||
IStatus.CANCEL,
|
IStatus.CANCEL,
|
||||||
NLS.bind(CommonMessages.MSG_DISCONNECT_CANCELLED, hostName));
|
NLS.bind(CommonMessages.MSG_DISCONNECT_CANCELLED, hostName));
|
||||||
|
@ -602,7 +602,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
* Test if this connector service requires a password. Telnet connector
|
* Test if this connector service requires a password. Telnet connector
|
||||||
* service returns false since a password is not necessarily required, i.e.
|
* service returns false since a password is not necessarily required, i.e.
|
||||||
* the corresponding password field may be empty.
|
* the corresponding password field may be empty.
|
||||||
*
|
*
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
|
@ -614,7 +614,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
* Test if this connector service requires a user id. Telnet connector
|
* Test if this connector service requires a user id. Telnet connector
|
||||||
* service returns false since a user id is not necessarily required, i.e.
|
* service returns false since a user id is not necessarily required, i.e.
|
||||||
* the corresponding user id field may be empty.
|
* the corresponding user id field may be empty.
|
||||||
*
|
*
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
|
@ -624,7 +624,7 @@ public class TelnetConnectorService extends StandardConnectorService implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if this connector service requires logging in.
|
* Test if this connector service requires logging in.
|
||||||
*
|
*
|
||||||
* @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED} is set and
|
* @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED} is set and
|
||||||
* false. Returns true otherwise.
|
* false. Returns true otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,10 @@
|
||||||
*
|
*
|
||||||
* Initial Contributors:
|
* Initial Contributors:
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
* The following IBM employees contributed to the Remote System Explorer
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sheldon D'souza (Celunite) - adapted from ISshSessionProvider
|
* Sheldon D'souza (Celunite) - adapted from ISshSessionProvider
|
||||||
* Sheldon D'souza (Celunite) - [187301] support multiple telnet shells
|
* Sheldon D'souza (Celunite) - [187301] support multiple telnet shells
|
||||||
|
@ -20,24 +20,51 @@ package org.eclipse.rse.internal.services.telnet;
|
||||||
|
|
||||||
import org.apache.commons.net.telnet.TelnetClient;
|
import org.apache.commons.net.telnet.TelnetClient;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
|
|
||||||
public interface ITelnetSessionProvider {
|
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
|
* @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
|
* @throws Exception in case of any error
|
||||||
*/
|
*/
|
||||||
public TelnetClient makeNewTelnetClient(IProgressMonitor monitor) throws Exception ;
|
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("vt100");
|
||||||
|
* client.addOptionHandler(new EchoOptionHandler(false, true, true, true));
|
||||||
|
* client = fSessionProvider.loginTelnetClient(client, new NullProgressMonitor());
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param client telnet client already created
|
* @param client telnet client already created
|
||||||
* @param monitor progress monitor
|
* @param monitor progress monitor
|
||||||
* @return authenticated client for the given connection
|
* @return authenticated client for the given connection, or
|
||||||
* @throws Exception in case of any error
|
* <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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class TelnetTerminalShell extends AbstractTerminalShell {
|
||||||
true, true, true));
|
true, true, true));
|
||||||
fTelnetClient.addOptionHandler(new TerminalTypeOptionHandler(
|
fTelnetClient.addOptionHandler(new TerminalTypeOptionHandler(
|
||||||
ptyType, true, true, true, true));
|
ptyType, true, true, true, true));
|
||||||
fTelnetClient = fSessionProvider.makeNewTelnetClient(fTelnetClient,
|
fTelnetClient = fSessionProvider.loginTelnetClient(fTelnetClient,
|
||||||
new NullProgressMonitor());
|
new NullProgressMonitor());
|
||||||
fOutputStream = fTelnetClient.getOutputStream();
|
fOutputStream = fTelnetClient.getOutputStream();
|
||||||
if (onUNIX)
|
if (onUNIX)
|
||||||
|
|
Loading…
Add table
Reference in a new issue