From ebeab3de94ec34fbbba218dbcc8121199db1befa Mon Sep 17 00:00:00 2001
From: David Dykstal
- * An {@link org.eclipse.rse.core.subsystems.IConnectorService} object is returned from a subsystem object via getSystem(), and
- * it is used to represent the live connection to a particular subsystem.
- *
- * All this could have been done in the subsystem object, but that would clutter it
- * up too much.
+ * An {@link org.eclipse.rse.core.subsystems.IConnectorService} object
+ * is returned from a subsystem object via getSystem(), and
+ * it is used to represent the live connection to a particular subsystem.
*
* You must override/implement
*
- * By default returns an instance of SystemPasswordPromptDialog.
- * Calls forcePasswordToUpperCase() to decide whether the
- * user Id and password should be folded to uppercase.
- *
- * Calls {@link #getUserIdValidator()} and {@link #getPasswordValidator()}
- * to set the validators. These return null by default by you can override them.
- *
- * Before calling open() on the dialog, the getPassword(Shell) method that calls this will
- * call setSystemInput(this).
- *
- * After return, it will call wasCancelled() and getUserId(), getIsUserIdChanged(), getIsUserIdChangePermanent()
- * and getPassword().
- *
- *
- * @return An instance of a dialog class that implements the ISystemPasswordPromptDialog interface
- */
+ * A default implementation is supplied, but can be overridden if desired.
+ * By default returns an instance of SystemPasswordPromptDialog. Calls forcePasswordToUpperCase() to decide whether the user Id and password should be folded to uppercase.
+ *
+ * Calls {@link #getUserIdValidator()} and {@link #getPasswordValidator()} to set the validators. These return null by default by you can override them.
+ *
+ * Before calling open() on the dialog, the getPassword(Shell) method that calls this will call setSystemInput(this).
+ *
+ * After return, it will call wasCancelled() and getUserId(), getIsUserIdChanged(), getIsUserIdChangePermanent() and getPassword().
+ *
+ *
+ * @return An instance of a dialog class that implements the ISystemPasswordPromptDialog interface
+ */
protected final ISystemPasswordPromptDialog getPasswordPromptDialog(Shell shell)
{
ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell);
@@ -657,9 +624,9 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
/**
* Useful utility method. Fully implemented, no need to override.
* Attempt to connect to the remote system.
* This is called, by default, from the connect(...) methods of the subsystem.
*/
@@ -1118,6 +1086,10 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
return RSEUIPlugin.getThePersistenceManager().commit(getHost());
}
+ private void logException(Throwable t) {
+ Logger log = LoggerFactory.getInst(RSEUIPlugin.getDefault());
+ log.logError("Unexpected exception", t);
+ }
protected NewPasswordInfo promptForNewPassword(SystemMessage prompt) throws InterruptedException
{
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 aa1a596185d..0e7aca88927 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
@@ -22,28 +22,23 @@ import org.eclipse.swt.widgets.Shell;
/**
- * This is the interface implemented by System objects.
+ * This is the interface implemented by ConnectorService (formerly System) objects.
*
- * A system object manages a live connection to a remote system, with
- * operations for connecting and disconnecting, and storing information
- * typically cached from a subsystem: user ID, password, port, etc. Any
- * information in a System object is thrown out when the workbench goes
- * down... it is not modelled for persistence.
+ * A connector service manages a live connection to a remote system, with
+ * operations for connecting and disconnecting, and storing information
+ * typically cached from a subsystem: user ID, password, port, etc.
*
- * The SubSystem interface includes a method, getSystem(), which returns an
- * instance of this interface for that subsystem.
+ * The SubSystem interface includes a method, getConnectorService(), which returns an
+ * instance of an object that implements this interface for that subsystem.
*
- * A single system object can be unique to a subsystem (which is always unique
- * for a particular tool to a particular connection). It can also be shared
- * across multiple subsystems in a single connection if those subsystems share
- * their physical connection to the remote system. This sharing is done via
- * subclasses of {@link org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager}
- * which are returned via another getter method in SubSystem.
+ * A single connector service object can be unique to a subsystem instance, but
+ * it can also be shared across multiple subsystems in a single host if those
+ * subsystems share a physical connection to the remote system. This sharing is done via
+ * subclasses of {@link org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager}
+ * which are returned by another getter method in SubSystem.
*/
public interface IConnectorService extends IRSEModelObject
{
-
-
/**
* Return the subsystem object this system is associated with
diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IIBMServerLauncher.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IIBMServerLauncher.java
index e2becfd7809..dabd6965f1f 100644
--- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IIBMServerLauncher.java
+++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IIBMServerLauncher.java
@@ -16,42 +16,31 @@
package org.eclipse.rse.core.subsystems;
/**
- *
- * This is the IBM default implementation of {@link IServerLauncherProperties}. It basically allows for numerous types
+ * This is the implementation of {@link IServerLauncherProperties}. It basically allows for numerous types
* of server connecting, as identified in {@link org.eclipse.rse.core.subsystems.ServerLaunchType}. It
* also captures the attributes needed to support these.
*
* A server launcher is responsible for starting the server-side code needed for this client subsystem to
- * access remote resources on the remote system. It starts the server half of the client/server code needed
- * for this subsystem. It is consulted in the default implementation of connect() in ISystem, and the
- * manages the properties in the Remote Server Launcher property page.
- *
- *
+ * access remote resources on the remote system. It starts the server half of the client/server code needed
+ * for this subsystem. It is consulted in the default implementation of connect() in ISystem, and the
+ * manages the properties in the Remote Server Launcher property page.
*
* The following features are supported:
* IRSESystemType
.
- * Otherwise, returns the value of the parent implementation.
+ * Returns the name of the system type if the object passed in is of type IRSESystemType
. Otherwise, returns the value of the parent implementation.
+ *
* @see org.eclipse.ui.model.WorkbenchAdapter#getLabel(java.lang.Object)
*/
public String getLabel(Object object) {
@@ -136,10 +143,8 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
}
public boolean isEnableOffline(Object object) {
-
if ((object != null) && (object instanceof IRSESystemType)) {
String property = ((IRSESystemType)object).getProperty(ENABLE_OFFLINE);
-
if (property != null) {
return Boolean.valueOf(property).booleanValue();
}
@@ -152,21 +157,89 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
}
}
+ /**
+ * Returns the enabled state of a particular system type.
+ * @param object the object being adapted, usually a system type.
+ * @return true if that system type is enabled. false if the object is
+ * not a system type or if it is not enabled.
+ */
public boolean isEnabled(Object object) {
- //TODO
- return true;
+ boolean result = false;
+ IRSESystemType systemType = getSystemType(object);
+ if ( systemType != null) {
+ Preferences prefs = RSECorePlugin.getDefault().getPluginPreferences();
+ String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED);
+ if (!prefs.contains(key)) {
+ prefs.setDefault(key, true);
+ }
+ result = prefs.getBoolean(key);
+ }
+ return result;
}
+ /**
+ * Sets the enabled state of a particular system type.
+ * @param object The system type being adapted.
+ * @param isEnabled true if the system type is enabled. false if it is not.
+ */
public void setIsEnabled(Object object, boolean isEnabled) {
- //TODO
+ IRSESystemType systemType = getSystemType(object);
+ if ( systemType != null) {
+ Plugin core = RSECorePlugin.getDefault();
+ Preferences prefs = core.getPluginPreferences();
+ String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED);
+ prefs.setValue(key, isEnabled);
+ core.savePluginPreferences();
+ }
}
+ /**
+ * Return the default user id for a particular system type. If none
+ * is defined then the "user.name" system property is used.
+ * @param object The system type being adapted.
+ * @return The default user id. Will be null if the object is not a system type
+ */
public String getDefaultUserId(Object object) {
- //TODO
- return "";
+ String result = null;
+ IRSESystemType systemType = getSystemType(object);
+ if ( systemType != null) {
+ Preferences prefs = RSECorePlugin.getDefault().getPluginPreferences();
+ String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID);
+ if (!prefs.contains(key)) {
+ prefs.setDefault(key, System.getProperty("user.name"));
+ }
+ result = prefs.getString(key);
+ }
+ return result;
}
+ /**
+ * Set the default user id for this system type. Stored in the RSE core preferences.
+ * @param object the system type that we are adapting
+ * @param defaultUserId the id to set for this system type
+ */
public void setDefaultUserId(Object object, String defaultUserId) {
- //TODO
+ IRSESystemType systemType = getSystemType(object);
+ if ( systemType != null) {
+ Plugin core = RSECorePlugin.getDefault();
+ Preferences prefs = core.getPluginPreferences();
+ String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID);
+ prefs.setValue(key, defaultUserId);
+ core.savePluginPreferences();
+ }
}
+
+ private String getPreferencesKey(IRSESystemType systemType, String preference) {
+ String key = systemType.getName() + "." + preference;
+ return key;
+ }
+
+ private IRSESystemType getSystemType(Object systemTypeCandidate) {
+ IRSESystemType result = null;
+ if (systemTypeCandidate instanceof IRSESystemType) {
+ result = (IRSESystemType) systemTypeCandidate;
+ }
+ return result;
+ }
+
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemClearPasswordAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemClearPasswordAction.java
index 6d64c570604..88a195fbc72 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemClearPasswordAction.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemClearPasswordAction.java
@@ -49,20 +49,20 @@ public class SystemClearPasswordAction extends SystemBaseAction
}
/**
- * Override of parent. Called when testing if action should be enabled base on current
- * selection. We check the selected object is one of our subsystems, and we are not
- * already connected.
+ * Override of parent.
+ * Called when testing if an action should be enabled based on the current selection.
+ * The clear password action can be enabled if the selected object is a subsystem
+ * that is not connected and has a password that is saved.
+ * @return true if the clear password action can be enabled.
*/
- public boolean checkObjectType(Object obj)
- {
- if (!(obj instanceof ISubSystem) ||
- ((ISubSystem)obj).getConnectorService().isConnected() ||
- !(((ISubSystem)obj).getConnectorService().isPasswordCached(true))) {
- return false;
- }
- else {
- return true;
+ public boolean checkObjectType(Object obj) {
+ boolean result = false;
+ if (obj instanceof ISubSystem) {
+ ISubSystem subsystem = (ISubSystem) obj;
+ IConnectorService cs = subsystem.getConnectorService();
+ result = !cs.isConnected() && cs.isPasswordCached(true);
}
+ return result;
}
/**
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java
index 7882dc70287..b0875865226 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java
@@ -196,6 +196,7 @@ public class RemoteSystemsPreferencePage
// ---------------------------------------------------------
// GETTERS/SETTERS FOR EACH OF THE USER PREFERENCE VALUES...
// ---------------------------------------------------------
+ // DWD these preferences methods should be moved to SystemPreferencesManager since they are not a proper function of a preference page.
/**
* Return the names of the profiles the user has elected to make "active".
*/
@@ -566,10 +567,11 @@ public class RemoteSystemsPreferencePage
}
/**
- * Save the preference store
+ * Save the preference store.
*/
private static void savePreferenceStore()
{
+ /* plugin preferences and preference stores are actually the same store and are flushed to disk using this call */
RSEUIPlugin.getDefault().savePluginPreferences();
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemTypeFieldEditor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemTypeFieldEditor.java
index a3818fff388..e70072fb08f 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemTypeFieldEditor.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/SystemTypeFieldEditor.java
@@ -132,7 +132,7 @@ public class SystemTypeFieldEditor extends FieldEditor
tableViewer.setCellModifier(this);
CellEditor editors[] = new CellEditor[columnHeaders.length];
userIdCellEditor = new TextCellEditor(table);
- enabledCellEditor = new ComboBoxCellEditor(table, enabledStateStrings, SWT.READ_ONLY);
+ enabledCellEditor = new ComboBoxCellEditor(table, enabledStateStrings, SWT.READ_ONLY); // DWD should consider a checkbox for this.
editors[COLUMN_USERID] = userIdCellEditor;
editors[COLUMN_ENABLED] = enabledCellEditor;
tableViewer.setCellEditors(editors);
diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java
index 62ca6c6a89e..58380f1bd73 100644
--- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java
+++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java
@@ -32,12 +32,9 @@ import org.eclipse.rse.ui.SystemResources;
/**
* A pool of host objects.
* There is one pool per profile.
- * It is named the same as its owning profile.
- */
-/*
- * DWD this may be a candidate for elimination. It is not persisted but derived
- * when Host objects come into existance. Not sure it provides much value. Code
- * could be implemented directly in the profile.
+ * It is named the same as its owning profile.
+ * It is not persisted but provides a means of manipulating lists of host objects.
+ * Hosts are created and destroyed by the host pool so that the the relationships between the two can be maintained.
*/
public class SystemHostPool extends RSEModelObject implements ISystemHostPool
{
@@ -50,13 +47,15 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
protected String name = NAME_EDEFAULT;
private java.util.List connections = null;
- /**
- * Default constructor. Typically called by MOF.
+
+ /**
+ * Default constructor.
*/
protected SystemHostPool()
{
super();
}
+
/**
* Reset for a full refresh from disk, such as after a team synch
*/
@@ -209,6 +208,10 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
addHost(conn); // only record internally if saved successfully
conn.setHostPool(this);
conn.setAliasName(aliasName);
+ // DWD if default userID is null, and location is in the connection we should retrieve it and use it as the initial value.
+ if (defaultUserId == null && defaultUserIdLocation == ISystemUserIdConstants.USERID_LOCATION_CONNECTION) {
+ defaultUserId = conn.getDefaultUserId();
+ }
updateHost(conn, systemType, aliasName, hostName, description, defaultUserId, defaultUserIdLocation);
} catch (Exception e)
diff --git a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java
index e81516e4c2a..39d015189f3 100644
--- a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java
+++ b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java
@@ -313,7 +313,6 @@ public class RSEDOMExporter implements IRSEDOMExporter
node.addAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE, getBooleanString(host.isPromptable()));
node.addAttribute(IRSEDOMConstants.ATTRIBUTE_HOSTNAME, host.getHostName());
node.addAttribute(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION, host.getDescription());
- node.addAttribute(IRSEDOMConstants.ATTRIBUTE_USER_ID, host.getDefaultUserId());
}
diff --git a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java
index 0d9a290f626..aec9cb75138 100644
--- a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java
+++ b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java
@@ -120,7 +120,6 @@ public class RSEDOMImporter implements IRSEDOMImporter
String description = hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_DESCRIPTION).getValue();
boolean isOffline = getBooleanValue(hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_OFFLINE).getValue());
boolean isPromptable = getBooleanValue(hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_PROMPTABLE).getValue());
- String userId = hostNode.getAttribute(IRSEDOMConstants.ATTRIBUTE_USER_ID).getValue();
// create host and set it's attributes
try
@@ -130,7 +129,6 @@ public class RSEDOMImporter implements IRSEDOMImporter
host = profile.createHost(systemType, connectionName, hostName, description);
host.setOffline(isOffline);
host.setPromptable(isPromptable);
- host.setDefaultUserId(userId);
}
catch (Exception e)
{
@@ -275,10 +273,6 @@ public class RSEDOMImporter implements IRSEDOMImporter
subSystem = factory.createSubSystemInternal(host);
}
subSystem.setHidden(isHidden);
-
- // name should always be based on the one in plugin.xml
- // so commenting this out
- //subSystem.setName(name);
subSystem.setHost(host);
subSystem.setSubSystemConfiguration(factory);
subSystem.setWasRestored(true);
@@ -480,10 +474,17 @@ public class RSEDOMImporter implements IRSEDOMImporter
{
ISystemFilterPoolManager filterPoolManager = factory.getFilterPoolManager(subSystem.getSystemProfile());
ISystemFilterPool filterPool = filterPoolManager.getSystemFilterPool(name);
-
- // create reference to the filterpool
- ISystemFilterPoolReferenceManager referenceManager = subSystem.getFilterPoolReferenceManager();
- filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPool);
+ /*
+ * DWD filterpool can be null when restoring since there can be forward references.
+ * A profile may be being restored that has references to a filter pool in a profile that doesn't yet exist.
+ * Need to create an "unresolved" reference instead of a null object and then patch them up
+ * at the end.
+ */
+ if (filterPool != null) { // for the time being don't restore a reference if the pool isn't found.
+ // create reference to the filterpool
+ ISystemFilterPoolReferenceManager referenceManager = subSystem.getFilterPoolReferenceManager();
+ filterPoolReference = referenceManager.addReferenceToSystemFilterPool(filterPool);
+ }
}
return filterPoolReference;
diff --git a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java
index dc80aac3969..6ae4210baad 100644
--- a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java
+++ b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/persistence/dom/IRSEDOMConstants.java
@@ -48,7 +48,6 @@ public interface IRSEDOMConstants
public static final String ATTRIBUTE_HOSTNAME = "hostname";
public static final String ATTRIBUTE_OFFLINE = "offline";
public static final String ATTRIBUTE_DESCRIPTION = "description";
- public static final String ATTRIBUTE_USER_ID = "defaultUserId";
// ConnectorService attributes
public static final String ATTRIBUTE_GROUP="group";
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 8185e9f7645..e226d73c158 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
@@ -23,6 +23,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.ISystemUserIdConstants;
import org.eclipse.rse.core.PasswordPersistenceManager;
import org.eclipse.rse.internal.model.RSEModelObject;
+import org.eclipse.rse.logging.Logger;
+import org.eclipse.rse.logging.LoggerFactory;
import org.eclipse.rse.model.IHost;
import org.eclipse.rse.model.ISystemRegistry;
import org.eclipse.rse.model.SystemSignonInformation;
@@ -40,26 +42,24 @@ import org.eclipse.swt.widgets.Shell;
/**
- * This is a base class to make it easier to create system classes.
+ * This is a base class to make it easier to create connector service classes.
*
- *
* You should override:
*
- *
*
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager
@@ -181,12 +181,15 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
// Utility methods...
// ------------------
- public ISubSystem[] getSubSystems()
+ final public ISubSystem[] getSubSystems()
{
return (ISubSystem[])_registeredSubSystems.toArray(new ISubSystem[_registeredSubSystems.size()]);
}
- public ISubSystem getPrimarySubSystem()
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.IConnectorService#getPrimarySubSystem()
+ */
+ final public ISubSystem getPrimarySubSystem()
{
if (_primarySubSystem == null)
{
@@ -196,7 +199,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
return _primarySubSystem;
}
- public IHost getHost()
+ final public IHost getHost()
{
return _host;
}
@@ -205,7 +208,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
* Useful utility method. Fully implemented, do not override.
* Returns the system type for this connection:
getSubSystem().getSystemConnection().getSystemType()
*/
- public String getHostType()
+ final public String getHostType()
{
return getHost().getSystemType();
}
@@ -213,12 +216,12 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
/**
*
*/
- public String getName()
+ final public String getName()
{
return _name;
}
- public String getDescription()
+ final public String getDescription()
{
return _description;
}
@@ -228,141 +231,141 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
* Returns the host name for the connection this system's subsystem is associated with:
* getSubSystem().getSystemConnection().getHostName()
*/
- public String getHostName()
+ final public String getHostName()
{
return getHost().getHostName();
}
/**
- * Useful utility method. Fully implemented, do not override.
- * Returns the user Id for this system's subsystem we are associated with.
- * This is the same as {@link #getLocalUserId()}, but first clears the local
- * user Id cache if we are not currently connected.
- */
- public String getUserId()
- {
- if (_userId != null)
- {
- return _userId;
- }
-
- return getLocalUserId();
- }
+ * Useful utility method. Fully implemented, do not override.
+ * Returns the active userId if we are connected.
+ * If not it returns the userId for the primary subsystem ignoring the
+ * cached userId.
+ */
+ final public String getUserId() {
+ String result = getSubsystemUserId();
+ ISubSystem ss = getPrimarySubSystem();
+ if (ss.isConnected()) {
+ result = getLocalUserId();
+ }
+ return result;
+ }
+
+ /**
+ * Useful utility method. Fully implemented, do not override.
+ * Return the userId for this connector service. If there is none
+ * set for this service then it is retrieved from the primary subsystem.
+ */
+ final protected String getLocalUserId() {
+ if (_userId == null) {
+ _userId = getSubsystemUserId();
+ }
+ return _userId;
+ }
+
+ /**
+ * @return the userId from the primary subsystem.
+ */
+ private String getSubsystemUserId() {
+ ISubSystem ss = getPrimarySubSystem();
+ String result = ss.getUserId();
+ return result;
+ }
- public void setUserId(String newId)
- {
- if (!_userId.equals(newId))
- {
- _userId = newId;
- setDirty(true);
- }
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.IConnectorService#setUserId(java.lang.String)
+ */
+ final public void setUserId(String newId) {
+ if (!_userId.equals(newId)) {
+ _userId = newId;
+ setDirty(true);
+ }
+ }
- public void setHost(IHost host)
- {
- _host = host;
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.core.subsystems.IConnectorService#setHost(org.eclipse.rse.model.IHost)
+ */
+ final public void setHost(IHost host) {
+ _host = host;
+ }
/**
- * Useful utility method. Fully implemented, do not override.
- * Return the userId for this systems' subsystem we are associated with. If there
- * is no local user Id value here, then it is queried from the subsystem. However,
- * if we are connected then the user may have termporarily changed his userId on
- * the userId/password prompt dialog, in which that temp value is stored here in
- * a local cache and this method will return it, versus the persistent user Id stored
- * in the subsystem.
- */
- protected String getLocalUserId()
- {
- if (_userId == null)
- {
- _userId = System.getProperty("user.name");
- }
- return _userId;
- }
-
- /**
- * Useful utility method. Fully implemented, do not override.
- * Clear internal userId cache. Called when user uses the property dialog to
- * change his userId. By default, sets internal userId value to null so that on
- * the next call to getUserId() it is requeried from subsystem.
- * Also calls {@link #clearPasswordCache()}.
- */
- public void clearUserIdCache()
- {
- _userId = null;
- clearPasswordCache();
- }
-
- /**
- * Useful utility method. Fully implemented, do not override.
- * Clear internal password cache. Called when user uses the property dialog to
- * change his userId. This method does not remove the password from the disk
- * cache - only the memory cache.
- *
- * @see #clearUserIdCache()
- */
- public void clearPasswordCache()
- {
- clearPasswordCache(false);
- }
-
- /**
- * Useful utility method. Fully implemented, do not override.
- * Clear internal password cache. Called when user uses the property dialog to
- * change his userId.
- *
- * @param onDisk if this is true, clear the password from the disk cache as well
- * @see #clearUserIdCache(boolean)
- */
- public void clearPasswordCache(boolean onDisk)
- {
- setPasswordInformation(null);
-
- if (onDisk)
- {
- // now get rid of userid/password from disk
- String systemType = getHostType();
- String hostName = getHostName();
+ * Useful utility method. Fully implemented, do not override.
+ * Clear internal userId cache. Called when user uses the property dialog to
+ * change his userId. By default, sets internal userId value to null so that on
+ * the next call to getUserId() it is requeried from subsystem.
+ * Also calls {@link #clearPasswordCache()}.
+ */
+ final public void clearUserIdCache() {
+ _userId = null;
+ clearPasswordCache();
+ }
+
+ /**
+ * Useful utility method. Fully implemented, do not override.
+ * Clear internal password cache. Called when user uses the property dialog to
+ * change his userId. This method does not remove the password from the disk
+ * cache - only the memory cache.
+ *
+ * @see #clearUserIdCache()
+ */
+ final public void clearPasswordCache() {
+ clearPasswordCache(false);
+ }
+
+ /**
+ * Useful utility method. Fully implemented, do not override.
+ * Clear internal password cache. Called when user uses the property dialog to
+ * change his userId.
+ *
+ * @param onDisk if this is true, clear the password from the disk cache as well
+ * @see #clearUserIdCache(boolean)
+ */
+ final public void clearPasswordCache(boolean onDisk) {
+ setPasswordInformation(null);
+
+ if (onDisk) {
+ // now get rid of userid/password from disk
+ String systemType = getHostType();
+ String hostName = getHostName();
if (_userId != null)
- PasswordPersistenceManager.getInstance().remove(systemType, hostName, _userId);
- }
-
- if (shareUserPasswordWithConnection())
- {
- // clear this uid/password with other ISystems in connection
- clearPasswordForOtherSystemsInConnection(_userId, onDisk);
- }
- }
-
-
+ PasswordPersistenceManager.getInstance().remove(systemType, hostName, _userId);
+ }
+
+ if (shareUserPasswordWithConnection()) {
+ // clear this uid/password with other ISystems in connection
+ clearPasswordForOtherSystemsInConnection(_userId, onDisk);
+ }
+ }
+
/**
- * Useful utility method. Fully implemented, do not override.
- * Return true if password is currently cached.
+ * Useful utility method. Fully implemented, do not override.
+ * Return true if password is currently saved either here or in its persisted
+ * form.
+ * @param onDisk true if the check should be made for a persisted form as well,
+ * false if the check should be made for a password in memory only.
+ * @return true if the password is known, false otherwise.
*/
- public boolean isPasswordCached(boolean onDisk)
- {
- boolean cached = (getPasswordInformation() != null);
- if (!cached && onDisk)
- {
- // now check if cached on disk
- String systemType = getHostType();
- String hostName = getHostName();
- String userId = getUserId();
- if (userId != null)
- {
- return PasswordPersistenceManager.getInstance().passwordExists(systemType, hostName, getUserId());
+ final public boolean isPasswordCached(boolean onDisk) {
+ boolean cached = (getPasswordInformation() != null);
+ if (!cached && onDisk) {
+ // now check if cached on disk
+ String systemType = getHostType();
+ String hostName = getHostName();
+ String userId = getUserId();
+ if (userId != null) {
+ return PasswordPersistenceManager.getInstance().passwordExists(systemType, hostName, getUserId());
}
- }
- return cached;
- }
+ }
+ return cached;
+ }
/**
* Useful utility method. Fully implemented, do not override.
* Return true if password is currently cached.
*/
- public boolean isPasswordCached()
+ final public boolean isPasswordCached() // DWD Can we make this final?
{
return isPasswordCached(false);
}
@@ -373,12 +376,12 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
*
* @return true if it can inherit the user/password
*/
- public boolean inheritConnectionUserPassword()
+ final public boolean inheritConnectionUserPassword()
{
return true;
}
- /*
+ /**
* Return true if this system can share it's uid and password
* with other ISystems in this connection
*
@@ -406,66 +409,61 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
* @param forcePrompt if true then present the prompt even if the password is stored.
* Can be null if the password is known to exist.
*/
- public void promptForPassword(Shell shell, boolean forcePrompt)
- throws InterruptedException
- {
+ 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();
- }
+ if (isSuppressSignonPrompt()) throw new InterruptedException();
- // Get the password information associated with this connector service.
+ 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 oldUserId = getLocalUserId();
+ PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
// Check the transient in memory password ...
// Test if userId has been changed... d43274
- String oldUserId = getUserId();
if (passwordInformation != null && !forcePrompt) {
- boolean same = getPrimarySubSystem().getHost().compareUserIds(oldUserId, passwordInformation.getUserid());
- //RSEUIPlugin.getQualifiedHostName(getHostName());
- String hostName = getHostName();
+ boolean same = host.compareUserIds(oldUserId, passwordInformation.getUserid());
same = same && hostName.equalsIgnoreCase(passwordInformation.getHostname());
if (!same) {
clearPasswordCache();
passwordInformation = null;
}
- }
+ }
- // 1b. If a transient in memory password was found, test if it is still valid ...
+ // 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
- boolean pwdInvalidFlag = false;
- if (passwordInformation != null &&
- getSignonValidator() != null &&
- !getSignonValidator().isValid(shell, passwordInformation))
- {
- pwdInvalidFlag = true;
+ if (passwordInformation != null && validator != null && !validator.isValid(shell, passwordInformation)) {
+ passwordValid = false;
clearPasswordCache();
passwordInformation = null;
}
- // 2a. Check the saved passwords if we still haven't found a good password.
- if (passwordInformation == null && getLocalUserId() != null && !forcePrompt)
- {
- setPasswordInformation(PasswordPersistenceManager.getInstance().find(getHostType(), getHostName(), getLocalUserId()));
- passwordInformation = getPasswordInformation();
-
- // 2b. Check if saved passwordInfo is still valid
- if (passwordInformation != null
- && getSignonValidator() != null
- && !getSignonValidator().isValid(shell, passwordInformation))
- {
- pwdInvalidFlag = true;
- clearPasswordCache();
- passwordInformation = null;
- }
+ // Check the saved passwords if we still haven't found a good password.
+ if (passwordInformation == null && oldUserId != null && !forcePrompt) {
+ SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, oldUserId);
+ if (savedPasswordInformation != null) {
+ if (validator != null) {
+ if (!validator.isValid(shell, savedPasswordInformation)) {
+ passwordValid = false;
+ clearPasswordCache();
+ passwordInformation = null;
+ } else {
+ setPasswordInformation(savedPasswordInformation);
+ passwordInformation = getPasswordInformation();
+ }
+ }
+ }
}
- // If we had a saved password (in memory or on disk) that was invalid the tell the user
- if ((passwordInformation == null) && (pwdInvalidFlag == true))
- {
+ // 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) {
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID);
msg.makeSubstitution(getLocalUserId(), getHostName());
SystemMessageDialog dialog = new SystemMessageDialog(shell, msg);
@@ -473,60 +471,41 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
}
// Valid password not found so prompt, or force prompt
- if (forcePrompt || ((passwordInformation == null) && (shell != null)))
- {
+ if ((forcePrompt || (passwordInformation == null)) && (shell != null)) {
ISystemPasswordPromptDialog dlg = getPasswordPromptDialog(shell);
dlg.setSystemInput(this);
-
- SystemSignonInformation passInfo = PasswordPersistenceManager.getInstance().find(getHostType(), getHostName(), getLocalUserId());
- if (passInfo != null)
- {
- String password = passInfo.getPassword();
+ passwordInformation = ppm.find(hostType, hostName, oldUserId);
+ if (passwordInformation != null) {
+ String password = passwordInformation.getPassword();
dlg.setPassword(password);
+ dlg.setSavePassword(true);
+ } else {
+ dlg.setPassword("");
+ dlg.setSavePassword(false);
}
-
- // Check if password was saved, if so preselect the save checkbox
- if (getLocalUserId() != null)
- {
- dlg.setSavePassword(PasswordPersistenceManager.getInstance().passwordExists(getHostType(), getHostName(), getLocalUserId()));
- }
-
- try
- {
+ try {
dlg.open();
- }
- catch (Exception e)
- {
- e.printStackTrace();
+ } catch (Exception e) {
+ logException(e);
}
- if (!dlg.wasCancelled())
- {
- boolean userIdChanged = dlg.getIsUserIdChanged();
- if (userIdChanged)
- {
- String newUserId = dlg.getUserId();
- boolean userIdChangePermanent = dlg.getIsUserIdChangePermanent();
- if (userIdChangePermanent)
- {
- updateDefaultUserId(getPrimarySubSystem(), 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);
- }
- }
- else
- throw new InterruptedException();
+ 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);
+ }
}
}
@@ -600,50 +579,38 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
}
}
-
-
/**
- * Change the default user Id value in the SubSystem if it is non-null,
- * else update it in the Connection object
- */
- private void updateDefaultUserId(ISubSystem subsystem, String userId)
- {
- if (subsystem.getLocalUserId() != null) // defect 42709
- {
- subsystem.getSubSystemConfiguration().
- updateSubSystem(shell, subsystem, true, userId, false, 0);
- }
- // it seems intuitive to update the connection object. defect 42709. Phil
- else
- {
- int whereToUpdate = USERID_LOCATION_CONNECTION;
- IHost conn = subsystem.getHost();
- ISystemRegistry sr = RSEUIPlugin.getDefault().getSystemRegistry();
- sr.updateHost(null, conn, conn.getSystemType(), conn.getAliasName(),
- conn.getHostName(), conn.getDescription(), userId, whereToUpdate);
- }
- }
+ * Change the default user Id value in the SubSystem if it is non-null, else
+ * update it in the Connection object
+ */
+ private void updateDefaultUserId(ISubSystem subsystem, String userId) {
+ String ssLocalUserId = subsystem.getLocalUserId();
+ if (ssLocalUserId != null) { // defect 42709
+ ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
+ ssc.updateSubSystem(shell, subsystem, true, userId, false, 0);
+ } else { // it seems intuitive to update the connection object. defect 42709. Phil
+ int whereToUpdate = USERID_LOCATION_CONNECTION;
+ IHost conn = subsystem.getHost();
+ ISystemRegistry sr = RSEUIPlugin.getDefault().getSystemRegistry();
+ sr.updateHost(null, conn, conn.getSystemType(), conn.getAliasName(), conn.getHostName(), conn.getDescription(), userId, whereToUpdate);
+ }
+ }
/**
- * 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.
+ *
- * Return the password information for this system's subsystem we are associated with.
- * This is transient. Assumes it has been set already. The password stored in
- * SystemSignonInformation is encrypted.
+ * Return the password information for the primary subsystem of this
+ * connector service. Assumes it has been set by the subsystem at the
+ * time the subsystem acquires the connector service.
*/
protected SystemSignonInformation getPasswordInformation()
{
@@ -766,10 +733,10 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
/**
- * This connection method wrappers the others (internal connect) so that registered subsystems can be notified and initialized after a connect
+ * This connection method wrappers the others (internal connect) so that registered subsystems
+ * can be notified and initialized after a connect
* Previous implementations that overrode this method should now change
* their connect() method to internalConnect()
- *
*/
public final void connect(IProgressMonitor monitor) throws Exception
{
@@ -796,14 +763,15 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
}
/**
- * Abstract - you must override, unless subsystem.getParentSubSystemFactory().supportsServerLaunchProperties
- * returns true
+ * You must override
+ * unless subsystem.getParentSubSystemFactory().supportsServerLaunchProperties
+ * returns true.
*
* If the subsystem supports server launch,
- * the default behaviour here is to get the remote server launcher via
- * {@link #getRemoteServerLauncher()}, and if {@link IServerLauncher#isLaunched()}
- * returns false, to call {@link IServerLauncher#launch(IProgressMonitor)}.
+ * the default behavior is to get the remote server launcher by
+ * {@link #getRemoteServerLauncher()}, and if {@link IServerLauncher#isLaunched()}
+ * returns false, to call {@link IServerLauncher#launch(IProgressMonitor)}.
*
- *
*
* If you have your own attributes and own GUI to prompt for these, then call your own - * method to set your attributes, and call this method via super().xxx(...). + * method to set your attributes, and call this method via super(). *
- * The subsystem will be saved to disk. + * The changes to the subsystem configuration will be saved to disk. * Further, it will be asked to disconnect as this data affects the connection. *
* @param shell parent shell needed in case an error message is displayed @@ -1563,7 +1563,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration /** * Used by child classes that override updateSubSystem to establish if anything really - * needs to be changed. + * needs to be changed. */ protected boolean needsUpdate(ISubSystem subsystem, boolean updateUserId, String userId, boolean updatePort, int port) { diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java index 8716e133572..ec8ce06ba8c 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java +++ b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java @@ -34,7 +34,6 @@ import org.eclipse.rse.ui.propertypages.RemoteSystemsPreferencePage; * These include: *