1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Add new persistence provider. Streamlined connection path formatting in preparation for investigation of 141835.

This commit is contained in:
David Dykstal 2006-05-19 01:27:15 +00:00
parent c797d09625
commit 4373e7f2a2
2 changed files with 68 additions and 81 deletions

View file

@ -390,20 +390,21 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
}
/**
* <i>Method used internally, and available externally. Fully implemented, do not override.</i><br>
* Return the password for this system's subsystem we are associated with.
* <i>Do not override.</i>
* <p>Returns the password for this connector service.
* <p>
* The search order for the password is as follows:</p>
* <ol>
* <li>First check if the password is in transient memory and that it is still valid.
* <li>If password not found in transient memory then check password on disk and
* verify that it is still valid.
* <li>If a valid password is not found in transient memory or on disk then prompt
* the user.
* <li>First check if the password is in transient memory and that it is still valid.
* <li>If password not found in transient memory then check password on disk and
* verify that it is still valid.
* <li>If a valid password is not found in transient memory or on disk then prompt
* the user.
* </ol>
* Throws InterruptedException if user is prompted and user cancels that prompt.
*
* @param shell parent for the prompt dialog if needed. Can be null if know password exists.
* @param shell parent for the prompt dialog if needed.
* @param forcePrompt if true then present the prompt even if the password is stored.
* Can be null if the password is known to exist.
*/
public void promptForPassword(Shell shell, boolean forcePrompt)
throws InterruptedException
@ -416,23 +417,22 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
throw new InterruptedException();
}
// Get the password information associated with this connector service.
SystemSignonInformation passwordInformation = getPasswordInformation();
// 1a. Check the transient in memory password ...
// Test if userId has been changed... d43274
// Check the transient in memory password ...
// Test if userId has been changed... d43274
String oldUserId = getUserId();
if (passwordInformation != null && !forcePrompt)
{
boolean same = getPrimarySubSystem().getHost().compareUserIds(oldUserId, passwordInformation.getUserid());
String hostName = getHostName();//RSEUIPlugin.getQualifiedHostName(getHostName());
same = same && hostName.equalsIgnoreCase(passwordInformation.getHostname());
if (!same)
{
clearPasswordCache();
passwordInformation = null;
}
}
if (passwordInformation != null && !forcePrompt) {
boolean same = getPrimarySubSystem().getHost().compareUserIds(oldUserId, passwordInformation.getUserid());
//RSEUIPlugin.getQualifiedHostName(getHostName());
String hostName = getHostName();
same = same && hostName.equalsIgnoreCase(passwordInformation.getHostname());
if (!same) {
clearPasswordCache();
passwordInformation = null;
}
}
// 1b. If a transient in memory password was found, test if it is still valid ...
// but don't issue a message yet, just set a flag
@ -528,7 +528,6 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
else
throw new InterruptedException();
}
//return password;
}

View file

@ -52,7 +52,6 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.ui.GenericMessages;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.swt.widgets.Composite;
@ -64,8 +63,6 @@ import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.progress.WorkbenchJob;
/**
* This class is designed to be subclassed. Its role is three-fold:
* <ol>
@ -671,17 +668,23 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
public String getConnectionOwnedFilterPoolName(String profileName, String connectionName)
{
// Similar to SubSystemFactoryImpl#getDefaultFilterPoolName(String)...
//System.out.println("ProfileName: " + profileName);
//System.out.println("ConnectionName: " + connectionName);
// System.out.println("ProfileName: " + profileName);
// System.out.println("ConnectionName: " + connectionName);
// RESID_PERCONNECTION_FILTERPOOL = com.ibm.etools.systems.ui.perConnection.filterpool=Filter Pool for connection %1
String name = SystemResources.RESID_PERCONNECTION_FILTERPOOL;
StringBuffer profileNameBuffer = new StringBuffer(profileName.toLowerCase());
profileNameBuffer.setCharAt(0, Character.toUpperCase(profileNameBuffer.charAt(0)));
name = SystemMessage.sub(name, "%1", profileNameBuffer.toString());
name = SystemMessage.sub(name, "%2", connectionName);
// String name = SystemResources.RESID_PERCONNECTION_FILTERPOOL;
//
// StringBuffer profileNameBuffer = new StringBuffer(profileName.toLowerCase());
// profileNameBuffer.setCharAt(0, Character.toUpperCase(profileNameBuffer.charAt(0)));
//
// name = SystemMessage.sub(name, "%1", profileNameBuffer.toString());
// name = SystemMessage.sub(name, "%2", connectionName);
/*
* DWD - Need to keep this name short and not translatable
* since it names a team sharable resource. Not qualified by the profile
* name since that is implicit by being in a profile.
*/
String name = "CN-" + connectionName;
return name;
}
@ -2515,56 +2518,41 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
* @param forcePrompt Forces the signon prompt to be displayed even if a valid password in cached in memory
* or saved on disk.
*/
public void connect(Shell shell, boolean forcePrompt) throws Exception
{
public void connect(Shell shell, boolean forcePrompt) throws Exception {
// yantzi: artemis60, (defect 53082) check that the connection has not been deleted before continuing,
// this is a defenisve measure to protect against code that stores a handle to subsystems but does
// not do this check
if (RSEUIPlugin.getTheSystemRegistry().getHost(getSystemProfile(), getHost().getAliasName()) == null)
{
// connection no longer exists
ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
IHost host = getHost();
String hostName = host.getAliasName();
ISystemProfile profile = getSystemProfile();
if (registry.getHost(profile, hostName) == null) { // connection no longer exists
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTION_DELETED);
msg.makeSubstitution(getHost().getAliasName());
msg.makeSubstitution(hostName);
throw new SystemMessageException(msg);
}
this.shell = shell; //FIXME remove this
// yantzi: artemis 6.0, offline support
if (isOffline())
{
SystemMessage sMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OFFLINE_CANT_CONNECT);
sMsg.makeSubstitution(getHost().getAliasName());
throw new SystemMessageException(sMsg);
}
//DY operation = OPERATION_CONNECT;
if (isConnected() || !supportsConnecting)
return;
IRunnableContext runnableContext = getRunnableContext(shell);
if (runnableContext instanceof ProgressMonitorDialog)
((ProgressMonitorDialog)runnableContext).setCancelable(true);
try
{
getConnectorService().promptForPassword(shell, forcePrompt); // prompt for password
ConnectJob job = new ConnectJob();
scheduleJob(job, null, shell != null);
IStatus status = job.getResult();
if (status != null && status.isOK())
{
ISystemRegistry sr = RSEUIPlugin.getDefault().getSystemRegistry();
sr.connectedStatusChange(this, true, false);
return;
}
}
catch (InterruptedException exc)
{
throw exc;
}
}
this.shell = shell; //FIXME remove this
// yantzi: artemis 6.0, offline support
if (isOffline()) {
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OFFLINE_CANT_CONNECT);
msg.makeSubstitution(hostName);
throw new SystemMessageException(msg);
}
//DY operation = OPERATION_CONNECT;
if (!isConnected() && supportsConnecting) {
IRunnableContext runnableContext = getRunnableContext(shell);
if (runnableContext instanceof ProgressMonitorDialog) {
((ProgressMonitorDialog) runnableContext).setCancelable(true);
}
getConnectorService().promptForPassword(shell, forcePrompt); // prompt for userid and password
ConnectJob job = new ConnectJob();
scheduleJob(job, null, shell != null);
IStatus status = job.getResult();
if (status != null && status.isOK()) {
registry.connectedStatusChange(this, true, false);
}
}
}