1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

[168977][api][refactor] - stage 3.4

- introduced AuthenticatingConnectorService as a superclass of AbstractConnectorService
- moved almost all methods from AbstractConnectorService to AuthenticatingConnectorService. AbstractConnectorService now handled the creation of the StandardCredentialsProvider for all subclasses.
- moved AbstractConnectorService back to UI with the intention of renaming it StandardConnectorService
- moved requiresPassword, supportsPassword, requiresUserId, and supportsUserId back to IConnectorService from ICredentialsProvider.
- removed SshCredentialsProvider and DStoreCredentialsProvider, their connector services can now use the StandardCredentialsProvider
This commit is contained in:
David Dykstal 2007-03-28 14:10:53 +00:00
parent 64282f800a
commit afa5e999a1
21 changed files with 336 additions and 354 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -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.
* <p>
* 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.
* <p>
* You must override/implement
* <ul>
* <li>isConnected
* <li>internalConnect
* <li>internalDisconnect
* </ul>
* You should override:
* <ul>
* <li>reset
* <li>getVersionReleaseModification
* <li>getHomeDirectory
* <li>getTempDirectory
* </ul>
* You can override:
* <ul>
* <li>supportsUserId
* <li>requiresUserId
* <li>supportsPassword
* <li>requiresPassword
* </ul>
*
* @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.
* <p>
* You must override
* if <code>subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties</code>
* returns false.
* <p>
* If the subsystem supports server launch
* the default behavior is to use the same remote server
* launcher created in <code>connect()</code> and call <code>disconnect()</code>.
* <p>
* This is called, by default, from the <code>disconnect()</code>
* 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;
}
}

View file

@ -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.
* <p>
* 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.
* <p>
* You must override/implement
* <ul>
* <li>isConnected
* <li>internalConnect
* <li>internalDisconnect
* </ul>
* You should override:
* <ul>
* <li>reset
* <li>getVersionReleaseModification
* <li>getHomeDirectory
* <li>getTempDirectory
* </ul>
* You can override:
* <ul>
* <li>supportsUserId
* <li>requiresUserId
* <li>supportsPassword
* <li>requiresPassword
* </ul>
*
* @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;
}
}

View file

@ -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;
}
}

View file

@ -350,4 +350,8 @@ public interface IConnectorService extends IRSEModelObject {
*/
IServerLauncher getRemoteServerLauncher();
boolean requiresPassword();
boolean requiresUserId();
}

View file

@ -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();
}

View file

@ -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.
* <p>
* You must override
* if <code>subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties</code>
* returns false.
* <p>
* If the subsystem supports server launch
* the default behavior is to use the same remote server
* launcher created in <code>connect()</code> and call <code>disconnect()</code>.
* <p>
* This is called, by default, from the <code>disconnect()</code>
* 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();
}

View file

@ -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());

View file

@ -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:</p>
* <ul>
* <li>{@link org.eclipse.rse.core.servicesubsystem.ServiceSubSystem} for the subsystem
* <li>{@link AbstractConnectorService} for the connector service
* <li>{@link SuperAbstractConnectorService} for the connector service
* <li>{@link AbstractConnectorServiceManager} for the connector service manager
* <li>{@link org.eclipse.rse.core.subsystems.AbstractResource} for the individual remote resources
* </ul>
@ -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
*/

View file

@ -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}.
* <p>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,

View file

@ -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.
* <p>
* 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.
* <p>
* You must override/implement
* <ul>
* <li>isConnected
* <li>internalConnect
* <li>internalDisconnect
* </ul>
* You should override:
* <ul>
* <li>reset
* <li>getVersionReleaseModification
* <li>getHomeDirectory
* <li>getTempDirectory
* </ul>
* You can override:
* <ul>
* <li>supportsUserId
* <li>requiresUserId
* <li>supportsPassword
* <li>requiresPassword
* </ul>
*
* @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;
}
}

View file

@ -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}.
* <p>
* 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.
* <p>
@ -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;
}
/**
* <i>A default implementation is supplied, but can be overridden if desired.</i><br>
* Instantiates and returns the dialog to prompt for the userId and password.

View file

@ -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;
}
}