diff --git a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java index a4a8bb72b0d..2c5eb036f90 100644 --- a/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java +++ b/rse/examples/org.eclipse.rse.examples.daytime/src/org/eclipse/rse/examples/daytime/connectorservice/DaytimeConnectorService.java @@ -23,9 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osgi.util.NLS; 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; +import org.eclipse.rse.core.subsystems.BasicConnectorService; import org.eclipse.rse.examples.daytime.DaytimeResources; import org.eclipse.rse.examples.daytime.service.DaytimeService; import org.eclipse.rse.examples.daytime.service.IDaytimeService; @@ -38,11 +36,10 @@ import org.eclipse.rse.examples.daytime.service.IDaytimeService; * here. We basically keep a local "connected" flag only, so to make sure that * the remote host is only accessed when the user explicitly requested so. */ -public class DaytimeConnectorService extends AbstractConnectorService { +public class DaytimeConnectorService extends BasicConnectorService { private boolean fIsConnected = false; private DaytimeService fDaytimeService; - private ICredentialsProvider fCredentialsProvider = new BasicCredentialsProvider(this); public DaytimeConnectorService(IHost host) { super(DaytimeResources.Daytime_Connector_Name, DaytimeResources.Daytime_Connector_Description, host, 13); @@ -77,8 +74,4 @@ public class DaytimeConnectorService extends AbstractConnectorService { fIsConnected = false; } - protected ICredentialsProvider getCredentialsProvider() { - return fCredentialsProvider; - } - } diff --git a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java index b37a303c191..cbb55e4977c 100644 --- a/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java +++ b/rse/examples/org.eclipse.rse.examples.tutorial/src/samples/subsystems/DeveloperConnectorService.java @@ -19,9 +19,7 @@ package samples.subsystems; 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; +import org.eclipse.rse.core.subsystems.BasicConnectorService; import samples.RSESamplesPlugin; @@ -29,10 +27,9 @@ import samples.RSESamplesPlugin; * Our system class that manages connecting to, and disconnecting from, * our remote server-side code. */ -public class DeveloperConnectorService extends AbstractConnectorService { +public class DeveloperConnectorService extends BasicConnectorService { private boolean connected = false; - private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(this); /** * Constructor for DeveloperConnectorService. @@ -73,9 +70,4 @@ public class DeveloperConnectorService extends AbstractConnectorService { // pretend. Normally, we'd disconnect from our remote server-side code here connected=false; } - - protected ICredentialsProvider getCredentialsProvider() { - return credentialsProvider; - } - } diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java index 9c1db915f08..158025229dd 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java @@ -43,15 +43,14 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.connectorservice.dstore.util.ConnectionStatusListener; import org.eclipse.rse.connectorservice.dstore.util.StatusMonitor; import org.eclipse.rse.connectorservice.dstore.util.StatusMonitorFactory; +import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.comm.ISystemKeystoreProvider; import org.eclipse.rse.core.comm.SystemKeystoreProviderManager; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.SystemSignonInformation; -import org.eclipse.rse.core.subsystems.AbstractConnectorService; import org.eclipse.rse.core.subsystems.CommunicationsEvent; -import org.eclipse.rse.core.subsystems.ICredentialsProvider; import org.eclipse.rse.core.subsystems.IRemoteServerLauncher; import org.eclipse.rse.core.subsystems.IServerLauncher; import org.eclipse.rse.core.subsystems.IServerLauncherProperties; @@ -68,7 +67,7 @@ import org.eclipse.rse.ui.SystemPropertyResources; import org.eclipse.rse.ui.actions.DisplayHidableSystemMessageAction; import org.eclipse.rse.ui.actions.DisplaySystemMessageAction; import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.rse.ui.subsystems.StandardCredentialsProvider; +import org.eclipse.rse.ui.subsystems.AbstractConnectorService; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.osgi.framework.Bundle; @@ -83,7 +82,6 @@ import org.osgi.framework.Version; */ public class DStoreConnectorService extends AbstractConnectorService implements IDataStoreProvider { - private ICredentialsProvider credentialsProvider = null; private ClientConnection clientConnection = null; private ConnectionStatusListener _connectionStatusListener = null; private IServerLauncher starter = null; @@ -252,13 +250,6 @@ public class DStoreConnectorService extends AbstractConnectorService implements return ""; //$NON-NLS-1$ } - protected ICredentialsProvider getCredentialsProvider() { - if (credentialsProvider == null) { - credentialsProvider = new DStoreCredentialsProvider(this); - } - return credentialsProvider; - } - /** * Return the Client IP that the RSE server is connected to. When connected, * the client IP is obtained from the server-side. When not-connected, @@ -1348,5 +1339,31 @@ public class DStoreConnectorService extends AbstractConnectorService implements { return true; } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + */ + public boolean supportsPassword() { + boolean result = super.supportsPassword(); + IHost host = getHost(); + String systemType = host.getSystemType(); + if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) { + result = false; + } + return result; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserid() + */ + public boolean supportsUserId() { + boolean result = super.supportsUserId(); + IHost host = getHost(); + String systemType = host.getSystemType(); + if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) { + result = false; + } + return result; + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreCredentialsProvider.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreCredentialsProvider.java deleted file mode 100644 index de9b85f801d..00000000000 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreCredentialsProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************** - * Copyright (c) 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 - * - * Contributors: - * David Dykstal (IBM) - 168977: refactoring IConnectorService - ********************************************************************************/ - -package org.eclipse.rse.connectorservice.dstore; - -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.ui.subsystems.StandardCredentialsProvider; - -public class DStoreCredentialsProvider extends StandardCredentialsProvider { - - public DStoreCredentialsProvider(DStoreConnectorService connectorService) { - super(connectorService); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - boolean result = super.supportsPassword(); - IHost host = getConnectorService().getHost(); - String systemType = host.getSystemType(); - if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) { - result = false; - } - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserid() - */ - public boolean supportsUserId() { - boolean result = super.supportsUserId(); - IHost host = getConnectorService().getHost(); - String systemType = host.getSystemType(); - if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) { - result = false; - } - return result; - } -} diff --git a/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/internal/connectorservice/local/LocalConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/internal/connectorservice/local/LocalConnectorService.java index ecebb960888..4d858cbc8d7 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/internal/connectorservice/local/LocalConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.local/src/org/eclipse/rse/internal/connectorservice/local/LocalConnectorService.java @@ -17,10 +17,8 @@ package org.eclipse.rse.internal.connectorservice.local; 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.BasicConnectorService; import org.eclipse.rse.core.subsystems.CommunicationsEvent; -import org.eclipse.rse.core.subsystems.ICredentialsProvider; /** * System class required by the remote systems framework. @@ -28,11 +26,9 @@ import org.eclipse.rse.core.subsystems.ICredentialsProvider; * Since we don't really have such a thing for local files, this * is pretty well empty. */ -public class LocalConnectorService extends AbstractConnectorService +public class LocalConnectorService extends BasicConnectorService { - - private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(this); - + /** * Constructor when we don't have a subsystem yet. * Call setSubSystem after. @@ -45,7 +41,7 @@ public class LocalConnectorService extends AbstractConnectorService /** - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#disconnect(IProgressMonitor) + * @see org.eclipse.rse.ui.subsystems.AbstractConnectorService#disconnect(IProgressMonitor) */ protected void internalDisconnect(IProgressMonitor monitor) throws Exception { @@ -98,8 +94,4 @@ public class LocalConnectorService extends AbstractConnectorService return System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ } - protected ICredentialsProvider getCredentialsProvider() { - return credentialsProvider; - } - } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java index f9da016d272..fb14076ec20 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java @@ -54,10 +54,8 @@ import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemSignonInformation; -import org.eclipse.rse.core.subsystems.AbstractConnectorService; import org.eclipse.rse.core.subsystems.CommunicationsEvent; import org.eclipse.rse.core.subsystems.IConnectorService; -import org.eclipse.rse.core.subsystems.ICredentialsProvider; import org.eclipse.rse.core.subsystems.SubSystemConfiguration; import org.eclipse.rse.internal.services.ssh.ISshSessionProvider; import org.eclipse.rse.services.RemoteUtil; @@ -65,6 +63,7 @@ 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.messages.SystemMessageDialog; +import org.eclipse.rse.ui.subsystems.AbstractConnectorService; /** * Create SSH connections. @@ -76,7 +75,6 @@ public class SshConnectorService extends AbstractConnectorService implements ISs private static JSch jsch=new JSch(); private Session session; private SessionLostHandler fSessionLostHandler; - private ICredentialsProvider credentialsProvider = null; public SshConnectorService(IHost host) { //TODO the port parameter doesnt really make sense here since @@ -705,12 +703,13 @@ public class SshConnectorService extends AbstractConnectorService implements ISs } return false; } - - protected ICredentialsProvider getCredentialsProvider() { - if (credentialsProvider == null) { - credentialsProvider = new SshCredentialsProvider(this); - } - return credentialsProvider; + + public boolean requiresPassword() { + return false; + } + + public boolean requiresUserId() { + return false; } } diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshCredentialsProvider.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshCredentialsProvider.java deleted file mode 100644 index 61b9b33a2d5..00000000000 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshCredentialsProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************** - * Copyright (c) 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 - * - * Contributors: - * David Dykstal (IBM) - 168977: refactoring IConnectorService - ********************************************************************************/ - -package org.eclipse.rse.internal.connectorservice.ssh; - -import org.eclipse.rse.core.subsystems.IConnectorService; -import org.eclipse.rse.ui.subsystems.StandardCredentialsProvider; - -public class SshCredentialsProvider extends StandardCredentialsProvider { - - public SshCredentialsProvider(IConnectorService connectorService) { - super(connectorService); - } - - public boolean requiresPassword() { - return false; - } - - public boolean requiresUserId() { - return false; - } - -} diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractCredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractCredentialsProvider.java index d68b4c597f2..71a6248e288 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractCredentialsProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractCredentialsProvider.java @@ -37,5 +37,21 @@ public abstract class AbstractCredentialsProvider implements ICredentialsProvide public final void setSuppressed(boolean suppressed) { this.suppressed = suppressed; } + + protected final boolean supportsUserId() { + return connectorService.supportsUserId(); + } + + protected final boolean requiresUserId() { + return connectorService.requiresUserId(); + } + + protected final boolean supportsPassword() { + return connectorService.supportsPassword(); + } + + protected final boolean requiresPassword() { + return connectorService.requiresPassword(); + } } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java index 26dcb301cc1..d2092b9add8 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java @@ -538,5 +538,23 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC } return false; } + + public boolean requiresPassword() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.requiresPassword(); + } + return false; + } + + public boolean requiresUserId() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.requiresUserId(); + } + return false; + } } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java similarity index 60% rename from rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java rename to rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java index 2a568aba336..8965848c8a4 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java @@ -1,24 +1,8 @@ -/******************************************************************************** - * 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) - 168977: refactoring IConnectorService and ServerLauncher hierarchies - ********************************************************************************/ package org.eclipse.rse.core.subsystems; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.PasswordPersistenceManager; import org.eclipse.rse.core.RSECorePlugin; @@ -26,38 +10,11 @@ import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemSignonInformation; -/** - * 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 - *

- * You should override: - * - * You can override: - * - * - * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager - */ -public abstract class AbstractConnectorService extends SuperAbstractConnectorService implements IRSEUserIdConstants { - public AbstractConnectorService(String name, String description, IHost host, int port) { +public abstract class AuthenticatingConnectorService extends SuperAbstractConnectorService { + + protected ICredentialsProvider credentialsProvider = null; + + public AuthenticatingConnectorService(String name, String description, IHost host, int port) { super(name, description, host, port); } @@ -67,26 +24,21 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer * If not it returns the userId for the primary subsystem ignoring the * cached userId. */ - final public String getUserId() { - return getCredentialsProvider().getUserId(); + public final String getUserId() { + return credentialsProvider.getUserId(); } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#setUserId(java.lang.String) - */ - final public void setUserId(String newId) { - ICredentialsProvider provider = getCredentialsProvider(); - String oldUserId = provider.getUserId(); + public final void setUserId(String newId) { + String oldUserId = credentialsProvider.getUserId(); if (oldUserId == null || oldUserId.equals(newId)) { updateDefaultUserId(getPrimarySubSystem(), getUserId()); - provider.setUserId(newId); + credentialsProvider.setUserId(newId); setDirty(true); } } public final void saveUserId() { - ICredentialsProvider provider = getCredentialsProvider(); - String userId = provider.getUserId(); + String userId = credentialsProvider.getUserId(); updateDefaultUserId(getPrimarySubSystem(), userId); } @@ -102,14 +54,13 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer * @param persist if this is true, clear the password from the disk cache as well * @see #clearCredentials() */ - final public void clearPassword(boolean persist, boolean propagate) { - ICredentialsProvider provider = getCredentialsProvider(); - provider.clearPassword(); + public final void clearPassword(boolean persist, boolean propagate) { + credentialsProvider.clearPassword(); if (persist) { removePassword(); } if (sharesCredentials() && propagate) { - String userId = provider.getUserId(); + String userId = credentialsProvider.getUserId(); clearPasswordForOtherSystemsInConnection(userId, false); } } @@ -122,7 +73,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer * false if the check should be made for a password in memory only. * @return true if the password is known, false otherwise. */ - final public boolean hasPassword(boolean onDisk) { + public final boolean hasPassword(boolean onDisk) { SystemSignonInformation signonInformation = getSignonInformation(); boolean cached = (signonInformation != null && signonInformation.getPassword() != null); if (!cached && onDisk) { @@ -149,11 +100,10 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer if (getPrimarySubSystem().forceUserIdToUpperCase()) { userId = userId.toUpperCase(); } - ICredentialsProvider provider = getCredentialsProvider(); - String myUserId = provider.getUserId(); + String myUserId = credentialsProvider.getUserId(); IHost host = getHost(); if (host.compareUserIds(userId, myUserId)) { - provider.setPassword(password); + credentialsProvider.setPassword(password); } if (sharesCredentials() && propagate) { updatePasswordForOtherSystemsInConnection(userId, password, persist); @@ -166,8 +116,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer } public final void savePassword() { - ICredentialsProvider provider = getCredentialsProvider(); - ICredentials credentials = provider.getCredentials(); + ICredentials credentials = credentialsProvider.getCredentials(); if (credentials instanceof SystemSignonInformation) { SystemSignonInformation signonInformation = (SystemSignonInformation) credentials; PasswordPersistenceManager.getInstance().add(signonInformation, true, true); @@ -175,61 +124,26 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer } public final void removePassword() { - ICredentialsProvider provider = getCredentialsProvider(); String systemType = getHostType(); String hostName = getHostName(); - String userId = provider.getUserId(); + String userId = credentialsProvider.getUserId(); PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId); } - /** - * 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 { - internalConnect(monitor); - intializeSubSystems(monitor); - } - - /** - * Disconnects from the remote system. - *

- * You must override - * if subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties - * returns false. - *

- * If the subsystem supports server launch - * the default behavior is to use the same remote server - * launcher created in connect() and call disconnect(). - *

- * This is called, by default, from the disconnect() - * method of the subsystem. - * @see IServerLauncher#disconnect() - */ - public final void disconnect(IProgressMonitor monitor) throws Exception { - internalDisconnect(monitor); - unintializeSubSystems(monitor); + protected final void postDisconnect() { clearPassword(false, true); } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#isSuppressed() - */ public final boolean isSuppressed() { - return getCredentialsProvider().isSuppressed(); + return credentialsProvider.isSuppressed(); } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#setSuppressed(boolean) - */ public final void setSuppressed(boolean suppressed) { - getCredentialsProvider().setSuppressed(suppressed); + credentialsProvider.setSuppressed(suppressed); } public final void acquireCredentials(boolean reacquire) throws InterruptedException { - getCredentialsProvider().acquireCredentials(reacquire); + credentialsProvider.acquireCredentials(reacquire); } /** @@ -239,8 +153,8 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer * the next call to getUserId() it is requeried from subsystem. * Also clears the password. */ - final public void clearCredentials() { - getCredentialsProvider().clearCredentials(); + public final void clearCredentials() { + credentialsProvider.clearCredentials(); setDirty(true); } @@ -250,10 +164,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer * connector service. Assumes it has been set by the subsystem at the * time the subsystem acquires the connector service. */ - final protected SystemSignonInformation getSignonInformation() { + protected final SystemSignonInformation getSignonInformation() { SystemSignonInformation result = null; - ICredentialsProvider provider = getCredentialsProvider(); - ICredentials credentials = provider.getCredentials(); + ICredentials credentials = credentialsProvider.getCredentials(); result = (SystemSignonInformation) credentials; return result; } @@ -322,4 +235,35 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer sr.updateHost(host, host.getSystemType(), host.getAliasName(), host.getHostName(), host.getDescription(), userId, whereToUpdate); } } + + /** + * 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; + } + + protected final void setCredentialsProvider(ICredentialsProvider credentialsProvider) { + this.credentialsProvider = credentialsProvider; + } + + protected final ICredentialsProvider getCredentialsProvider() { + return credentialsProvider; + } + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java new file mode 100644 index 00000000000..a0a8c885eaa --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java @@ -0,0 +1,73 @@ +/******************************************************************************** + * 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) - 168977: refactoring IConnectorService and ServerLauncher hierarchies + ********************************************************************************/ +package org.eclipse.rse.core.subsystems; + +import org.eclipse.rse.core.model.IHost; + +/** + * 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 + *

+ * You should override: + * + * You can override: + * + * + * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager + */ +public abstract class BasicConnectorService extends AuthenticatingConnectorService { + + public BasicConnectorService(String name, String description, IHost host, int port) { + super(name, description, host, port); + setCredentialsProvider(new BasicCredentialsProvider(this)); + } + + public boolean supportsPassword() { + return false; + } + + public boolean requiresPassword() { + return false; + } + + public boolean supportsUserId() { + return false; + } + + public boolean requiresUserId() { + return false; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java index f49055c2dae..b674121ada7 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java @@ -44,26 +44,10 @@ public class BasicCredentialsProvider extends AbstractCredentialsProvider { public void repairCredentials(SystemMessage message) throws InterruptedException { } - public boolean requiresPassword() { - return false; - } - - public boolean requiresUserId() { - return false; - } - public void setPassword(String password) { } public void setUserId(String userId) { } - 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 a1f77b9a524..18a8e8ea583 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 @@ -350,4 +350,8 @@ public interface IConnectorService extends IRSEModelObject { */ IServerLauncher getRemoteServerLauncher(); + boolean requiresPassword(); + + boolean requiresUserId(); + } \ No newline at end of file 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 3b8bb6c9468..d8128c6c631 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 @@ -15,32 +15,24 @@ public interface ICredentialsProvider { void acquireCredentials(boolean reacquire) throws InterruptedException; + void repairCredentials(SystemMessage message)throws InterruptedException; + void clearCredentials(); - void clearPassword(); - ICredentials getCredentials(); + void clearPassword(); + + void setPassword(String password); + + void setUserId(String userId); + String getUserId(); boolean isSuppressed(); - void repairCredentials(SystemMessage message)throws InterruptedException; - - boolean requiresPassword(); - - boolean requiresUserId(); - - void setPassword(String password); - void setSuppressed(boolean suppressed); - void setUserId(String userId); - - boolean supportsPassword(); - - boolean supportsUserId(); - IConnectorService getConnectorService(); } 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 4dc2ef8ff73..e5229d83fec 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 @@ -333,44 +333,42 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple return getPort(); } + /** + * 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 { + internalConnect(monitor); + intializeSubSystems(monitor); + } + + /** + * Disconnects from the remote system. + *

+ * You must override + * if subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties + * returns false. + *

+ * If the subsystem supports server launch + * the default behavior is to use the same remote server + * launcher created in connect() and call disconnect(). + *

+ * This is called, by default, from the disconnect() + * method of the subsystem. + * @see IServerLauncher#disconnect() + */ + public final void disconnect(IProgressMonitor monitor) throws Exception { + internalDisconnect(monitor); + unintializeSubSystems(monitor); + postDisconnect(); + } + 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; - } + protected abstract void postDisconnect(); } \ 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 80121e2ccc8..c5d31ef8f7b 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 @@ -26,12 +26,10 @@ import org.eclipse.rse.core.model.IHost; 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.rse.ui.subsystems.AbstractConnectorService; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.MessageConsole; @@ -42,7 +40,6 @@ public class FTPConnectorService extends AbstractConnectorService { protected FTPService _ftpService; private IPropertySet _propertySet; - private ICredentialsProvider credentialsProvider = null; public FTPConnectorService(IHost host, int port) { @@ -107,13 +104,6 @@ public class FTPConnectorService extends AbstractConnectorService _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/subsystems/org/eclipse/rse/core/servicesubsystem/ServiceSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/servicesubsystem/ServiceSubSystemConfiguration.java index e563ad3b0cb..89f23a532a8 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/servicesubsystem/ServiceSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/servicesubsystem/ServiceSubSystemConfiguration.java @@ -22,12 +22,12 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilterPool; import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage; -import org.eclipse.rse.core.subsystems.AbstractConnectorService; import org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager; import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.SubSystemConfiguration; +import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService; import org.eclipse.rse.ui.SystemMenuManager; import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter; import org.eclipse.swt.widgets.Shell; @@ -54,7 +54,7 @@ import org.eclipse.swt.widgets.Shell; * This class is typically used together with:

* @@ -63,7 +63,7 @@ import org.eclipse.swt.widgets.Shell; * this class, and ignore the hundreds in {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration} * * @see org.eclipse.rse.core.servicesubsystem.ServiceSubSystem - * @see AbstractConnectorService + * @see SuperAbstractConnectorService * @see AbstractConnectorServiceManager */ diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index 7c2e904e6da..8921b19b464 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -2531,7 +2531,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS /** * Return the {@link org.eclipse.rse.core.subsystems.IConnectorService IConnectorService} object that represents the live connection for this system. * This must return an object that implements {@link IConnectorService}. A good starting point for that - * is the base class {@link AbstractConnectorService}. + * is the base class {@link SuperAbstractConnectorService}. *

If you only have a single subsystem class, you may override this method to return the * IConnectorService object that manages the connect/disconnect actions. If, on the other hand, * you have multiple subsystem classes that desire to share a single IConnectorService connection, diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/AbstractConnectorService.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/AbstractConnectorService.java new file mode 100644 index 00000000000..9793c1978f8 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/AbstractConnectorService.java @@ -0,0 +1,74 @@ +/******************************************************************************** + * 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) - 168977: refactoring IConnectorService and ServerLauncher hierarchies + ********************************************************************************/ +package org.eclipse.rse.ui.subsystems; + +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.subsystems.AuthenticatingConnectorService; + +/** + * 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 + *

+ * You should override: + * + * You can override: + * + * + * @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager + */ +public abstract class AbstractConnectorService extends AuthenticatingConnectorService { + + public AbstractConnectorService(String name, String description, IHost host, int port) { + super(name, description, host, port); + setCredentialsProvider(new StandardCredentialsProvider(this)); + } + + public boolean supportsPassword() { + return true; + } + + public boolean requiresPassword() { + return true; + } + + public boolean supportsUserId() { + return true; + } + + public boolean requiresUserId() { + return true; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/StandardCredentialsProvider.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/StandardCredentialsProvider.java index 2c31d7fb0ee..2b054cd9186 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/StandardCredentialsProvider.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/ui/subsystems/StandardCredentialsProvider.java @@ -18,7 +18,6 @@ import org.eclipse.rse.core.subsystems.ICredentials; import org.eclipse.rse.core.subsystems.ICredentialsProvider; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService; import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; import org.eclipse.rse.logging.Logger; import org.eclipse.rse.logging.LoggerFactory; @@ -43,7 +42,7 @@ import org.eclipse.ui.PlatformUI; * 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} + * This is suitable for use by subclasses of {@link AbstractConnectorService} * that wish to provide prompting and persistence for userids and passwords when * connecting. *

@@ -231,14 +230,6 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider { promptForNewPassword(prompt); } - public boolean requiresPassword() { - return true; - } - - public boolean requiresUserId() { - return true; - } - public void setPassword(String password) { this.password = password; } @@ -275,14 +266,6 @@ public class StandardCredentialsProvider extends AbstractCredentialsProvider { } } - public boolean supportsPassword() { - return true; - } - - public boolean supportsUserId() { - return true; - } - /** * A default implementation is supplied, but can be overridden if desired.
* Instantiates and returns the dialog to prompt for the userId and password. 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 07f019d3124..d6257bb9d11 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 @@ -13,14 +13,11 @@ 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; +import org.eclipse.rse.core.subsystems.BasicConnectorService; -public class TestSubSystemConnectorService extends AbstractConnectorService { +public class TestSubSystemConnectorService extends BasicConnectorService { private boolean connected = false; - private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(this); /** * Constructor. @@ -54,10 +51,4 @@ public class TestSubSystemConnectorService extends AbstractConnectorService { connected = false; } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.SuperAbstractConnectorService#getCredentialsProvider() - */ - protected ICredentialsProvider getCredentialsProvider() { - return credentialsProvider; - } }