mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 01:55:24 +02:00
Adding SSL autodetect
This commit is contained in:
parent
21ed0c009f
commit
af1afc9318
8 changed files with 117 additions and 6 deletions
|
@ -480,9 +480,11 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
|||
IIBMServerLauncher serverLauncher = getIBMServerLauncher();
|
||||
|
||||
ServerLaunchType serverLauncherType = null;
|
||||
boolean autoDetectSSL = true;
|
||||
if (serverLauncher != null)
|
||||
{
|
||||
serverLauncherType = serverLauncher.getServerLaunchType();
|
||||
autoDetectSSL = serverLauncher.getAutoDetectSSL();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -511,7 +513,8 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
|||
IServerLauncher starter = getRemoteServerLauncher();
|
||||
starter.setSignonInformation(info);
|
||||
starter.setServerLauncherProperties(serverLauncher);
|
||||
|
||||
if (autoDetectSSL) timeout = 3000;
|
||||
else setSSLProperties(isUsingSSL());
|
||||
|
||||
int iServerPort = launchUsingRexec(monitor, info, serverLauncher);
|
||||
|
||||
|
@ -528,7 +531,7 @@ public class DStoreConnectorService extends AbstractConnectorService implements
|
|||
|
||||
// connect to launched server
|
||||
connectStatus = clientConnection.connect(null, timeout);
|
||||
if (!connectStatus.isConnected() && connectStatus.getMessage().startsWith(ClientConnection.CANNOT_CONNECT))
|
||||
if (!connectStatus.isConnected() && connectStatus.getMessage().startsWith(ClientConnection.CANNOT_CONNECT) && autoDetectSSL)
|
||||
{
|
||||
if (setSSLProperties(true))
|
||||
{
|
||||
|
|
|
@ -521,6 +521,9 @@ public class SystemResources extends NLS
|
|||
public static String RESID_SUBSYSTEM_SSL_LABEL;
|
||||
public static String RESID_SUBSYSTEM_SSL_TIP;
|
||||
|
||||
public static String RESID_SUBSYSTEM_AUTODETECT_LABEL;
|
||||
public static String RESID_SUBSYSTEM_AUTODETECT_TIP;
|
||||
|
||||
public static String RESID_SUBSYSTEM_SSL_ALERT_LABEL;
|
||||
public static String RESID_SUBSYSTEM_SSL_ALERT_TIP;
|
||||
|
||||
|
|
|
@ -366,6 +366,8 @@ RESID_SUBSYSTEM_USERID_INHERITBUTTON_LOCAL_TIP=Click to inherit the user ID from
|
|||
# Communications property page
|
||||
RESID_SUBSYSTEM_SSL_LABEL=Use SSL for network communications
|
||||
RESID_SUBSYSTEM_SSL_TIP=Use Secure Sockets Layer (SSL) for communicating with the server
|
||||
RESID_SUBSYSTEM_AUTODETECT_LABEL=Auto-detect SSL
|
||||
RESID_SUBSYSTEM_AUTODETECT_TIP=Automatically detect whether or not the server uses SSL. On some systems this may cause a longer connection time.
|
||||
RESID_SUBSYSTEM_SSL_ALERT_LABEL=Alert me when connecting using SSL
|
||||
RESID_SUBSYSTEM_SSL_ALERT_TIP=Show a confirmation dialog when the Secure Sockets Layer (SSL) is used for connecting with the RSE server
|
||||
RESID_SUBSYSTEM_NONSSL_ALERT_LABEL=Alert me when connecting insecurely
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
||||
{
|
||||
|
||||
private Button _radioDaemon, _radioRexec, _radioNone, _checkBoxSSL;
|
||||
private Button _radioDaemon, _radioRexec, _radioNone, _checkBoxSSL, _checkBoxRexecSSL, _checkBoxAutoDetect;
|
||||
private Text _fieldDaemonPort;
|
||||
private Label _labelDaemonPort;
|
||||
|
||||
|
@ -65,6 +65,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
private int _origRexecPort;
|
||||
private int _origDaemonPort;
|
||||
private boolean _origUseSSL;
|
||||
private boolean _origAutoDetect;
|
||||
|
||||
/**
|
||||
* Constructor for EnvironmentVariablesForm.
|
||||
|
@ -85,7 +86,8 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
!_origInvocation.equals(getServerInvocation()) ||
|
||||
_origRexecPort != getREXECPortAsInt() ||
|
||||
_origDaemonPort != getDaemonPortAsInt() ||
|
||||
_origUseSSL != getUseSSL();
|
||||
_origUseSSL != getUseSSL() ||
|
||||
_origAutoDetect != getAutoDetect();
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
|
@ -99,6 +101,8 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
_fieldRexecPort.setEnabled(false);
|
||||
_fieldDaemonPort.setEnabled(false);
|
||||
_checkBoxSSL.setEnabled(false);
|
||||
_checkBoxRexecSSL.setEnabled(false);
|
||||
_checkBoxAutoDetect.setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,6 +186,11 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
|
||||
subRexecControls.setLayout(l2);
|
||||
subRexecControls.setLayoutData(d2);
|
||||
|
||||
_checkBoxAutoDetect = SystemWidgetHelpers.createCheckBox(_rexecControls, SystemResources.RESID_SUBSYSTEM_AUTODETECT_LABEL, this);
|
||||
_checkBoxAutoDetect.setToolTipText(SystemResources.RESID_SUBSYSTEM_AUTODETECT_TIP);
|
||||
_checkBoxRexecSSL = SystemWidgetHelpers.createCheckBox(_rexecControls, SystemResources.RESID_SUBSYSTEM_SSL_LABEL, this);
|
||||
_checkBoxRexecSSL.setToolTipText(SystemResources.RESID_SUBSYSTEM_SSL_TIP);
|
||||
|
||||
_rexecControls.setLayout(layout);
|
||||
_rexecControls.setLayoutData(data);
|
||||
|
@ -221,6 +230,8 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
_labelRexecInvocation.setEnabled(_radioRexec.getSelection());
|
||||
_labelRexecPort.setEnabled(_radioRexec.getSelection());
|
||||
_fieldRexecPort.setEnabled(_radioRexec.getSelection());
|
||||
_checkBoxRexecSSL.setEnabled(_radioRexec.getSelection());
|
||||
_checkBoxAutoDetect.setEnabled(_radioRexec.getSelection());
|
||||
_checkBoxSSL.setEnabled(_radioNone.getSelection());
|
||||
|
||||
_fieldDaemonPort.setText(String.valueOf(DEFAULT_DAEMON_PORT));
|
||||
|
@ -242,6 +253,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
int rexecport = isl.getRexecPort(); // changed from getPortAsInt via d54335
|
||||
int daemonPort = isl.getDaemonPort(); // defect 54335
|
||||
boolean useSSL = isl.getConnectorService().isUsingSSL();
|
||||
boolean autoDetectSSL = isl.getAutoDetectSSL();
|
||||
|
||||
// find out if daemon can be launched
|
||||
boolean allowDaemon = isl.isEnabledServerLaunchType(ServerLaunchType.DAEMON_LITERAL);
|
||||
|
@ -264,6 +276,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
setServerInvocation(invocation);
|
||||
setREXECPort(rexecport);
|
||||
setUseSSL(useSSL);
|
||||
setAutoDetect(autoDetectSSL);
|
||||
|
||||
if (!allowDaemon && !allowRexec && !allowNo) {
|
||||
disable();
|
||||
|
@ -276,6 +289,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
_origRexecPort = getREXECPortAsInt();
|
||||
_origDaemonPort = getDaemonPortAsInt();
|
||||
_origUseSSL = getUseSSL();
|
||||
_origAutoDetect = getAutoDetect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,6 +362,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
int rexecPort = getREXECPortAsInt();
|
||||
int daemonPort = getDaemonPortAsInt();
|
||||
boolean useSSL = getUseSSL();
|
||||
boolean autoDetect = getAutoDetect();
|
||||
|
||||
IIBMServerLauncher isl = (IIBMServerLauncher)launcher;
|
||||
isl.setServerLaunchType(launchType);
|
||||
|
@ -355,6 +370,7 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
isl.setServerScript(invocation);
|
||||
isl.setRexecPort(rexecPort); // changed from setPort via d54335. Phil
|
||||
isl.setDaemonPort(daemonPort);
|
||||
isl.setAutoDetectSSL(autoDetect);
|
||||
isl.getConnectorService().setIsUsingSSL(useSSL);
|
||||
try
|
||||
{
|
||||
|
@ -379,6 +395,8 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
_labelRexecInvocation.setEnabled(useRexec);
|
||||
_fieldRexecPort.setEnabled(useRexec);
|
||||
_labelRexecPort.setEnabled(useRexec);
|
||||
_checkBoxAutoDetect.setEnabled(useRexec);
|
||||
_checkBoxRexecSSL.setEnabled(useRexec && !_checkBoxAutoDetect.getSelection());
|
||||
_checkBoxSSL.setEnabled(_radioNone.getSelection());
|
||||
|
||||
verify();
|
||||
|
@ -398,12 +416,28 @@ public class IBMServerLauncherForm extends IBMBaseServerLauncherForm
|
|||
|
||||
protected boolean getUseSSL()
|
||||
{
|
||||
return _checkBoxSSL.getSelection();
|
||||
if (_radioRexec.getSelection())
|
||||
return _checkBoxRexecSSL.getSelection();
|
||||
else return _checkBoxSSL.getSelection();
|
||||
}
|
||||
|
||||
protected boolean getAutoDetect()
|
||||
{
|
||||
if (_radioNone.getSelection()) return false;
|
||||
if (_radioRexec.getSelection())
|
||||
return _checkBoxAutoDetect.getSelection();
|
||||
else return true;
|
||||
}
|
||||
|
||||
protected void setUseSSL(boolean use)
|
||||
{
|
||||
_checkBoxSSL.setSelection(use);
|
||||
_checkBoxRexecSSL.setSelection(use);
|
||||
}
|
||||
|
||||
protected void setAutoDetect(boolean use)
|
||||
{
|
||||
_checkBoxAutoDetect.setSelection(use);
|
||||
}
|
||||
|
||||
protected void setLaunchType(ServerLaunchType type)
|
||||
|
|
|
@ -21,10 +21,12 @@ public interface IPropertyType
|
|||
public static final int TYPE_STRING = 0;
|
||||
public static final int TYPE_INTEGER = 1;
|
||||
public static final int TYPE_ENUM = 2;
|
||||
public static final int TYPE_BOOLEAN = 3;
|
||||
|
||||
public boolean isString();
|
||||
public boolean isInteger();
|
||||
public boolean isEnum();
|
||||
public boolean isBoolean();
|
||||
|
||||
public int getType();
|
||||
public String[] getEnumValues();
|
||||
|
|
|
@ -50,6 +50,10 @@ public class PropertyType implements IPropertyType
|
|||
String[] enumValues = subString.split(",");
|
||||
setEnumValues(enumValues);
|
||||
}
|
||||
else if (typeStr.equals(Boolean.class.toString()))
|
||||
{
|
||||
setType(TYPE_BOOLEAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
setType(TYPE_STRING);
|
||||
|
@ -80,6 +84,11 @@ public class PropertyType implements IPropertyType
|
|||
{
|
||||
return _type == TYPE_ENUM;
|
||||
}
|
||||
|
||||
public boolean isBoolean()
|
||||
{
|
||||
return _type == TYPE_BOOLEAN;
|
||||
}
|
||||
|
||||
public void setEnumValues(String[] enumValues)
|
||||
{
|
||||
|
@ -117,6 +126,10 @@ public class PropertyType implements IPropertyType
|
|||
}
|
||||
return buf.toString();
|
||||
}
|
||||
else if (isBoolean())
|
||||
{
|
||||
return Boolean.class.getName();
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
protected final String KEY_SERVER_LAUNCH_TYPE_NAME = "server.launch.type.name";
|
||||
protected final String KEY_SERVER_PATH = "server.path";
|
||||
protected final String KEY_SERVER_SCRIPT = "server.script";
|
||||
protected final String KEY_AUTODETECT_SSL = "autodetect.ssl";
|
||||
|
||||
|
||||
protected ServerLaunchType _serverLaunchType = SERVER_LAUNCH_TYPE_EDEFAULT;
|
||||
|
@ -91,9 +92,14 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
protected static final String IBM_ATTRIBUTES_EDEFAULT = null;
|
||||
|
||||
protected static final String RESTRICTED_TYPES_EDEFAULT = null;
|
||||
|
||||
protected static final boolean AUTODETECT_SSL_EDEFAULT = true;
|
||||
|
||||
protected boolean _autoDetectSSL = AUTODETECT_SSL_EDEFAULT;
|
||||
|
||||
protected PropertyType _serverLauncherEnumType;
|
||||
protected PropertyType _intPropertyType;
|
||||
protected PropertyType _booleanPropertyType;
|
||||
|
||||
protected IBMServerLauncher(String name, IConnectorService connectorService)
|
||||
{
|
||||
|
@ -109,6 +115,15 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
return _intPropertyType;
|
||||
}
|
||||
|
||||
public IPropertyType getBooleanPropertyType()
|
||||
{
|
||||
if (_booleanPropertyType == null)
|
||||
{
|
||||
_booleanPropertyType = new PropertyType(IPropertyType.TYPE_BOOLEAN);
|
||||
}
|
||||
return _booleanPropertyType;
|
||||
}
|
||||
|
||||
public IPropertyType getServerLauncherPropertyType()
|
||||
{
|
||||
if (_serverLauncherEnumType == null)
|
||||
|
@ -146,6 +161,15 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
|
||||
_daemonPort = Integer.parseInt(daemonPortProperty.getValue());
|
||||
|
||||
IProperty autoDetectProperty = set.getProperty(KEY_AUTODETECT_SSL);
|
||||
if (autoDetectProperty != null)
|
||||
{
|
||||
autoDetectProperty.setEnabled(_serverLaunchType.getType() == ServerLaunchType.REXEC);
|
||||
autoDetectProperty.setLabel(SystemResources.RESID_SUBSYSTEM_AUTODETECT_LABEL);
|
||||
|
||||
_autoDetectSSL = Boolean.getBoolean(autoDetectProperty.getValue());
|
||||
}
|
||||
|
||||
boolean usingRexec = _serverLaunchType.getType() == ServerLaunchType.REXEC;
|
||||
IProperty rexecPortProperty = set.getProperty(KEY_REXEC_PORT);
|
||||
rexecPortProperty.setEnabled(usingRexec);
|
||||
|
@ -193,6 +217,10 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
rexecPortProperty.setEnabled(usingRexec);
|
||||
rexecPortProperty.setLabel(SystemResources.RESID_CONNECTION_PORT_LABEL);
|
||||
|
||||
IProperty autoDetectSSLProperty = set.addProperty(KEY_AUTODETECT_SSL, ""+_autoDetectSSL, getBooleanPropertyType());
|
||||
autoDetectSSLProperty.setEnabled(usingRexec);
|
||||
autoDetectSSLProperty.setLabel(SystemResources.RESID_SUBSYSTEM_AUTODETECT_LABEL);
|
||||
|
||||
IProperty serverPathProperty = set.addProperty(KEY_SERVER_PATH, ""+_serverPath);
|
||||
serverPathProperty.setLabel(SystemResources.RESID_PROP_SERVERLAUNCHER_PATH);
|
||||
serverPathProperty.setEnabled(usingRexec);
|
||||
|
@ -219,6 +247,7 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
ibmNewOne.setServerLaunchType(getServerLaunchTypeGen());
|
||||
ibmNewOne.setServerPath(getServerPath());
|
||||
ibmNewOne.setServerScript(getServerScript());
|
||||
ibmNewOne.setAutoDetectSSL(getAutoDetectSSL());
|
||||
return ibmNewOne;
|
||||
}
|
||||
|
||||
|
@ -305,6 +334,25 @@ public class IBMServerLauncher extends ServerLauncher implements IIBMServerLaunc
|
|||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the whether or not to auto-detect SSL
|
||||
*/
|
||||
public boolean getAutoDetectSSL()
|
||||
{
|
||||
return _autoDetectSSL;
|
||||
}
|
||||
/**
|
||||
* Sets whether or not to auto-detect SSL
|
||||
*/
|
||||
public void setAutoDetectSSL(boolean auto)
|
||||
{
|
||||
if (auto != _autoDetectSSL)
|
||||
{
|
||||
_autoDetectSSL = auto;
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the port used for the DAEMON option, as an Integer
|
||||
|
|
|
@ -111,7 +111,13 @@ public interface IIBMServerLauncher extends IServerLauncherProperties{
|
|||
*/
|
||||
public void setRexecPort(int newRexecPort);
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether or not to auto-detect SSL
|
||||
*/
|
||||
public void setAutoDetectSSL(boolean auto);
|
||||
|
||||
boolean getAutoDetectSSL();
|
||||
|
||||
int getDaemonPort();
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue