mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[168977][api][refactor] - stage 2.4
- introduce "credentials" terminology to methods that needed it - began moving "requiresUserId" and "requiresPassword" from connector service API to credentials providers
This commit is contained in:
parent
41c71f3360
commit
178f374a52
12 changed files with 141 additions and 109 deletions
|
@ -952,7 +952,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
|||
{
|
||||
try
|
||||
{
|
||||
promptForPassword(true);
|
||||
acquireCredentials(true);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
@ -1064,7 +1064,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
|||
{
|
||||
try
|
||||
{
|
||||
promptForPassword(true);
|
||||
acquireCredentials(true);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
|
|
@ -35,5 +35,11 @@ public class BasicCredentialsProvider implements ICredentialsProvider {
|
|||
public boolean supportsUserId() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void acquireCredentials(boolean reacquire) {
|
||||
}
|
||||
|
||||
public void clearCredentials() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,6 +165,41 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
public void setIsUsingSSL(boolean flag);
|
||||
|
||||
/**
|
||||
* Reports 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();
|
||||
|
||||
/**
|
||||
* Determines if this connector service understand the concept of a
|
||||
* password.
|
||||
* The default implementation of this interface should return true.
|
||||
* @return true if the connector service can use a password,
|
||||
* false if a password is irrelevant.
|
||||
*/
|
||||
public boolean supportsPassword();
|
||||
|
||||
/**
|
||||
* Reports 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();
|
||||
|
||||
/**
|
||||
* Determines if a password is required for this connector service.
|
||||
* Must be ignored if {@link #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();
|
||||
|
||||
/**
|
||||
* @return the userId that will be used by this connector when
|
||||
* establishing its connection.
|
||||
|
@ -178,19 +213,6 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
public void setUserId(String userId);
|
||||
|
||||
/**
|
||||
* Acquire the password for this connector service.
|
||||
* <p>
|
||||
* Implementations may retain a remembered password or
|
||||
* use this acquire the password using some implementation defined means.
|
||||
* <p>
|
||||
* Throws InterruptedException if acquisition of the
|
||||
* password is canceled for some reason.
|
||||
* @param reacquire if true will force the connector service to discard
|
||||
* any remembered value and reacquire the password.
|
||||
*/
|
||||
public void promptForPassword(boolean reacquire) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Sets the password used by this connector service.
|
||||
* Can be used if the connector service acquires a password by some external
|
||||
|
@ -201,13 +223,6 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
public void setPassword(String matchingUserId, String password, boolean persist);
|
||||
|
||||
/**
|
||||
* Clears the userId held by this service.
|
||||
* Should be called if there is a change to the user id for
|
||||
* any using subsystem.
|
||||
*/
|
||||
public void clearUserId();
|
||||
|
||||
/**
|
||||
* Clear password held by this service and optionally
|
||||
* clear its persistent form.
|
||||
|
@ -237,6 +252,49 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
public boolean sharesCredentials();
|
||||
|
||||
/**
|
||||
* Clears the credentials held by this service.
|
||||
* Should be called if there is a change to any part of the credentials
|
||||
* expected by any using subsystem.
|
||||
*/
|
||||
public void clearCredentials();
|
||||
|
||||
/**
|
||||
* Acquire the credentials for this connector service.
|
||||
* Acquisition may be temporarily suppressed
|
||||
* by using the {@link #setSuppressed(boolean)}.
|
||||
* <p>
|
||||
* Implementations may retain a remembered credentials or
|
||||
* use this acquire the credentials using some implementation defined means.
|
||||
* <p>
|
||||
* Throws InterruptedException if acquisition of the
|
||||
* credentials is canceled or is being suppressed.
|
||||
* @param refresh if true will force the connector service to discard
|
||||
* any remembered value and reacquire the credentials.
|
||||
*/
|
||||
public void acquireCredentials(boolean refresh) throws InterruptedException;
|
||||
|
||||
/**
|
||||
* @return true if the acquisition of credentials is being suppressed.
|
||||
*/
|
||||
public boolean isSuppressed();
|
||||
|
||||
/**
|
||||
* Suppresses the acquisition of a credentials by the connector service.
|
||||
* Causes {@link #acquireCredentials(boolean)} to immediately
|
||||
* throw an InterruptedException.
|
||||
* <p>
|
||||
* The intent is to allow tool writers to prevent multiple
|
||||
* attempts to acquire credentials during a set period of time.
|
||||
* <b>It is the callers responsibility to set this value
|
||||
* back to false when the tool no longer needs to suppress
|
||||
* acquisition credentials.</b>
|
||||
*
|
||||
* @param suppress <code>true</code> if acquisition is to be suppressed.
|
||||
* <code>false</code> if acquisition is to be allowed.
|
||||
*/
|
||||
public void setSuppressed(boolean suppress);
|
||||
|
||||
/**
|
||||
* Register a communications listener. These listeners will be informed
|
||||
* of connect and disconnect events.
|
||||
|
@ -250,27 +308,6 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
public void removeCommunicationsListener(ICommunicationsListener listener);
|
||||
|
||||
/**
|
||||
* @return true if the password acquisition is to be suppressed.
|
||||
*/
|
||||
public boolean isSuppressSignonPrompt();
|
||||
|
||||
/**
|
||||
* Suppresses the acquisition of a password by the connector service.
|
||||
* Causes {@link #promptForPassword(boolean)} to immediately
|
||||
* throw an InterruptedException.
|
||||
* <p>
|
||||
* The intent is to allow tool writers to prevent multiple
|
||||
* attempts to acquire a password during a set period of time.
|
||||
* <b>It is the callers responsibility to set this value
|
||||
* back to false when the tool no longer needs to suppress
|
||||
* acquisition of the password.</b>
|
||||
*
|
||||
* @param suppressSignonPrompt <code>true</code> if acquisition is to be suppressed.
|
||||
* <code>false</code> if acquisition is to be allowed.
|
||||
*/
|
||||
public void setSuppressSignonPrompt(boolean suppressSignonPrompt);
|
||||
|
||||
/**
|
||||
* This methods returns the enablement state of a server launch type.
|
||||
* If {@link RemoteServerLauncher#enableServerLaunchType(ServerLaunchType, boolean)} has not been
|
||||
|
@ -326,39 +363,4 @@ public interface IConnectorService extends IRSEModelObject {
|
|||
*/
|
||||
IServerLauncher getRemoteServerLauncher();
|
||||
|
||||
/**
|
||||
* Reports 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();
|
||||
|
||||
/**
|
||||
* Reports 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();
|
||||
|
||||
/**
|
||||
* Determines if this connector service understand the concept of a
|
||||
* password.
|
||||
* The default implementation of this interface should return true.
|
||||
* @return true if the connector service can use a password,
|
||||
* false if a password is irrelevant.
|
||||
*/
|
||||
public boolean supportsPassword();
|
||||
|
||||
/**
|
||||
* Determines if a password is required for this connector service.
|
||||
* Must be ignored if {@link #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();
|
||||
|
||||
}
|
|
@ -19,4 +19,8 @@ public interface ICredentialsProvider {
|
|||
|
||||
boolean requiresUserId();
|
||||
|
||||
void acquireCredentials(boolean reacquire);
|
||||
|
||||
void clearCredentials();
|
||||
|
||||
}
|
||||
|
|
|
@ -372,5 +372,5 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
|
|||
boolean result = cp.supportsUserId();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
||||
* Copyright (c) 2006, 2007 IBM Corporation. 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
|
||||
|
@ -11,7 +11,7 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.eclipse.filesystem;
|
||||
|
@ -130,7 +130,7 @@ public class RSEFileSystem extends FileSystem
|
|||
{
|
||||
|
||||
|
||||
fs.getConnectorService().promptForPassword(false);
|
||||
fs.getConnectorService().acquireCredentials(false);
|
||||
fs.getConnectorService().connect(new NullProgressMonitor());
|
||||
//fs.connect(shell);
|
||||
}
|
||||
|
|
|
@ -41,13 +41,14 @@ 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.
|
||||
* This class is final due to the sensitive nature of the
|
||||
* information being prompted for.
|
||||
*/
|
||||
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;
|
||||
// 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;
|
||||
|
@ -61,6 +62,8 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
|
|||
private boolean forceToUpperCase;
|
||||
private boolean userIdChanged = false;
|
||||
private boolean validate = true;
|
||||
private boolean requiresPassword;
|
||||
private boolean requiresUserId;
|
||||
private ISystemValidator userIdValidator;
|
||||
private ISystemValidator passwordValidator;
|
||||
private ICredentialsValidator signonValidator;
|
||||
|
@ -69,10 +72,18 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
|
|||
/**
|
||||
* Constructor for SystemPasswordPromptDialog
|
||||
* @param shell The shell in which to base this dialog.
|
||||
* @param requiresUserId true if the userid field of the dialog must not be empty.
|
||||
* Used only if there is no validator specified for
|
||||
* {@link #setUserIdValidator(ISystemValidator)}.
|
||||
* @param requiresPassword true if the password field of the dialog must not be empty.
|
||||
* Used only if there is no password validator specified using
|
||||
* {@link #setPasswordValidator(ISystemValidator)}.
|
||||
*/
|
||||
public SystemPasswordPromptDialog(Shell shell) {
|
||||
public SystemPasswordPromptDialog(Shell shell, boolean requiresUserId, boolean requiresPassword) {
|
||||
super(shell, SystemResources.RESID_PASSWORD_TITLE);
|
||||
setHelp(RSEUIPlugin.HELPPREFIX + "pwdp0000"); //$NON-NLS-1$
|
||||
this.requiresPassword = requiresPassword;
|
||||
this.requiresUserId = requiresUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -341,7 +352,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
|
|||
if (connectorService.supportsUserId() && validate) {
|
||||
if (userIdValidator != null) {
|
||||
m = userIdValidator.validate(userId);
|
||||
} else if (connectorService.requiresUserId() && userId.length() == 0) {
|
||||
} else if (requiresUserId && userId.length() == 0) {
|
||||
m = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_USERID_EMPTY);
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +377,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
|
|||
}
|
||||
okButton.setEnabled(m == null);
|
||||
if (savePasswordCB != null) {
|
||||
savePasswordCB.setEnabled(!(connectorService.requiresPassword() && password.length() == 0));
|
||||
savePasswordCB.setEnabled(!(requiresPassword && password.length() == 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +390,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
|
|||
if (connectorService.supportsPassword() && validate) {
|
||||
if (passwordValidator != null) {
|
||||
m = passwordValidator.validate(password);
|
||||
} else if (connectorService.requiresPassword() && password.length() == 0) {
|
||||
} else if (requiresPassword && password.length() == 0) {
|
||||
m = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EMPTY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* Michael Scharf (Wind River) - patch for an NPE in getSubSystemConfigurations()
|
||||
* David Dykstal (IBM) - moved SystemsPreferencesManager to a new package
|
||||
* Uwe Stieber (Wind River) - bugfixing
|
||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.model;
|
||||
|
@ -2538,7 +2539,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
|
|||
if (subsystems[idx].isConnected()) subsystems[idx].disconnect(); // MJB: added conditional for defect 45754
|
||||
if (defaultUserIdChanged)
|
||||
{
|
||||
subsystems[idx].getConnectorService().clearUserId();
|
||||
subsystems[idx].getConnectorService().clearCredentials();
|
||||
}
|
||||
subsystems[idx].getConnectorService().clearPassword(false);
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
* the next call to getUserId() it is requeried from subsystem.
|
||||
* Also clears the password.
|
||||
*/
|
||||
final public void clearUserId() {
|
||||
final public void clearCredentials() {
|
||||
_userId = null;
|
||||
clearPassword(false);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
* change his userId.
|
||||
*
|
||||
* @param onDisk if this is true, clear the password from the disk cache as well
|
||||
* @see #clearUserId()
|
||||
* @see #clearCredentials()
|
||||
*/
|
||||
final public void clearPassword(boolean onDisk) {
|
||||
setPasswordInformation(null);
|
||||
|
@ -227,11 +227,11 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
* @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(boolean forcePrompt) throws InterruptedException {
|
||||
public void acquireCredentials(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()) {
|
||||
if (isSuppressed()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
*/
|
||||
protected final ISystemPasswordPromptDialog getPasswordPromptDialog(Shell shell)
|
||||
{
|
||||
ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell);
|
||||
ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell, requiresUserId(), requiresPassword());
|
||||
dlg.setForceToUpperCase(forcePasswordToUpperCase());
|
||||
dlg.setUserIdValidator(getUserIdValidator());
|
||||
dlg.setPasswordValidator(getPasswordValidator());
|
||||
|
@ -629,7 +629,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isSuppressSignonPrompt()
|
||||
public boolean isSuppressed()
|
||||
{
|
||||
return _suppressSignonPrompt;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
*
|
||||
* @param suppressSignonPrompt
|
||||
*/
|
||||
public void setSuppressSignonPrompt(boolean suppressSignonPrompt)
|
||||
public void setSuppressed(boolean suppressSignonPrompt)
|
||||
{
|
||||
_suppressSignonPrompt = suppressSignonPrompt;
|
||||
}
|
||||
|
|
|
@ -63,11 +63,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
}
|
||||
}
|
||||
|
||||
public void clearUserId() {
|
||||
public void clearCredentials() {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
conServ.clearUserId();
|
||||
conServ.clearCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,11 +318,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isSuppressSignonPrompt() {
|
||||
public boolean isSuppressed() {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
return conServ.isSuppressSignonPrompt();
|
||||
return conServ.isSuppressed();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -336,12 +336,12 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
return false;
|
||||
}
|
||||
|
||||
public void promptForPassword(boolean forcePrompt)
|
||||
public void acquireCredentials(boolean forcePrompt)
|
||||
throws InterruptedException {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
conServ.promptForPassword(forcePrompt);
|
||||
conServ.acquireCredentials(forcePrompt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,11 +446,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
}
|
||||
}
|
||||
|
||||
public void setSuppressSignonPrompt(boolean suppressSignonPrompt) {
|
||||
public void setSuppressed(boolean suppressSignonPrompt) {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
conServ.setSuppressSignonPrompt(suppressSignonPrompt);
|
||||
conServ.setSuppressed(suppressSignonPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
|||
RSEPreferencesManager.clearUserId(previousUserIdKey);
|
||||
IConnectorService system = getConnectorService();
|
||||
if (system != null)
|
||||
system.clearUserId();
|
||||
system.clearCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2394,7 +2394,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
|||
//dwd if (runnableContext instanceof ProgressMonitorDialog) {
|
||||
//dwd ((ProgressMonitorDialog) runnableContext).setCancelable(true);
|
||||
//dwd }
|
||||
getConnectorService().promptForPassword(forcePrompt); // prompt for userid and password
|
||||
getConnectorService().acquireCredentials(forcePrompt); // prompt for userid and password
|
||||
ConnectJob job = new ConnectJob(this);
|
||||
scheduleJob(job, null);
|
||||
}
|
||||
|
@ -2438,7 +2438,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
|
|||
|
||||
try
|
||||
{
|
||||
getConnectorService().promptForPassword(force); // prompt for password
|
||||
getConnectorService().acquireCredentials(force); // prompt for password
|
||||
doConnection = true;
|
||||
ok = true;
|
||||
}
|
||||
|
|
|
@ -60,4 +60,12 @@ public class StandardCredentialsProvider implements ICredentialsProvider {
|
|||
return connectorService.getHost();
|
||||
}
|
||||
|
||||
public void acquireCredentials(boolean reacquire) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void clearCredentials() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue