From 52f4211900aa9522badafa50f48020af138a8ff6 Mon Sep 17 00:00:00 2001
From: David Dykstal
+ * This class is not meant to be subclassed.
+ */
+public class BasicCredentialsProvider implements ICredentialsProvider {
+
+ public boolean requiresPassword() {
+ return false;
+ }
+
+ public boolean requiresUserId() {
+ return false;
+ }
+
+ public boolean supportsPassword() {
+ return false;
+ }
+
+ public boolean supportsUserId() {
+ return false;
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java
index 3fdf9580417..b49931dcf37 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
+ * Copyright (c) 2002, 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
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@@ -224,18 +224,18 @@ public interface IConnectorService extends IRSEModelObject {
public boolean hasPassword(boolean onDisk);
/**
- * Returns true if this system can inherit the uid and password of
+ * Returns true if this system can inherit the credentials of
* from the connection (Host).
- * @return true if it can inherit the user/password
+ * @return true if it can inherit the credentials, false otherwise
*/
- public boolean inheritConnectionUserPassword();
+ public boolean inheritsCredentials();
/**
- * Return true if this system can share it's userId and password
+ * Return true if this system can share it's credentials
* with other connector services in this host.
- * @return true if it can share the userId/password
+ * @return true if it can share the credentials
*/
- public boolean shareUserPasswordWithConnection();
+ public boolean sharesCredentials();
/**
* Register a communications listener. These listeners will be informed
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java
index 3fd0fe91349..899ff0d1b98 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java
@@ -10,4 +10,13 @@
package org.eclipse.rse.core.subsystems;
public interface ICredentialsProvider {
+
+ boolean supportsPassword();
+
+ boolean supportsUserId();
+
+ boolean requiresPassword();
+
+ boolean requiresUserId();
+
}
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java
index fb1a3629108..651d6b986be 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java
@@ -24,6 +24,36 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.RSEModelObject;
+/**
+ * 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 getConnectorService(), and
+ * it is used to represent the live connection to a particular subsystem.
+ *
+ * You must override/implement
+ *
- * Up to each implementer to decide how to implement, and if this will be cached.
- *
- * Returns an empty string by default, override if possible
- */
- public String getHomeDirectory() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Not implemented, you should override if possible.
- * Up to each implementer to decide how to implement, and if this will be cached.
- *
- * Returns an empty string by default, override if possible
- */
- public String getTempDirectory() {
- return ""; //$NON-NLS-1$
- }
-
/**
* Useful utility method. Fully implemented, do not override.
+ * This is used to show the VRM in the property sheet
+ * when the subsystem is selected.
*
* Up to each implementer to decide if this will be cached.
*
- * Returns an empty string by default, override if possible
+ * @return an empty string
*/
public String getVersionReleaseModification() {
return ""; //$NON-NLS-1$
}
- protected void intializeSubSystems(IProgressMonitor monitor) {
+ public final ISubSystem[] getSubSystems() {
+ return (ISubSystem[])_registeredSubSystems.toArray(new ISubSystem[_registeredSubSystems.size()]);
+ }
+
+ protected final void intializeSubSystems(IProgressMonitor monitor) {
for (int i = 0; i < _registeredSubSystems.size(); i++)
{
ISubSystem ss = (ISubSystem)_registeredSubSystems.get(i);
@@ -273,7 +258,7 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
- protected void unintializeSubSystems(IProgressMonitor monitor) {
+ protected final void unintializeSubSystems(IProgressMonitor monitor) {
for (int i = 0; i < _registeredSubSystems.size(); i++)
{
ISubSystem ss = (ISubSystem)_registeredSubSystems.get(i);
@@ -281,28 +266,17 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
- /**
- * Optionally override if you add any instance variables.
+ * Any context will need to be set in the implementations of this interface
+ * prior to its validation.
+ */
+public interface ICredentialsValidator {
+
+ /**
+ * Verify if credentials are valid.
+ *
+ * @param credentials The credentials to be validated.
+ *
+ * @return null if the credentials are valid, a SystemMessage describing the
+ * type of problem if invalid.
+ */
+ public SystemMessage validate(ICredentials credentials);
+
+}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java
deleted file mode 100644
index 876d69a3a65..00000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.ui.dialogs;
-
-import org.eclipse.rse.core.model.SystemSignonInformation;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * Interace for providing a signon validator to the password prompt dialog.
- */
-public interface ISignonValidator
-{
-
- /**
- * Used by ISystemPasswordPromptDialog to verify if the password entered by the user
- * is correct.
- *
- * @return null if the password is valid, otherwise a SystemMessage is returned that can
- * be displayed to the end user.
- */
- public SystemMessage isValid(ISystemPasswordPromptDialog dialog, String userid, String password);
-
- /**
- * Verify if persisted userid and password are still valid
- *
- * @param shell Shell: if null the validator will run headless, if not null then the validator
- * may use the shell to prompt the user (for example, if the password has expired.)
- *
- * @return true if signonInfo contains a valid signon, false otherwise.
- */
- public boolean isValid(Shell shell, SystemSignonInformation signonInfo);
-}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java
index cdcb64ab730..b99223fcb37 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
+ * Copyright (c) 2002, 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.ui.dialogs;
@@ -55,7 +55,7 @@ public interface ISystemPasswordPromptDialog
/**
* Call this to specify a validator for the signon. It will be called when the OK button is pressed.
*/
- public void setSignonValidator(ISignonValidator v);
+ public void setSignonValidator(ICredentialsValidator v);
/**
* Call this to force the userId and password to uppercase
*/
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 12166be1197..df9301fbb86 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
@@ -12,12 +12,15 @@
*
* Contributors:
* David Dykstal (IBM) - moved SystemPreferencesManager to a new package
+ * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
********************************************************************************/
package org.eclipse.rse.ui.dialogs;
import org.eclipse.rse.core.RSEPreferencesManager;
+import org.eclipse.rse.core.model.SystemSignonInformation;
import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ICredentials;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
@@ -60,7 +63,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
private boolean validate = true;
private ISystemValidator userIdValidator;
private ISystemValidator passwordValidator;
- private ISignonValidator signonValidator;
+ private ICredentialsValidator signonValidator;
private IConnectorService connectorService = null;
/**
@@ -113,7 +116,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
* This must be called prior to opening this dialog if something other than the default is needed.
* @param v a signon validator
*/
- public void setSignonValidator(ISignonValidator v) {
+ public void setSignonValidator(ICredentialsValidator v) {
signonValidator = v;
}
@@ -478,7 +481,10 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme
// If all inputs are OK then validate signon
if (getErrorMessage() == null && (signonValidator != null)) {
- SystemMessage m = signonValidator.isValid(this, userId, password);
+ String hostName = connectorService.getHostName();
+ String hostType = connectorService.getHostType();
+ ICredentials credentials = new SystemSignonInformation(hostName, userId, password, hostType);
+ SystemMessage m = signonValidator.validate(credentials);
setErrorMessage(m);
}
boolean closeDialog = (getErrorMessage() == 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 00cef91f036..4c582fd458a 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
@@ -32,7 +32,7 @@ import org.eclipse.rse.model.ISystemRegistryUI;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.dialogs.ISignonValidator;
+import org.eclipse.rse.ui.dialogs.ICredentialsValidator;
import org.eclipse.rse.ui.dialogs.ISystemPasswordPromptDialog;
import org.eclipse.rse.ui.dialogs.SystemChangePasswordDialog;
import org.eclipse.rse.ui.dialogs.SystemPasswordPromptDialog;
@@ -169,7 +169,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
if (userId != null)
PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId);
}
- if (shareUserPasswordWithConnection()) {
+ if (sharesCredentials()) {
// clear this uid/password with other ISystems in connection
clearPasswordForOtherSystemsInConnection(userId, onDisk);
}
@@ -197,17 +197,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
return cached;
}
- /**
- * Return true if this system can inherit the uid and password of
- * other ISystems in this connection
- *
- * @return true if it can inherit the user/password
- */
- final public boolean inheritConnectionUserPassword()
- {
- return true;
- }
-
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.IConnectorService#requiresPassword()
*/
@@ -216,14 +205,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
}
- /* (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()
*/
@@ -232,46 +213,28 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
}
- /* (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()
- {
- return true;
- }
-
- /**
- * Do not override.
- * Sets the signon information for this connector service.
- * The search order for the password is as follows:
+ *
+ * You should override:
+ *
+ *
+ * You can override:
+ *
+ *
+ *
+ */
public abstract class SuperAbstractConnectorService extends RSEModelObject implements IConnectorService {
private Vector commListeners = new Vector(5);
@@ -34,6 +64,7 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
private String _name;
private int _port;
private boolean _usingSSL;
+
/**
* The result of calling launch in the server launcher object, in the connect method
*/
@@ -101,43 +132,15 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
/**
- * Private - used internally.
- * Returns the count of active communication listeners (i.e. excludes
- * passive listeners.)
+ * Fires the communication event mentioned in the eventType.
+ * @param eventType the communications event to fire.
*/
- protected int getCommunicationListenerCount() {
- int count = 0;
- for (int i = 0; i < commListeners.size(); i++)
- {
- if (!((ICommunicationsListener) commListeners.get(i)).isPassiveCommunicationsListener())
- {
- count++;
- }
- }
-
- return count;
- }
-
- /**
- * Private - used internally.
- */
- protected void clearCommunicationListeners() {
- commListeners.clear();
- }
-
- /**
- * Private - used internally.
- * Helper method for firing communication events
- */
- protected void fireCommunicationsEvent(int eventType) {
+ final protected void fireCommunicationsEvent(int eventType) {
CommunicationsEvent e = new CommunicationsEvent(this, eventType);
-
Object[] items = commListeners.toArray();
-
for (int loop=0; loop < items.length; loop++) {
((ICommunicationsListener) items[loop]).communicationsStateChange(e);
}
-
}
public final IHost getHost() {
@@ -209,30 +212,6 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
return RSECorePlugin.getThePersistenceManager().commit(getHost());
}
- /**
- * Not implemented, you should override if possible.
- * Return the home directory of the remote system for the current user, if available.
- *
- * Return the temp directory of the remote system for the current user, if available.
- *
* Returns the system type for this connection:
getSubSystem().getSystemConnection().getSystemType()
@@ -251,21 +230,27 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
/**
- * Not implemented, you should override if possible.
* Return the version, release, modification of the remote system,
- * if connected, if applicable and if available. Else return null. It
- * is up to each subsystem to decide how to interpret what is returned.
- * This is used to show the VRM in the property sheet, when the subsystem is selected.
+ * if connected, if applicable and if available. Else return null. It
+ * is up to each subsystem to decide how to interpret what is returned.
+ * This implementation returns the empty string.
+ *
- * The following is called whenever a system is redefined or disconnected.
- * Each subsystem needs to be informed so it can clear out any expansions, etc.
- * By default it does nothing. Override if you have an internal object that must be nulled out.
- */
- public void reset() {
- }
-
- protected void notifyDisconnection() {
-
+ protected final void notifyDisconnection() {
// Fire comm event to signal state changed
if (!isConnected()) fireCommunicationsEvent(CommunicationsEvent.AFTER_DISCONNECT);
}
- protected void notifyConnection() {
+ protected final void notifyConnection() {
if (isConnected()) fireCommunicationsEvent(CommunicationsEvent.AFTER_CONNECT);
}
- protected void notifyError() {
+ protected final void notifyError() {
fireCommunicationsEvent(CommunicationsEvent.CONNECTION_ERROR);
-
}
public final boolean isUsingSSL() {
@@ -317,6 +291,37 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
+ /**
+ * Return the temp directory of the remote system for the current user,
+ * if available. This implementation returns the empty string.
+ * Up to each implementer to decide how to implement, and if this will be cached.
+ * @return an empty string
+ */
+ public String getTempDirectory() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the home directory of the remote system for the current user,
+ * if available. This implementation returns the empty string.
+ * Up to each implementer to decide how to implement, and if this will be cached.
+ * @return an empty string
+ */
+ public String getHomeDirectory() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Optionally override if you add any instance variables.
+ * The following is called whenever a system is redefined or disconnected.
+ * Each subsystem needs to be informed so it can clear out any expansions, etc.
+ * By default it does nothing.
+ * Override if you have an internal object that must be nulled out.
+ * If overridden you should call super.reset();
+ */
+ public void reset() {
+ }
+
/**
* Return the port to use for connecting to the remote server, once it is running.
* By default, this is the subsystem's port property, via {@link #getPort()}.
@@ -328,11 +333,44 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
return getPort();
}
- public final ISubSystem[] getSubSystems() {
- return (ISubSystem[])_registeredSubSystems.toArray(new ISubSystem[_registeredSubSystems.size()]);
- }
-
protected abstract void internalConnect(IProgressMonitor monitor) throws Exception;
protected abstract void internalDisconnect(IProgressMonitor monitor) throws Exception;
+
+ protected abstract ICredentialsProvider getCredentialsProvider();
+
+ /**
+ * Returns true if this connector service can share it's credentials
+ * with other connector services in this host.
+ * This default implementation will always return true.
+ * Override if necessary.
+ * @return true
+ */
+ public boolean sharesCredentials() {
+ return true;
+ }
+
+ /**
+ * Returns true if this connector service can inherit the credentials of
+ * other connector services in this host.
+ * This default implementation always returns true.
+ * Override if necessary.
+ * @return true
+ */
+ public boolean inheritsCredentials() {
+ return true;
+ }
+
+ public final boolean supportsPassword() {
+ ICredentialsProvider cp = getCredentialsProvider();
+ boolean result = cp.supportsPassword();
+ return result;
+ }
+
+ public final boolean supportsUserId() {
+ ICredentialsProvider cp = getCredentialsProvider();
+ boolean result = cp.supportsUserId();
+ return result;
+ }
+
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java b/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
index 2425af630eb..85060b3e1c3 100644
--- a/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
+++ b/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
@@ -27,9 +27,11 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.PropertyType;
import org.eclipse.rse.core.model.SystemSignonInformation;
import org.eclipse.rse.core.subsystems.AbstractConnectorService;
+import org.eclipse.rse.core.subsystems.ICredentialsProvider;
import org.eclipse.rse.internal.services.files.ftp.FTPService;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
+import org.eclipse.rse.ui.subsystems.StandardCredentialsProvider;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.MessageConsole;
@@ -40,6 +42,7 @@ public class FTPConnectorService extends AbstractConnectorService
{
protected FTPService _ftpService;
private IPropertySet _propertySet;
+ private ICredentialsProvider credentialsProvider = null;
public FTPConnectorService(IHost host, int port)
{
@@ -47,7 +50,7 @@ public class FTPConnectorService extends AbstractConnectorService
_ftpService = new FTPService();
}
- public void internalConnect(IProgressMonitor monitor) throws Exception
+ protected void internalConnect(IProgressMonitor monitor) throws Exception
{
internalConnect();
}
@@ -99,11 +102,18 @@ public class FTPConnectorService extends AbstractConnectorService
return _ftpService;
}
- public void internalDisconnect(IProgressMonitor monitor)
+ protected void internalDisconnect(IProgressMonitor monitor)
{
_ftpService.disconnect();
}
+ protected ICredentialsProvider getCredentialsProvider() {
+ if (credentialsProvider == null) {
+ credentialsProvider = new StandardCredentialsProvider(this);
+ }
+ return credentialsProvider;
+ }
+
public boolean isConnected()
{
return (_ftpService != null && _ftpService.isConnected());
diff --git a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
index c93ddd43282..ed042ef6ff7 100644
--- a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
+++ b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
@@ -43,6 +43,7 @@ Export-Package: org.eclipse.rse.core,
org.eclipse.rse.ui.open,
org.eclipse.rse.ui.operations,
org.eclipse.rse.ui.propertypages,
+ org.eclipse.rse.ui.subsystems,
org.eclipse.rse.ui.validators,
org.eclipse.rse.ui.view,
org.eclipse.rse.ui.widgets,
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java
new file mode 100644
index 00000000000..a4ea9a35d6f
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java
@@ -0,0 +1,44 @@
+/********************************************************************************
+ * Copyright (c) 2002, 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
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * David Dykstal (IBM) - Changed from ISignonValidator to generalize the concept and
+ * remove the UI dependencies.
+ ********************************************************************************/
+
+package org.eclipse.rse.ui.dialogs;
+
+import org.eclipse.rse.core.subsystems.ICredentials;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+
+
+/**
+ * Interface for providing a credentials validator. This will be used when
+ * credentials are acquired or when they are about to be used. Can check
+ * credentials for expiration or for validity.
+ *
- *
- * Must be run in the UI thread.
- * 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(boolean forcePrompt) throws InterruptedException {
+ * Do not override.
+ * Sets the signon information for this connector service.
+ * The search order for the password is as follows:
getSubSystem().getParentSubSystemConfiguration().getUserIdValidator()
*/
- public ISystemValidator getUserIdValidator()
+ final public ISystemValidator getUserIdValidator()
{
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
-
return adapter.getUserIdValidator(ssFactory);
}
@@ -579,29 +546,24 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
* By default, returns:
* getSubSystem().getParentSubSystemConfiguration().getPasswordValidator()
*/
- public ISystemValidator getPasswordValidator()
+ final public ISystemValidator getPasswordValidator()
{
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
-
return adapter.getPasswordValidator(ssFactory);
}
+
/**
* Optionally overridable, not implemented by default.+ * It uses a {@link PasswordPersistenceManager} to store the passwords in the + * keychain keyed by {@link IHost} and possibly by {@link ISubSystemConfiguration}. + *
+ * This is suitable for use by subclasses of {@link SuperAbstractConnectorService} + * that wish to provide prompting and persistence for userids and passwords when + * connecting. + *
+ * This class is may be subclassed. Typically to provide connector service + * specific prompting. + */ +public class StandardCredentialsProvider implements ICredentialsProvider { + + private IConnectorService connectorService = null; + + public StandardCredentialsProvider(IConnectorService connectorService) { + this.connectorService = connectorService; + } + + public boolean requiresPassword() { + return true; + } + + public boolean requiresUserId() { + return true; + } + + public boolean supportsPassword() { + return true; + } + + public boolean supportsUserId() { + return true; + } + + protected final IHost getHost() { + return connectorService.getHost(); + } + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java index 32f20a56c3c..1911fdae030 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java @@ -14,10 +14,13 @@ package org.eclipse.rse.tests.internal.testsubsystem; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.AbstractConnectorService; +import org.eclipse.rse.core.subsystems.BasicCredentialsProvider; +import org.eclipse.rse.core.subsystems.ICredentialsProvider; public class TestSubSystemConnectorService extends AbstractConnectorService { private boolean connected = false; + private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(); /** * Constructor. @@ -47,21 +50,14 @@ public class TestSubSystemConnectorService extends AbstractConnectorService { /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#internalDisconnect(org.eclipse.core.runtime.IProgressMonitor) */ - public void internalDisconnect(IProgressMonitor monitor) throws Exception { + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { connected = false; } /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + * @see org.eclipse.rse.core.subsystems.SuperAbstractConnectorService#getCredentialsProvider() */ - public boolean supportsPassword() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return false; + protected ICredentialsProvider getCredentialsProvider() { + return credentialsProvider; } }