1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 07:35:24 +02:00

[168977][api][refactor] - stage 2.1

1) remove convenience methods from IConnectorService, propagate change to callers
2) remove the "cache" terminology as it is not meaningful
This commit is contained in:
David Dykstal 2007-03-08 17:20:51 +00:00
parent 1452a4c0bf
commit 927be1022e
10 changed files with 34 additions and 108 deletions

View file

@ -324,7 +324,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
notifyDisconnection();
clientConnection = null;
// DKM - no need to clear uid cache
clearPasswordCache(false); // clear in-memory password
clearPassword(false); // clear in-memory password
//clearUserIdCache(); // Clear any cached local user IDs
sysInfo = null;
installInfo = null;
@ -933,7 +933,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
{
if (launchFailed)
{
clearPasswordCache(true);
clearPassword(true);
}
// Display error message
@ -1048,7 +1048,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
{
if (launchFailed)
{
clearPasswordCache(true);
clearPassword(true);
}
DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg);

View file

@ -350,7 +350,7 @@ public class SshConnectorService extends AbstractConnectorService implements ISs
//TODO MOB - keep the session to avoid NPEs in services (disables gc for the session!)
// session = null;
// DKM - no need to clear uid cache
clearPasswordCache(false); // clear in-memory password
clearPassword(false); // clear in-memory password
//clearUserIdCache(); // Clear any cached local user IDs
}
}

View file

@ -184,11 +184,6 @@ public interface IConnectorService extends IRSEModelObject {
*/
public void promptForPassword(boolean forcePrompt) throws InterruptedException;
/**
* Set the password if you got it from somewhere
*/
public void setPassword(String matchingUserId, String password);
/**
* Set the password if you got it from somewhere
*/
@ -198,30 +193,19 @@ public interface IConnectorService extends IRSEModelObject {
* Clear internal userId cache. Called when user uses the property dialog to
* change his userId.
*/
public void clearUserIdCache();
/**
* Clear internal password cache. Called when user uses the property dialog to
* change his userId.
*/
public void clearPasswordCache();
public void clearUserId();
/**
* Clear internal password cache. Called when user uses the property dialog to
* change his userId.
* @param clearDiskCache if true, clears the password from disk
* @param onDisk if true, clears the password from disk
*/
public void clearPasswordCache(boolean clearDiskCache);
public void clearPassword(boolean onDisk);
/**
* Return true if password is currently cached.
*/
public boolean isPasswordCached();
/**
* Return true if password is currently cached.
*/
public boolean isPasswordCached(boolean onDisk);
public boolean hasPassword(boolean onDisk);
/**
* Return true if this system can inherit the uid and password of

View file

@ -64,7 +64,7 @@ public class SystemClearAllPasswordsAction extends SystemBaseAction {
ISubSystem subsystem = subsystems[i];
IConnectorService system = subsystem.getConnectorService();
anyOk = !system.isConnected() && system.isPasswordCached(true);
anyOk = !system.isConnected() && system.hasPassword(true);
if (anyOk)
{
@ -92,13 +92,13 @@ public class SystemClearAllPasswordsAction extends SystemBaseAction {
{
IConnectorService system = ss.getConnectorService();
if (system.isPasswordCached() || system.isPasswordCached(true))
if (system.hasPassword(false) || system.hasPassword(true))
{
// get the user id
// clear userid/password from memory and fire event
//DKM and disk now
system.clearPasswordCache(true);
system.clearPassword(true);
RSEUIPlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(ss,
ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE,
ss.getHost()));

View file

@ -58,7 +58,7 @@ public class SystemClearPasswordAction extends SystemBaseAction
if (obj instanceof ISubSystem) {
ISubSystem subsystem = (ISubSystem) obj;
IConnectorService cs = subsystem.getConnectorService();
result = !cs.isConnected() && cs.isPasswordCached(true);
result = !cs.isConnected() && cs.hasPassword(true);
}
return result;
}
@ -71,7 +71,7 @@ public class SystemClearPasswordAction extends SystemBaseAction
ISubSystem ss = (ISubSystem)getFirstSelection();
try {
IConnectorService system = ss.getConnectorService();
system.clearPasswordCache(true);
system.clearPassword(true);
RSEUIPlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(ss,
ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE,
ss.getHost()));

View file

@ -368,7 +368,7 @@ public final class SignonPreferencePage extends PreferencePage implements IWorkb
system = subsystems[k].getConnectorService();
if (system != null)
{
system.clearPasswordCache();
system.clearPassword(false);
}
}
}

View file

@ -2544,9 +2544,9 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
if (subsystems[idx].isConnected()) subsystems[idx].disconnect(); // MJB: added conditional for defect 45754
if (defaultUserIdChanged)
{
subsystems[idx].getConnectorService().clearUserIdCache();
subsystems[idx].getConnectorService().clearUserId();
}
subsystems[idx].getConnectorService().clearPasswordCache();
subsystems[idx].getConnectorService().clearPassword(false);
}
catch (Exception exc)
{

View file

@ -141,26 +141,14 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
/**
* <i>Useful utility method. Fully implemented, do not override.</i><br>
* Clear internal userId cache. Called when user uses the property dialog to
* Clear internal userId. Called when user uses the property dialog to
* change his userId. By default, sets internal userId value to null so that on
* the next call to getUserId() it is requeried from subsystem.
* Also calls {@link #clearPasswordCache()}.
* Also clears the password.
*/
final public void clearUserIdCache() {
final public void clearUserId() {
_userId = null;
clearPasswordCache();
}
/**
* <i>Useful utility method. Fully implemented, do not override.</i><br>
* Clear internal password cache. Called when user uses the property dialog to
* change his userId. This method does not remove the password from the disk
* cache - only the memory cache.
*
* @see #clearUserIdCache()
*/
final public void clearPasswordCache() {
clearPasswordCache(false);
clearPassword(false);
}
/**
@ -169,9 +157,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
* change his userId.
*
* @param onDisk if this is true, clear the password from the disk cache as well
* @see #clearUserIdCache()
* @see #clearUserId()
*/
final public void clearPasswordCache(boolean onDisk) {
final public void clearPassword(boolean onDisk) {
setPasswordInformation(null);
String userId = getUserId();
if (onDisk) {
@ -195,7 +183,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 isPasswordCached(boolean onDisk) {
final public boolean hasPassword(boolean onDisk) {
boolean cached = (getPasswordInformation() != null);
if (!cached && onDisk) {
// now check if cached on disk
@ -209,15 +197,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
return cached;
}
/**
* <i>Useful utility method. Fully implemented, do not override.</i><br>
* Return true if password is currently cached.
*/
final public boolean isPasswordCached()
{
return isPasswordCached(false);
}
/**
* Return true if this system can inherit the uid and password of
* other ISystems in this connection
@ -436,9 +415,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
for (int s = 0; s < uniqueSystems.size(); s++)
{
IConnectorService system = (IConnectorService)uniqueSystems.get(s);
if (system.isPasswordCached(fromDisk))
if (system.hasPassword(fromDisk))
{
system.clearPasswordCache(fromDisk);
system.clearPassword(fromDisk);
}
}
}
@ -467,7 +446,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
for (int s = 0; s < uniqueSystems.size(); s++)
{
IConnectorService system = (IConnectorService)uniqueSystems.get(s);
if (!system.isConnected() && !system.isPasswordCached())
if (!system.isConnected() && !system.hasPassword(false))
{
if (system.getPrimarySubSystem().forceUserIdToUpperCase())
{
@ -567,16 +546,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
}
}
/**
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
* A convenience method, fully equivalent to <code>setPassword(matchingUserId, password, false)</code>
* @param matchingUserId the user for which to set the password
* @param password the password to set for this userid
*/
public void setPassword(String matchingUserId, String password) {
setPassword(matchingUserId, password, false);
}
/**
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
* Should passwords be folded to uppercase?
@ -688,7 +657,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
{
internalDisconnect(monitor);
unintializeSubSystems(monitor);
clearPasswordCache();
clearPassword(false);
}
/**

View file

@ -39,30 +39,20 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
}
public void clearPasswordCache()
{
public void clearPassword(boolean clearDiskCache) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.clearPasswordCache();
conServ.clearPassword(clearDiskCache);
}
}
public void clearPasswordCache(boolean clearDiskCache) {
public void clearUserId() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.clearPasswordCache(clearDiskCache);
}
}
public void clearUserIdCache() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.clearUserIdCache();
conServ.clearUserId();
}
}
@ -223,20 +213,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false;
}
public boolean isPasswordCached() {
public boolean hasPassword(boolean onDisk) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
return conServ.isPasswordCached();
}
return false;
}
public boolean isPasswordCached(boolean onDisk) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
return conServ.isPasswordCached(onDisk);
return conServ.hasPassword(onDisk);
}
return false;
}
@ -350,14 +331,6 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
}
}
public void setPassword(String matchingUserId, String password) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.setPassword(matchingUserId, password);
}
}
public void setPassword(String matchingUserId, String password,
boolean persist) {
IConnectorService conServ = getRealConnectorService();

View file

@ -448,7 +448,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS
RSEPreferencesManager.clearUserId(previousUserIdKey);
IConnectorService system = getConnectorService();
if (system != null)
system.clearUserIdCache();
system.clearUserId();
}
/**