mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-23 08:13:50 +02:00
[180313] restoring behavior of StandardCredentialsProvider when invoked with an uninitialized workbench.
This commit is contained in:
parent
70f93e8772
commit
2f54eead46
2 changed files with 71 additions and 48 deletions
|
@ -39,6 +39,7 @@ public interface ICredentialsProvider {
|
||||||
* remembered credentials.
|
* remembered credentials.
|
||||||
* @throws InterruptedException if the acquisition of credentials is
|
* @throws InterruptedException if the acquisition of credentials is
|
||||||
* canceled by the user, if the provider is in suppressed state,
|
* canceled by the user, if the provider is in suppressed state,
|
||||||
|
* a resource (such as the workbench) not being available,
|
||||||
* or interrupted by some other means.
|
* or interrupted by some other means.
|
||||||
*/
|
*/
|
||||||
void acquireCredentials(boolean reacquire) throws InterruptedException;
|
void acquireCredentials(boolean reacquire) throws InterruptedException;
|
||||||
|
@ -50,7 +51,9 @@ public interface ICredentialsProvider {
|
||||||
* an expired password.
|
* an expired password.
|
||||||
* @param message the message indicating the nature of the damage that must
|
* @param message the message indicating the nature of the damage that must
|
||||||
* be repaired. For example, indicating expiration of a password.
|
* be repaired. For example, indicating expiration of a password.
|
||||||
* @throws InterruptedException if the repair is canceled for some reason.
|
* @throws InterruptedException if the repair is canceled for some reason. This could
|
||||||
|
* include the inability of a credentials provider to open a dialog or a dialog being
|
||||||
|
* canceled.
|
||||||
*/
|
*/
|
||||||
void repairCredentials(SystemMessage message)throws InterruptedException;
|
void repairCredentials(SystemMessage message)throws InterruptedException;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
package org.eclipse.rse.ui.subsystems;
|
package org.eclipse.rse.ui.subsystems;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.rse.core.PasswordPersistenceManager;
|
import org.eclipse.rse.core.PasswordPersistenceManager;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.core.model.SystemSignonInformation;
|
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||||
|
@ -29,9 +30,11 @@ import org.eclipse.rse.ui.dialogs.SystemChangePasswordDialog;
|
||||||
import org.eclipse.rse.ui.dialogs.SystemPasswordPromptDialog;
|
import org.eclipse.rse.ui.dialogs.SystemPasswordPromptDialog;
|
||||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
import org.eclipse.rse.ui.validators.ISystemValidator;
|
import org.eclipse.rse.ui.validators.ISystemValidator;
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link StandardCredentialsProvider} is an extension of
|
* The {@link StandardCredentialsProvider} is an extension of
|
||||||
|
@ -66,7 +69,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
* @see java.lang.Runnable#run()
|
* @see java.lang.Runnable#run()
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
ISystemPasswordPromptDialog dialog = getPasswordPromptDialog(getShell());
|
Shell shell = getShell();
|
||||||
|
if (shell != null) {
|
||||||
|
ISystemPasswordPromptDialog dialog = getPasswordPromptDialog(shell);
|
||||||
dialog.setSystemInput(getConnectorService());
|
dialog.setSystemInput(getConnectorService());
|
||||||
dialog.setForceToUpperCase(forcePasswordToUpperCase());
|
dialog.setForceToUpperCase(forcePasswordToUpperCase());
|
||||||
dialog.setSignonValidator(getSignonValidator());
|
dialog.setSignonValidator(getSignonValidator());
|
||||||
|
@ -90,6 +95,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
saveUserId = dialog.getIsUserIdChangePermanent();
|
saveUserId = dialog.getIsUserIdChangePermanent();
|
||||||
savePassword = dialog.getIsSavePassword();
|
savePassword = dialog.getIsSavePassword();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
canceled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +118,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
SystemChangePasswordDialog dlg = new SystemChangePasswordDialog(getShell(), getConnectorService().getHostName(), getUserId(), message);
|
Shell shell = getShell();
|
||||||
|
if (shell != null) {
|
||||||
|
SystemChangePasswordDialog dlg = new SystemChangePasswordDialog(shell, getConnectorService().getHostName(), getUserId(), message);
|
||||||
dlg.setSavePassword(savePassword);
|
dlg.setSavePassword(savePassword);
|
||||||
dlg.open();
|
dlg.open();
|
||||||
canceled = dlg.wasCancelled();
|
canceled = dlg.wasCancelled();
|
||||||
|
@ -118,6 +128,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
password = dlg.getNewPassword();
|
password = dlg.getNewPassword();
|
||||||
savePassword = dlg.getIsSavePassword();
|
savePassword = dlg.getIsSavePassword();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
canceled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,15 +198,16 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
if (validator != null) {
|
if (validator != null) {
|
||||||
SystemMessage m = validator.validate(getCredentials());
|
SystemMessage m = validator.validate(getCredentials());
|
||||||
signonValid = (m == null);
|
signonValid = (m == null);
|
||||||
}
|
if (!signonValid) { // If we ran into an invalid stored password we need to tell the user.
|
||||||
// If we ran into an invalid password we need to tell the user.
|
Shell shell = getShell();
|
||||||
// Not sure this is necessary, shouldn't this message show up on the password prompt itself?
|
if (shell != null) {
|
||||||
if (!signonValid) {
|
|
||||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID);
|
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID);
|
||||||
msg.makeSubstitution(userId, getConnectorService().getHostName());
|
msg.makeSubstitution(userId, getConnectorService().getHostName());
|
||||||
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
SystemMessageDialog dialog = new SystemMessageDialog(shell, msg);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (supportsPassword() || supportsUserId()) {
|
if (supportsPassword() || supportsUserId()) {
|
||||||
boolean passwordNeeded = supportsPassword() && password == null;
|
boolean passwordNeeded = supportsPassword() && password == null;
|
||||||
boolean userIdNeeded = supportsUserId() && userId == null;
|
boolean userIdNeeded = supportsUserId() && userId == null;
|
||||||
|
@ -326,9 +340,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISystemValidator getPasswordValidator() {
|
private ISystemValidator getPasswordValidator() {
|
||||||
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
ISubSystemConfiguration subsystemConfiguration = getPrimarySubSystem().getSubSystemConfiguration();
|
||||||
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) Platform.getAdapterManager().getAdapter(subsystemConfiguration, ISubSystemConfigurationAdapter.class);
|
||||||
return adapter.getPasswordValidator(ssFactory);
|
return adapter.getPasswordValidator(subsystemConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISubSystem getPrimarySubSystem() {
|
private ISubSystem getPrimarySubSystem() {
|
||||||
|
@ -336,8 +350,14 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Shell getShell() {
|
private Shell getShell() {
|
||||||
Display display = Display.getDefault();
|
Shell shell = null;
|
||||||
Shell shell = new Shell(display, SWT.APPLICATION_MODAL);
|
IWorkbench workbench = PlatformUI.getWorkbench();
|
||||||
|
if (workbench != null) {
|
||||||
|
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
|
||||||
|
if (window != null) {
|
||||||
|
shell = window.getShell();
|
||||||
|
}
|
||||||
|
}
|
||||||
return shell;
|
return shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,9 +368,9 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISystemValidator getUserIdValidator() {
|
private ISystemValidator getUserIdValidator() {
|
||||||
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
ISubSystemConfiguration subsystemConfiguration = getPrimarySubSystem().getSubSystemConfiguration();
|
||||||
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) Platform.getAdapterManager().getAdapter(subsystemConfiguration, ISubSystemConfigurationAdapter.class);
|
||||||
ISystemValidator validator = adapter.getUserIdValidator(ssFactory);
|
ISystemValidator validator = adapter.getUserIdValidator(subsystemConfiguration);
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue