diff --git a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java index 0375465fce9..b7de9b3c57d 100644 --- a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java +++ b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java @@ -86,4 +86,22 @@ public class DaytimeConnectorService extends AbstractConnectorService { return false; } + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + */ + public boolean supportsPassword() { + return false; + } + + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() + */ + public boolean supportsUserId() { + return false; + } + + + } diff --git a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystemConfiguration.java b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystemConfiguration.java index 052db784f17..ddb26f8cbc7 100644 --- a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystemConfiguration.java +++ b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/subsystems/DaytimeSubSystemConfiguration.java @@ -57,9 +57,6 @@ public class DaytimeSubSystemConfiguration extends ServiceSubSystemConfiguration public boolean isPortEditable() { return false; } - public boolean supportsUserId() { - return false; - } public boolean isFactoryFor(Class subSystemType) { return DaytimeSubSystem.class.equals(subSystemType); } diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java index eab4f2da601..37700858ff6 100644 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java +++ b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java @@ -96,4 +96,20 @@ public class DeveloperConnectorService extends AbstractConnectorService { return false; } + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + */ + public boolean supportsPassword() { + return false; + } + + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() + */ + public boolean supportsUserId() { + return false; + } + } diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java index 83fc084b8df..92cb56f4aba 100644 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java +++ b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperSubSystemConfiguration.java @@ -101,13 +101,6 @@ public class DeveloperSubSystemConfiguration extends SubSystemConfiguration { return RSESamplesPlugin.getResourceString("property.type.devrfilter"); //$NON-NLS-1$ } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsUserId() - */ - public boolean supportsUserId() { - return false; - } - /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchProperties(org.eclipse.rse.model.IHost) */ diff --git a/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/connectorservice/local/LocalConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/connectorservice/local/LocalConnectorService.java index e033fea85c6..39f8236673c 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/connectorservice/local/LocalConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/connectorservice/local/LocalConnectorService.java @@ -102,19 +102,30 @@ public class LocalConnectorService extends AbstractConnectorService return false; } - - public boolean supportsRemoteServerLaunching() { return false; } - - public boolean supportsServerLaunchProperties() { return false; + } + + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + */ + public boolean supportsPassword() { + return false; + } + + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() + */ + public boolean supportsUserId() { + return false; } - } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/connectorservice/ssh/SshConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/connectorservice/ssh/SshConnectorService.java index 9c9ebef39c6..ee55e0f4386 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/connectorservice/ssh/SshConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/connectorservice/ssh/SshConnectorService.java @@ -224,9 +224,9 @@ public class SshConnectorService extends AbstractConnectorService implements ISs } } - public static class ResponsiveSocketFacory extends SimpleSocketFactory { + public static class ResponsiveSocketFactory extends SimpleSocketFactory { private IProgressMonitor monitor; - public ResponsiveSocketFacory(IProgressMonitor monitor) { + public ResponsiveSocketFactory(IProgressMonitor monitor) { this.monitor = monitor; } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { @@ -275,7 +275,7 @@ public class SshConnectorService extends AbstractConnectorService implements ISs session.setPassword(password); MyUserInfo userInfo = new MyUserInfo(user, password); session.setUserInfo(userInfo); - session.setSocketFactory(new ResponsiveSocketFacory(monitor)); + session.setSocketFactory(new ResponsiveSocketFactory(monitor)); //java.util.Hashtable config=new java.util.Hashtable(); //config.put("StrictHostKeyChecking", "no"); @@ -692,4 +692,20 @@ public class SshConnectorService extends AbstractConnectorService implements ISs return false; } + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword() + */ + public boolean requiresPassword() { + return false; + } + + /** + * @return false + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresUserId() + */ + public boolean requiresUserId() { + return false; + } + } diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/wizards/SystemFileNewConnectionWizardPage.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/wizards/SystemFileNewConnectionWizardPage.java index 1cf22302328..a90a22eb911 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/wizards/SystemFileNewConnectionWizardPage.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/wizards/SystemFileNewConnectionWizardPage.java @@ -160,13 +160,6 @@ public class SystemFileNewConnectionWizardPage extends AbstractSystemNewConnecti { return parentFactory.isPortEditable(); } - /** - * Return true if the userId is applicable for this subsystem - */ - protected boolean isUserIdApplicable() - { - return parentFactory.supportsUserId(); - } /** * @see ISystemWizardPage#performFinish() diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystemConfiguration.java index 215229b7b9f..00863678f29 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystemConfiguration.java @@ -199,14 +199,6 @@ public abstract class RemoteFileSubSystemConfiguration extends SubSystemConfigur // -------------------------------------------- // PARENT METHODS RELATED TO WHAT WE SUPPORT... // -------------------------------------------- - /** - * We return true. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsUserId() - */ - public boolean supportsUserId() - { - return true; - } /** * We return true. * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsSubSystemConnect() diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.ssh/src/org/eclipse/rse/subsystems/files/ssh/SftpFileSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.ssh/src/org/eclipse/rse/subsystems/files/ssh/SftpFileSubSystemConfiguration.java index 4f6345082e8..5a4434e766f 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.ssh/src/org/eclipse/rse/subsystems/files/ssh/SftpFileSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.ssh/src/org/eclipse/rse/subsystems/files/ssh/SftpFileSubSystemConfiguration.java @@ -106,13 +106,4 @@ public class SftpFileSubSystemConfiguration extends FileServiceSubSystemConfigur return true; } - /** - * Ssh allows authentification through public key, so the password - * can be empty. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#requiresPassword() - */ - public boolean requiresPassword() { - return false; - } - } diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemConfiguration.java index b404984ffcd..7f0ddcffb2c 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.core/src/org/eclipse/rse/subsystems/processes/core/subsystem/impl/RemoteProcessSubSystemConfiguration.java @@ -47,14 +47,6 @@ public abstract class RemoteProcessSubSystemConfiguration extends // -------------------------------------------- // PARENT METHODS RELATED TO WHAT WE SUPPORT... // -------------------------------------------- - /** - * We return true. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsUserId() - */ - public boolean supportsUserId() - { - return true; - } /** * We return true. diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteCmdSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteCmdSubSystemConfiguration.java index 36173029b7f..4a2938ed22f 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteCmdSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteCmdSubSystemConfiguration.java @@ -39,14 +39,6 @@ public abstract class RemoteCmdSubSystemConfiguration extends SubSystemConfigura // -------------------------------------------- // PARENT METHODS RELATED TO WHAT WE SUPPORT... // -------------------------------------------- - /** - * We return true. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsUserId() - */ - public boolean supportsUserId() - { - return true; - } /** * We return true. * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsSubSystemConnect() diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshShellSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshShellSubSystemConfiguration.java index 22b3db7cd2b..027b360dbae 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshShellSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/subsystems/shells/ssh/SshShellSubSystemConfiguration.java @@ -79,15 +79,4 @@ public class SshShellSubSystemConfiguration extends return new SshServiceCommandShell(cmdSS, hostShell); } - /** - * Ssh allows authentification through public key, so the password - * can be empty. - * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#requiresPassword() - */ - public boolean requiresPassword() { - return false; - } - - - } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemChangePasswordDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemChangePasswordDialog.java index b025a7f8775..a3660a5fc8a 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemChangePasswordDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemChangePasswordDialog.java @@ -33,6 +33,12 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +/** + * A SystemChangePasswordDialog is typically presented when the password on the remote system has expired + * and a new one needs to be saved. This dialog presents presents two enabled text fields - the first holds + * the new password, the second holds its confirmation. + * There is also a checkbox to save the password. Actually saving the password is the responsibility of the client. + */ public class SystemChangePasswordDialog extends SystemPromptDialog { private String _hostname; @@ -48,6 +54,16 @@ public class SystemChangePasswordDialog extends SystemPromptDialog private boolean newPasswordModified = false; private boolean confirmModified = false; + /** + * Construct a new SystemChangePasswordDialog. Since this dialog is asking for a new password + * there is no need to supply the old password, however a remote system will usually require + * the old password to effect a change. Thus clients of this class would typically be expected + * to have this available. + * @param shell The shell the dialog will use to present itself. + * @param hostname The remote host name. + * @param userid The user id that will be presented. May be the empty string. + * @param msg The message that will be presented when the dialog is initially shown. This may be null. + */ public SystemChangePasswordDialog(Shell shell, String hostname, String userid, SystemMessage msg) { super(shell, SystemResources.RESID_CHANGE_PASSWORD_TITLE, false); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java index 2a84c5b1d5b..55e6ade708c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java @@ -15,6 +15,7 @@ ********************************************************************************/ package org.eclipse.rse.ui.dialogs; + import org.eclipse.rse.core.SystemPreferencesManager; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.services.clientserver.messages.SystemMessage; @@ -35,490 +36,439 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; - - /** * Prompt user for password. * This class is final due to the sensitive nature of the information being prompted for. */ -public final class SystemPasswordPromptDialog - extends SystemPromptDialog - implements ISystemMessages, ISystemPasswordPromptDialog -{ - - // lables are not as big as text fields so we need to set the height for the system type - // and hostname labels so they are equally spaced with the user ID and password entry fields - private static final int LABEL_HEIGHT = 17; - - protected Text textPassword; +public final class SystemPasswordPromptDialog extends SystemPromptDialog implements ISystemPasswordPromptDialog { + + // labels are not as big as text fields so we need to set the height for the system type + // and hostname labels so they are equally spaced with the user ID and password entry fields +// private static final int LABEL_HEIGHT = 17; + + private Text textPassword; + private Text textUserId; + private Button userIdPermanentCB; + private Button savePasswordCB; + private String originalUserId; + private String userId; + private String password; + private boolean userIdPermanent = false; + private boolean savePassword = false; + private boolean forceToUpperCase; + private boolean userIdChanged = false; + private boolean validate = true; + private ISystemValidator userIdValidator; + private ISystemValidator passwordValidator; + private ISignonValidator signonValidator; + private IConnectorService connectorService = null; - // yantzi: artemis 6.0, at request of zOS team I am changing the system type and hostname - // to labels so they are clearer to read then non-editable entry fields - //protected Text textSystemType, textHostName, textUserId; - protected Text textUserId; - - protected Button userIdPermanentCB, savePasswordCB; - //protected String userId,password; - protected String originalUserId; - protected String userId, password; - protected boolean userIdPermanent = false; - protected boolean savePassword = false; - protected boolean forceToUpperCase; - protected boolean userIdChanged = false; - protected boolean userIdOK = true; - protected boolean passwordOK = false; - protected boolean noValidate = false; - protected ISystemValidator userIdValidator, passwordValidator; - protected ISignonValidator signonValidator; - protected SystemMessage errorMessage = null; - /** * Constructor for SystemPasswordPromptDialog */ - public SystemPasswordPromptDialog(Shell shell) - { + public SystemPasswordPromptDialog(Shell shell) { super(shell, SystemResources.RESID_PASSWORD_TITLE); - //pack(); - setHelp(RSEUIPlugin.HELPPREFIX+"pwdp0000"); + setHelp(RSEUIPlugin.HELPPREFIX + "pwdp0000"); } + /** - * Set the input System object in which the user is attempting to do a connect action. - * This is used to query the system type, host name and userId to display to the user for + * Set the connector service from which the user is attempting to do a connect action. + * This is used to query the system type, host name and user id to display to the user for * contextual information. *

- * This must be called right after instantiating this dialog. + * This must be called prior to opening this dialog. */ - public void setSystemInput(IConnectorService systemObject) - { - setInputObject(systemObject); + public void setSystemInput(IConnectorService connectorService) { + this.connectorService = connectorService; } + /** - * Call this to specify a validator for the userId. It will be called per keystroke. + * Sets the validator for the userId. If not null it will be called per keystroke. + *

+ * This must be called prior to opening this dialog if something other than the default is needed. */ - public void setUserIdValidator(ISystemValidator v) - { + public void setUserIdValidator(ISystemValidator v) { userIdValidator = v; } + /** - * Call this to specify a validator for the password. It will be called per keystroke. + * Sets the validator for the password. If not null it will be called per keystroke. + * The default validator is null. + *

+ * This must be called prior to opening this dialog if something other than the default is needed. */ - public void setPasswordValidator(ISystemValidator v) - { + public void setPasswordValidator(ISystemValidator v) { passwordValidator = v; } + /** - * Call this to specify a validator for the signon. It will be called when the user presses OK. + * Sets the validator for the signon. + * The default validator is null. + * If not null the validator will be called when the user presses OK. + *

+ * This must be called prior to opening this dialog if something other than the default is needed. */ - public void setSignonValidator(ISignonValidator v) - { + public void setSignonValidator(ISignonValidator v) { signonValidator = v; } + /** - * Call this to force the userId and password to uppercase + * Sets the option to force the userId and password to uppercase. + *

+ * The default is false. + * This must be called prior to opening this dialog if something other than the default is needed. */ - public void setForceToUpperCase(boolean force) - { + public void setForceToUpperCase(boolean force) { this.forceToUpperCase = force; } + /** * Call this to query the force-to-uppercase setting */ - public boolean getForceToUpperCase() - { + public boolean getForceToUpperCase() { return forceToUpperCase; } - /** - * @see SystemPromptDialog#getInitialFocusControl() - */ - protected Control getInitialFocusControl() - { - okButton.setEnabled(false); - - - if (textUserId.getText().length()==0) - return textUserId; - else - { - if (password != null) - { - validatePasswordInput(); - textPassword.selectAll(); - } - return textPassword; - } - } - /** * @see SystemPromptDialog#createInner(Composite) */ - protected Control createInner(Composite parent) - { - // top level composite - Composite composite = new Composite(parent,SWT.NONE); + protected Control createInner(Composite parent) { + + // top level composite + Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData( - GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); // Inner composite - Composite composite_prompts = SystemWidgetHelpers.createComposite( - composite, 2); + Composite composite_prompts = SystemWidgetHelpers.createComposite(composite, 2); - IConnectorService systemObject = (IConnectorService)getInputObject(); + // yantzi: artemis 6.0, at request of zOS team I am changing the system type and hostname + // to labels so they are clearer to read than non-editable entry fields // System type - //textSystemType = SystemWidgetHelpers.createLabeledReadonlyTextField( - // composite_prompts,rb,RESID_CONNECTION_SYSTEMTYPE_READONLY_ROOT); String text = SystemWidgetHelpers.appendColon(SystemResources.RESID_CONNECTION_SYSTEMTYPE_READONLY_LABEL); Label label = SystemWidgetHelpers.createLabel(composite_prompts, text); GridData gd = new GridData(); - gd.heightHint = LABEL_HEIGHT; - label.setLayoutData(gd); - - label = SystemWidgetHelpers.createLabel(composite_prompts, systemObject.getHostType()); +// gd.heightHint = LABEL_HEIGHT; + label.setLayoutData(gd); + label = SystemWidgetHelpers.createLabel(composite_prompts, connectorService.getHostType()); gd = new GridData(); - gd.heightHint = LABEL_HEIGHT; - label.setLayoutData(gd); +// gd.heightHint = LABEL_HEIGHT; + label.setLayoutData(gd); // Host name - //textHostName = SystemWidgetHelpers.createLabeledReadonlyTextField( - // composite_prompts, rb, ISystemConstants.RESID_CONNECTION_HOSTNAME_READONLY_ROOT); text = SystemWidgetHelpers.appendColon(SystemResources.RESID_CONNECTION_HOSTNAME_READONLY_LABEL); label = SystemWidgetHelpers.createLabel(composite_prompts, text); gd = new GridData(); - gd.heightHint = LABEL_HEIGHT; - label.setLayoutData(gd); - label = SystemWidgetHelpers.createLabel(composite_prompts, systemObject.getHostName()); +// gd.heightHint = LABEL_HEIGHT; + label.setLayoutData(gd); + label = SystemWidgetHelpers.createLabel(composite_prompts, connectorService.getHostName()); gd = new GridData(); - gd.heightHint = LABEL_HEIGHT; - label.setLayoutData(gd); - +// gd.heightHint = LABEL_HEIGHT; + label.setLayoutData(gd); + // UserId - textUserId = SystemWidgetHelpers.createLabeledTextField( - composite_prompts,this,SystemResources.RESID_CONNECTION_USERID_LABEL, SystemResources.RESID_CONNECTION_USERID_TIP); - - // Password prompt - textPassword = SystemWidgetHelpers.createLabeledTextField( - composite_prompts,this,SystemResources.RESID_PASSWORD_LABEL, SystemResources.RESID_PASSWORD_TIP); - textPassword.setEchoChar('*'); + if (connectorService.supportsUserId()) { + textUserId = SystemWidgetHelpers.createLabeledTextField(composite_prompts, this, SystemResources.RESID_CONNECTION_USERID_LABEL, SystemResources.RESID_CONNECTION_USERID_TIP); + } + + // Password prompt + if (connectorService.supportsPassword()) { + textPassword = SystemWidgetHelpers.createLabeledTextField(composite_prompts, this, SystemResources.RESID_PASSWORD_LABEL, SystemResources.RESID_PASSWORD_TIP); + textPassword.setEchoChar('*'); + } // UserId_make_permanent checkbox // DY: align user ID checkbox with entry fields // yantzi:5.1 move checkboxes to be below entry fields - SystemWidgetHelpers.createLabel(composite_prompts, ""); - userIdPermanentCB = SystemWidgetHelpers.createCheckBox( - composite_prompts, 1, this, SystemResources.RESID_PASSWORD_USERID_ISPERMANENT_LABEL, SystemResources.RESID_PASSWORD_USERID_ISPERMANENT_TIP ); - userIdPermanentCB.setEnabled(false); + if (connectorService.supportsUserId()) { + SystemWidgetHelpers.createLabel(composite_prompts, ""); + userIdPermanentCB = SystemWidgetHelpers.createCheckBox(composite_prompts, 1, this, SystemResources.RESID_PASSWORD_USERID_ISPERMANENT_LABEL, + SystemResources.RESID_PASSWORD_USERID_ISPERMANENT_TIP); + userIdPermanentCB.setEnabled(false); + } - // Save signon information checkbox - // DY: align password checkbox with entry fields - SystemWidgetHelpers.createLabel(composite_prompts, ""); - savePasswordCB = SystemWidgetHelpers.createCheckBox( - composite_prompts, 1, this, SystemResources.RESID_PASSWORD_SAVE_LABEL, SystemResources.RESID_PASSWORD_SAVE_TOOLTIP); - savePasswordCB.setSelection(savePassword); - // disable until the user enters something for consistency with the save user ID checkbox - savePasswordCB.setEnabled(false); - - initializeInput(); + // Save signon information checkbox + // DY: align password checkbox with entry fields + if (connectorService.supportsPassword()) { + SystemWidgetHelpers.createLabel(composite_prompts, ""); + savePasswordCB = SystemWidgetHelpers.createCheckBox(composite_prompts, 1, this, SystemResources.RESID_PASSWORD_SAVE_LABEL, SystemResources.RESID_PASSWORD_SAVE_TOOLTIP); + savePasswordCB.setSelection(savePassword); + // disable until the user enters something for consistency with the save user ID checkbox + savePasswordCB.setEnabled(false); + } + + initializeInput(); // add keystroke listeners... - textUserId.addModifyListener( - new ModifyListener() { + if (textUserId != null) { + textUserId.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - validateUserIdInput(); + processUserIdField(); } - } - ); - textPassword.addModifyListener( - new ModifyListener() { + }); + } + if (textPassword != null) { + textPassword.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - validatePasswordInput(); + processPasswordField(); } - } - ); - - - //SystemWidgetHelpers.setHelp(composite, RSEUIPlugin.HELPPREFIX+"pwdp0000"); - return composite; + }); + } + + return composite; } -// yantzi: artemis 6.0 not required, the Window class handles ESC processing -// /** -// * @see SystemPromptDialog#createContents(Composite) -// */ -// protected Control createContents(Composite parent) -// { -// //System.out.println("INSIDE CREATECONTENTS"); -// Control c = super.createContents(parent); -// // Listen for ESC keypress, simulate the user pressing -// // the cancel button -// -// KeyListener keyListener = new KeyAdapter() { -// public void keyPressed(KeyEvent e) { -// if (e.character == SWT.ESC) { -// buttonPressed(CANCEL_ID); -// } -// } -// }; -// -// textUserId.addKeyListener(keyListener); -// textPassword.addKeyListener(keyListener); -// userIdPermanentCB.addKeyListener(keyListener); -// okButton.addKeyListener(keyListener); -// cancelButton.addKeyListener(keyListener); -// -// return c; -// } + /** + * @see SystemPromptDialog#getInitialFocusControl() + */ + protected Control getInitialFocusControl() { + okButton.setEnabled(true); + processUserIdField(); + processPasswordField(); + if (textUserId != null) { + if (userId.length() == 0 || textPassword == null) { + return textUserId; + } + } + if (textPassword != null) { + textPassword.selectAll(); + return textPassword; + } + if (okButton.isEnabled()) return okButton; + return cancelButton; + } + /** + * Initialize values using input data + */ + private void initializeInput() { + originalUserId = connectorService.getUserId(); + userId = originalUserId; + if (connectorService.supportsUserId() && (userId == null || userId.length() == 0)) { + userId = SystemPreferencesManager.getPreferencesManager().getDefaultUserId(connectorService.getHostType()); + } + if (textUserId != null && userId != null) { + textUserId.setText(userId); + } + if (textPassword != null && password != null) { + textPassword.setText(password); + } + } + + /** + * Retrieves the userId entered by user + */ + private void internalGetUserId() { + if (textUserId != null) { + userId = textUserId.getText().trim(); + } + } + + /** + * Retrieves the password entered by user + */ + private void internalGetPassword() { + if (textPassword != null) { + password = textPassword.getText().trim(); + } + } + + /** + * Retrieves the value of the "save user id" checkbox + */ + private void internalGetIsUserIdChangePermanent() { + if (userIdPermanentCB != null) { + userIdPermanent = userIdPermanentCB.isEnabled() && userIdPermanentCB.getSelection(); + } + } + + /** + * Retrieves the value of the "save password" checkbox + */ + private void internalGetIsSavePassword() { + if (savePasswordCB != null) { + savePassword = savePasswordCB.isEnabled() && savePasswordCB.getSelection(); + } + } + + /** + * This method is called whenever the text changes in the user id input field. + * Checks the user id field and if there are no errors, other fields on the dialog. + * If an error was reported it is displayed on the message line. + * @see #setUserIdValidator(ISystemValidator) + */ + private void processUserIdField() { + internalGetUserId(); + internalGetPassword(); + SystemMessage m = checkUserId(); + if (m == null) { + m = checkPassword(); + } + okButton.setEnabled(m == null); + setErrorMessage(m); + if (userId == null || originalUserId == null) { + userIdChanged = (userId != originalUserId); + } else { + userIdChanged = !userId.equals(originalUserId); + } + if (userIdPermanentCB != null) { + userIdPermanentCB.setEnabled(userIdChanged); + } + } /** - * Init values using input data + * Performs the actual validation check for the user id. + * Delegates the request to an ISystemValidator object. + * @return the message returned by the validator or null. */ - protected void initializeInput() - { - IConnectorService systemObject = (IConnectorService)getInputObject(); - //textSystemType.setText(systemObject.getSystemType()); - //textHostName.setText(systemObject.getHostName()); - originalUserId = systemObject.getUserId(); - if ((originalUserId != null) && (originalUserId.length()>0)) - { - //textUserId.setEditable(false); - //textUserId.setEnabled(false); - textUserId.setText(originalUserId); + private SystemMessage checkUserId() { + SystemMessage m = null; + if (connectorService.supportsUserId() && validate) { + if (userIdValidator != null) { + m = userIdValidator.validate(userId); + } else if (connectorService.requiresUserId() && userId.length() == 0) { + m = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_EMPTY); + } } - else - { - // added by phil: if we don't prompt for userId at new connection time, - // then we should default here to the preferences setting for the user id, - // by SystemType... - String preferencesUserId = SystemPreferencesManager.getPreferencesManager().getDefaultUserId(systemObject.getHostType()); - if (preferencesUserId != null) - textUserId.setText(preferencesUserId); - originalUserId = ""; - } - - if (password != null) - { - textPassword.setText(password); - } - - } - /** - * Return the userId entered by user - */ - private String internalGetUserId() - { - userId = textUserId.getText().trim(); - return userId; - } - - /** - * Return the password entered by user - */ - private String internalGetPassword() - { - password = textPassword.getText().trim(); - return password; - } - /** - * Return true if the user elected to make the changed user Id a permanent change. - */ - private boolean internalGetIsUserIdChangePermanent() - { - userIdPermanent = userIdPermanentCB.getSelection(); - return userIdPermanent; - } - /** - * Return true if the user elected to save the password - */ - private boolean internalGetIsSavePassword() - { - savePassword = savePasswordCB.getSelection(); - return savePassword; - } - - - /** - * This hook method is called whenever the text changes in the user Id input field. - * The default implementation delegates the request to an ISystemValidator object. - * If the ISystemValidator reports an error the error message is displayed - * in the Dialog's message line. - * @see #setUserIdValidator(ISystemValidator) - */ - protected SystemMessage validateUserIdInput() - { - if (noValidate) - return null; - clearErrorMessage(); - errorMessage= null; - String userId = internalGetUserId(); - userIdChanged = !userId.equals(originalUserId); - userIdPermanentCB.setEnabled(userIdChanged); - if (userIdValidator != null) - errorMessage= userIdValidator.validate(userId); - else if (userId.equals("")) - errorMessage = RSEUIPlugin.getPluginMessage(MSG_VALIDATE_USERID_EMPTY); - userIdOK = (errorMessage == null); - if (!userIdOK) - { - okButton.setEnabled(false); - setErrorMessage(errorMessage); - } - else - okButton.setEnabled(passwordOK); - return errorMessage; + return m; } - /** - * This hook method is called whenever the text changes in the password input field. + /** + * This method is called whenever the text changes in the password input field. * The default implementation delegates the request to an ISystemValidator object. * If the ISystemValidator reports an error the error message is displayed * in the Dialog's message line. * @see #setPasswordValidator(ISystemValidator) - */ - protected SystemMessage validatePasswordInput() - { - // yantzi: artemis 6.0, disable save checkbox when blank - savePasswordCB.setEnabled(!internalGetPassword().equals("")); - - if (noValidate) - return null; - clearErrorMessage(); - errorMessage= null; - String password = internalGetPassword(); - if (passwordValidator != null) - errorMessage= passwordValidator.validate(password); - else if (password.equals("")) - errorMessage = RSEUIPlugin.getPluginMessage(MSG_VALIDATE_PASSWORD_EMPTY); - passwordOK = (errorMessage == null); - if (!passwordOK) - { - setErrorMessage(errorMessage); - okButton.setEnabled(false); - } - else - okButton.setEnabled(userIdOK); - return errorMessage; + */ + private void processPasswordField() { + internalGetUserId(); + internalGetPassword(); + SystemMessage m = checkPassword(); + if (m == null) { + m = checkUserId(); + } + okButton.setEnabled(m == null); + setErrorMessage(m); + if (savePasswordCB != null) { + savePasswordCB.setEnabled(password.length() > 0); // yantzi: artemis 6.0, disable save checkbox when blank + } } - - /** - * Return the userId entered by user - */ - public String getUserId() - { - return userId; - } - - /** - * Return the password entered by user - */ - public String getPassword() - { - return password; - } /** - * Sets the password + * Checks the value of the password instance variable. */ - public void setPassword(String password) - { + private SystemMessage checkPassword() { + SystemMessage m = null; + if (connectorService.supportsPassword() && validate) { + if (passwordValidator != null) { + m = passwordValidator.validate(password); + } else if (connectorService.requiresPassword() && password.length() == 0) { + m = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EMPTY); + } + } + return m; + } + + /** + * Return the userId entered by user + */ + public String getUserId() { + return userId; + } + + /** + * Returns the password may have been modified by the user. + */ + public String getPassword() { + return password; + } + + /** + * Sets the password, may be null if no password is available. + */ + public void setPassword(String password) { this.password = password; } - /** - * Return true if the user changed the user id - */ - public boolean getIsUserIdChanged() - { - return userIdChanged; - } - /** - * Return true if the user elected to make the changed user Id a permanent change. - */ - public boolean getIsUserIdChangePermanent() - { - return userIdPermanent; - } - /** - * Return true if the user elected to make the changed user Id a permanent change. - */ - public boolean getIsSavePassword() - { - return savePassword; - } - /** - * Preselect the save password checkbox. Default value is to not - * select the save password checkbox. - */ - public void setSavePassword(boolean save) - { - savePassword = save; - } + + /** + * Return true if the user changed the user id + */ + public boolean getIsUserIdChanged() { + return userIdChanged; + } + + /** + * Return true if the user elected to make the changed user Id a permanent change. + */ + public boolean getIsUserIdChangePermanent() { + return userIdPermanent; + } + + /** + * Return true if the user elected to make the changed user Id a permanent change. + */ + public boolean getIsSavePassword() { + return savePassword; + } + + /** + * Preselect the save password checkbox. Default value is to not + * select the save password checkbox. + */ + public void setSavePassword(boolean save) { + savePassword = save; + } + /** * Verifies all input. * @return true if there are no errors in the user input */ - protected boolean verify() - { - SystemMessage errMsg = null; + private void verify() { Control controlInError = null; - clearErrorMessage(); - errorMessage = null; - errMsg = validateUserIdInput(); - if (errMsg != null) - controlInError = textUserId; - else - { - errMsg = validatePasswordInput(); - if (errMsg != null) - controlInError = textPassword; - } - if (errMsg != null) - controlInError.setFocus(); // validate methods already displayed error message - return (errMsg == null); + processUserIdField(); + if (getErrorMessage() != null) { + controlInError = textUserId; + } else { + processPasswordField(); + if (getErrorMessage() != null) { + controlInError = textPassword; + } + } + if (getErrorMessage() != null) { + controlInError.setFocus(); // validate methods already displayed error message + } } - + /** * Called when user presses OK button. * Return true to close dialog. * Return false to not close dialog. */ - protected boolean processOK() - { - //busyCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT); - //getShell().setCursor(busyCursor); - setBusyCursor(true); // phil - - password = internalGetPassword(); - userId = internalGetUserId(); - userIdPermanent = internalGetIsUserIdChangePermanent(); - savePassword = internalGetIsSavePassword(); - if (forceToUpperCase) - { - userId = userId.toUpperCase(); - password = password.toUpperCase(); - noValidate = true; - textUserId.setText(userId); - textPassword.setText(password); - noValidate = false; - } - - boolean closeDialog = verify(); - - //getShell().setCursor(null); - //busyCursor.dispose(); - setBusyCursor(false); // phil - - // If all inputs are OK then verify signon - if (closeDialog && (signonValidator != null)) - { - SystemMessage msg = signonValidator.isValid(this, userId, password); - if (msg != null) - { - closeDialog = false; - setErrorMessage(msg); - } + protected boolean processOK() { + setBusyCursor(true); + internalGetPassword(); + internalGetUserId(); + internalGetIsUserIdChangePermanent(); + internalGetIsSavePassword(); + if (forceToUpperCase) { + userId = userId.toUpperCase(); + password = password.toUpperCase(); + validate = false; + textUserId.setText(userId); + textPassword.setText(password); + validate = true; } - + + verify(); + setBusyCursor(false); // phil + + // If all inputs are OK then validate signon + if (getErrorMessage() == null && (signonValidator != null)) { + SystemMessage m = signonValidator.isValid(this, userId, password); + setErrorMessage(m); + } + boolean closeDialog = (getErrorMessage() == null); return closeDialog; - } + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemSubSystemPropertyPageCoreForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemSubSystemPropertyPageCoreForm.java index fb1a85d2c27..9bb1b6adbcc 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemSubSystemPropertyPageCoreForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemSubSystemPropertyPageCoreForm.java @@ -127,7 +127,7 @@ public class SystemSubSystemPropertyPageCoreForm extends AbstractSystemSubSystem */ protected boolean isUserIdApplicable() { - return getSubSystem().getSubSystemConfiguration().supportsUserId(); + return getSubSystem().getConnectorService().supportsUserId(); } private ISystemValidator getPortValidator() diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java index d49f2056bd4..c03c43ec4bd 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SubSystemConfigurationAdapter.java @@ -529,7 +529,7 @@ public class SubSystemConfigurationAdapter implements ISubSystemConfigurationAda if (factory.supportsSubSystemConnect()) { //nbrBaseActions += 2; // 4; MJB: RE defect 50854 - if (factory.supportsUserId()) + if (selectedSubSystem.getConnectorService().supportsUserId()) nbrBaseActions += 1; } //if (supportsFilters()) @@ -542,7 +542,7 @@ public class SubSystemConfigurationAdapter implements ISubSystemConfigurationAda //subSystemActions[ssIdx++] = new SystemConnectAction(shell); //subSystemActions[ssIdx++] = new SystemDisconnectAction(shell); - if (factory.supportsUserId()) + if (selectedSubSystem.getConnectorService().supportsUserId()) subSystemActions[ssIdx++] = new SystemClearPasswordAction(shell); } } // end if subsystemActons == null diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java index 12893919209..cf514305240 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java @@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Shell; * This is a base class to make it easier to create connector service classes. *

* An {@link org.eclipse.rse.core.subsystems.IConnectorService} object - * is returned from a subsystem object via getSystem(), and + * is returned from a subsystem object via getConnectorService(), and * it is used to represent the live connection to a particular subsystem. *

* You must override/implement @@ -61,6 +61,13 @@ import org.eclipse.swt.widgets.Shell; *

  • getHomeDirectory *
  • getTempDirectory * + * You can override: + * * * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager */ @@ -251,9 +258,12 @@ public abstract class AbstractConnectorService extends RSEModelObject implements * cached userId. */ final public String getUserId() { - String result = getLocalUserId(); - if (result == null) { - result = getSubSystemUserId(); + String result = null; + if (supportsUserId()) { + result = getLocalUserId(); + if (result == null) { + result = getSubSystemUserId(); + } } return result; } @@ -370,7 +380,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements * Useful utility method. Fully implemented, do not override.
    * Return true if password is currently cached. */ - final public boolean isPasswordCached() // DWD Can we make this final? + final public boolean isPasswordCached() { return isPasswordCached(false); } @@ -386,10 +396,41 @@ public abstract class AbstractConnectorService extends RSEModelObject implements return true; } - /** - * Return true if this system can share it's uid and password - * with other ISystems in this connection - * + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IConnectorService#requiresPassword() + */ + public boolean requiresPassword() { + return true; + } + + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsPassword() + */ + public boolean supportsPassword() { + return true; + } + + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IConnectorService#requiresUserId() + */ + public boolean requiresUserId() { + return true; + } + + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsUserId() + */ + public boolean supportsUserId() + { + return true; + } + + /** + * Return true if this connector service can share it's uid and password + * with other connector services in this host (connection). * @return true if it can share the user/password */ public boolean shareUserPasswordWithConnection() @@ -399,120 +440,120 @@ public abstract class AbstractConnectorService extends RSEModelObject implements /** * Do not override. - *

    Returns the password for this connector service. - *

    + * Sets the signon information for this connector service. * The search order for the password is as follows:

    *
      - *
    1. First check if the password is in transient memory and that it is still valid. - *
    2. If password not found in transient memory then check password on disk and - * verify that it is still valid. - *
    3. If a valid password is not found in transient memory or on disk then prompt - * the user. + *
    4. First check if the password is already known by this connector service and that it is still valid. + *
    5. If password not known then look in the password store and verify that it is still valid. + *
    6. If a valid password is not found then prompt the user. *
    - * Throws InterruptedException if user is prompted and user cancels that prompt. + * Must be run in the UI thread. * @param shell parent for the prompt dialog if needed. - * @param forcePrompt if true then present the prompt even if the password is stored. - * Can be null if the password is known to exist. + * Can be null if the password is known to exist in either this class or in the password store. + * @param forcePrompt if true then present the prompt even if the password was found and is valid. + * @throws InterruptedException if user is prompted and user cancels that prompt or if isSuppressSignonPrompt is true. */ public void promptForPassword(Shell shell, boolean forcePrompt) throws InterruptedException { // dy: March 24, 2003: check if prompting is temporarily suppressed by a tool // vendor, this should only be suppressed if the user cancelled a previous signon // dialog (or some other good reason) if (isSuppressSignonPrompt()) throw new InterruptedException(); - - boolean passwordValid = true; - ISignonValidator validator = getSignonValidator(); - SystemSignonInformation passwordInformation = getPasswordInformation(); + ISubSystem subsystem = getPrimarySubSystem(); IHost host = subsystem.getHost(); String hostName = host.getHostName(); String hostType = host.getSystemType(); - String userId = getUserId(); - PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance(); - - // Check the transient in memory password ... - // Test if userId has been changed... d43274 - if (passwordInformation != null && !forcePrompt) { - boolean same = host.compareUserIds(userId, passwordInformation.getUserid()); - same = same && hostName.equalsIgnoreCase(passwordInformation.getHostname()); - if (!same) { - clearPasswordCache(); - passwordInformation = null; + boolean savePassword = false; + if (_passwordInfo == null) { + _passwordInfo = new SystemSignonInformation(hostName, null, null, hostType); + } + if (supportsUserId()) { + String userId = getUserId(); + if (_passwordInfo.getUserid() == null) { + _passwordInfo.setUserid(userId); + } + boolean sameUserId = host.compareUserIds(userId, _passwordInfo.getUserid()); + boolean sameHost = hostName.equalsIgnoreCase(_passwordInfo.getHostname()); + if (!(sameHost && sameUserId)) { + _passwordInfo.setPassword(null); + _passwordInfo.setUserid(userId); } } - - // If a transient in memory password was found, test if it is still valid ... - // but don't issue a message yet, just set a flag - if (passwordInformation != null && validator != null && !validator.isValid(shell, passwordInformation)) { - passwordValid = false; - clearPasswordCache(); - passwordInformation = null; - } - - // Check the saved passwords if we still haven't found a good password. - if (passwordInformation == null && userId != null) { - SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, userId); - if (savedPasswordInformation != null) { - if (validator == null || validator.isValid(shell, savedPasswordInformation)) { - setPasswordInformation(savedPasswordInformation); - passwordInformation = getPasswordInformation(); - } else { - passwordValid = false; - clearPasswordCache(); - passwordInformation = null; + if (supportsPassword()) { + if (_passwordInfo.getPassword() == null) { + PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance(); + String userId = _passwordInfo.getUserid(); + SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, userId); + if (savedPasswordInformation != null) { + _passwordInfo = savedPasswordInformation; + savePassword = true; } } - } + } + ISignonValidator validator = getSignonValidator(); + boolean signonValid = (validator == null) || validator.isValid(shell, _passwordInfo); // If we ran into an invalid password we need to tell the user. // DWD refactor - want to move this to a pluggable class so that this can be moved to core. - if (!passwordValid) { + // DWD not sure this is necessary, shouldn't this message show up on the password prompt itself? + if (!signonValid) { SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID); msg.makeSubstitution(getLocalUserId(), getHostName()); SystemMessageDialog dialog = new SystemMessageDialog(shell, msg); dialog.open(); } - // Valid password not found so prompt, or force prompt - if ((forcePrompt || (passwordInformation == null)) && (shell != null)) { - ISystemPasswordPromptDialog dlg = getPasswordPromptDialog(shell); - dlg.setSystemInput(this); - passwordInformation = ppm.find(hostType, hostName, userId); - if (passwordInformation != null) { - String password = passwordInformation.getPassword(); - dlg.setPassword(password); - dlg.setSavePassword(true); - } else { - dlg.setPassword(""); - dlg.setSavePassword(false); - } - try { - dlg.open(); - } catch (Exception e) { - logException(e); - } - if (dlg.wasCancelled()) throw new InterruptedException(); - boolean userIdChanged = dlg.getIsUserIdChanged(); - if (userIdChanged) { - String newUserId = dlg.getUserId(); - boolean userIdChangePermanent = dlg.getIsUserIdChangePermanent(); - if (userIdChangePermanent) { - updateDefaultUserId(subsystem, newUserId); - } else { - setUserId(newUserId); - _userId = newUserId; - } - } - boolean persistPassword = dlg.getIsSavePassword(); - setPassword(dlg.getUserId(), dlg.getPassword(), persistPassword); - if (shareUserPasswordWithConnection()) { - // share this uid/password with other ISystems in connection - updatePasswordForOtherSystemsInConnection(dlg.getUserId(), dlg.getPassword(), persistPassword); - } - } + if (supportsPassword() || supportsUserId()) { + if (shell != null) { + boolean passwordNeeded = supportsPassword() && _passwordInfo.getPassword() == null; + boolean userIdNeeded = supportsUserId() && _passwordInfo.getUserid() == null; + if (passwordNeeded || userIdNeeded || forcePrompt) { + ISystemPasswordPromptDialog dialog = getPasswordPromptDialog(shell); + if (dialog != null) { + dialog.setSystemInput(this); + dialog.setSignonValidator(getSignonValidator()); + if (supportsUserId()) { + dialog.setUserIdValidator(getUserIdValidator()); + } + if (supportsPassword()) { + String password = _passwordInfo.getPassword(); + dialog.setSavePassword(savePassword); + dialog.setPassword(password); + dialog.setPasswordValidator(getPasswordValidator()); + } + try { + dialog.open(); + } catch (Exception e) { + logException(e); + } + if (dialog.wasCancelled()) { + throw new InterruptedException(); + } + String userId = dialog.getUserId(); + boolean userIdChanged = dialog.getIsUserIdChanged(); + boolean saveUserId = dialog.getIsUserIdChangePermanent(); + String password = dialog.getPassword(); + savePassword = dialog.getIsSavePassword(); + if (supportsUserId() && userIdChanged) { + if (saveUserId) { + updateDefaultUserId(subsystem, userId); + } else { + setUserId(userId); + _passwordInfo.setUserid(userId); + } + } + if (supportsPassword()) { + setPassword(userId, password, savePassword); + if (shareUserPasswordWithConnection()) { + updatePasswordForOtherSystemsInConnection(userId, password, savePassword); + } + } + } + } + } + } } - protected void clearPasswordForOtherSystemsInConnection(String uid, boolean fromDisk) { if (uid != null) @@ -601,7 +642,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements /** * A default implementation is supplied, but can be overridden if desired.
    - * Instantiates and returns the dialog to prompt for the userId. + * Instantiates and returns the dialog to prompt for the userId and password. *

    * By default returns an instance of SystemPasswordPromptDialog. Calls forcePasswordToUpperCase() to decide whether the user Id and password should be folded to uppercase. *

    @@ -618,7 +659,6 @@ public abstract class AbstractConnectorService extends RSEModelObject implements { ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell); dlg.setForceToUpperCase(forcePasswordToUpperCase()); - //dlg.setBlockOnOpen(true); now done by default in SystemPromptDialog dlg.setUserIdValidator(getUserIdValidator()); dlg.setPasswordValidator(getPasswordValidator()); dlg.setSignonValidator(getSignonValidator()); @@ -697,7 +737,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements return getPrimarySubSystem().forceUserIdToUpperCase(); } - /** + /** * Useful utility method. Fully implemented, no need to override.
    * Get the userId input validator to use in the password dialog prompt. *

    @@ -708,6 +748,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements { return getPrimarySubSystem().getSubSystemConfiguration().getUserIdValidator(); } + /** * Useful utility method. Fully implemented, no need to override.
    * Get the password input validator to use in the password dialog prompt. diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IConnectorService.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IConnectorService.java index 76c82c52f0b..8c973a19ee2 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IConnectorService.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IConnectorService.java @@ -291,16 +291,49 @@ public interface IConnectorService extends IRSEModelObject */ void setRemoteServerLauncherProperties(IServerLauncherProperties value); - boolean hasRemoteServerLauncherProperties(); boolean supportsRemoteServerLaunching(); /** * Tell us if this subsystem factory supports server launch properties, which allow the user - * to configure how the server-side code for these subsystems are started. There is a Server - * Launch Setting property page, with a pluggable composite, where users can configure these - * properties. + * to configure how the server-side code for these subsystems are started. There is a Server + * Launch Setting property page, with a pluggable composite, where users can configure these + * properties. */ public boolean supportsServerLaunchProperties(); + + /** + * Report if this connector service can use a user identifier. + * Returns true in default implementation. + * Typically used to indicate if a login dialog needs to be presented when connecting. + * @return true if and only if the connector service can use a user id. + */ + public boolean supportsUserId(); + + /** + * Report if this connector service requires a user id. + * Returns true in default implementation. + * Typically used to indicate if a login dialog can allow an empty user id. + * Must be ignored if supportsUserId() is false. + * @return true or false to indicate if the connector service requires a user id. + */ + public boolean requiresUserId(); + + /** + * Can be used to determine if a password field is present on a login dialog for this connector service. + * The default implementation of this interface should return true. + * @return true if the subsystem can use a password, false if a password is irrelevant. + */ + public boolean supportsPassword(); + + /** + * If a password is supported this is used to determine if the password is required. + * Must be ignored if supportsPassword() returns false. + * The default implementation of this interface should return true. + * @return true if the connector service requires a password, false if a password may be empty. + */ + public boolean requiresPassword(); + + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/ISubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/ISubSystemConfiguration.java index 14d7078bf1f..0c13dfe9cb7 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/ISubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/ISubSystemConfiguration.java @@ -53,39 +53,6 @@ public interface ISubSystemConfiguration extends ISystemFilterPoolManagerProvide // --------------------------------- // CRITICAL METHODS... // --------------------------------- - /** - * Determines if a user id is relevant for this subsystem. - * Returns true in default implementation. - * Typically used to indicate if a login dialog needs to be presented when the subsystem - * connects. - * @return true or false to indicate if subsystems can use a user id. - */ - public boolean supportsUserId(); - - /** - * Determines if a user id is required if a user id can be used to connect subsystems of this configuration. - * Returns true in default implementation. - * Typically used to indicate if a login dialog can allow an empty user id. - * @return true or false to indicate if subsystems requires a user id. - */ - public boolean requiresUserId(); - - /** - * Can be used to determine if a password field is present on a login dialog for subsystems - * of this configuration. - * The default implementation of this interface should return true. - * @return true if the subsystem can use a password, false if a password is irrelevant. - */ - public boolean supportsPassword(); - - /** - * If a password is supported this is used to determine if the password can be the empty string. - * Must be ignored if supportsPassword() returns false. - * The default implementation of this interface should return true. - * @return true if the subsystem requires, false if a password may be empty. - */ - public boolean requiresPassword(); - /** * Return true if the subsystem supports more than one filter string *

    RETURNS true BY DEFAULT diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index 870e41ebf7e..10fcb059f04 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -2508,16 +2508,16 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS /** * Connect to the remote system, optionally forcing a signon prompt even if the password * is cached in memory or on disk. - * You do not need to override this, as it does the progress monitor and error message - * displaying for you. - *

    - * Override internalConnect if you want, but by default it calls getSystem().connect(IProgressMonitor). - * - * @param Shell parent shell used to show error message. Null means you will handle showing the error message. - * @param forcePrompt Forces the signon prompt to be displayed even if a valid password in cached in memory - * or saved on disk. + * You do not need to override this, as it does the progress monitor and error message + * displaying for you. + *

    + * Override internalConnect if you want, but by default it calls getSystem().connect(IProgressMonitor). + * + * @param Shell parent shell used to show error message. Null means you will handle showing the error message. + * @param forcePrompt Forces the signon prompt to be displayed even if a valid password in cached in memory + * or saved on disk. */ - public void connect(Shell shell, boolean forcePrompt) throws Exception { + public void connect(Shell shell, boolean forcePrompt) throws Exception { // yantzi: artemis60, (defect 53082) check that the connection has not been deleted before continuing, // this is a defenisve measure to protect against code that stores a handle to subsystems but does // not do this check @@ -2543,9 +2543,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS if (runnableContext instanceof ProgressMonitorDialog) { ((ProgressMonitorDialog) runnableContext).setCancelable(true); } - if (getSubSystemConfiguration().supportsUserId()) { - getConnectorService().promptForPassword(shell, forcePrompt); // prompt for userid and password - } + getConnectorService().promptForPassword(shell, forcePrompt); // prompt for userid and password ConnectJob job = new ConnectJob(); scheduleJob(job, null, shell != null); IStatus status = job.getResult(); @@ -2558,13 +2556,24 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS /** - * Prompt the user for a password to the remote system. The primary request was something else, - * but we have detected the user is not connected so we prompt for password outside - * of the progress monitor, then set a flag to do the connection within the progress - * monitor. - * @param Shell parent shell used to show error message. Null means you will handle showing the error message. + * A convenience method, fully equivalent to promptForPassword(shell, false). + * @param Shell parent shell used to show any error messages. */ public boolean promptForPassword(Shell shell) throws Exception + { + return promptForPassword(shell, false); + } + + /** + * Prompt the user for a password to the remote system. The primary request was something else, + * but we have detected the user is not connected so we prompt for password outside + * of the progress monitor, then set a flag to do the connection within the progress + * monitor. + * @param Shell parent shell used to show error messages. + * @param force true if the prompting should be forced, false if prompting can be skipped if credentials have been stored. + * @return true if the credentials are obtained + */ + public boolean promptForPassword(Shell shell, boolean force) throws Exception { boolean ok = false; if (!supportsConnecting) @@ -2581,17 +2590,10 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS doConnection = true; // this gets handled later when it comes time to connect return true; } - else if (!getSubSystemConfiguration().supportsUserId()) - { - // subsystem needs no user id so dont bother prompting - doConnection = true; // this gets handled later when it comes time to connect - return true; - } - try { - getConnectorService().promptForPassword(shell, false); // prompt for password + getConnectorService().promptForPassword(shell, force); // prompt for password doConnection = true; ok = true; } @@ -2768,45 +2770,45 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS } /** - * Actually connect to the remote host. This is called by the run(IProgressMonitor monitor) method. + * Connect to the remote host. This is called by the run(IProgressMonitor monitor) method. *

    - * You DO NOT OVERRIDE THIS typically. Rather, this calls connect(IProgressMonitor) in your - * ISystem class that is returned from getSystem(). That is where your code to connect should go! + * DO NOT OVERRIDE THIS. Rather, this calls connect(IProgressMonitor) in the + * IConnectorService class that is returned from getConnectorService(). *

    - * Your connect method in your ISystem class must follow these IRunnableWithProgress rules: + * Your connect method in your IConnectorService class must follow these IRunnableWithProgress rules: *

    * */ protected void internalConnect(IProgressMonitor monitor) - throws java.lang.reflect.InvocationTargetException, - java.lang.InterruptedException + throws InvocationTargetException, InterruptedException { try { getConnectorService().connect(monitor); } - catch(Exception exc) - { - if (exc instanceof java.lang.reflect.InvocationTargetException) - throw (java.lang.reflect.InvocationTargetException)exc; - if (exc instanceof java.lang.InterruptedException) - throw (java.lang.InterruptedException)exc; - throw new java.lang.reflect.InvocationTargetException(exc); + catch(InvocationTargetException exc) { + throw exc; + } + catch (InterruptedException exc) { + throw exc; + } + catch (Exception exc) { + throw new InvocationTargetException(exc); } } /** * Actually disconnect from the remote host. This is called by the run(IProgressMonitor monitor) method. *

    - * You DO NOT OVERRIDE THIS typically. Rather, this calls connect(IProgressMonitor) in your - * ISystem class that is returned from getSystem(). That is where your code to disconnect should go! + * You DO NOT OVERRIDE THIS. Rather, this calls connect(IProgressMonitor) in your + * IConnectorService class that is returned from getConnectorService(). That is where your code to disconnect should go! *

    - * Your connect method in your ISystem class must follow these IRunnableWithProgress rules: + * Your disconnect method in your IConnectorService class must follow these IRunnableWithProgress rules: *

    */ protected void internalDisconnect(IProgressMonitor monitor) - throws java.lang.reflect.InvocationTargetException, - java.lang.InterruptedException + throws InvocationTargetException, InterruptedException { try { getConnectorService().disconnect(monitor); } - catch(Exception exc) - { - if (exc instanceof java.lang.reflect.InvocationTargetException) - throw (java.lang.reflect.InvocationTargetException)exc; - if (exc instanceof java.lang.InterruptedException) - throw (java.lang.InterruptedException)exc; - throw new java.lang.reflect.InvocationTargetException(exc); + catch (InterruptedException exc) { + throw exc; + } + catch (InvocationTargetException exc) { + throw exc; + } + catch(Exception exc) { + throw new InvocationTargetException(exc); } } diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java index 5e3b4c61756..d1a4877bd13 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java @@ -189,38 +189,6 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration // --------------------------------- // CRITICAL METHODS... // --------------------------------- - /** - * Return true (default) or false to indicate if subsystems of this factory require a userId to - * do connection or not. If not, no GUI will be supplied related to user Ids in the remote systems - * explorer view. - *

    - * Returns TRUE by default. - */ - public boolean supportsUserId() - { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#requiresUserId() - */ - public boolean requiresUserId() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#supportsPassword() - */ - public boolean supportsPassword() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.ISubSystemConfiguration#requiresPassword() - */ - public boolean requiresPassword() { - return true; - } /** * Return true if instance of this factory's subsystems support connect and disconnect actions. diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java index c02a6c5d778..b7bd0b721f0 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java +++ b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java @@ -429,10 +429,6 @@ public class PasswordPersistenceManager { */ public SystemSignonInformation find(String systemtype, String hostname, String userid) { - if (userid == null) - { - return null; - } return find(systemtype, hostname, userid, true); } @@ -550,7 +546,7 @@ public class PasswordPersistenceManager { { String hostname = hname;//RSEUIPlugin.getQualifiedHostName(hname); // Convert userid to upper case if required - if (!isUserIDCaseSensitive(systemtype)) + if (!isUserIDCaseSensitive(systemtype) && userid != null) { userid = userid.toUpperCase(); }