1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-11 11:05: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(); notifyDisconnection();
clientConnection = null; clientConnection = null;
// DKM - no need to clear uid cache // 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 //clearUserIdCache(); // Clear any cached local user IDs
sysInfo = null; sysInfo = null;
installInfo = null; installInfo = null;
@ -933,7 +933,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
{ {
if (launchFailed) if (launchFailed)
{ {
clearPasswordCache(true); clearPassword(true);
} }
// Display error message // Display error message
@ -1048,7 +1048,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
{ {
if (launchFailed) if (launchFailed)
{ {
clearPasswordCache(true); clearPassword(true);
} }
DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg); 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!) //TODO MOB - keep the session to avoid NPEs in services (disables gc for the session!)
// session = null; // session = null;
// DKM - no need to clear uid cache // 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 //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; 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 * 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 * Clear internal userId cache. Called when user uses the property dialog to
* change his userId. * change his userId.
*/ */
public void clearUserIdCache(); public void clearUserId();
/** /**
* Clear internal password cache. Called when user uses the property dialog to * Clear internal password cache. Called when user uses the property dialog to
* change his userId. * change his userId.
* @param onDisk if true, clears the password from disk
*/ */
public void clearPasswordCache(); public void clearPassword(boolean onDisk);
/**
* Clear internal password cache. Called when user uses the property dialog to
* change his userId.
* @param clearDiskCache if true, clears the password from disk
*/
public void clearPasswordCache(boolean clearDiskCache);
/** /**
* Return true if password is currently cached. * Return true if password is currently cached.
*/ */
public boolean isPasswordCached(); public boolean hasPassword(boolean onDisk);
/**
* Return true if password is currently cached.
*/
public boolean isPasswordCached(boolean onDisk);
/** /**
* Return true if this system can inherit the uid and password of * 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]; ISubSystem subsystem = subsystems[i];
IConnectorService system = subsystem.getConnectorService(); IConnectorService system = subsystem.getConnectorService();
anyOk = !system.isConnected() && system.isPasswordCached(true); anyOk = !system.isConnected() && system.hasPassword(true);
if (anyOk) if (anyOk)
{ {
@ -92,13 +92,13 @@ public class SystemClearAllPasswordsAction extends SystemBaseAction {
{ {
IConnectorService system = ss.getConnectorService(); IConnectorService system = ss.getConnectorService();
if (system.isPasswordCached() || system.isPasswordCached(true)) if (system.hasPassword(false) || system.hasPassword(true))
{ {
// get the user id // get the user id
// clear userid/password from memory and fire event // clear userid/password from memory and fire event
//DKM and disk now //DKM and disk now
system.clearPasswordCache(true); system.clearPassword(true);
RSEUIPlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(ss, RSEUIPlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(ss,
ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE,
ss.getHost())); ss.getHost()));

View file

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

View file

@ -368,7 +368,7 @@ public final class SignonPreferencePage extends PreferencePage implements IWorkb
system = subsystems[k].getConnectorService(); system = subsystems[k].getConnectorService();
if (system != null) 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 (subsystems[idx].isConnected()) subsystems[idx].disconnect(); // MJB: added conditional for defect 45754
if (defaultUserIdChanged) if (defaultUserIdChanged)
{ {
subsystems[idx].getConnectorService().clearUserIdCache(); subsystems[idx].getConnectorService().clearUserId();
} }
subsystems[idx].getConnectorService().clearPasswordCache(); subsystems[idx].getConnectorService().clearPassword(false);
} }
catch (Exception exc) 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> * <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 * change his userId. By default, sets internal userId value to null so that on
* the next call to getUserId() it is requeried from subsystem. * 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; _userId = null;
clearPasswordCache(); clearPassword(false);
}
/**
* <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);
} }
/** /**
@ -169,9 +157,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
* change his userId. * change his userId.
* *
* @param onDisk if this is true, clear the password from the disk cache as well * @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); setPasswordInformation(null);
String userId = getUserId(); String userId = getUserId();
if (onDisk) { 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. * false if the check should be made for a password in memory only.
* @return true if the password is known, false otherwise. * @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); boolean cached = (getPasswordInformation() != null);
if (!cached && onDisk) { if (!cached && onDisk) {
// now check if cached on disk // now check if cached on disk
@ -209,15 +197,6 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
return cached; 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 * Return true if this system can inherit the uid and password of
* other ISystems in this connection * other ISystems in this connection
@ -436,9 +415,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
for (int s = 0; s < uniqueSystems.size(); s++) for (int s = 0; s < uniqueSystems.size(); s++)
{ {
IConnectorService system = (IConnectorService)uniqueSystems.get(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++) for (int s = 0; s < uniqueSystems.size(); s++)
{ {
IConnectorService system = (IConnectorService)uniqueSystems.get(s); IConnectorService system = (IConnectorService)uniqueSystems.get(s);
if (!system.isConnected() && !system.isPasswordCached()) if (!system.isConnected() && !system.hasPassword(false))
{ {
if (system.getPrimarySubSystem().forceUserIdToUpperCase()) 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> * <i>Useful utility method. Fully implemented, no need to override.</i><br>
* Should passwords be folded to uppercase? * Should passwords be folded to uppercase?
@ -688,7 +657,7 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
{ {
internalDisconnect(monitor); internalDisconnect(monitor);
unintializeSubSystems(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(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)
{ {
conServ.clearPasswordCache(); conServ.clearPassword(clearDiskCache);
} }
} }
public void clearPasswordCache(boolean clearDiskCache) { public void clearUserId() {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)
{ {
conServ.clearPasswordCache(clearDiskCache); conServ.clearUserId();
}
}
public void clearUserIdCache() {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
conServ.clearUserIdCache();
} }
} }
@ -223,20 +213,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return false; return false;
} }
public boolean isPasswordCached() { public boolean hasPassword(boolean onDisk) {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();
if (conServ != null) if (conServ != null)
{ {
return conServ.isPasswordCached(); return conServ.hasPassword(onDisk);
}
return false;
}
public boolean isPasswordCached(boolean onDisk) {
IConnectorService conServ = getRealConnectorService();
if (conServ != null)
{
return conServ.isPasswordCached(onDisk);
} }
return false; 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, public void setPassword(String matchingUserId, String password,
boolean persist) { boolean persist) {
IConnectorService conServ = getRealConnectorService(); IConnectorService conServ = getRealConnectorService();

View file

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