mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-23 16:23:52 +02:00
[168977][api][refactor] - stage 2.5
- moved function from AbstractConnectorService into the StandardCredentialsProvider. All dialogs are now handled in the StandardCredentialsProvider. - updated ICredentialsProvider, ICredentials, and IConnectorService
This commit is contained in:
parent
21ae98e8ec
commit
91db5014c0
19 changed files with 746 additions and 734 deletions
|
@ -332,7 +332,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
|
||||||
clearPassword(false); // clear in-memory password
|
clearPassword(false, true); // 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;
|
||||||
|
@ -528,7 +528,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
monitor.subTask(cmsg.getLevelOneText());
|
monitor.subTask(cmsg.getLevelOneText());
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemSignonInformation info = getPasswordInformation();
|
SystemSignonInformation info = getSignonInformation();
|
||||||
|
|
||||||
// GC: - if failed to get a connection in another way, try
|
// GC: - if failed to get a connection in another way, try
|
||||||
// starting the datastore server with rexec
|
// starting the datastore server with rexec
|
||||||
|
@ -597,7 +597,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
// should be the same as the one stored in the password info (and for Windows
|
// should be the same as the one stored in the password info (and for Windows
|
||||||
// this will be the temp remoteuser userid.
|
// this will be the temp remoteuser userid.
|
||||||
//launchStatus = clientConnection.launchServer(getLocalUserId(), getPassword(getPasswordInformation()));
|
//launchStatus = clientConnection.launchServer(getLocalUserId(), getPassword(getPasswordInformation()));
|
||||||
SystemSignonInformation info = getPasswordInformation();
|
SystemSignonInformation info = getSignonInformation();
|
||||||
if (info == null)
|
if (info == null)
|
||||||
{
|
{
|
||||||
System.out.println("password info = null!");
|
System.out.println("password info = null!");
|
||||||
|
@ -632,17 +632,20 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
// If password has expired and must be changed
|
// If password has expired and must be changed
|
||||||
if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
||||||
{
|
{
|
||||||
NewPasswordInfo newPasswordInfo = null;
|
SystemSignonInformation oldCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials();
|
||||||
|
SystemSignonInformation newCredentials = null;
|
||||||
while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
||||||
{
|
{
|
||||||
newPasswordInfo = promptForNewPassword(isPasswordExpired(launchMsg) ? RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED) : RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID));
|
String messageId = isPasswordExpired(launchMsg) ? ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED : ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID;
|
||||||
launchStatus = changePassword(clientConnection, getPasswordInformation(), serverLauncher, monitor, newPasswordInfo.newPassword);
|
SystemMessage message = RSEUIPlugin.getPluginMessage(messageId);
|
||||||
|
getCredentialsProvider().repairCredentials(message);
|
||||||
|
newCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials();
|
||||||
|
launchStatus = changePassword(clientConnection, oldCredentials, serverLauncher, monitor, newCredentials.getPassword());
|
||||||
launchMsg = launchStatus.getMessage();
|
launchMsg = launchStatus.getMessage();
|
||||||
}
|
}
|
||||||
if (newPasswordInfo != null)
|
if (newCredentials != null)
|
||||||
{
|
{
|
||||||
setPassword(info.getUserid(), newPasswordInfo.newPassword, newPasswordInfo.savePassword);
|
info = newCredentials;
|
||||||
info = getPasswordInformation();
|
|
||||||
}
|
}
|
||||||
if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
|
if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
|
||||||
{
|
{
|
||||||
|
@ -757,7 +760,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
// server launcher type is unknown
|
// server launcher type is unknown
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SystemSignonInformation info = getPasswordInformation();
|
SystemSignonInformation info = getSignonInformation();
|
||||||
connectStatus = launchServer(clientConnection, info, serverLauncher, monitor);
|
connectStatus = launchServer(clientConnection, info, serverLauncher, monitor);
|
||||||
if (!connectStatus.isConnected() && !clientConnection.isKnownStatus(connectStatus.getMessage()))
|
if (!connectStatus.isConnected() && !clientConnection.isKnownStatus(connectStatus.getMessage()))
|
||||||
{
|
{
|
||||||
|
@ -935,7 +938,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
{
|
{
|
||||||
if (launchFailed)
|
if (launchFailed)
|
||||||
{
|
{
|
||||||
clearPassword(true);
|
clearPassword(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display error message
|
// Display error message
|
||||||
|
@ -978,22 +981,38 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
// If password has expired and must be changed
|
// If password has expired and must be changed
|
||||||
else if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
else if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
||||||
{
|
{
|
||||||
NewPasswordInfo newPasswordInfo = null;
|
SystemSignonInformation oldCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials();
|
||||||
|
SystemSignonInformation newCredentials = null;
|
||||||
while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
||||||
{
|
{
|
||||||
newPasswordInfo = promptForNewPassword(isPasswordExpired(launchMsg) ? RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED) : RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID));
|
String messageId = isPasswordExpired(launchMsg) ? ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED : ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID;
|
||||||
launchStatus = changePassword(clientConnection, getPasswordInformation(), serverLauncher, monitor, newPasswordInfo.newPassword);
|
SystemMessage message = RSEUIPlugin.getPluginMessage(messageId);
|
||||||
|
getCredentialsProvider().repairCredentials(message);
|
||||||
|
newCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials();
|
||||||
|
launchStatus = changePassword(clientConnection, oldCredentials, serverLauncher, monitor, newCredentials.getPassword());
|
||||||
launchMsg = launchStatus.getMessage();
|
launchMsg = launchStatus.getMessage();
|
||||||
}
|
}
|
||||||
if (newPasswordInfo != null)
|
|
||||||
{
|
|
||||||
setPassword(getPasswordInformation().getUserid(), newPasswordInfo.newPassword, newPasswordInfo.savePassword);
|
|
||||||
}
|
|
||||||
if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
|
if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
|
||||||
{
|
{
|
||||||
internalConnect(monitor);
|
internalConnect(monitor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// NewPasswordInfo newPasswordInfo = null;
|
||||||
|
// while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
|
||||||
|
// {
|
||||||
|
// newPasswordInfo = promptForNewPassword(isPasswordExpired(launchMsg) ? RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED) : RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID));
|
||||||
|
// launchStatus = changePassword(clientConnection, getPasswordInformation(), serverLauncher, monitor, newPasswordInfo.newPassword);
|
||||||
|
// launchMsg = launchStatus.getMessage();
|
||||||
|
// }
|
||||||
|
// if (newPasswordInfo != null)
|
||||||
|
// {
|
||||||
|
// setPassword(getPasswordInformation().getUserid(), newPasswordInfo.newPassword, newPasswordInfo.savePassword);
|
||||||
|
// }
|
||||||
|
// if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
|
||||||
|
// {
|
||||||
|
// internalConnect(monitor);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else if (launchMsg != null)
|
else if (launchMsg != null)
|
||||||
{
|
{
|
||||||
|
@ -1050,7 +1069,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
{
|
{
|
||||||
if (launchFailed)
|
if (launchFailed)
|
||||||
{
|
{
|
||||||
clearPassword(true);
|
clearPassword(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg);
|
DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg);
|
||||||
|
@ -1188,7 +1207,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
||||||
*/
|
*/
|
||||||
protected ConnectionStatus launchServer(ClientConnection clientConnection, SystemSignonInformation info, int daemonPort, IProgressMonitor monitor, int timeout)
|
protected ConnectionStatus launchServer(ClientConnection clientConnection, SystemSignonInformation info, int daemonPort, IProgressMonitor monitor, int timeout)
|
||||||
{
|
{
|
||||||
return clientConnection.launchServer(info.getUserid(), info.getPassword(), daemonPort, timeout);
|
return clientConnection.launchServer(info.getUserId(), info.getPassword(), daemonPort, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class DStoreCredentialsProvider extends StandardCredentialsProvider {
|
||||||
*/
|
*/
|
||||||
public boolean supportsPassword() {
|
public boolean supportsPassword() {
|
||||||
boolean result = super.supportsPassword();
|
boolean result = super.supportsPassword();
|
||||||
IHost host = getHost();
|
IHost host = getConnectorService().getHost();
|
||||||
String systemType = host.getSystemType();
|
String systemType = host.getSystemType();
|
||||||
if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) {
|
if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) {
|
||||||
result = false;
|
result = false;
|
||||||
|
@ -38,7 +38,7 @@ public class DStoreCredentialsProvider extends StandardCredentialsProvider {
|
||||||
*/
|
*/
|
||||||
public boolean supportsUserId() {
|
public boolean supportsUserId() {
|
||||||
boolean result = super.supportsUserId();
|
boolean result = super.supportsUserId();
|
||||||
IHost host = getHost();
|
IHost host = getConnectorService().getHost();
|
||||||
String systemType = host.getSystemType();
|
String systemType = host.getSystemType();
|
||||||
if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) {
|
if (systemType.equals(IRSESystemType.SYSTEMTYPE_WINDOWS)) {
|
||||||
result = false;
|
result = false;
|
||||||
|
|
|
@ -440,7 +440,7 @@ public class RexecDstoreServer implements IServerLauncher
|
||||||
rxOut.flush();
|
rxOut.flush();
|
||||||
|
|
||||||
// send userid and password on rexec socket
|
// send userid and password on rexec socket
|
||||||
rxOut.writeBytes(signonInfo.getUserid());
|
rxOut.writeBytes(signonInfo.getUserId());
|
||||||
rxOut.writeByte(0); // send null terminator
|
rxOut.writeByte(0); // send null terminator
|
||||||
rxOut.writeBytes(signonInfo.getPassword());
|
rxOut.writeBytes(signonInfo.getPassword());
|
||||||
rxOut.writeByte(0); // send null terminator
|
rxOut.writeByte(0); // send null terminator
|
||||||
|
|
|
@ -294,9 +294,9 @@ public class SshConnectorService extends AbstractConnectorService implements ISs
|
||||||
//session.setTimeout(getSshTimeoutInMillis());
|
//session.setTimeout(getSshTimeoutInMillis());
|
||||||
session.setTimeout(0); //never time out on the session
|
session.setTimeout(0); //never time out on the session
|
||||||
String password=""; //$NON-NLS-1$
|
String password=""; //$NON-NLS-1$
|
||||||
SystemSignonInformation ssi = getPasswordInformation();
|
SystemSignonInformation ssi = getSignonInformation();
|
||||||
if (ssi!=null) {
|
if (ssi!=null) {
|
||||||
password = getPasswordInformation().getPassword();
|
password = getSignonInformation().getPassword();
|
||||||
}
|
}
|
||||||
session.setPassword(password);
|
session.setPassword(password);
|
||||||
MyUserInfo userInfo = new MyUserInfo(user, password);
|
MyUserInfo userInfo = new MyUserInfo(user, password);
|
||||||
|
@ -352,7 +352,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
|
||||||
clearPassword(false); // clear in-memory password
|
clearPassword(false, true); // clear in-memory password
|
||||||
//clearUserIdCache(); // Clear any cached local user IDs
|
//clearUserIdCache(); // Clear any cached local user IDs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -706,14 +706,6 @@ public class SshConnectorService extends AbstractConnectorService implements ISs
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return false
|
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
|
|
||||||
*/
|
|
||||||
public boolean requiresPassword() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ICredentialsProvider getCredentialsProvider() {
|
protected ICredentialsProvider getCredentialsProvider() {
|
||||||
if (credentialsProvider == null) {
|
if (credentialsProvider == null) {
|
||||||
credentialsProvider = new SshCredentialsProvider(this);
|
credentialsProvider = new SshCredentialsProvider(this);
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class PasswordPersistenceManager {
|
||||||
*/
|
*/
|
||||||
public void remove(SystemSignonInformation info)
|
public void remove(SystemSignonInformation info)
|
||||||
{
|
{
|
||||||
remove(info.getSystemType(), info.getHostname(), info.getUserid());
|
remove(info.getSystemType(), info.getHostname(), info.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,11 +247,11 @@ public class PasswordPersistenceManager {
|
||||||
// Convert userid to upper case if required
|
// Convert userid to upper case if required
|
||||||
if (!isUserIDCaseSensitive(systemtype))
|
if (!isUserIDCaseSensitive(systemtype))
|
||||||
{
|
{
|
||||||
info.setUserid(info.getUserid().toUpperCase());
|
info.setUserId(info.getUserId().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
String hostname = info.getHostname();
|
String hostname = info.getHostname();
|
||||||
String userid = info.getUserid();
|
String userid = info.getUserId();
|
||||||
Map passwords = getPasswordMap(systemtype);
|
Map passwords = getPasswordMap(systemtype);
|
||||||
String passwordKey = getPasswordKey(hostname, userid);
|
String passwordKey = getPasswordKey(hostname, userid);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.rse.core.subsystems.ICredentials;
|
||||||
public final class SystemSignonInformation implements ICredentials {
|
public final class SystemSignonInformation implements ICredentials {
|
||||||
|
|
||||||
private String _hostname;
|
private String _hostname;
|
||||||
private String _userid;
|
private String _userId;
|
||||||
private String _systemType;
|
private String _systemType;
|
||||||
private String _password;
|
private String _password;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public final class SystemSignonInformation implements ICredentials {
|
||||||
*/
|
*/
|
||||||
public SystemSignonInformation(String hostname, String userid, String systemType) {
|
public SystemSignonInformation(String hostname, String userid, String systemType) {
|
||||||
_hostname = hostname;//RSEUIPlugin.getQualifiedHostName(hostname).toUpperCase();
|
_hostname = hostname;//RSEUIPlugin.getQualifiedHostName(hostname).toUpperCase();
|
||||||
_userid = userid;
|
_userId = userid;
|
||||||
_systemType = systemType;
|
_systemType = systemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public final class SystemSignonInformation implements ICredentials {
|
||||||
*/
|
*/
|
||||||
public SystemSignonInformation(String hostname, String userid, String password, String systemType) {
|
public SystemSignonInformation(String hostname, String userid, String password, String systemType) {
|
||||||
_hostname = hostname;//RSEUIPlugin.getQualifiedHostName(hostname).toUpperCase();
|
_hostname = hostname;//RSEUIPlugin.getQualifiedHostName(hostname).toUpperCase();
|
||||||
_userid = userid;
|
_userId = userid;
|
||||||
_password = password;
|
_password = password;
|
||||||
_systemType = systemType;
|
_systemType = systemType;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ public final class SystemSignonInformation implements ICredentials {
|
||||||
* Returns the userid for the remote system
|
* Returns the userid for the remote system
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String getUserid() {
|
public String getUserId() {
|
||||||
return _userid;
|
return _userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,10 +114,10 @@ public final class SystemSignonInformation implements ICredentials {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the userid.
|
* Sets the userid.
|
||||||
* @param userid The userid to set
|
* @param userId The userid to set
|
||||||
*/
|
*/
|
||||||
public void setUserid(String userid) {
|
public void setUserId(String userId) {
|
||||||
_userid = userid;
|
_userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,9 +7,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService
|
* David Dykstal (IBM) - 168977: refactoring IConnectorService
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.subsystems;
|
package org.eclipse.rse.core.subsystems;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link BasicCredentialsProvider} provides a simple implementation of the {@link ICredentialsProvider}
|
* The {@link BasicCredentialsProvider} provides a simple implementation of the {@link ICredentialsProvider}
|
||||||
|
@ -19,27 +19,65 @@ package org.eclipse.rse.core.subsystems;
|
||||||
* This class is not meant to be subclassed.
|
* This class is not meant to be subclassed.
|
||||||
*/
|
*/
|
||||||
public class BasicCredentialsProvider implements ICredentialsProvider {
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void acquireCredentials(boolean reacquire) {
|
public void acquireCredentials(boolean reacquire) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCredentials() {
|
public void clearCredentials() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearPassword() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICredentials getCredentials() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuppressed() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repairCredentials(SystemMessage message) throws InterruptedException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean requiresPassword() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean requiresUserId() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuppressed(boolean suppressed) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supportsPassword() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supportsUserId() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConnectorService getConnectorService() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,11 +118,6 @@ public interface IConnectorService extends IRSEModelObject {
|
||||||
*/
|
*/
|
||||||
public String getHostType();
|
public String getHostType();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name of this connector service
|
|
||||||
*/
|
|
||||||
public String getName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the host used by this connector service.
|
* Sets the host used by this connector service.
|
||||||
* @param host
|
* @param host
|
||||||
|
@ -182,24 +177,6 @@ public interface IConnectorService extends IRSEModelObject {
|
||||||
*/
|
*/
|
||||||
public boolean supportsPassword();
|
public boolean supportsPassword();
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports if this connector service requires a user id.
|
|
||||||
* Returns true in default implementation.
|
|
||||||
* Typically used to indicate if a login dialog can allow an empty user id.
|
|
||||||
* Must be ignored if supportsUserId() is false.
|
|
||||||
* @return true or false to indicate if the connector service requires a user id.
|
|
||||||
*/
|
|
||||||
public boolean requiresUserId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if a password is required for this connector service.
|
|
||||||
* Must be ignored if {@link #supportsPassword()} returns false.
|
|
||||||
* The default implementation of this interface should return true.
|
|
||||||
* @return true if the connector service requires a password,
|
|
||||||
* false if a password may be empty.
|
|
||||||
*/
|
|
||||||
public boolean requiresPassword();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the userId that will be used by this connector when
|
* @return the userId that will be used by this connector when
|
||||||
* establishing its connection.
|
* establishing its connection.
|
||||||
|
@ -213,6 +190,10 @@ public interface IConnectorService extends IRSEModelObject {
|
||||||
*/
|
*/
|
||||||
public void setUserId(String userId);
|
public void setUserId(String userId);
|
||||||
|
|
||||||
|
public void saveUserId();
|
||||||
|
|
||||||
|
public void removeUserId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the password used by this connector service.
|
* Sets the password used by this connector service.
|
||||||
* Can be used if the connector service acquires a password by some external
|
* Can be used if the connector service acquires a password by some external
|
||||||
|
@ -220,17 +201,23 @@ public interface IConnectorService extends IRSEModelObject {
|
||||||
* @param matchingUserId The user id to be associated with this password.
|
* @param matchingUserId The user id to be associated with this password.
|
||||||
* @param password the password
|
* @param password the password
|
||||||
* @param persist true if the password is to be persisted for later use.
|
* @param persist true if the password is to be persisted for later use.
|
||||||
|
* @param propagate true if this password should be propagated to related connector services.
|
||||||
*/
|
*/
|
||||||
public void setPassword(String matchingUserId, String password, boolean persist);
|
public void setPassword(String matchingUserId, String password, boolean persist, boolean propagate);
|
||||||
|
|
||||||
|
public void savePassword();
|
||||||
|
|
||||||
|
public void removePassword();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear password held by this service and optionally
|
* Clear password held by this service and optionally
|
||||||
* clear its persistent form.
|
* clear its persistent form.
|
||||||
* Called when user uses the property dialog to
|
* Called when user uses the property dialog to
|
||||||
* change his userId.
|
* change his userId.
|
||||||
* @param onDisk if true, clears the persistent form of the password
|
* @param persist if true, clears the persistent form of the password
|
||||||
|
* @param propagate true if this password should be cleared in related connector services.
|
||||||
*/
|
*/
|
||||||
public void clearPassword(boolean onDisk);
|
public void clearPassword(boolean persist, boolean propagate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param onDisk retrieve the persistent form of the password.
|
* @param onDisk retrieve the persistent form of the password.
|
||||||
|
|
|
@ -10,4 +10,9 @@
|
||||||
package org.eclipse.rse.core.subsystems;
|
package org.eclipse.rse.core.subsystems;
|
||||||
|
|
||||||
public interface ICredentials {
|
public interface ICredentials {
|
||||||
|
|
||||||
|
String getPassword();
|
||||||
|
|
||||||
|
String getUserId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,38 @@
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
package org.eclipse.rse.core.subsystems;
|
package org.eclipse.rse.core.subsystems;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
|
|
||||||
public interface ICredentialsProvider {
|
public interface ICredentialsProvider {
|
||||||
|
|
||||||
boolean supportsPassword();
|
void acquireCredentials(boolean reacquire) throws InterruptedException;
|
||||||
|
|
||||||
boolean supportsUserId();
|
void clearCredentials();
|
||||||
|
|
||||||
|
void clearPassword();
|
||||||
|
|
||||||
|
ICredentials getCredentials();
|
||||||
|
|
||||||
|
String getUserId();
|
||||||
|
|
||||||
|
boolean isSuppressed();
|
||||||
|
|
||||||
|
void repairCredentials(SystemMessage message)throws InterruptedException;
|
||||||
|
|
||||||
boolean requiresPassword();
|
boolean requiresPassword();
|
||||||
|
|
||||||
boolean requiresUserId();
|
boolean requiresUserId();
|
||||||
|
|
||||||
void acquireCredentials(boolean reacquire);
|
void setPassword(String password);
|
||||||
|
|
||||||
void clearCredentials();
|
void setSuppressed(boolean suppressed);
|
||||||
|
|
||||||
|
void setUserId(String userId);
|
||||||
|
|
||||||
|
boolean supportsPassword();
|
||||||
|
|
||||||
|
boolean supportsUserId();
|
||||||
|
|
||||||
|
IConnectorService getConnectorService();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,9 @@ public class FTPConnectorService extends AbstractConnectorService
|
||||||
_propertySet.addProperty("passive","false",PropertyType.getEnumPropertyType(new String[]{"true","false"})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
_propertySet.addProperty("passive","false",PropertyType.getEnumPropertyType(new String[]{"true","false"})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemSignonInformation info = getPasswordInformation();
|
SystemSignonInformation info = getSignonInformation();
|
||||||
_ftpService.setHostName(info.getHostname());
|
_ftpService.setHostName(info.getHostname());
|
||||||
_ftpService.setUserId(info.getUserid());
|
_ftpService.setUserId(info.getUserId());
|
||||||
_ftpService.setPassword(info.getPassword());
|
_ftpService.setPassword(info.getPassword());
|
||||||
_ftpService.setPortNumber(getPort());
|
_ftpService.setPortNumber(getPort());
|
||||||
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class SystemClearAllPasswordsAction extends SystemBaseAction {
|
||||||
|
|
||||||
// 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.clearPassword(true);
|
system.clearPassword(true, 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()));
|
||||||
|
|
|
@ -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.clearPassword(true);
|
system.clearPassword(true, 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()));
|
||||||
|
|
|
@ -183,12 +183,12 @@ public final class SystemPasswordPersistencePrompt extends SystemPromptDialog im
|
||||||
|
|
||||||
if (change)
|
if (change)
|
||||||
{
|
{
|
||||||
if (exists(signonInfo.getHostname(), signonInfo.getUserid(), signonInfo.getSystemType()))
|
if (exists(signonInfo.getHostname(), signonInfo.getUserId(), signonInfo.getSystemType()))
|
||||||
{
|
{
|
||||||
if (!signonInfo.getSystemType().equals(originalSystemType) ||
|
if (!signonInfo.getSystemType().equals(originalSystemType) ||
|
||||||
!signonInfo.getHostname().equalsIgnoreCase(originalHostname) ||
|
!signonInfo.getHostname().equalsIgnoreCase(originalHostname) ||
|
||||||
//!signonInfo.getHostname().equalsIgnoreCase(RSEUIPlugin.getQualifiedHostName(originalHostname)) ||
|
//!signonInfo.getHostname().equalsIgnoreCase(RSEUIPlugin.getQualifiedHostName(originalHostname)) ||
|
||||||
!signonInfo.getUserid().equals(originalUserid))
|
!signonInfo.getUserId().equals(originalUserid))
|
||||||
{
|
{
|
||||||
// User changed hostname, systemtype or userid and the change conflicts with an existing entry
|
// User changed hostname, systemtype or userid and the change conflicts with an existing entry
|
||||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_EXISTS);
|
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_EXISTS);
|
||||||
|
@ -203,7 +203,7 @@ public final class SystemPasswordPersistencePrompt extends SystemPromptDialog im
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Adding a new entry, make sure it doesn't already exist
|
// Adding a new entry, make sure it doesn't already exist
|
||||||
if (exists(signonInfo.getHostname(), signonInfo.getUserid(), signonInfo.getSystemType()))
|
if (exists(signonInfo.getHostname(), signonInfo.getUserId(), signonInfo.getSystemType()))
|
||||||
{
|
{
|
||||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_EXISTS);
|
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_PWD_EXISTS);
|
||||||
msg.makeSubstitution(sUserID, sHostName);
|
msg.makeSubstitution(sUserID, sHostName);
|
||||||
|
@ -234,11 +234,11 @@ public final class SystemPasswordPersistencePrompt extends SystemPromptDialog im
|
||||||
{
|
{
|
||||||
if (!manager.isUserIDCaseSensitive(info.getSystemType()))
|
if (!manager.isUserIDCaseSensitive(info.getSystemType()))
|
||||||
{
|
{
|
||||||
found = userID.equalsIgnoreCase(info.getUserid());
|
found = userID.equalsIgnoreCase(info.getUserId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
found = userID.equals(info.getUserid());
|
found = userID.equals(info.getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public final class SignonPreferencePage extends PreferencePage implements IWorkb
|
||||||
return ((SystemSignonInformation) element).getSystemType();
|
return ((SystemSignonInformation) element).getSystemType();
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return ((SystemSignonInformation) element).getUserid();
|
return ((SystemSignonInformation) element).getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should never get here
|
// Should never get here
|
||||||
|
@ -281,7 +281,7 @@ public final class SignonPreferencePage extends PreferencePage implements IWorkb
|
||||||
SystemPasswordPersistencePrompt dialog = new SystemPasswordPersistencePrompt(getShell(), SystemResources.RESID_PREF_SIGNON_CHANGE_DIALOG_TITLE, passwords, true);
|
SystemPasswordPersistencePrompt dialog = new SystemPasswordPersistencePrompt(getShell(), SystemResources.RESID_PREF_SIGNON_CHANGE_DIALOG_TITLE, passwords, true);
|
||||||
int index = pwdTable.getSelectionIndex();
|
int index = pwdTable.getSelectionIndex();
|
||||||
SystemSignonInformation info = (SystemSignonInformation) passwords.get(index);
|
SystemSignonInformation info = (SystemSignonInformation) passwords.get(index);
|
||||||
dialog.setInputData(info.getSystemType(), info.getHostname(), info.getUserid());
|
dialog.setInputData(info.getSystemType(), info.getHostname(), info.getUserId());
|
||||||
if (dialog.open() == Window.OK)
|
if (dialog.open() == Window.OK)
|
||||||
{
|
{
|
||||||
// Remove old and add new
|
// Remove old and add new
|
||||||
|
@ -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.clearPassword(false);
|
system.clearPassword(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2549,7 +2549,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven
|
||||||
{
|
{
|
||||||
subsystems[idx].getConnectorService().clearCredentials();
|
subsystems[idx].getConnectorService().clearCredentials();
|
||||||
}
|
}
|
||||||
subsystems[idx].getConnectorService().clearPassword(false);
|
subsystems[idx].getConnectorService().clearPassword(false, true);
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,35 +13,19 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
|
* David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.subsystems;
|
package org.eclipse.rse.core.subsystems;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.rse.core.IRSEUserIdConstants;
|
import org.eclipse.rse.core.IRSEUserIdConstants;
|
||||||
import org.eclipse.rse.core.PasswordPersistenceManager;
|
import org.eclipse.rse.core.PasswordPersistenceManager;
|
||||||
import org.eclipse.rse.core.SystemBasePlugin;
|
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.core.model.SystemSignonInformation;
|
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||||
import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter;
|
|
||||||
import org.eclipse.rse.logging.Logger;
|
|
||||||
import org.eclipse.rse.logging.LoggerFactory;
|
|
||||||
import org.eclipse.rse.model.ISystemRegistryUI;
|
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.RSEUIPlugin;
|
||||||
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;
|
|
||||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
|
||||||
import org.eclipse.rse.ui.validators.ISystemValidator;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a base class to make it easier to create connector service classes.
|
* This is a base class to make it easier to create connector service classes.
|
||||||
|
@ -72,83 +56,43 @@ import org.eclipse.ui.PlatformUI;
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager
|
* @see org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractConnectorService extends SuperAbstractConnectorService implements IRSEUserIdConstants
|
public abstract class AbstractConnectorService extends SuperAbstractConnectorService implements IRSEUserIdConstants {
|
||||||
{
|
public AbstractConnectorService(String name, String description, IHost host, int port) {
|
||||||
|
|
||||||
private String _userId;
|
|
||||||
private transient SystemSignonInformation _passwordInfo;
|
|
||||||
protected Shell shell;
|
|
||||||
// dy: March 24, 2003 Added _suppressSignonPrompt flag to suppress prompting the
|
|
||||||
// user to signon if they already cancelled signon. Then intent is to allows tools
|
|
||||||
// writers to prevent multiple signon prompts during a "transaction" if the user cancel
|
|
||||||
// the first signon prompt
|
|
||||||
private boolean _suppressSignonPrompt = false;
|
|
||||||
|
|
||||||
|
|
||||||
public AbstractConnectorService(String name, String description, IHost host, int port)
|
|
||||||
{
|
|
||||||
super(name, description, host, port);
|
super(name, description, host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
||||||
* Returns the active userId if we are connected.
|
* Returns the active userId if we are connected.
|
||||||
* If not it returns the userId for the primary subsystem ignoring the
|
* If not it returns the userId for the primary subsystem ignoring the
|
||||||
* cached userId.
|
* cached userId.
|
||||||
*/
|
*/
|
||||||
final public String getUserId() {
|
final public String getUserId() {
|
||||||
String result = null;
|
return getCredentialsProvider().getUserId();
|
||||||
if (supportsUserId()) {
|
|
||||||
result = getLocalUserId();
|
|
||||||
if (result == null) {
|
|
||||||
result = getSubSystemUserId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
|
||||||
* Return the userId for this connector service. If there is none
|
|
||||||
* set for this service then it is retrieved from the primary subsystem.
|
|
||||||
*/
|
|
||||||
final protected String getLocalUserId() {
|
|
||||||
return _userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the userId from the primary subsystem.
|
|
||||||
*/
|
|
||||||
private String getSubSystemUserId() {
|
|
||||||
ISubSystem ss = getPrimarySubSystem();
|
|
||||||
String result = ss.getUserId();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.rse.core.subsystems.IConnectorService#setUserId(java.lang.String)
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#setUserId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
final public void setUserId(String newId)
|
final public void setUserId(String newId) {
|
||||||
{
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
|
String oldUserId = provider.getUserId();
|
||||||
if (_userId == null || !_userId.equals(newId)) {
|
if (oldUserId == null || oldUserId.equals(newId)) {
|
||||||
_userId = newId;
|
updateDefaultUserId(getPrimarySubSystem(), getUserId());
|
||||||
|
provider.setUserId(newId);
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public final void saveUserId() {
|
||||||
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
* Clear internal userId. Called when user uses the property dialog to
|
String userId = provider.getUserId();
|
||||||
* change his userId. By default, sets internal userId value to null so that on
|
updateDefaultUserId(getPrimarySubSystem(), userId);
|
||||||
* the next call to getUserId() it is requeried from subsystem.
|
}
|
||||||
* Also clears the password.
|
|
||||||
*/
|
public final void removeUserId() {
|
||||||
final public void clearCredentials() {
|
updateDefaultUserId(getPrimarySubSystem(), null);
|
||||||
_userId = null;
|
|
||||||
clearPassword(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,22 +100,18 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
||||||
* 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 this is true, clear the password from the disk cache as well
|
* @param persist if this is true, clear the password from the disk cache as well
|
||||||
* @see #clearCredentials()
|
* @see #clearCredentials()
|
||||||
*/
|
*/
|
||||||
final public void clearPassword(boolean onDisk) {
|
final public void clearPassword(boolean persist, boolean propagate) {
|
||||||
setPasswordInformation(null);
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
String userId = getUserId();
|
provider.clearPassword();
|
||||||
if (onDisk) {
|
if (persist) {
|
||||||
// now get rid of userid/password from disk
|
removePassword();
|
||||||
String systemType = getHostType();
|
|
||||||
String hostName = getHostName();
|
|
||||||
if (userId != null)
|
|
||||||
PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId);
|
|
||||||
}
|
}
|
||||||
if (sharesCredentials()) {
|
if (sharesCredentials() && propagate) {
|
||||||
// clear this uid/password with other ISystems in connection
|
String userId = provider.getUserId();
|
||||||
clearPasswordForOtherSystemsInConnection(userId, onDisk);
|
clearPasswordForOtherSystemsInConnection(userId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,9 +124,9 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
||||||
* @return true if the password is known, false otherwise.
|
* @return true if the password is known, false otherwise.
|
||||||
*/
|
*/
|
||||||
final public boolean hasPassword(boolean onDisk) {
|
final public boolean hasPassword(boolean onDisk) {
|
||||||
boolean cached = (getPasswordInformation() != null);
|
SystemSignonInformation signonInformation = getSignonInformation();
|
||||||
|
boolean cached = (signonInformation != null && signonInformation.getPassword() != null);
|
||||||
if (!cached && onDisk) {
|
if (!cached && onDisk) {
|
||||||
// now check if cached on disk
|
|
||||||
String systemType = getHostType();
|
String systemType = getHostType();
|
||||||
String hostName = getHostName();
|
String hostName = getHostName();
|
||||||
String userId = getUserId();
|
String userId = getUserId();
|
||||||
|
@ -196,530 +136,191 @@ public abstract class AbstractConnectorService extends SuperAbstractConnectorSer
|
||||||
}
|
}
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.rse.core.subsystems.IConnectorService#requiresPassword()
|
|
||||||
*/
|
|
||||||
public boolean requiresPassword() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.rse.core.subsystems.IConnectorService#requiresUserId()
|
|
||||||
*/
|
|
||||||
public boolean requiresUserId() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <i>Do not override.</i>
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
* Sets the signon information for this connector service.
|
* Set the password if you got it from somewhere
|
||||||
* The search order for the password is as follows:</p>
|
* @param userId the user for which to set the password
|
||||||
* <ol>
|
* @param password the password to set for this userId
|
||||||
* <li>First check if the password is already known by this connector service and that it is still valid.
|
* @param persist true if the password is to be persisted,
|
||||||
* <li>If password not known then look in the password store and verify that it is still valid.
|
* false if its persistent form is to be removed.
|
||||||
* <li>If a valid password is not found then prompt the user.
|
* @param propagate if the password should be propagated to related connector services.
|
||||||
* </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 acquireCredentials(boolean forcePrompt) throws InterruptedException {
|
public final void setPassword(String userId, String password, boolean persist, boolean propagate) {
|
||||||
// dy: March 24, 2003: check if prompting is temporarily suppressed by a tool
|
if (getPrimarySubSystem().forceUserIdToUpperCase()) {
|
||||||
// vendor, this should only be suppressed if the user cancelled a previous signon
|
userId = userId.toUpperCase();
|
||||||
// dialog (or some other good reason)
|
|
||||||
if (isSuppressed()) {
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
}
|
||||||
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
ISubSystem subsystem = getPrimarySubSystem();
|
String myUserId = provider.getUserId();
|
||||||
IHost host = subsystem.getHost();
|
IHost host = getHost();
|
||||||
String hostName = host.getHostName();
|
if (host.compareUserIds(userId, myUserId)) {
|
||||||
String hostType = host.getSystemType();
|
provider.setPassword(password);
|
||||||
boolean savePassword = false;
|
|
||||||
if (_passwordInfo == null) {
|
|
||||||
_passwordInfo = new SystemSignonInformation(hostName, null, null, hostType);
|
|
||||||
}
|
}
|
||||||
if (supportsUserId()) {
|
if (sharesCredentials() && propagate) {
|
||||||
String userId = getUserId();
|
updatePasswordForOtherSystemsInConnection(userId, password, persist);
|
||||||
if (_passwordInfo.getUserid() == null) {
|
|
||||||
_passwordInfo.setUserid(userId);
|
|
||||||
}
|
|
||||||
boolean sameUserId = host.compareUserIds(userId, _passwordInfo.getUserid());
|
|
||||||
boolean sameHost = hostName.equalsIgnoreCase(_passwordInfo.getHostname());
|
|
||||||
if (!(sameHost && sameUserId)) {
|
|
||||||
_passwordInfo.setPassword(null);
|
|
||||||
_passwordInfo.setUserid(userId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (supportsPassword()) {
|
if (persist) {
|
||||||
if (_passwordInfo.getPassword() == null) {
|
savePassword();
|
||||||
PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
|
} else {
|
||||||
String userId = _passwordInfo.getUserid();
|
removePassword();
|
||||||
SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, userId);
|
|
||||||
if (savedPasswordInformation != null) {
|
|
||||||
_passwordInfo = savedPasswordInformation;
|
|
||||||
savePassword = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
if (shell == null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
shell = SystemBasePlugin.getActiveWorkbenchShell();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
shell = new Shell();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsPassword() || supportsUserId())
|
|
||||||
{
|
|
||||||
if (shell == null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
shell = new Shell();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (shell != null) {
|
|
||||||
boolean passwordNeeded = supportsPassword() && _passwordInfo.getPassword() == null;
|
|
||||||
boolean userIdNeeded = supportsUserId() && _passwordInfo.getUserid() == null;
|
|
||||||
if (passwordNeeded || userIdNeeded || forcePrompt) {
|
|
||||||
ISystemPasswordPromptDialog dialog = getPasswordPromptDialog(shell);
|
|
||||||
if (dialog != null) {
|
|
||||||
dialog.setSystemInput(this);
|
|
||||||
dialog.setSignonValidator(getSignonValidator());
|
|
||||||
if (supportsUserId()) {
|
|
||||||
dialog.setUserIdValidator(getUserIdValidator());
|
|
||||||
}
|
|
||||||
if (supportsPassword()) {
|
|
||||||
String password = _passwordInfo.getPassword();
|
|
||||||
dialog.setSavePassword(savePassword);
|
|
||||||
dialog.setPassword(password);
|
|
||||||
dialog.setPasswordValidator(getPasswordValidator());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
dialog.open();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logException(e);
|
|
||||||
}
|
|
||||||
if (dialog.wasCancelled()) {
|
|
||||||
_passwordInfo = null;
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
String userId = dialog.getUserId();
|
|
||||||
boolean userIdChanged = dialog.getIsUserIdChanged();
|
|
||||||
boolean saveUserId = dialog.getIsUserIdChangePermanent();
|
|
||||||
String password = dialog.getPassword();
|
|
||||||
savePassword = dialog.getIsSavePassword();
|
|
||||||
if (supportsUserId() && userIdChanged) {
|
|
||||||
if (saveUserId) {
|
|
||||||
updateDefaultUserId(subsystem, userId);
|
|
||||||
} else {
|
|
||||||
setUserId(userId);
|
|
||||||
_passwordInfo.setUserid(userId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (supportsPassword()) {
|
|
||||||
setPassword(userId, password, savePassword);
|
|
||||||
if (sharesCredentials()) {
|
|
||||||
updatePasswordForOtherSystemsInConnection(userId, password, savePassword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void savePassword() {
|
||||||
protected void clearPasswordForOtherSystemsInConnection(String uid, boolean fromDisk)
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
{
|
ICredentials credentials = provider.getCredentials();
|
||||||
if (uid != null)
|
if (credentials instanceof SystemSignonInformation) {
|
||||||
{
|
SystemSignonInformation signonInformation = (SystemSignonInformation) credentials;
|
||||||
IHost connection = getHost();
|
PasswordPersistenceManager.getInstance().add(signonInformation, true, true);
|
||||||
ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
|
|
||||||
ISubSystem[] subsystems = registry.getSubSystems(connection);
|
|
||||||
|
|
||||||
List uniqueSystems = new ArrayList();
|
|
||||||
for (int i = 0; i < subsystems.length; i++)
|
|
||||||
{
|
|
||||||
IConnectorService system = subsystems[i].getConnectorService();
|
|
||||||
if (system != this && system.inheritsCredentials())
|
|
||||||
{
|
|
||||||
if (!uniqueSystems.contains(system))
|
|
||||||
{
|
|
||||||
uniqueSystems.add(system);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int s = 0; s < uniqueSystems.size(); s++)
|
|
||||||
{
|
|
||||||
IConnectorService system = (IConnectorService)uniqueSystems.get(s);
|
|
||||||
if (system.hasPassword(fromDisk))
|
|
||||||
{
|
|
||||||
system.clearPassword(fromDisk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void updatePasswordForOtherSystemsInConnection(String uid, String password, boolean persistPassword)
|
|
||||||
{
|
|
||||||
IHost connection = getPrimarySubSystem().getHost();
|
|
||||||
ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
|
|
||||||
ISubSystem[] subsystems = registry.getSubSystems(connection);
|
|
||||||
|
|
||||||
List uniqueSystems = new ArrayList();
|
|
||||||
for (int i = 0; i < subsystems.length; i++)
|
|
||||||
{
|
|
||||||
IConnectorService system = subsystems[i].getConnectorService();
|
|
||||||
if (system != this && system.inheritsCredentials())
|
|
||||||
{
|
|
||||||
if (!uniqueSystems.contains(system))
|
|
||||||
{
|
|
||||||
uniqueSystems.add(system);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int s = 0; s < uniqueSystems.size(); s++)
|
|
||||||
{
|
|
||||||
IConnectorService system = (IConnectorService)uniqueSystems.get(s);
|
|
||||||
if (!system.isConnected() && !system.hasPassword(false))
|
|
||||||
{
|
|
||||||
if (system.getPrimarySubSystem().forceUserIdToUpperCase())
|
|
||||||
{
|
|
||||||
system.setPassword(uid.toUpperCase(), password.toUpperCase(), persistPassword);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
system.setPassword(uid, password, persistPassword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the default user Id value in the SubSystem if it is non-null, else
|
|
||||||
* update it in the Connection object
|
|
||||||
*/
|
|
||||||
private void updateDefaultUserId(ISubSystem subsystem, String userId) {
|
|
||||||
String ssLocalUserId = subsystem.getLocalUserId();
|
|
||||||
if (ssLocalUserId != null) { // defect 42709
|
|
||||||
ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
|
|
||||||
ssc.updateSubSystem(subsystem, true, userId, false, 0);
|
|
||||||
} else { // it seems intuitive to update the connection object. defect 42709. Phil
|
|
||||||
int whereToUpdate = IRSEUserIdConstants.USERID_LOCATION_HOST;
|
|
||||||
IHost conn = subsystem.getHost();
|
|
||||||
ISystemRegistryUI sr = RSEUIPlugin.getDefault().getSystemRegistry();
|
|
||||||
sr.updateHost(null, conn, conn.getSystemType(), conn.getAliasName(), conn.getHostName(), conn.getDescription(), userId, whereToUpdate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public final void removePassword() {
|
||||||
* <i>A default implementation is supplied, but can be overridden if desired.</i><br>
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
* Instantiates and returns the dialog to prompt for the userId and password.
|
String systemType = getHostType();
|
||||||
* <p>
|
String hostName = getHostName();
|
||||||
* By default returns an instance of SystemPasswordPromptDialog. Calls forcePasswordToUpperCase() to decide whether the user Id and password should be folded to uppercase.
|
String userId = provider.getUserId();
|
||||||
* <p>
|
PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId);
|
||||||
* Calls {@link #getUserIdValidator()} and {@link #getPasswordValidator()} to set the validators. These return null by default by you can override them.
|
}
|
||||||
* <p>
|
|
||||||
* Before calling open() on the dialog, the getPassword(Shell) method that calls this will call setSystemInput(this).
|
|
||||||
* <p>
|
|
||||||
* After return, it will call wasCancelled() and getUserId(), getIsUserIdChanged(), getIsUserIdChangePermanent() and getPassword().
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @return An instance of a dialog class that implements the ISystemPasswordPromptDialog interface
|
|
||||||
*/
|
|
||||||
protected final ISystemPasswordPromptDialog getPasswordPromptDialog(Shell shell)
|
|
||||||
{
|
|
||||||
ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell, requiresUserId(), requiresPassword());
|
|
||||||
dlg.setForceToUpperCase(forcePasswordToUpperCase());
|
|
||||||
dlg.setUserIdValidator(getUserIdValidator());
|
|
||||||
dlg.setPasswordValidator(getPasswordValidator());
|
|
||||||
dlg.setSignonValidator(getSignonValidator());
|
|
||||||
return dlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This connection method wrappers the others (internal connect) so that registered subsystems
|
||||||
|
* can be notified and initialized after a connect
|
||||||
|
* Previous implementations that overrode this method should now change
|
||||||
|
* their connect() method to internalConnect()
|
||||||
|
*/
|
||||||
|
public final void connect(IProgressMonitor monitor) throws Exception {
|
||||||
|
internalConnect(monitor);
|
||||||
|
intializeSubSystems(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects from the remote system.
|
||||||
|
* <p>
|
||||||
|
* You must override
|
||||||
|
* if <code>subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties</code>
|
||||||
|
* returns false.
|
||||||
|
* <p>
|
||||||
|
* If the subsystem supports server launch
|
||||||
|
* the default behavior is to use the same remote server
|
||||||
|
* launcher created in <code>connect()</code> and call <code>disconnect()</code>.
|
||||||
|
* <p>
|
||||||
|
* This is called, by default, from the <code>disconnect()</code>
|
||||||
|
* method of the subsystem.
|
||||||
|
* @see IServerLauncher#disconnect()
|
||||||
|
*/
|
||||||
|
public final void disconnect(IProgressMonitor monitor) throws Exception {
|
||||||
|
internalDisconnect(monitor);
|
||||||
|
unintializeSubSystems(monitor);
|
||||||
|
clearPassword(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#isSuppressed()
|
||||||
|
*/
|
||||||
|
public final boolean isSuppressed() {
|
||||||
|
return getCredentialsProvider().isSuppressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#setSuppressed(boolean)
|
||||||
|
*/
|
||||||
|
public final void setSuppressed(boolean suppressed) {
|
||||||
|
getCredentialsProvider().setSuppressed(suppressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void acquireCredentials(boolean reacquire) throws InterruptedException {
|
||||||
|
getCredentialsProvider().acquireCredentials(reacquire);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
||||||
|
* 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 clears the password.
|
||||||
|
*/
|
||||||
|
final public void clearCredentials() {
|
||||||
|
getCredentialsProvider().clearCredentials();
|
||||||
|
setDirty(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
* @return the password information for the primary subsystem of this
|
* @return the password information for the primary subsystem of this
|
||||||
* connector service. Assumes it has been set by the subsystem at the
|
* connector service. Assumes it has been set by the subsystem at the
|
||||||
* time the subsystem acquires the connector service.
|
* time the subsystem acquires the connector service.
|
||||||
*/
|
*/
|
||||||
final protected SystemSignonInformation getPasswordInformation() {
|
final protected SystemSignonInformation getSignonInformation() {
|
||||||
return _passwordInfo;
|
SystemSignonInformation result = null;
|
||||||
|
ICredentialsProvider provider = getCredentialsProvider();
|
||||||
|
ICredentials credentials = provider.getCredentials();
|
||||||
|
result = (SystemSignonInformation) credentials;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void updatePasswordForOtherSystemsInConnection(String uid, String password, boolean persist) {
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
IHost connection = getPrimarySubSystem().getHost();
|
||||||
* Sets the password information for this system's subsystem.
|
ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
|
||||||
* @param passwordInfo the password information object
|
ISubSystem[] subsystems = registry.getSubSystems(connection);
|
||||||
*/
|
List uniqueSystems = new ArrayList();
|
||||||
final protected void setPasswordInformation(SystemSignonInformation passwordInfo) {
|
for (int i = 0; i < subsystems.length; i++) {
|
||||||
_passwordInfo = passwordInfo;
|
IConnectorService cs = subsystems[i].getConnectorService();
|
||||||
if (passwordInfo != null) {
|
if (cs != this && cs.inheritsCredentials()) {
|
||||||
_userId = passwordInfo.getUserid();
|
if (!uniqueSystems.contains(cs)) {
|
||||||
}
|
uniqueSystems.add(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
|
||||||
* Set the password if you got it from somewhere
|
|
||||||
* @param matchingUserId the user for which to set the password
|
|
||||||
* @param password the password to set for this userid
|
|
||||||
* @param persist true if the password is to be persisted as well
|
|
||||||
*/
|
|
||||||
public void setPassword(String matchingUserId, String password, boolean persist) {
|
|
||||||
if (getPrimarySubSystem().forceUserIdToUpperCase()) {
|
|
||||||
matchingUserId = matchingUserId.toUpperCase();
|
|
||||||
}
|
|
||||||
SystemSignonInformation tempPasswordInfo = new SystemSignonInformation(getHostName(), matchingUserId, password, getHostType());
|
|
||||||
setPasswordInformation(tempPasswordInfo);
|
|
||||||
if (persist) { // if password should be persisted, then add to disk
|
|
||||||
PasswordPersistenceManager.getInstance().add(tempPasswordInfo, true, true);
|
|
||||||
} else { // otherwise, remove from both memory and disk
|
|
||||||
String systemType = getHostType();
|
|
||||||
String hostName = getHostName();
|
|
||||||
PasswordPersistenceManager.getInstance().remove(systemType, hostName, _userId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
|
||||||
* Should passwords be folded to uppercase?
|
|
||||||
* By default, returns:
|
|
||||||
* <pre><code>getSubSystem().forceUserIdToUpperCase()</code></pre>
|
|
||||||
*/
|
|
||||||
protected boolean forcePasswordToUpperCase()
|
|
||||||
{
|
|
||||||
return getPrimarySubSystem().forceUserIdToUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
|
||||||
* Get the userId input validator to use in the password dialog prompt.
|
|
||||||
* <p>
|
|
||||||
* By default, returns </p>
|
|
||||||
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getUserIdValidator()</code></pre>
|
|
||||||
*/
|
|
||||||
final public ISystemValidator getUserIdValidator()
|
|
||||||
{
|
|
||||||
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
|
||||||
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
|
||||||
return adapter.getUserIdValidator(ssFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
|
||||||
* Get the password input validator to use in the password dialog prompt.
|
|
||||||
* <p>
|
|
||||||
* By default, returns:</p>
|
|
||||||
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getPasswordValidator()</code></pre>
|
|
||||||
*/
|
|
||||||
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 ICredentialsValidator getSignonValidator()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This connection method wrappers the others (internal connect) so that registered subsystems
|
|
||||||
* can be notified and initialized after a connect
|
|
||||||
* Previous implementations that overrode this method should now change
|
|
||||||
* their connect() method to internalConnect()
|
|
||||||
*/
|
|
||||||
public final void connect(IProgressMonitor monitor) throws Exception
|
|
||||||
{
|
|
||||||
internalConnect(monitor);
|
|
||||||
intializeSubSystems(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// protected void internalConnect(IProgressMonitor monitor) throws Exception
|
|
||||||
// {
|
|
||||||
// if (supportsServerLaunchProperties())
|
|
||||||
// {
|
|
||||||
// IServerLauncher starter = getRemoteServerLauncher();
|
|
||||||
// starter.setSignonInformation(getPasswordInformation());
|
|
||||||
// starter.setServerLauncherProperties(getRemoteServerLauncherProperties());
|
|
||||||
// launchResult = null;
|
|
||||||
// if (!starter.isLaunched())
|
|
||||||
// {
|
|
||||||
// try {
|
|
||||||
// launchResult = starter.launch(monitor);
|
|
||||||
// } catch (Exception exc) {
|
|
||||||
// throw new java.lang.reflect.InvocationTargetException(exc);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// connectResult = null;
|
|
||||||
// try {
|
|
||||||
// connectResult = starter.connect(monitor, getConnectPort());
|
|
||||||
// } catch (Exception exc) {
|
|
||||||
// throw new java.lang.reflect.InvocationTargetException(exc);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/**
|
|
||||||
* Disconnects from the remote system.
|
|
||||||
* <p>
|
|
||||||
* You must override
|
|
||||||
* if <code>subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties</code>
|
|
||||||
* returns false.
|
|
||||||
* <p>
|
|
||||||
* If the subsystem supports server launch
|
|
||||||
* the default behavior is to use the same remote server
|
|
||||||
* launcher created in <code>connect()</code> and call <code>disconnect()</code>.
|
|
||||||
* <p>
|
|
||||||
* This is called, by default, from the <code>disconnect()</code>
|
|
||||||
* method of the subsystem.
|
|
||||||
* @see IServerLauncher#disconnect()
|
|
||||||
*/
|
|
||||||
public final void disconnect(IProgressMonitor monitor) throws Exception
|
|
||||||
{
|
|
||||||
internalDisconnect(monitor);
|
|
||||||
unintializeSubSystems(monitor);
|
|
||||||
clearPassword(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the suppressSignonPrompt flag. If this is set to true then the user
|
|
||||||
* will not be prompted to signon, instead an InterruptedException will be thrown
|
|
||||||
* by the promptForPassword method.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isSuppressed()
|
|
||||||
{
|
|
||||||
return _suppressSignonPrompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the suppressSignonPrompt flag. Tool writers can use this to temporarily
|
|
||||||
* disable the user from being prompted to signon. This would cause the promptForPassword
|
|
||||||
* method to throw an InterruptedException instead of prompting. The intent of this
|
|
||||||
* method is to allow tool writeres to prevent multiple signon prompts during a
|
|
||||||
* set period of time (such as a series of related communication calls) if the user
|
|
||||||
* cancels the first prompt. <b>It is the callers responsability to set this value
|
|
||||||
* back to false when the tool no longer needs to suppress the signon prompt or all
|
|
||||||
* other tools sharing this connection will be affected.</b>
|
|
||||||
*
|
|
||||||
* @param suppressSignonPrompt
|
|
||||||
*/
|
|
||||||
public void setSuppressed(boolean suppressSignonPrompt)
|
|
||||||
{
|
|
||||||
_suppressSignonPrompt = suppressSignonPrompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logException(Throwable t) {
|
|
||||||
Logger log = LoggerFactory.getLogger(RSEUIPlugin.getDefault());
|
|
||||||
log.logError("Unexpected exception", t); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewPasswordInfo promptForNewPassword(SystemMessage prompt) throws InterruptedException
|
|
||||||
{
|
|
||||||
ShowPromptForNewPassword msgAction = new ShowPromptForNewPassword(prompt);
|
|
||||||
Display.getDefault().syncExec(msgAction);
|
|
||||||
if (msgAction.isCancelled()) throw new InterruptedException();
|
|
||||||
return new NewPasswordInfo(msgAction.getNewPassword(), msgAction.isSavePassword());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ShowPromptForNewPassword implements Runnable
|
|
||||||
{
|
|
||||||
private SystemMessage _msg;
|
|
||||||
private String newPassword;
|
|
||||||
private boolean savePassword;
|
|
||||||
private boolean cancelled = false;
|
|
||||||
|
|
||||||
public ShowPromptForNewPassword(SystemMessage msg)
|
|
||||||
{
|
|
||||||
_msg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
SystemChangePasswordDialog dlg = new SystemChangePasswordDialog(SystemBasePlugin.getActiveWorkbenchShell(), getHostName(), getUserId(), _msg);
|
|
||||||
// Check if password was saved, if so preselect the save checkbox
|
|
||||||
if (getLocalUserId() != null)
|
|
||||||
{
|
|
||||||
dlg.setSavePassword(PasswordPersistenceManager.getInstance().passwordExists(getHostType(), getHostName(), getLocalUserId()));
|
|
||||||
}
|
}
|
||||||
dlg.open();
|
}
|
||||||
if (dlg.wasCancelled())
|
for (int s = 0; s < uniqueSystems.size(); s++) {
|
||||||
{
|
IConnectorService system = (IConnectorService) uniqueSystems.get(s);
|
||||||
cancelled = true;
|
if (!system.isConnected() && !system.hasPassword(false)) {
|
||||||
return;
|
if (system.getPrimarySubSystem().forceUserIdToUpperCase()) {
|
||||||
|
uid = uid.toUpperCase();
|
||||||
|
password = password.toUpperCase();
|
||||||
|
}
|
||||||
|
system.setPassword(uid, password, false, false);
|
||||||
}
|
}
|
||||||
newPassword = dlg.getNewPassword();
|
|
||||||
savePassword = dlg.getIsSavePassword();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCancelled()
|
|
||||||
{
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNewPassword()
|
|
||||||
{
|
|
||||||
return newPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSavePassword()
|
|
||||||
{
|
|
||||||
return savePassword;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NewPasswordInfo
|
private void clearPasswordForOtherSystemsInConnection(String uid, boolean persist) {
|
||||||
{
|
if (uid != null) {
|
||||||
public String newPassword;
|
IHost connection = getHost();
|
||||||
public boolean savePassword;
|
ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
|
||||||
|
ISubSystem[] subsystems = registry.getSubSystems(connection);
|
||||||
public NewPasswordInfo(String newPW, boolean savePW)
|
List uniqueSystems = new ArrayList();
|
||||||
{
|
for (int i = 0; i < subsystems.length; i++) {
|
||||||
newPassword = newPW;
|
IConnectorService system = subsystems[i].getConnectorService();
|
||||||
savePassword = savePW;
|
if (system != this && system.inheritsCredentials()) {
|
||||||
|
if (!uniqueSystems.contains(system)) {
|
||||||
|
uniqueSystems.add(system);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int s = 0; s < uniqueSystems.size(); s++) {
|
||||||
|
IConnectorService system = (IConnectorService) uniqueSystems.get(s);
|
||||||
|
if (system.hasPassword(persist)) {
|
||||||
|
system.clearPassword(persist, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the default user Id value in the SubSystem if it is non-null, else
|
||||||
|
* update it in the Connection object
|
||||||
|
*/
|
||||||
|
private void updateDefaultUserId(ISubSystem subsystem, String userId) {
|
||||||
|
String ssLocalUserId = subsystem.getLocalUserId();
|
||||||
|
if (ssLocalUserId != null) {
|
||||||
|
ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
|
||||||
|
ssc.updateSubSystem(subsystem, true, userId, false, 0);
|
||||||
|
} else {
|
||||||
|
int whereToUpdate = IRSEUserIdConstants.USERID_LOCATION_HOST;
|
||||||
|
IHost host = subsystem.getHost();
|
||||||
|
ISystemRegistryUI sr = RSEUIPlugin.getTheSystemRegistry();
|
||||||
|
sr.updateHost(null, host, host.getSystemType(), host.getAliasName(), host.getHostName(), host.getDescription(), userId, whereToUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -55,11 +55,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPassword(boolean clearDiskCache) {
|
public void clearPassword(boolean clearDiskCache, boolean propagate) {
|
||||||
IConnectorService conServ = getRealConnectorService();
|
IConnectorService conServ = getRealConnectorService();
|
||||||
if (conServ != null)
|
if (conServ != null)
|
||||||
{
|
{
|
||||||
conServ.clearPassword(clearDiskCache);
|
conServ.clearPassword(clearDiskCache, propagate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,24 +370,6 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresPassword() {
|
|
||||||
IConnectorService conServ = getRealConnectorService();
|
|
||||||
if (conServ != null)
|
|
||||||
{
|
|
||||||
return conServ.requiresPassword();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean requiresUserId() {
|
|
||||||
IConnectorService conServ = getRealConnectorService();
|
|
||||||
if (conServ != null)
|
|
||||||
{
|
|
||||||
return conServ.requiresUserId();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
IConnectorService conServ = getRealConnectorService();
|
IConnectorService conServ = getRealConnectorService();
|
||||||
if (conServ != null)
|
if (conServ != null)
|
||||||
|
@ -421,11 +403,11 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String matchingUserId, String password,
|
public void setPassword(String matchingUserId, String password,
|
||||||
boolean persist) {
|
boolean persist, boolean propagate) {
|
||||||
IConnectorService conServ = getRealConnectorService();
|
IConnectorService conServ = getRealConnectorService();
|
||||||
if (conServ != null)
|
if (conServ != null)
|
||||||
{
|
{
|
||||||
conServ.setPassword(matchingUserId, password, persist);
|
conServ.setPassword(matchingUserId, password, persist, propagate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +497,39 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveUserId() {
|
||||||
|
IConnectorService conServ = getRealConnectorService();
|
||||||
|
if (conServ != null)
|
||||||
|
{
|
||||||
|
conServ.saveUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeUserId() {
|
||||||
|
IConnectorService conServ = getRealConnectorService();
|
||||||
|
if (conServ != null)
|
||||||
|
{
|
||||||
|
conServ.removeUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePassword() {
|
||||||
|
IConnectorService conServ = getRealConnectorService();
|
||||||
|
if (conServ != null)
|
||||||
|
{
|
||||||
|
conServ.savePassword();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePassword() {
|
||||||
|
IConnectorService conServ = getRealConnectorService();
|
||||||
|
if (conServ != null)
|
||||||
|
{
|
||||||
|
conServ.removePassword();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean wasRestored() {
|
public boolean wasRestored() {
|
||||||
IConnectorService conServ = getRealConnectorService();
|
IConnectorService conServ = getRealConnectorService();
|
||||||
if (conServ != null)
|
if (conServ != null)
|
||||||
|
|
|
@ -7,15 +7,32 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - 168977: refactoring IConnectorService
|
* David Dykstal (IBM) - 168977: refactoring IConnectorService
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.ui.subsystems;
|
package org.eclipse.rse.ui.subsystems;
|
||||||
|
|
||||||
import org.eclipse.rse.core.PasswordPersistenceManager;
|
import org.eclipse.rse.core.PasswordPersistenceManager;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
|
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||||
import org.eclipse.rse.core.subsystems.IConnectorService;
|
import org.eclipse.rse.core.subsystems.IConnectorService;
|
||||||
|
import org.eclipse.rse.core.subsystems.ICredentials;
|
||||||
import org.eclipse.rse.core.subsystems.ICredentialsProvider;
|
import org.eclipse.rse.core.subsystems.ICredentialsProvider;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService;
|
import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService;
|
||||||
|
import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter;
|
||||||
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
import org.eclipse.rse.logging.LoggerFactory;
|
||||||
|
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.ICredentialsValidator;
|
||||||
|
import org.eclipse.rse.ui.dialogs.ISystemPasswordPromptDialog;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemChangePasswordDialog;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemPasswordPromptDialog;
|
||||||
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
|
import org.eclipse.rse.ui.validators.ISystemValidator;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link StandardCredentialsProvider} is an implementation of
|
* The {@link StandardCredentialsProvider} is an implementation of
|
||||||
|
@ -33,13 +50,199 @@ import org.eclipse.rse.core.subsystems.SuperAbstractConnectorService;
|
||||||
* specific prompting.
|
* specific prompting.
|
||||||
*/
|
*/
|
||||||
public class StandardCredentialsProvider implements ICredentialsProvider {
|
public class StandardCredentialsProvider implements ICredentialsProvider {
|
||||||
|
|
||||||
private IConnectorService connectorService = null;
|
|
||||||
|
|
||||||
|
private class PromptForCredentials implements Runnable {
|
||||||
|
private boolean canceled = false;
|
||||||
|
|
||||||
|
public boolean isCanceled() {
|
||||||
|
return canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
ISystemPasswordPromptDialog dialog = getPasswordPromptDialog(getShell());
|
||||||
|
dialog.setSystemInput(connectorService);
|
||||||
|
dialog.setForceToUpperCase(forcePasswordToUpperCase());
|
||||||
|
dialog.setSignonValidator(getSignonValidator());
|
||||||
|
if (supportsUserId()) {
|
||||||
|
dialog.setUserIdValidator(getUserIdValidator());
|
||||||
|
}
|
||||||
|
if (supportsPassword()) {
|
||||||
|
dialog.setSavePassword(savePassword);
|
||||||
|
dialog.setPassword(password);
|
||||||
|
dialog.setPasswordValidator(getPasswordValidator());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
dialog.open();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logException(e);
|
||||||
|
}
|
||||||
|
canceled = dialog.wasCancelled();
|
||||||
|
if (!canceled) {
|
||||||
|
userId = dialog.getUserId();
|
||||||
|
password = dialog.getPassword();
|
||||||
|
saveUserId = dialog.getIsUserIdChangePermanent();
|
||||||
|
savePassword = dialog.getIsSavePassword();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private class PromptForNewPassword implements Runnable {
|
||||||
|
private SystemMessage message;
|
||||||
|
private boolean canceled = false;
|
||||||
|
|
||||||
|
public PromptForNewPassword(SystemMessage message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
SystemChangePasswordDialog dlg = new SystemChangePasswordDialog(getShell(), connectorService.getHostName(), getUserId(), message);
|
||||||
|
dlg.setSavePassword(savePassword);
|
||||||
|
dlg.open();
|
||||||
|
canceled = dlg.wasCancelled();
|
||||||
|
if (!canceled) {
|
||||||
|
password = dlg.getNewPassword();
|
||||||
|
savePassword = dlg.getIsSavePassword();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private IConnectorService connectorService = null;
|
||||||
|
private String userId = null;
|
||||||
|
private String password = null;
|
||||||
|
private boolean suppressed = false;
|
||||||
|
private boolean savePassword = false;
|
||||||
|
private boolean saveUserId = false;
|
||||||
|
|
||||||
public StandardCredentialsProvider(IConnectorService connectorService) {
|
public StandardCredentialsProvider(IConnectorService connectorService) {
|
||||||
this.connectorService = connectorService;
|
this.connectorService = connectorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <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 reacquire 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 acquireCredentials(boolean reacquire) throws InterruptedException {
|
||||||
|
if (isSuppressed()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
|
ISubSystem subsystem = getPrimarySubSystem();
|
||||||
|
IHost host = subsystem.getHost();
|
||||||
|
String hostName = host.getHostName();
|
||||||
|
String hostType = host.getSystemType();
|
||||||
|
savePassword = false;
|
||||||
|
if (supportsUserId()) {
|
||||||
|
boolean sameHost = hostName.equalsIgnoreCase(connectorService.getHostName());
|
||||||
|
if (!sameHost) {
|
||||||
|
clearCredentials();
|
||||||
|
}
|
||||||
|
getUserId();
|
||||||
|
}
|
||||||
|
if (supportsPassword()) {
|
||||||
|
if (password == null) {
|
||||||
|
PasswordPersistenceManager ppm = PasswordPersistenceManager.getInstance();
|
||||||
|
SystemSignonInformation savedSignonInformation = ppm.find(hostType, hostName, userId);
|
||||||
|
if (savedSignonInformation != null) {
|
||||||
|
password = savedSignonInformation.getPassword();
|
||||||
|
savePassword = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICredentialsValidator validator = getSignonValidator();
|
||||||
|
boolean signonValid = true;
|
||||||
|
if (validator != null) {
|
||||||
|
SystemMessage m = validator.validate(getCredentials());
|
||||||
|
signonValid = (m == null);
|
||||||
|
}
|
||||||
|
// If we ran into an invalid password we need to tell the user.
|
||||||
|
// 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(userId, connectorService.getHostName());
|
||||||
|
SystemMessageDialog dialog = new SystemMessageDialog(getShell(), msg);
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
if (supportsPassword() || supportsUserId()) {
|
||||||
|
boolean passwordNeeded = supportsPassword() && password == null;
|
||||||
|
boolean userIdNeeded = supportsUserId() && userId == null;
|
||||||
|
if (passwordNeeded || userIdNeeded || reacquire) {
|
||||||
|
promptForCredentials();
|
||||||
|
if (savePassword) {
|
||||||
|
connectorService.savePassword();
|
||||||
|
} else {
|
||||||
|
connectorService.removePassword();
|
||||||
|
}
|
||||||
|
if (saveUserId) {
|
||||||
|
connectorService.saveUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCredentials() {
|
||||||
|
password = null;
|
||||||
|
userId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <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.
|
||||||
|
*/
|
||||||
|
final public void clearPassword() {
|
||||||
|
password = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConnectorService getConnectorService() {
|
||||||
|
return connectorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICredentials getCredentials() {
|
||||||
|
IHost host = connectorService.getHost();
|
||||||
|
String hostName = host.getHostName();
|
||||||
|
String systemType = host.getSystemType();
|
||||||
|
SystemSignonInformation result = new SystemSignonInformation(hostName, userId, password, systemType);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, do not override.</i><br>
|
||||||
|
* Returns the active userId if we are connected.
|
||||||
|
* If not it returns the userId for the primary subsystem ignoring the
|
||||||
|
* cached userId.
|
||||||
|
*/
|
||||||
|
final public String getUserId() {
|
||||||
|
if (supportsUserId()) {
|
||||||
|
if (userId == null) {
|
||||||
|
userId = getSubSystemUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#isSuppressed()
|
||||||
|
*/
|
||||||
|
public final boolean isSuppressed() {
|
||||||
|
return suppressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repairCredentials(SystemMessage prompt) throws InterruptedException {
|
||||||
|
promptForNewPassword(prompt);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean requiresPassword() {
|
public boolean requiresPassword() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +251,48 @@ public class StandardCredentialsProvider implements ICredentialsProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
|
* Set the password if you got it from somewhere
|
||||||
|
* @param matchingUserId the user for which to set the password
|
||||||
|
* @param password the password to set for this userid
|
||||||
|
* @param persist true if the password is to be persisted as well
|
||||||
|
*/
|
||||||
|
public final void setPassword(String matchingUserId, String password, boolean persist) {
|
||||||
|
if (getPrimarySubSystem().forceUserIdToUpperCase()) {
|
||||||
|
matchingUserId = matchingUserId.toUpperCase();
|
||||||
|
}
|
||||||
|
SystemSignonInformation signonInformation = new SystemSignonInformation(connectorService.getHostName(), matchingUserId, password, connectorService.getHostType());
|
||||||
|
setSignonInformation(signonInformation);
|
||||||
|
if (persist) { // if password should be persisted, then add to disk
|
||||||
|
PasswordPersistenceManager.getInstance().add(signonInformation, true, true);
|
||||||
|
} else { // otherwise, remove from both memory and disk
|
||||||
|
String systemType = connectorService.getHostType();
|
||||||
|
String hostName = connectorService.getHostName();
|
||||||
|
PasswordPersistenceManager.getInstance().remove(systemType, hostName, userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#setSuppressed(boolean)
|
||||||
|
*/
|
||||||
|
public final void setSuppressed(boolean suppressed) {
|
||||||
|
this.suppressed = suppressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.subsystems.IConnectorService#setUserId(java.lang.String)
|
||||||
|
*/
|
||||||
|
final public void setUserId(String newId) {
|
||||||
|
if (userId == null || !userId.equals(newId)) {
|
||||||
|
userId = newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean supportsPassword() {
|
public boolean supportsPassword() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -56,16 +301,108 @@ public class StandardCredentialsProvider implements ICredentialsProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final IHost getHost() {
|
/**
|
||||||
return connectorService.getHost();
|
* <i>A default implementation is supplied, but can be overridden if desired.</i><br>
|
||||||
|
* Instantiates and returns the dialog to prompt for the userId and password.
|
||||||
|
* @return An instance of a dialog class that implements the ISystemPasswordPromptDialog interface
|
||||||
|
*/
|
||||||
|
protected ISystemPasswordPromptDialog getPasswordPromptDialog(Shell shell) {
|
||||||
|
ISystemPasswordPromptDialog dlg = new SystemPasswordPromptDialog(shell, requiresUserId(), requiresPassword());
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Optionally overridable, not implemented by default.</i><br>
|
||||||
|
* Get the signon validator to use in the password dialog prompt.
|
||||||
|
* By default, returns null.
|
||||||
|
*/
|
||||||
|
protected ICredentialsValidator getSignonValidator() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
|
* Should passwords be folded to uppercase?
|
||||||
|
* By default, returns:
|
||||||
|
* <pre><code>getSubSystem().forceUserIdToUpperCase()</code></pre>
|
||||||
|
*/
|
||||||
|
private boolean forcePasswordToUpperCase() {
|
||||||
|
return getPrimarySubSystem().forceUserIdToUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
|
* Get the password input validator to use in the password dialog prompt.
|
||||||
|
* <p>
|
||||||
|
* By default, returns:</p>
|
||||||
|
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getPasswordValidator()</code></pre>
|
||||||
|
*/
|
||||||
|
private ISystemValidator getPasswordValidator() {
|
||||||
|
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
||||||
|
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
||||||
|
return adapter.getPasswordValidator(ssFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISubSystem getPrimarySubSystem() {
|
||||||
|
return connectorService.getPrimarySubSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Shell getShell() {
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||||
|
return shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userId from the primary subsystem.
|
||||||
|
*/
|
||||||
|
private String getSubSystemUserId() {
|
||||||
|
ISubSystem ss = getPrimarySubSystem();
|
||||||
|
String result = ss.getUserId();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
|
* Get the userId input validator to use in the password dialog prompt.
|
||||||
|
* <p>
|
||||||
|
* By default, returns </p>
|
||||||
|
* <pre><code>getSubSystem().getParentSubSystemConfiguration().getUserIdValidator()</code></pre>
|
||||||
|
*/
|
||||||
|
private ISystemValidator getUserIdValidator() {
|
||||||
|
ISubSystemConfiguration ssFactory = getPrimarySubSystem().getSubSystemConfiguration();
|
||||||
|
ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter) ssFactory.getAdapter(ISubSystemConfigurationAdapter.class);
|
||||||
|
ISystemValidator validator = adapter.getUserIdValidator(ssFactory);
|
||||||
|
return validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logException(Throwable t) {
|
||||||
|
Logger log = LoggerFactory.getLogger(RSEUIPlugin.getDefault());
|
||||||
|
log.logError("Unexpected exception", t); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
private void promptForCredentials() throws InterruptedException {
|
||||||
|
PromptForCredentials runnable = new PromptForCredentials();
|
||||||
|
Display.getDefault().syncExec(runnable);
|
||||||
|
if (runnable.isCanceled()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acquireCredentials(boolean reacquire) {
|
private void promptForNewPassword(SystemMessage prompt) throws InterruptedException {
|
||||||
// TODO Auto-generated method stub
|
PromptForNewPassword runnable = new PromptForNewPassword(prompt);
|
||||||
|
Display.getDefault().syncExec(runnable);
|
||||||
|
if (runnable.isCancelled()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCredentials() {
|
/**
|
||||||
// TODO Auto-generated method stub
|
* <i>Useful utility method. Fully implemented, no need to override.</i><br>
|
||||||
|
* Sets the password information for this system's subsystem.
|
||||||
|
* @param signonInfo the password information object
|
||||||
|
*/
|
||||||
|
private void setSignonInformation(SystemSignonInformation signonInfo) {
|
||||||
|
password = signonInfo.getPassword();
|
||||||
|
userId = signonInfo.getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue