Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 67256 Details for
Bug 186570
[telnet] Telnet should handle invalid user id or password more gracefully
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for bug 186570
patch186570.txt (text/plain), 36.32 KB, created by
Sheldon
on 2007-05-15 11:12:39 EDT
(
hide
)
Description:
patch for bug 186570
Filename:
MIME Type:
Creator:
Sheldon
Created:
2007-05-15 11:12:39 EDT
Size:
36.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.connectorservice.telnet >Index: src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.java,v >retrieving revision 1.2 >diff -u -r1.2 TelnetConnectorResources.java >--- src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.java 11 May 2007 13:02:14 -0000 1.2 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.java 15 May 2007 14:07:34 -0000 >@@ -25,8 +25,21 @@ > > public static String TelnetConnectorService_Name; > public static String TelnetConnectorService_Description; >- >- public static String PropertySet_Description; >+ >+ //Telnet property set >+ >+ public static String PropertySet_Description; >+ >+ //These are from org.eclipse.team.cvs.ui.CVSUIMessages >+ public static String UserValidationDialog_required; >+ public static String UserValidationDialog_labelUser; >+ public static String UserValidationDialog_labelPassword; >+ public static String UserValidationDialog_password; >+ public static String UserValidationDialog_user; >+ public static String UserValidationDialog_5; >+ public static String UserValidationDialog_6; >+ public static String UserValidationDialog_7; >+ > > public static String TelnetConnectorService_ErrorDisconnecting; > >Index: src/org/eclipse/rse/internal/connectorservice/telnet/Activator.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/Activator.java,v >retrieving revision 1.1 >diff -u -r1.1 Activator.java >--- src/org/eclipse/rse/internal/connectorservice/telnet/Activator.java 11 May 2007 09:49:26 -0000 1.1 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/Activator.java 15 May 2007 14:07:34 -0000 >@@ -16,6 +16,7 @@ > import java.util.Date; > > import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; > >@@ -45,6 +46,17 @@ > plugin = this; > } > >+ /** >+ * Returns an image descriptor for the image file at the given >+ * plug-in relative path. >+ * >+ * @param path the path >+ * @return the image descriptor >+ */ >+ public static ImageDescriptor getImageDescriptor(String path) { >+ return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); >+ } >+ > /* > * (non-Javadoc) > * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) >Index: src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.properties >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.properties,v >retrieving revision 1.2 >diff -u -r1.2 TelnetConnectorResources.properties >--- src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.properties 11 May 2007 13:02:14 -0000 1.2 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorResources.properties 15 May 2007 14:07:34 -0000 >@@ -20,3 +20,13 @@ > PropertySet_Description=Telnet login properties. Set these according to your remote system's login prompts. > > TelnetConnectorService_ErrorDisconnecting=ConnectionStatusListener: Error disconnecting >+ >+#These are from cvs.ui/messages.properties >+UserValidationDialog_required=Password Required >+UserValidationDialog_labelUser={0} >+UserValidationDialog_labelPassword={1} >+UserValidationDialog_password=&Password: >+UserValidationDialog_user=&User name: >+UserValidationDialog_5=Connection: >+UserValidationDialog_6=&Save password >+UserValidationDialog_7=Saved passwords are stored on your computer in a file that is difficult, but not impossible, for an intruder to read. >\ No newline at end of file >Index: src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java,v >retrieving revision 1.6 >diff -u -r1.6 TelnetConnectorService.java >--- src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java 11 May 2007 13:30:44 -0000 1.6 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/TelnetConnectorService.java 15 May 2007 14:07:35 -0000 >@@ -9,9 +9,6 @@ > * Martin Oberhuber (Wind River) - initial API and implementation > * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies > * Sheldon D'souza (Celunite) - adapted from SshConnectorService >- * Martin Oberhuber (Wind River) - apply refactorings for StandardConnectorService >- * Martin Oberhuber (Wind River) - [178606] fix endless loop in readUntil() >- * Sheldon D'souza (Celunite) - [186536] login and password should be configurable > *******************************************************************************/ > package org.eclipse.rse.internal.connectorservice.telnet; > >@@ -27,18 +24,20 @@ > import org.eclipse.jface.dialogs.ProgressMonitorDialog; > import org.eclipse.jface.operation.IRunnableContext; > import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.window.Window; > import org.eclipse.rse.core.RSECorePlugin; > import org.eclipse.rse.core.SystemBasePlugin; > import org.eclipse.rse.core.model.IHost; > import org.eclipse.rse.core.model.IPropertySet; > import org.eclipse.rse.core.model.ISystemRegistry; > import org.eclipse.rse.core.model.PropertyType; >+import org.eclipse.rse.core.model.SystemSignonInformation; > import org.eclipse.rse.core.subsystems.CommunicationsEvent; > import org.eclipse.rse.core.subsystems.IConnectorService; >-import org.eclipse.rse.core.subsystems.ICredentials; > import org.eclipse.rse.core.subsystems.SubSystemConfiguration; > import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider; > import org.eclipse.rse.services.clientserver.messages.SystemMessage; >+import org.eclipse.rse.services.clientserver.messages.SystemMessageException; > import org.eclipse.rse.ui.ISystemMessages; > import org.eclipse.rse.ui.RSEUIPlugin; > import org.eclipse.rse.ui.messages.SystemMessageDialog; >@@ -50,6 +49,7 @@ > > public class TelnetConnectorService extends StandardConnectorService implements ITelnetSessionProvider { > >+ > public static final String PROPERTY_SET_NAME="Telnet Settings"; //$NON-NLS-1$ > public static final String PROPERTY_LOGIN_REQUIRED="Login.Required"; //$NON-NLS-1$ > public static final String PROPERTY_LOGIN_PROMPT="Login.Prompt"; //$NON-NLS-1$ >@@ -57,12 +57,15 @@ > public static final String PROPERTY_COMMAND_PROMPT="Command.Prompt"; //$NON-NLS-1$ > > private static final int TELNET_DEFAULT_PORT = 23; >- private static TelnetClient fTelnetClient = new TelnetClient(); >+ private TelnetClient fTelnetClient = new TelnetClient(); > private SessionLostHandler fSessionLostHandler; > private InputStream in; > private PrintStream out; > private IPropertySet telnetPropertySet = null; >- >+ private static final int ERROR_CODE = 100; //filed error code >+ private static final int SUCCESS_CODE = 150; //login pass code >+ private static final int CONNECT_CLOSED = 200; //code for end of login attempts >+ > public TelnetConnectorService(IHost host) { > super(TelnetConnectorResources.TelnetConnectorService_Name, > TelnetConnectorResources.TelnetConnectorService_Description, >@@ -70,7 +73,7 @@ > fSessionLostHandler = null; > telnetPropertySet = getTelnetPropertySet(); > } >- >+ > /** > * Return the telnet property set, and fill it with default > * values if it has not been created yet. >@@ -93,52 +96,50 @@ > } > return telnetSet; > } >- >+ > public static void checkCanceled(IProgressMonitor monitor) { > if (monitor.isCanceled()) > throw new OperationCanceledException(); > } >+ > > protected void internalConnect(IProgressMonitor monitor) throws Exception { > String host = getHostName(); > String user = getUserId(); > String password = ""; //$NON-NLS-1$ >- telnetPropertySet = getTelnetPropertySet(); >- String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED); >- String login_prompt = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_PROMPT); >- String password_prompt = telnetPropertySet.getPropertyValue(PROPERTY_PASSWORD_PROMPT); >- String command_prompt = telnetPropertySet.getPropertyValue(PROPERTY_COMMAND_PROMPT); >- try { >+ >+ try { > Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$ > fTelnetClient.connect(host,TELNET_DEFAULT_PORT ); >- ICredentials cred = getCredentialsProvider().getCredentials(); >- if (cred!=null) { >- password = cred.getPassword(); >+ SystemSignonInformation ssi = getSignonInformation(); >+ if (ssi!=null) { >+ password = getSignonInformation().getPassword(); > } > > in = fTelnetClient.getInputStream(); > out = new PrintStream( fTelnetClient.getOutputStream() ); >- //Send login and password if needed >- if( Boolean.valueOf(login_required ).booleanValue() ) { >- if (login_prompt!=null && login_prompt.length()>0) { >- readUntil(login_prompt); >- write(user); >- } >- if (password_prompt!=null && password_prompt.length()>0) { >- readUntil(password_prompt); >- write(password); >- } >- } >- if (command_prompt!=null && command_prompt.length()>0) { >- readUntil(command_prompt); >+ >+ LoginThread checkLogin = new LoginThread(user,password); >+ checkLogin.start(); >+ checkLogin.join(); >+ String status = checkLogin.getLoginStatus(); >+ if( status == "fail") { //$NON-NLS-1$ >+ SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED); >+ msg.makeSubstitution(getHost().getAliasName()); >+ internalDisconnect( null ); >+ throw new SystemMessageException(msg); >+ > } >+ > Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$ > }catch( SocketException se) { > Activator.trace("Telnet Service failed: "+se.toString()); //$NON-NLS-1$ >- sessionDisconnect(); >+ if (fTelnetClient.isConnected()) >+ fTelnetClient.disconnect(); > }catch( IOException ioe ) { > Activator.trace("Telnet Service failed: "+ioe.toString()); //$NON-NLS-1$ >- sessionDisconnect(); >+ if (fTelnetClient.isConnected()) >+ fTelnetClient.disconnect(); > } > > fSessionLostHandler = new SessionLostHandler( this ); >@@ -146,50 +147,35 @@ > > } > >- /** >- * Disconnect the telnet session. >- * Synchronized in order to avoid NPE's from commons.net when called >- * quickly in succession. >- */ >- private synchronized void sessionDisconnect() { >- Activator.trace("TelnetConnectorService.sessionDisconnect"); //$NON-NLS-1$ >- try { >- if (fTelnetClient!=null) { >- synchronized(fTelnetClient) { >- if (fTelnetClient.isConnected()) >- fTelnetClient.disconnect(); >- } >- } >- } catch(Exception e) { >- //Avoid NPE on disconnect shown in UI >- //This is a non-critical exception so print only in debug mode >- if (Activator.isTracingOn()) e.printStackTrace(); >- } >- } >- >- public String readUntil(String pattern) { >- try { >- char lastChar = pattern.charAt(pattern.length() - 1); >- StringBuffer sb = new StringBuffer(); >- int ch = (char) in.read(); >- while (ch >= 0) { >- char tch = (char) ch; >- if (Activator.isTracingOn()) >- System.out.print(tch); >- sb.append(tch); >- if (tch == lastChar) { >- if (sb.toString().endsWith(pattern)) { >- return sb.toString(); >- } >- } >- ch = in.read(); >- } >- } catch (Exception e) { >- SystemBasePlugin.logError(e.getMessage()==null ? e.getClass().getName() : e.getMessage(), e); >- } >- return null; >+ public int readUntil( String pattern ) { >+ try { >+ char lastChar = pattern.charAt( pattern.length() - 1 ); >+ StringBuffer sb = new StringBuffer(); >+ int ch = in.read(); >+ while( ch >= 0 ) { >+ char tch = ( char )ch; >+ if(Activator.isTracingOn()) System.out.print(tch); >+ sb.append( tch ); >+ if( sb.indexOf("incorrect") >= 0) { //$NON-NLS-1$ >+ return ERROR_CODE; >+ } >+ if( sb.indexOf("closed") >= 0) { //$NON-NLS-1$ >+ return CONNECT_CLOSED; >+ } >+ if( tch == lastChar ) { >+ if( sb.toString().endsWith( pattern ) ) { >+ return SUCCESS_CODE; >+ } >+ } >+ ch = in.read(); >+ } >+ } >+ catch( Exception e ) { >+ e.printStackTrace(); >+ } >+ return CONNECT_CLOSED; > } >- >+ > public void write( String value ) { > try { > out.println( value ); >@@ -206,9 +192,11 @@ > } > } > >- protected void internalDisconnect(IProgressMonitor monitor) throws Exception { >+ public void internalDisconnect(IProgressMonitor monitor) throws Exception { > > Activator.trace("Telnet Service: Disconnecting ....."); //$NON-NLS-1$ >+ >+ > boolean sessionLost = (fSessionLostHandler!=null && fSessionLostHandler.isSessionLost()); > // no more interested in handling session-lost, since we are disconnecting anyway > fSessionLostHandler = null; >@@ -220,13 +208,16 @@ > // Fire comm event to signal state about to change > fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT); > } >- >- sessionDisconnect(); > >+ if( fTelnetClient.isConnected() ) { >+ fTelnetClient.disconnect(); >+ } >+ > // Fire comm event to signal state changed > notifyDisconnection(); > } > >+ > public TelnetClient getTelnetClient() { > return fTelnetClient; > } >@@ -422,93 +413,183 @@ > } > } > >- /* Notification from sub-services that our session was lost. >- * Notify all subsystems properly. >- * TODO allow user to try and reconnect? >- */ >- public void handleSessionLost() { >- Activator.trace("TelnetConnectorService: handleSessionLost"); //$NON-NLS-1$ >- if (fSessionLostHandler!=null) { >- fSessionLostHandler.sessionLost(); >- } >- } >- >- protected static Display getStandardDisplay() { >- Display display = Display.getCurrent(); >- if( display==null ) { >- display = Display.getDefault(); >- } >- return display; >- } > >- public boolean isConnected() { >- boolean connected = false; >- if (fTelnetClient!=null) { >- synchronized(fTelnetClient) { >- connected = fTelnetClient.isConnected(); >- } >+ /* >+ * A Login Thread to catch errors during login into telnet sessio >+ */ >+ >+ private class LoginThread extends Thread { >+ >+ private String username; >+ private String password; >+ private int failure = -1; >+ private String status = "pass"; //$NON-NLS-1$ >+ >+ public LoginThread( String username, String password) { >+ this.username = username; >+ this.password = password; >+ } >+ >+ private void setUsername( String username) { >+ this.username = username; >+ } >+ >+ private void setPassword( String password) { >+ this.password = password; > } >- if (!connected && fSessionLostHandler!=null) { >- Activator.trace("TelnetConnectorService.isConnected: false -> sessionLost"); //$NON-NLS-1$ >- fSessionLostHandler.sessionLost(); >+ >+ public void run() { >+ >+ telnetPropertySet = getTelnetPropertySet(); >+ String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED); >+ String login_prompt = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_PROMPT); >+ String password_prompt = telnetPropertySet.getPropertyValue(PROPERTY_PASSWORD_PROMPT); >+ String command_prompt = telnetPropertySet.getPropertyValue(PROPERTY_COMMAND_PROMPT); >+ >+ if( Boolean.valueOf(login_required ).booleanValue() ) { >+ >+ while( failure != SUCCESS_CODE) { >+ if (login_prompt!=null && login_prompt.length()>0) { >+ readUntil( login_prompt ); >+ write( username ); >+ } >+ if (password_prompt!=null && password_prompt.length()>0) { >+ readUntil( password_prompt ); >+ write( password ); >+ } >+ if (command_prompt!=null && command_prompt.length()>0) { >+ failure = readUntil( command_prompt ); >+ if( failure == ERROR_CODE) { >+ String [] userInfo = promptSecret(); >+ setUsername( userInfo[0] ); >+ setPassword( userInfo[1] ); >+ } >+ if( failure == CONNECT_CLOSED) { >+ this.status = "fail"; //$NON-NLS-1$ >+ break; >+ } >+ } >+ } >+ }else { >+ if (command_prompt!=null && command_prompt.length()>0) { >+ readUntil( command_prompt ); >+ } >+ } >+ } >+ >+ private String[] promptSecret() { >+ >+ final String[] retval = new String[2]; >+ final String finUser = username; >+ getStandardDisplay().syncExec(new Runnable() { >+ public void run() { >+ UserValidationDialog uvd = new UserValidationDialog(null, null, >+ finUser,"Login Incorrect"); //$NON-NLS-1$ >+ uvd.setUsernameMutable(true); >+ if (uvd.open() == Window.OK) { >+ retval[0] = uvd.getUsername(); >+ retval[1] = uvd.getPassword(); >+ } else { >+ retval[0] = null; >+ retval[1] = null; >+ } >+ } >+ }); >+ return retval; >+ } >+ >+ public String getLoginStatus() { >+ return this.status; > } >- return connected; > } >+ >+ /* Notification from sub-services that our session was lost. >+ * Notify all subsystems properly. >+ * TODO allow user to try and reconnect? >+ */ >+ public void handleSessionLost() { >+ Activator.trace("TelnetConnectorService: handleSessionLost"); //$NON-NLS-1$ >+ if (fSessionLostHandler!=null) { >+ fSessionLostHandler.sessionLost(); >+ } >+ } >+ >+ protected static Display getStandardDisplay() { >+ Display display = Display.getCurrent(); >+ if( display==null ) { >+ display = Display.getDefault(); >+ } >+ return display; >+ } >+ >+ public boolean isConnected() { >+ boolean connected = false; >+ if (fTelnetClient!=null) { >+ synchronized(fTelnetClient) { >+ connected = fTelnetClient.isConnected(); >+ } >+ } >+ if (!connected && fSessionLostHandler!=null) { >+ Activator.trace("TelnetConnectorService.isConnected: false -> sessionLost"); //$NON-NLS-1$ >+ fSessionLostHandler.sessionLost(); >+ } >+ return connected; >+ } > >- /** >- * Test if this connector service requires a password. >- * Telnet connector service returns false since a password is >- * not necessarily required, i.e. the corresponding >- * password field may be empty. >- * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword() >- * @return false >- */ >- public boolean requiresPassword() { >- return false; >- } >+ /** >+ * Test if this connector service requires a password. >+ * Telnet connector service returns false since a password is >+ * not necessarily required, i.e. the corresponding >+ * password field may be empty. >+ * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword() >+ * @return false >+ */ >+ public boolean requiresPassword() { >+ return false; >+ } > >- /** >- * Test if this connector service requires a user id. >- * Telnet connector service returns false since a user id >- * is not necessarily required, i.e. the corresponding >- * user id field may be empty. >- * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword() >- * @return false >- */ >- public boolean requiresUserId() { >- return false; >- } >+ /** >+ * Test if this connector service requires a user id. >+ * Telnet connector service returns false since a user id >+ * is not necessarily required, i.e. the corresponding >+ * user id field may be empty. >+ * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword() >+ * @return false >+ */ >+ public boolean requiresUserId() { >+ return false; >+ } > >- /** >- * Test if this connector service requires logging in. >- * @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED} >- * is set and false. Returns true otherwise. >- */ >- protected boolean supportsLogin() { >- boolean result = true; >- if (telnetPropertySet!=null) { >- String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED); >- if (login_required!=null && login_required.equalsIgnoreCase("false")) { //$NON-NLS-1$ >- result = false; >+ /** >+ * Test if this connector service requires logging in. >+ * @return false if the Property {@link #PROPERTY_LOGIN_REQUIRED} >+ * is set and false. Returns true otherwise. >+ */ >+ protected boolean supportsLogin() { >+ boolean result = true; >+ if (telnetPropertySet!=null) { >+ String login_required = telnetPropertySet.getPropertyValue(PROPERTY_LOGIN_REQUIRED); >+ if (login_required!=null && login_required.equalsIgnoreCase("false")) { //$NON-NLS-1$ >+ result = false; >+ } > } >+ return result; > } >- return result; >- } > >- /* >- * (non-Javadoc) >- * @see org.eclipse.rse.ui.subsystems.StandardConnectorService#supportsPassword() >- */ >- public boolean supportsPassword() { >- return supportsLogin(); >- } >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.rse.ui.subsystems.StandardConnectorService#supportsPassword() >+ */ >+ public boolean supportsPassword() { >+ return supportsLogin(); >+ } > >- /* >- * (non-Javadoc) >- * @see org.eclipse.rse.ui.subsystems.StandardConnectorService#supportsUserId() >- */ >- public boolean supportsUserId() { >- return supportsLogin(); >- } >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.rse.ui.subsystems.StandardConnectorService#supportsUserId() >+ */ >+ public boolean supportsUserId() { >+ return supportsLogin(); >+ } > > } >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.telnet/plugin.properties,v >retrieving revision 1.1 >diff -u -r1.1 plugin.properties >--- plugin.properties 11 May 2007 09:49:26 -0000 1.1 >+++ plugin.properties 15 May 2007 14:07:33 -0000 >@@ -1,17 +1,20 @@ >-################################################################################ >-# Copyright (c) 2006, 2007 Wind River Systems, Inc. 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 >-# http://www.eclipse.org/legal/epl-v10.html >-# >-# Contributors: >-# Martin Oberhuber - initial API and implementation >-# Sheldon D'souza - String modifications >-################################################################################ >- >-# NLS_MESSAGEFORMAT_NONE >-# NLS_ENCODING=UTF-8 >- >-pluginName = RSE Telnet Connector Service >-providerName = Eclipse.org >+################################################################################ >+# Copyright (c) 2006, 2007 Wind River Systems, Inc. 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 >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# Martin Oberhuber - initial API and implementation >+# Sheldon D'souza - String modifications >+################################################################################ >+ >+# NLS_MESSAGEFORMAT_NONE >+# NLS_ENCODING=UTF-8 >+ >+pluginName = RSE Telnet Connector Service >+providerName = Eclipse.org >+ >+TelnetSystemLabel = Telnet Only >+TelnetSystemDescription = Connection for Telnet access to remote systems >\ No newline at end of file >Index: src/org/eclipse/rse/internal/connectorservice/telnet/ITelnetConstants.java >=================================================================== >RCS file: src/org/eclipse/rse/internal/connectorservice/telnet/ITelnetConstants.java >diff -N src/org/eclipse/rse/internal/connectorservice/telnet/ITelnetConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/ITelnetConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River) - extracted from various team.cvs plugins >+ * Martin Oberhuber (Wind River) - [175686] Adapted to new IJSchService API >+ * Sheldon D'souza (Celunite) - extracted from ssh plugin >+ *******************************************************************************/ >+package org.eclipse.rse.internal.connectorservice.telnet; >+ >+ >+/** >+ * Defines the constants used by the terminal.ssh Plugin >+ */ >+public interface ITelnetConstants { >+ >+ // These are from cvs.ui.IHelpContextIds >+ public static final String CVSUIPREFIX = "org.eclipse.team.cvs.ui."; //$NON-NLS-1$ >+ public static final String HELP_USER_VALIDATION_DIALOG = CVSUIPREFIX + "user_validation_dialog_context"; //$NON-NLS-1$ >+ public static final String HELP_KEYBOARD_INTERACTIVE_DIALOG = CVSUIPREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$ >+ >+ // These are from TeamUIImages >+ public final String IMG_KEY_LOCK = "icons/full/wizban/keylock.gif"; //$NON-NLS-1$ >+ >+} >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<!-- >+ * Copyright (c) 2006, 2007 Celunite Inc. >+ * 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Sheldon D'souza ( Celunite ) >+--> >+<?eclipse version="3.1"?> >+<plugin> >+ <extension point="org.eclipse.rse.core.systemTypes"> >+ <systemType >+ description="%TelnetSystemDescription" >+ label="%TelnetSystemLabel" >+ icon="icons/full/obj16/systemcommands_obj.gif" >+ iconLive="icons/full/obj16/systemcommandslive_obj.gif" >+ id="org.eclipse.rse.systemtype.telnet" >+ name="Telnet Only"/> >+ </extension> >+</plugin> >Index: src/org/eclipse/rse/internal/connectorservice/telnet/UserValidationDialog.java >=================================================================== >RCS file: src/org/eclipse/rse/internal/connectorservice/telnet/UserValidationDialog.java >diff -N src/org/eclipse/rse/internal/connectorservice/telnet/UserValidationDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rse/internal/connectorservice/telnet/UserValidationDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,278 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River) - copied from org.eclipse.team.cvs.ui >+ * * Sheldon D'souza (Celunite) - copied from org.eclipse.rse.internal.connectorservice.telnet >+ *******************************************************************************/ >+package org.eclipse.rse.internal.connectorservice.telnet; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.TrayDialog; >+import org.eclipse.jface.window.Window; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * A dialog for prompting for a username and password >+ */ >+public class UserValidationDialog extends TrayDialog { >+ // widgets >+ protected Text usernameField; >+ protected Text passwordField; >+ protected Button allowCachingButton; >+ >+ protected String domain; >+ protected String defaultUsername; >+ protected String password = null; >+ protected boolean allowCaching = false; >+ protected Image keyLockImage; >+ >+ // whether or not the username can be changed >+ protected boolean isUsernameMutable = true; >+ protected String username = null; >+ protected String message = null; >+ >+ /** >+ * Creates a new UserValidationDialog. >+ * >+ * @param parentShell the parent shell >+ * @param location the location >+ * @param defaultName the default user name >+ * @param message a mesage to display to the user >+ */ >+ public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) { >+ super(parentShell); >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ this.defaultUsername = defaultName; >+ this.domain = location; >+ this.message = message; >+ } >+ /** >+ * @see Window#configureShell >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ newShell.setText(TelnetConnectorResources.UserValidationDialog_required); >+ // set F1 help >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ITelnetConstants.HELP_USER_VALIDATION_DIALOG); >+ } >+ /** >+ * @see Window#create >+ */ >+ public void create() { >+ super.create(); >+ // add some default values >+ usernameField.setText(defaultUsername); >+ >+ if (isUsernameMutable) { >+ // give focus to username field >+ usernameField.selectAll(); >+ usernameField.setFocus(); >+ } else { >+ usernameField.setEditable(false); >+ passwordField.setFocus(); >+ } >+ } >+ >+ /** >+ * @see Dialog#createDialogArea >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite top = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ >+ top.setLayout(layout); >+ top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ Composite imageComposite = new Composite(top, SWT.NONE); >+ layout = new GridLayout(); >+ imageComposite.setLayout(layout); >+ imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ >+ Composite main = new Composite(top, SWT.NONE); >+ layout = new GridLayout(); >+ layout.numColumns = 3; >+ main.setLayout(layout); >+ main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ Label imageLabel = new Label(imageComposite, SWT.NONE); >+ keyLockImage = Activator.getImageDescriptor(ITelnetConstants.IMG_KEY_LOCK).createImage(); >+ imageLabel.setImage(keyLockImage); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ imageLabel.setLayoutData(data); >+ >+ if (message != null) { >+ Label messageLabel = new Label(main, SWT.WRAP); >+ messageLabel.setText(message); >+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ data.horizontalSpan = 3; >+ data.widthHint = 300; >+ messageLabel.setLayoutData(data); >+ } >+ if (domain != null) { >+ Label d = new Label(main, SWT.WRAP); >+ d.setText(TelnetConnectorResources.UserValidationDialog_5); >+ data = new GridData(); >+ d.setLayoutData(data); >+ Label label = new Label(main, SWT.WRAP); >+ if (isUsernameMutable) { >+ label.setText(NLS.bind(TelnetConnectorResources.UserValidationDialog_labelUser, new String[] { domain })); >+ } else { >+ label.setText(NLS.bind(TelnetConnectorResources.UserValidationDialog_labelPassword, (new Object[]{defaultUsername, domain}))); >+ } >+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ data.horizontalSpan = 2; >+ data.widthHint = 300; >+ label.setLayoutData(data); >+ } >+ createUsernameFields(main); >+ createPasswordFields(main); >+ >+ if(domain != null) { >+ allowCachingButton = new Button(main, SWT.CHECK); >+ allowCachingButton.setText(TelnetConnectorResources.UserValidationDialog_6); >+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); >+ data.horizontalSpan = 3; >+ allowCachingButton.setLayoutData(data); >+ allowCachingButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ allowCaching = allowCachingButton.getSelection(); >+ } >+ }); >+ Composite warningComposite = new Composite(main, SWT.NONE); >+ layout = new GridLayout(); >+ layout.numColumns = 2; >+ layout.marginHeight = 0; >+ layout.marginHeight = 0; >+ warningComposite.setLayout(layout); >+ data = new GridData(GridData.FILL_HORIZONTAL); >+ data.horizontalSpan = 3; >+ warningComposite.setLayoutData(data); >+ Label warningLabel = new Label(warningComposite, SWT.NONE); >+ warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING)); >+ warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); >+ Label warningText = new Label(warningComposite, SWT.WRAP); >+ warningText.setText(TelnetConnectorResources.UserValidationDialog_7); >+ data = new GridData(GridData.FILL_HORIZONTAL); >+ data.widthHint = 300; >+ warningText.setLayoutData(data); >+ } >+ >+ Dialog.applyDialogFont(parent); >+ >+ return main; >+ } >+ >+ /** >+ * Creates the three widgets that represent the password entry area. >+ * >+ * @param parent the parent of the widgets >+ */ >+ protected void createPasswordFields(Composite parent) { >+ new Label(parent, SWT.NONE).setText(TelnetConnectorResources.UserValidationDialog_password); >+ >+ passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.horizontalSpan = 2; >+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); >+ passwordField.setLayoutData(data); >+ } >+ /** >+ * Creates the three widgets that represent the user name entry area. >+ * >+ * @param parent the parent of the widgets >+ */ >+ protected void createUsernameFields(Composite parent) { >+ new Label(parent, SWT.NONE).setText(TelnetConnectorResources.UserValidationDialog_user); >+ >+ usernameField = new Text(parent, SWT.BORDER); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.horizontalSpan = 2; >+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); >+ usernameField.setLayoutData(data); >+ } >+ >+ /** >+ * Returns the password entered by the user, or null >+ * if the user canceled. >+ * >+ * @return the entered password >+ */ >+ public String getPassword() { >+ return password; >+ } >+ >+ /** >+ * Returns the username entered by the user, or null >+ * if the user canceled. >+ * >+ * @return the entered username >+ */ >+ public String getUsername() { >+ return username; >+ } >+ >+ /** >+ * Returns <code>true</code> if the save password checkbox was selected. >+ * @return <code>true</code> if the save password checkbox was selected and <code>false</code> >+ * otherwise. >+ */ >+ public boolean getAllowCaching() { >+ return allowCaching; >+ } >+ >+ /** >+ * Notifies that the ok button of this dialog has been pressed. >+ * <p> >+ * The default implementation of this framework method sets >+ * this dialog's return code to <code>Window.OK</code> >+ * and closes the dialog. Subclasses may override. >+ * </p> >+ */ >+ protected void okPressed() { >+ password = passwordField.getText(); >+ username = usernameField.getText(); >+ >+ super.okPressed(); >+ } >+ /** >+ * Sets whether or not the username field should be mutable. >+ * This method must be called before create(), otherwise it >+ * will be ignored. >+ * >+ * @param value whether the username is mutable >+ */ >+ public void setUsernameMutable(boolean value) { >+ isUsernameMutable = value; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#close() >+ */ >+ public boolean close() { >+ if(keyLockImage != null) { >+ keyLockImage.dispose(); >+ } >+ return super.close(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mober.at+eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 186570
: 67256 |
67384
|
67386