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 4d10049fe62..9a943bfcd42 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 @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006 IBM Corporation and Wind River Systems, Inc. + * Copyright (c) 2006, 2007 IBM Corporation and Wind River Systems, Inc. * 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 @@ -24,6 +24,8 @@ 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.examples.daytime.DaytimeResources; import org.eclipse.rse.examples.daytime.service.DaytimeService; import org.eclipse.rse.examples.daytime.service.IDaytimeService; @@ -40,6 +42,7 @@ public class DaytimeConnectorService extends AbstractConnectorService { private boolean fIsConnected = false; private DaytimeService fDaytimeService; + private ICredentialsProvider fCredentialsProvider = new BasicCredentialsProvider(); public DaytimeConnectorService(IHost host) { super(DaytimeResources.Daytime_Connector_Name, DaytimeResources.Daytime_Connector_Description, host, 13); @@ -70,26 +73,12 @@ public class DaytimeConnectorService extends AbstractConnectorService { return fIsConnected; } - public void internalDisconnect(IProgressMonitor monitor) throws Exception { + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { fIsConnected = false; } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - return false; - } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return 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 fbc9cc2f92d..1b0528e3fae 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 @@ -20,6 +20,8 @@ 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 samples.RSESamplesPlugin; @@ -30,6 +32,7 @@ import samples.RSESamplesPlugin; public class DeveloperConnectorService extends AbstractConnectorService { private boolean connected = false; + private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(); /** * Constructor for DeveloperConnectorService. @@ -65,26 +68,14 @@ public class DeveloperConnectorService extends AbstractConnectorService { /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#internalDisconnect(org.eclipse.core.runtime.IProgressMonitor) */ - public void internalDisconnect(IProgressMonitor monitor) throws Exception + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { // pretend. Normally, we'd disconnect from our remote server-side code here connected=false; } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - return false; - } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return 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 ae665600aef..ee3a004225b 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,7 +43,6 @@ 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; @@ -52,6 +51,7 @@ 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,6 +68,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.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.osgi.framework.Bundle; @@ -82,7 +83,7 @@ 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; @@ -250,6 +251,13 @@ 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, @@ -293,7 +301,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements /** * @see org.eclipse.rse.core.subsystems.IConnectorService#disconnect(IProgressMonitor) */ - public void internalDisconnect(IProgressMonitor monitor) throws Exception + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { try { @@ -1322,31 +1330,4 @@ 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 new file mode 100644 index 00000000000..00c00f342d7 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreCredentialsProvider.java @@ -0,0 +1,48 @@ +/******************************************************************************** + * 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 = 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; + } +} 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 1643ed4a661..7024d2bcc9d 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 @@ -15,10 +15,14 @@ ********************************************************************************/ package org.eclipse.rse.internal.connectorservice.local; +import javax.security.auth.login.CredentialExpiredException; + 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.CommunicationsEvent; +import org.eclipse.rse.core.subsystems.ICredentialsProvider; /** * System class required by the remote systems framework. @@ -28,6 +32,8 @@ import org.eclipse.rse.core.subsystems.CommunicationsEvent; */ public class LocalConnectorService extends AbstractConnectorService { + + private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(); /** * Constructor when we don't have a subsystem yet. @@ -43,7 +49,7 @@ public class LocalConnectorService extends AbstractConnectorService /** * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#disconnect(IProgressMonitor) */ - public void internalDisconnect(IProgressMonitor monitor) throws Exception + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT); @@ -93,21 +99,9 @@ public class LocalConnectorService extends AbstractConnectorService { return System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - return false; - } - - /** - * @return false - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return false; - } + + 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 ad73f0efd7f..960234a4786 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 @@ -57,6 +57,7 @@ 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; @@ -75,6 +76,7 @@ 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 @@ -321,7 +323,7 @@ public class SshConnectorService extends AbstractConnectorService implements ISs notifyConnection(); } - public void internalDisconnect(IProgressMonitor monitor) throws Exception + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { //TODO Will services like the sftp service be disconnected too? Or notified? Activator.trace("SshConnectorService.disconnect"); //$NON-NLS-1$ @@ -711,5 +713,12 @@ public class SshConnectorService extends AbstractConnectorService implements ISs public boolean requiresPassword() { return false; } + + protected ICredentialsProvider getCredentialsProvider() { + if (credentialsProvider == null) { + credentialsProvider = new SshCredentialsProvider(this); + } + return credentialsProvider; + } } 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 new file mode 100644 index 00000000000..61b9b33a2d5 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshCredentialsProvider.java @@ -0,0 +1,30 @@ +/******************************************************************************** + * 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/BasicCredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java new file mode 100644 index 00000000000..0c2e72024dd --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicCredentialsProvider.java @@ -0,0 +1,39 @@ +/******************************************************************************** + * 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.core.subsystems; + + +/** + * The {@link BasicCredentialsProvider} provides a simple implementation of the {@link ICredentialsProvider} + * interface. It is suitable for use with a connector service that needs to provide + * no special authentication to connect to its target system. + *
+ * This class is not meant to be subclassed. + */ +public class BasicCredentialsProvider implements ICredentialsProvider { + + public boolean requiresPassword() { + return false; + } + + public boolean requiresUserId() { + return false; + } + + public boolean supportsPassword() { + return false; + } + + public boolean supportsUserId() { + return false; + } + +} diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java index 3fdf9580417..b49931dcf37 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David Dykstal (IBM) - 168977: refactoring IConnectorService ********************************************************************************/ package org.eclipse.rse.core.subsystems; @@ -224,18 +224,18 @@ public interface IConnectorService extends IRSEModelObject { public boolean hasPassword(boolean onDisk); /** - * Returns true if this system can inherit the uid and password of + * Returns true if this system can inherit the credentials of * from the connection (Host). - * @return true if it can inherit the user/password + * @return true if it can inherit the credentials, false otherwise */ - public boolean inheritConnectionUserPassword(); + public boolean inheritsCredentials(); /** - * Return true if this system can share it's userId and password + * Return true if this system can share it's credentials * with other connector services in this host. - * @return true if it can share the userId/password + * @return true if it can share the credentials */ - public boolean shareUserPasswordWithConnection(); + public boolean sharesCredentials(); /** * Register a communications listener. These listeners will be informed diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java index 3fd0fe91349..899ff0d1b98 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java @@ -10,4 +10,13 @@ package org.eclipse.rse.core.subsystems; public interface ICredentialsProvider { + + boolean supportsPassword(); + + boolean supportsUserId(); + + boolean requiresPassword(); + + boolean requiresUserId(); + } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java index fb1a3629108..651d6b986be 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/SuperAbstractConnectorService.java @@ -24,6 +24,36 @@ import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.RSEModelObject; +/** + * This is a base class to make it easier to create connector service classes. + *
+ * An {@link org.eclipse.rse.core.subsystems.IConnectorService} object + * is returned from a subsystem object via getConnectorService(), and + * it is used to represent the live connection to a particular subsystem. + *
+ * You must override/implement + *
- * Up to each implementer to decide how to implement, and if this will be cached. - *
- * Returns an empty string by default, override if possible
- */
- public String getHomeDirectory() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Not implemented, you should override if possible.
- * Return the temp directory of the remote system for the current user, if available.
- *
- * Up to each implementer to decide how to implement, and if this will be cached. - *
- * Returns an empty string by default, override if possible
- */
- public String getTempDirectory() {
- return ""; //$NON-NLS-1$
- }
-
/**
* Useful utility method. Fully implemented, do not override.
* Returns the system type for this connection:
getSubSystem().getSystemConnection().getSystemType()
@@ -251,21 +230,27 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
/**
- * Not implemented, you should override if possible.
* Return the version, release, modification of the remote system,
- * if connected, if applicable and if available. Else return null. It
- * is up to each subsystem to decide how to interpret what is returned.
- * This is used to show the VRM in the property sheet, when the subsystem is selected.
+ * if connected, if applicable and if available. Else return null. It
+ * is up to each subsystem to decide how to interpret what is returned.
+ * This implementation returns the empty string.
+ *
+ * This is used to show the VRM in the property sheet + * when the subsystem is selected. *
* Up to each implementer to decide if this will be cached. *
- * Returns an empty string by default, override if possible
+ * @return an empty string
*/
public String getVersionReleaseModification() {
return ""; //$NON-NLS-1$
}
- protected void intializeSubSystems(IProgressMonitor monitor) {
+ public final ISubSystem[] getSubSystems() {
+ return (ISubSystem[])_registeredSubSystems.toArray(new ISubSystem[_registeredSubSystems.size()]);
+ }
+
+ protected final void intializeSubSystems(IProgressMonitor monitor) {
for (int i = 0; i < _registeredSubSystems.size(); i++)
{
ISubSystem ss = (ISubSystem)_registeredSubSystems.get(i);
@@ -273,7 +258,7 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
- protected void unintializeSubSystems(IProgressMonitor monitor) {
+ protected final void unintializeSubSystems(IProgressMonitor monitor) {
for (int i = 0; i < _registeredSubSystems.size(); i++)
{
ISubSystem ss = (ISubSystem)_registeredSubSystems.get(i);
@@ -281,28 +266,17 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
- /**
- * Optionally override if you add any instance variables.
- * The following is called whenever a system is redefined or disconnected.
- * Each subsystem needs to be informed so it can clear out any expansions, etc.
- * By default it does nothing. Override if you have an internal object that must be nulled out.
- */
- public void reset() {
- }
-
- protected void notifyDisconnection() {
-
+ protected final void notifyDisconnection() {
// Fire comm event to signal state changed
if (!isConnected()) fireCommunicationsEvent(CommunicationsEvent.AFTER_DISCONNECT);
}
- protected void notifyConnection() {
+ protected final void notifyConnection() {
if (isConnected()) fireCommunicationsEvent(CommunicationsEvent.AFTER_CONNECT);
}
- protected void notifyError() {
+ protected final void notifyError() {
fireCommunicationsEvent(CommunicationsEvent.CONNECTION_ERROR);
-
}
public final boolean isUsingSSL() {
@@ -317,6 +291,37 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
}
}
+ /**
+ * Return the temp directory of the remote system for the current user,
+ * if available. This implementation returns the empty string.
+ * Up to each implementer to decide how to implement, and if this will be cached.
+ * @return an empty string
+ */
+ public String getTempDirectory() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the home directory of the remote system for the current user,
+ * if available. This implementation returns the empty string.
+ * Up to each implementer to decide how to implement, and if this will be cached.
+ * @return an empty string
+ */
+ public String getHomeDirectory() {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Optionally override if you add any instance variables.
+ * The following is called whenever a system is redefined or disconnected.
+ * Each subsystem needs to be informed so it can clear out any expansions, etc.
+ * By default it does nothing.
+ * Override if you have an internal object that must be nulled out.
+ * If overridden you should call super.reset();
+ */
+ public void reset() {
+ }
+
/**
* Return the port to use for connecting to the remote server, once it is running.
* By default, this is the subsystem's port property, via {@link #getPort()}.
@@ -328,11 +333,44 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
return getPort();
}
- public final ISubSystem[] getSubSystems() {
- return (ISubSystem[])_registeredSubSystems.toArray(new ISubSystem[_registeredSubSystems.size()]);
- }
-
protected abstract void internalConnect(IProgressMonitor monitor) throws Exception;
protected abstract void internalDisconnect(IProgressMonitor monitor) throws Exception;
+
+ protected abstract ICredentialsProvider getCredentialsProvider();
+
+ /**
+ * Returns true if this connector service can share it's credentials
+ * with other connector services in this host.
+ * This default implementation will always return true.
+ * Override if necessary.
+ * @return true
+ */
+ public boolean sharesCredentials() {
+ return true;
+ }
+
+ /**
+ * Returns true if this connector service can inherit the credentials of
+ * other connector services in this host.
+ * This default implementation always returns true.
+ * Override if necessary.
+ * @return true
+ */
+ public boolean inheritsCredentials() {
+ return true;
+ }
+
+ public final boolean supportsPassword() {
+ ICredentialsProvider cp = getCredentialsProvider();
+ boolean result = cp.supportsPassword();
+ return result;
+ }
+
+ public final boolean supportsUserId() {
+ ICredentialsProvider cp = getCredentialsProvider();
+ boolean result = cp.supportsUserId();
+ return result;
+ }
+
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java b/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
index 2425af630eb..85060b3e1c3 100644
--- a/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
+++ b/rse/plugins/org.eclipse.rse.subsystems.files.ftp/src/org/eclipse/rse/internal/subsystems/files/ftp/connectorservice/FTPConnectorService.java
@@ -27,9 +27,11 @@ import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.PropertyType;
import org.eclipse.rse.core.model.SystemSignonInformation;
import org.eclipse.rse.core.subsystems.AbstractConnectorService;
+import org.eclipse.rse.core.subsystems.ICredentialsProvider;
import org.eclipse.rse.internal.services.files.ftp.FTPService;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
+import org.eclipse.rse.ui.subsystems.StandardCredentialsProvider;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.MessageConsole;
@@ -40,6 +42,7 @@ public class FTPConnectorService extends AbstractConnectorService
{
protected FTPService _ftpService;
private IPropertySet _propertySet;
+ private ICredentialsProvider credentialsProvider = null;
public FTPConnectorService(IHost host, int port)
{
@@ -47,7 +50,7 @@ public class FTPConnectorService extends AbstractConnectorService
_ftpService = new FTPService();
}
- public void internalConnect(IProgressMonitor monitor) throws Exception
+ protected void internalConnect(IProgressMonitor monitor) throws Exception
{
internalConnect();
}
@@ -99,11 +102,18 @@ public class FTPConnectorService extends AbstractConnectorService
return _ftpService;
}
- public void internalDisconnect(IProgressMonitor monitor)
+ protected void internalDisconnect(IProgressMonitor monitor)
{
_ftpService.disconnect();
}
+ protected ICredentialsProvider getCredentialsProvider() {
+ if (credentialsProvider == null) {
+ credentialsProvider = new StandardCredentialsProvider(this);
+ }
+ return credentialsProvider;
+ }
+
public boolean isConnected()
{
return (_ftpService != null && _ftpService.isConnected());
diff --git a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
index c93ddd43282..ed042ef6ff7 100644
--- a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
+++ b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF
@@ -43,6 +43,7 @@ Export-Package: org.eclipse.rse.core,
org.eclipse.rse.ui.open,
org.eclipse.rse.ui.operations,
org.eclipse.rse.ui.propertypages,
+ org.eclipse.rse.ui.subsystems,
org.eclipse.rse.ui.validators,
org.eclipse.rse.ui.view,
org.eclipse.rse.ui.widgets,
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java
new file mode 100644
index 00000000000..a4ea9a35d6f
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ICredentialsValidator.java
@@ -0,0 +1,44 @@
+/********************************************************************************
+ * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * David Dykstal (IBM) - Changed from ISignonValidator to generalize the concept and
+ * remove the UI dependencies.
+ ********************************************************************************/
+
+package org.eclipse.rse.ui.dialogs;
+
+import org.eclipse.rse.core.subsystems.ICredentials;
+import org.eclipse.rse.services.clientserver.messages.SystemMessage;
+
+
+/**
+ * Interface for providing a credentials validator. This will be used when
+ * credentials are acquired or when they are about to be used. Can check
+ * credentials for expiration or for validity.
+ *
+ * Any context will need to be set in the implementations of this interface + * prior to its validation. + */ +public interface ICredentialsValidator { + + /** + * Verify if credentials are valid. + * + * @param credentials The credentials to be validated. + * + * @return null if the credentials are valid, a SystemMessage describing the + * type of problem if invalid. + */ + public SystemMessage validate(ICredentials credentials); + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java deleted file mode 100644 index 876d69a3a65..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISignonValidator.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.dialogs; - -import org.eclipse.rse.core.model.SystemSignonInformation; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.swt.widgets.Shell; - - -/** - * Interace for providing a signon validator to the password prompt dialog. - */ -public interface ISignonValidator -{ - - /** - * Used by ISystemPasswordPromptDialog to verify if the password entered by the user - * is correct. - * - * @return null if the password is valid, otherwise a SystemMessage is returned that can - * be displayed to the end user. - */ - public SystemMessage isValid(ISystemPasswordPromptDialog dialog, String userid, String password); - - /** - * Verify if persisted userid and password are still valid - * - * @param shell Shell: if null the validator will run headless, if not null then the validator - * may use the shell to prompt the user (for example, if the password has expired.) - * - * @return true if signonInfo contains a valid signon, false otherwise. - */ - public boolean isValid(Shell shell, SystemSignonInformation signonInfo); -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java index cdcb64ab730..b99223fcb37 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/ISystemPasswordPromptDialog.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies ********************************************************************************/ package org.eclipse.rse.ui.dialogs; @@ -55,7 +55,7 @@ public interface ISystemPasswordPromptDialog /** * Call this to specify a validator for the signon. It will be called when the OK button is pressed. */ - public void setSignonValidator(ISignonValidator v); + public void setSignonValidator(ICredentialsValidator v); /** * Call this to force the userId and password to uppercase */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java index 12166be1197..df9301fbb86 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java @@ -12,12 +12,15 @@ * * Contributors: * David Dykstal (IBM) - moved SystemPreferencesManager to a new package + * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies ********************************************************************************/ package org.eclipse.rse.ui.dialogs; import org.eclipse.rse.core.RSEPreferencesManager; +import org.eclipse.rse.core.model.SystemSignonInformation; import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.core.subsystems.ICredentials; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; @@ -60,7 +63,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme private boolean validate = true; private ISystemValidator userIdValidator; private ISystemValidator passwordValidator; - private ISignonValidator signonValidator; + private ICredentialsValidator signonValidator; private IConnectorService connectorService = null; /** @@ -113,7 +116,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme * This must be called prior to opening this dialog if something other than the default is needed. * @param v a signon validator */ - public void setSignonValidator(ISignonValidator v) { + public void setSignonValidator(ICredentialsValidator v) { signonValidator = v; } @@ -478,7 +481,10 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme // If all inputs are OK then validate signon if (getErrorMessage() == null && (signonValidator != null)) { - SystemMessage m = signonValidator.isValid(this, userId, password); + String hostName = connectorService.getHostName(); + String hostType = connectorService.getHostType(); + ICredentials credentials = new SystemSignonInformation(hostName, userId, password, hostType); + SystemMessage m = signonValidator.validate(credentials); setErrorMessage(m); } boolean closeDialog = (getErrorMessage() == null); diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java index 00cef91f036..4c582fd458a 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractConnectorService.java @@ -32,7 +32,7 @@ import org.eclipse.rse.model.ISystemRegistryUI; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.dialogs.ISignonValidator; +import org.eclipse.rse.ui.dialogs.ICredentialsValidator; import org.eclipse.rse.ui.dialogs.ISystemPasswordPromptDialog; import org.eclipse.rse.ui.dialogs.SystemChangePasswordDialog; import org.eclipse.rse.ui.dialogs.SystemPasswordPromptDialog; @@ -169,7 +169,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer if (userId != null) PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId); } - if (shareUserPasswordWithConnection()) { + if (sharesCredentials()) { // clear this uid/password with other ISystems in connection clearPasswordForOtherSystemsInConnection(userId, onDisk); } @@ -197,17 +197,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer return cached; } - /** - * Return true if this system can inherit the uid and password of - * other ISystems in this connection - * - * @return true if it can inherit the user/password - */ - final public boolean inheritConnectionUserPassword() - { - return true; - } - /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.IConnectorService#requiresPassword() */ @@ -216,14 +205,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsPassword() - */ - public boolean supportsPassword() { - return true; - } - - /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.IConnectorService#requiresUserId() */ @@ -232,46 +213,28 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer } - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.IConnectorService#supportsUserId() - */ - public boolean supportsUserId() - { - return true; - } - /** - * Return true if this connector service can share it's uid and password - * with other connector services in this host (connection). - * @return true if it can share the user/password - */ - public boolean shareUserPasswordWithConnection() - { - return true; - } - - /** - * Do not override. - * Sets the signon information for this connector service. - * The search order for the password is as follows:
- *getSubSystem().getParentSubSystemConfiguration().getUserIdValidator()
*/
- public ISystemValidator getUserIdValidator()
+ final public ISystemValidator getUserIdValidator()
{
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
-
return adapter.getUserIdValidator(ssFactory);
}
@@ -579,29 +546,24 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
* By default, returns:
* getSubSystem().getParentSubSystemConfiguration().getPasswordValidator()
*/
- public ISystemValidator getPasswordValidator()
+ final public ISystemValidator getPasswordValidator()
{
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
-
return adapter.getPasswordValidator(ssFactory);
}
+
/**
* Optionally overridable, not implemented by default.+ * It uses a {@link PasswordPersistenceManager} to store the passwords in the + * keychain keyed by {@link IHost} and possibly by {@link ISubSystemConfiguration}. + *
+ * This is suitable for use by subclasses of {@link SuperAbstractConnectorService} + * that wish to provide prompting and persistence for userids and passwords when + * connecting. + *
+ * This class is may be subclassed. Typically to provide connector service + * specific prompting. + */ +public class StandardCredentialsProvider implements ICredentialsProvider { + + private IConnectorService connectorService = null; + + public StandardCredentialsProvider(IConnectorService connectorService) { + this.connectorService = connectorService; + } + + public boolean requiresPassword() { + return true; + } + + public boolean requiresUserId() { + return true; + } + + public boolean supportsPassword() { + return true; + } + + public boolean supportsUserId() { + return true; + } + + protected final IHost getHost() { + return connectorService.getHost(); + } + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java index 32f20a56c3c..1911fdae030 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/testsubsystem/TestSubSystemConnectorService.java @@ -14,10 +14,13 @@ package org.eclipse.rse.tests.internal.testsubsystem; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.AbstractConnectorService; +import org.eclipse.rse.core.subsystems.BasicCredentialsProvider; +import org.eclipse.rse.core.subsystems.ICredentialsProvider; public class TestSubSystemConnectorService extends AbstractConnectorService { private boolean connected = false; + private ICredentialsProvider credentialsProvider = new BasicCredentialsProvider(); /** * Constructor. @@ -47,21 +50,14 @@ public class TestSubSystemConnectorService extends AbstractConnectorService { /* (non-Javadoc) * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#internalDisconnect(org.eclipse.core.runtime.IProgressMonitor) */ - public void internalDisconnect(IProgressMonitor monitor) throws Exception { + protected void internalDisconnect(IProgressMonitor monitor) throws Exception { connected = false; } /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsPassword() + * @see org.eclipse.rse.core.subsystems.SuperAbstractConnectorService#getCredentialsProvider() */ - public boolean supportsPassword() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#supportsUserId() - */ - public boolean supportsUserId() { - return false; + protected ICredentialsProvider getCredentialsProvider() { + return credentialsProvider; } }