mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
[168977][api][refactor] - stage 2.3
- Introduced ICredentialsProvider implementations - Refactored some AbstractConnectorService methods into the credentials providers - Further simplified the concrete connector services - made more methods final and explicitly indicated where overrides are allowed, required.
This commit is contained in:
parent
123cfd3fbc
commit
52f4211900
21 changed files with 485 additions and 323 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
* <p>
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -10,4 +10,13 @@
|
|||
package org.eclipse.rse.core.subsystems;
|
||||
|
||||
public interface ICredentialsProvider {
|
||||
|
||||
boolean supportsPassword();
|
||||
|
||||
boolean supportsUserId();
|
||||
|
||||
boolean requiresPassword();
|
||||
|
||||
boolean requiresUserId();
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <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
|
||||
* <li>getCredentialsProvider
|
||||
* </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>
|
||||
*
|
||||
*/
|
||||
public abstract class SuperAbstractConnectorService extends RSEModelObject implements IConnectorService {
|
||||
|
||||
private Vector commListeners = new Vector(5);
|
||||
|
@ -34,6 +64,7 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
|
|||
private String _name;
|
||||
private int _port;
|
||||
private boolean _usingSSL;
|
||||
|
||||
/**
|
||||
* The result of calling launch in the server launcher object, in the connect method
|
||||
*/
|
||||
|
@ -101,43 +132,15 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
|
|||
}
|
||||
|
||||
/**
|
||||
* <i><b>Private</b> - used internally.</i><br>
|
||||
* Returns the count of active communication listeners (i.e. excludes
|
||||
* passive listeners.)
|
||||
* Fires the communication event mentioned in the eventType.
|
||||
* @param eventType the communications event to fire.
|
||||
*/
|
||||
protected int getCommunicationListenerCount() {
|
||||
int count = 0;
|
||||
for (int i = 0; i < commListeners.size(); i++)
|
||||
{
|
||||
if (!((ICommunicationsListener) commListeners.get(i)).isPassiveCommunicationsListener())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* <i><b>Private</b> - used internally.</i><br>
|
||||
*/
|
||||
protected void clearCommunicationListeners() {
|
||||
commListeners.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* <i><b>Private</b> - used internally.</i><br>
|
||||
* Helper method for firing communication events
|
||||
*/
|
||||
protected void fireCommunicationsEvent(int eventType) {
|
||||
final protected void fireCommunicationsEvent(int eventType) {
|
||||
CommunicationsEvent e = new CommunicationsEvent(this, eventType);
|
||||
|
||||
Object[] items = commListeners.toArray();
|
||||
|
||||
for (int loop=0; loop < items.length; loop++) {
|
||||
((ICommunicationsListener) items[loop]).communicationsStateChange(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final IHost getHost() {
|
||||
|
@ -209,30 +212,6 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
|
|||
return RSECorePlugin.getThePersistenceManager().commit(getHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Not implemented, you should override if possible.</i><br>
|
||||
* Return the home directory of the remote system for the current user, if available.
|
||||
* <p>
|
||||
* Up to each implementer to decide how to implement, and if this will be cached.
|
||||
* <p>
|
||||
* Returns an empty string by default, override if possible
|
||||
*/
|
||||
public String getHomeDirectory() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Not implemented, you should override if possible.</i><br>
|
||||
* Return the temp directory of the remote system for the current user, if available.
|
||||
* <p>
|
||||
* Up to each implementer to decide how to implement, and if this will be cached.
|
||||
* <p>
|
||||
* Returns an empty string by default, override if possible
|
||||
*/
|
||||
public String getTempDirectory() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
||||
* Returns the system type for this connection:<br> <code>getSubSystem().getSystemConnection().getSystemType()</code>
|
||||
|
@ -251,21 +230,27 @@ public abstract class SuperAbstractConnectorService extends RSEModelObject imple
|
|||
}
|
||||
|
||||
/**
|
||||
* <i>Not implemented, you should override if possible.</i><br>
|
||||
* 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.<br>
|
||||
* 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.
|
||||
* <p>
|
||||
* This is used to show the VRM in the property sheet
|
||||
* when the subsystem is selected.
|
||||
* <p>
|
||||
* Up to each implementer to decide if this will be cached.
|
||||
* <p>
|
||||
* 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
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Optionally override if you add any instance variables.</i><br>
|
||||
* 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$
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Optionally override if you add any instance variables.</i><br>
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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());
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Do not override.</i>
|
||||
* Sets the signon information for this connector service.
|
||||
* The search order for the password is as follows:</p>
|
||||
* <ol>
|
||||
* <li>First check if the password is already known by this connector service and that it is still valid.
|
||||
* <li>If password not known then look in the password store and verify that it is still valid.
|
||||
* <li>If a valid password is not found then prompt the user.
|
||||
* </ol>
|
||||
* Must be run in the UI thread.
|
||||
* Can be null if the password is known to exist in either this class or in the password store.
|
||||
* @param forcePrompt if true then present the prompt even if the password was found and is valid.
|
||||
* @throws InterruptedException if user is prompted and user cancels that prompt or if isSuppressSignonPrompt is true.
|
||||
*/
|
||||
public void promptForPassword(boolean forcePrompt) throws InterruptedException {
|
||||
* <i>Do not override.</i>
|
||||
* Sets the signon information for this connector service.
|
||||
* The search order for the password is as follows:</p>
|
||||
* <ol>
|
||||
* <li>First check if the password is already known by this connector service and that it is still valid.
|
||||
* <li>If password not known then look in the password store and verify that it is still valid.
|
||||
* <li>If a valid password is not found then prompt the user.
|
||||
* </ol>
|
||||
* Must be run in the UI thread.
|
||||
* Can be null if the password is known to exist in either this class or in the password store.
|
||||
* @param forcePrompt if true then present the prompt even if the password was found and is valid.
|
||||
* @throws InterruptedException if user is prompted and user cancels that prompt or if isSuppressSignonPrompt is true.
|
||||
*/
|
||||
public void promptForPassword(boolean forcePrompt) throws InterruptedException {
|
||||
// dy: March 24, 2003: check if prompting is temporarily suppressed by a tool
|
||||
// vendor, this should only be suppressed if the user cancelled a previous signon
|
||||
// dialog (or some other good reason)
|
||||
if (isSuppressSignonPrompt()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
|
||||
ISubSystem subsystem = getPrimarySubSystem();
|
||||
IHost host = subsystem.getHost();
|
||||
String hostName = host.getHostName();
|
||||
|
@ -303,17 +266,21 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
}
|
||||
}
|
||||
}
|
||||
ISignonValidator validator = getSignonValidator();
|
||||
boolean signonValid = (validator == null) || validator.isValid(shell, _passwordInfo);
|
||||
|
||||
ICredentialsValidator validator = getSignonValidator();
|
||||
boolean signonValid = true;
|
||||
if (validator != null) {
|
||||
SystemMessage m = validator.validate(_passwordInfo);
|
||||
signonValid = (m == null);
|
||||
}
|
||||
|
||||
// If we ran into an invalid password we need to tell the user.
|
||||
// DWD refactor - want to move this to a pluggable class so that this can be moved to core.
|
||||
// DWD not sure this is necessary, shouldn't this message show up on the password prompt itself?
|
||||
if (!signonValid) {
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID);
|
||||
msg.makeSubstitution(getLocalUserId(), getHostName());
|
||||
SystemMessageDialog dialog = new SystemMessageDialog(shell, msg);
|
||||
dialog.open();
|
||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_INVALID);
|
||||
msg.makeSubstitution(getLocalUserId(), getHostName());
|
||||
SystemMessageDialog dialog = new SystemMessageDialog(shell, msg);
|
||||
dialog.open();
|
||||
}
|
||||
if (shell == null)
|
||||
{
|
||||
|
@ -326,7 +293,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
shell = new Shell();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (supportsPassword() || supportsUserId())
|
||||
{
|
||||
if (shell == null)
|
||||
|
@ -381,7 +348,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
}
|
||||
if (supportsPassword()) {
|
||||
setPassword(userId, password, savePassword);
|
||||
if (shareUserPasswordWithConnection()) {
|
||||
if (sharesCredentials()) {
|
||||
updatePasswordForOtherSystemsInConnection(userId, password, savePassword);
|
||||
}
|
||||
}
|
||||
|
@ -389,9 +356,10 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearPasswordForOtherSystemsInConnection(String uid, boolean fromDisk)
|
||||
}
|
||||
|
||||
|
||||
protected void clearPasswordForOtherSystemsInConnection(String uid, boolean fromDisk)
|
||||
{
|
||||
if (uid != null)
|
||||
{
|
||||
|
@ -403,7 +371,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
for (int i = 0; i < subsystems.length; i++)
|
||||
{
|
||||
IConnectorService system = subsystems[i].getConnectorService();
|
||||
if (system != this && system.inheritConnectionUserPassword())
|
||||
if (system != this && system.inheritsCredentials())
|
||||
{
|
||||
if (!uniqueSystems.contains(system))
|
||||
{
|
||||
|
@ -434,7 +402,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
for (int i = 0; i < subsystems.length; i++)
|
||||
{
|
||||
IConnectorService system = subsystems[i].getConnectorService();
|
||||
if (system != this && system.inheritConnectionUserPassword())
|
||||
if (system != this && system.inheritsCredentials())
|
||||
{
|
||||
if (!uniqueSystems.contains(system))
|
||||
{
|
||||
|
@ -508,7 +476,7 @@ 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.
|
||||
*/
|
||||
protected SystemSignonInformation getPasswordInformation() {
|
||||
final protected SystemSignonInformation getPasswordInformation() {
|
||||
return _passwordInfo;
|
||||
}
|
||||
|
||||
|
@ -517,7 +485,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
* Sets the password information for this system's subsystem.
|
||||
* @param passwordInfo the password information object
|
||||
*/
|
||||
protected void setPasswordInformation(SystemSignonInformation passwordInfo) {
|
||||
final protected void setPasswordInformation(SystemSignonInformation passwordInfo) {
|
||||
_passwordInfo = passwordInfo;
|
||||
if (passwordInfo != null) {
|
||||
_userId = passwordInfo.getUserid();
|
||||
|
@ -564,11 +532,10 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
|||
* By default, returns </p>
|
||||
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getUserIdValidator()</code></pre>
|
||||
*/
|
||||
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:</p>
|
||||
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getPasswordValidator()</code></pre>
|
||||
*/
|
||||
public ISystemValidator getPasswordValidator()
|
||||
final public ISystemValidator getPasswordValidator()
|
||||
{
|
||||
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
||||
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
||||
|
||||
return adapter.getPasswordValidator(ssFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Optionally overridable, not implemented by default.</i><br>
|
||||
* Get the signon validator to use in the password dialog prompt.
|
||||
* By default, returns null.
|
||||
*/
|
||||
public ISignonValidator getSignonValidator()
|
||||
public ICredentialsValidator getSignonValidator()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
// methods that must be overridden by child classes...
|
||||
// ---------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* This connection method wrappers the others (internal connect) so that registered subsystems
|
||||
* can be notified and initialized after a connect
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* component that contains this file: David McKnight.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.core.subsystems;
|
||||
|
||||
|
@ -281,11 +281,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean inheritConnectionUserPassword() {
|
||||
public boolean inheritsCredentials() {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
return conServ.inheritConnectionUserPassword();
|
||||
return conServ.inheritsCredentials();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -470,11 +470,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
|||
}
|
||||
}
|
||||
|
||||
public boolean shareUserPasswordWithConnection() {
|
||||
public boolean sharesCredentials() {
|
||||
IConnectorService conServ = getRealConnectorService();
|
||||
if (conServ != null)
|
||||
{
|
||||
return conServ.shareUserPasswordWithConnection();
|
||||
return conServ.sharesCredentials();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/********************************************************************************
|
||||
* 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.ui.subsystems;
|
||||
|
||||
import org.eclipse.rse.core.PasswordPersistenceManager;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.subsystems.IConnectorService;
|
||||
import org.eclipse.rse.core.subsystems.ICredentialsProvider;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService;
|
||||
|
||||
/**
|
||||
* The {@link StandardCredentialsProvider} is an implementation of
|
||||
* {@link ICredentialsProvider} that provides for the prompting of a userid
|
||||
* and password.
|
||||
* <p>
|
||||
* 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}
|
||||
* that wish to provide prompting and persistence for userids and passwords when
|
||||
* connecting.
|
||||
* <p>
|
||||
* 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue