mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
allow non-ssl for server when ssl is used for daemon
This commit is contained in:
parent
1226ebf334
commit
41f13fa015
5 changed files with 85 additions and 40 deletions
|
@ -17,10 +17,10 @@
|
|||
package org.eclipse.dstore.core.client;
|
||||
|
||||
import org.eclipse.dstore.core.model.ISSLProperties;
|
||||
|
||||
public class ClientSSLProperties implements ISSLProperties
|
||||
{
|
||||
private boolean _enableSSL = false;
|
||||
private boolean _disableServerSSL = false;
|
||||
private String _daemonKeyStorePath;
|
||||
private String _daemonKeyStorePassword;
|
||||
|
||||
|
@ -38,6 +38,18 @@ public class ClientSSLProperties implements ISSLProperties
|
|||
_serverKeyStorePassword = serverPassword;
|
||||
}
|
||||
|
||||
public ClientSSLProperties(boolean enableSSL, boolean disableServerSSL,
|
||||
String daemonKeystore, String daemonPassword,
|
||||
String serverKeystore, String serverPassword)
|
||||
{
|
||||
_enableSSL = enableSSL;
|
||||
_disableServerSSL = disableServerSSL;
|
||||
_daemonKeyStorePath = daemonKeystore;
|
||||
_daemonKeyStorePassword = daemonPassword;
|
||||
_serverKeyStorePath = serverKeystore;
|
||||
_serverKeyStorePassword = serverPassword;
|
||||
}
|
||||
|
||||
public ClientSSLProperties(boolean enableSSL, String keystore, String password)
|
||||
{
|
||||
_enableSSL = enableSSL;
|
||||
|
@ -48,10 +60,27 @@ public class ClientSSLProperties implements ISSLProperties
|
|||
_serverKeyStorePassword = password;
|
||||
}
|
||||
|
||||
public ClientSSLProperties(boolean enableSSL, boolean disableServerSSL, String keystore, String password)
|
||||
{
|
||||
_enableSSL = enableSSL;
|
||||
_disableServerSSL = disableServerSSL;
|
||||
_daemonKeyStorePath = keystore;
|
||||
_daemonKeyStorePassword = password;
|
||||
|
||||
_serverKeyStorePath = keystore;
|
||||
_serverKeyStorePassword = password;
|
||||
}
|
||||
|
||||
|
||||
public boolean usingSSL()
|
||||
{
|
||||
return _enableSSL;
|
||||
}
|
||||
|
||||
public boolean usingServerSSL()
|
||||
{
|
||||
return !_disableServerSSL;
|
||||
}
|
||||
|
||||
|
||||
public String getDaemonKeyStorePassword()
|
||||
|
|
|
@ -291,16 +291,16 @@ public final class DataStore
|
|||
_loaders.add(loader);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean usingSSL()
|
||||
{
|
||||
if (_sslProperties != null)
|
||||
{
|
||||
return _sslProperties.usingSSL();
|
||||
return _sslProperties.usingSSL() && _sslProperties.usingServerSSL();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the security properties of this DataStore.
|
||||
* These properties indicate whether or not to use ssl,
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.eclipse.dstore.core.model;
|
|||
public interface ISSLProperties
|
||||
{
|
||||
public boolean usingSSL();
|
||||
public boolean usingServerSSL();
|
||||
public String getDaemonKeyStorePassword();
|
||||
public String getDaemonKeyStorePath();
|
||||
public String getServerKeyStorePassword();
|
||||
|
|
|
@ -21,10 +21,11 @@ import java.util.ResourceBundle;
|
|||
import org.eclipse.dstore.core.model.ISSLProperties;
|
||||
|
||||
|
||||
|
||||
public class ServerSSLProperties implements ISSLProperties
|
||||
{
|
||||
private boolean _enableSSL = false;
|
||||
private boolean _disableServerSSL = false;
|
||||
|
||||
private String _daemonKeyStorePath;
|
||||
private String _daemonKeyStorePassword;
|
||||
|
||||
|
@ -33,6 +34,7 @@ public class ServerSSLProperties implements ISSLProperties
|
|||
|
||||
|
||||
private static final String ENABLE_SSL = "enable_ssl";
|
||||
private static final String DISABLE_SERVER_SSL = "disable_server_ssl";
|
||||
|
||||
private static final String DAEMON_KEYSTORE_FILE = "daemon_keystore_file";
|
||||
private static final String DAEMON_KEYSTORE_PASSWORD = "daemon_keystore_password";
|
||||
|
@ -46,19 +48,29 @@ public class ServerSSLProperties implements ISSLProperties
|
|||
try
|
||||
{
|
||||
ResourceBundle properties = ResourceBundle.getBundle("ssl");
|
||||
if (properties != null)
|
||||
_enableSSL = properties.getString(ENABLE_SSL).trim().equals("true");
|
||||
if (_enableSSL)
|
||||
{
|
||||
_enableSSL = properties.getString(ENABLE_SSL).trim().equals("true");
|
||||
if (_enableSSL)
|
||||
try
|
||||
{
|
||||
_disableServerSSL = properties.getString(DISABLE_SERVER_SSL).trim().equals("true");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_daemonKeyStorePath = properties.getString(DAEMON_KEYSTORE_FILE).trim();
|
||||
_daemonKeyStorePassword = properties.getString(DAEMON_KEYSTORE_PASSWORD).trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (!_disableServerSSL)
|
||||
{
|
||||
try
|
||||
{
|
||||
_daemonKeyStorePath = properties.getString(DAEMON_KEYSTORE_FILE).trim();
|
||||
_daemonKeyStorePassword = properties.getString(DAEMON_KEYSTORE_PASSWORD).trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
_serverKeyStorePath = properties.getString(SERVER_KEYSTORE_FILE).trim();
|
||||
|
@ -67,40 +79,36 @@ public class ServerSSLProperties implements ISSLProperties
|
|||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (_daemonKeyStorePath == null && _serverKeyStorePath != null)
|
||||
{
|
||||
_daemonKeyStorePath = _serverKeyStorePath;
|
||||
_daemonKeyStorePassword = _serverKeyStorePassword;
|
||||
}
|
||||
if (_serverKeyStorePath == null && _daemonKeyStorePath != null)
|
||||
{
|
||||
_serverKeyStorePath = _daemonKeyStorePath;
|
||||
_serverKeyStorePassword = _daemonKeyStorePassword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_enableSSL)
|
||||
if (_daemonKeyStorePath == null && _serverKeyStorePath != null)
|
||||
{
|
||||
_daemonKeyStorePath = _serverKeyStorePath;
|
||||
_daemonKeyStorePassword = _serverKeyStorePassword;
|
||||
}
|
||||
if (!_disableServerSSL && _serverKeyStorePath == null && _daemonKeyStorePath != null)
|
||||
{
|
||||
_serverKeyStorePath = _daemonKeyStorePath;
|
||||
_serverKeyStorePassword = _daemonKeyStorePassword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_enableSSL)
|
||||
{
|
||||
System.out.println("SSL Settings");
|
||||
System.out.println("[daemon keystore:\t"+_daemonKeyStorePath+"]");
|
||||
System.out.println("[daemon keystore pw:\t"+_daemonKeyStorePassword+"]");
|
||||
if (!_disableServerSSL)
|
||||
{
|
||||
System.out.println("SSL Settings");
|
||||
System.out.println("[daemon keystore:\t"+_daemonKeyStorePath+"]");
|
||||
System.out.println("[daemon keystore pw:\t"+_daemonKeyStorePassword+"]");
|
||||
System.out.println("[server keystore:\t"+_serverKeyStorePath+"]");
|
||||
System.out.println("[server keystore pw:\t"+_serverKeyStorePassword+"]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_enableSSL = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// no ssl properties...set to disabled
|
||||
_enableSSL = false;
|
||||
|
||||
//e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,6 +118,11 @@ public class ServerSSLProperties implements ISSLProperties
|
|||
return _enableSSL;
|
||||
}
|
||||
|
||||
public boolean usingServerSSL()
|
||||
{
|
||||
return !_disableServerSSL;
|
||||
}
|
||||
|
||||
|
||||
public String getDaemonKeyStorePath()
|
||||
{
|
||||
|
@ -131,5 +144,4 @@ public class ServerSSLProperties implements ISSLProperties
|
|||
return _serverKeyStorePassword;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -21,6 +21,9 @@
|
|||
# Specify this property as true to enable SSL
|
||||
enable_ssl=false
|
||||
|
||||
# Specify this property as true to disable SSL for the server when daemon ssl is enabled
|
||||
disable_server_ssl=false
|
||||
|
||||
###################################
|
||||
# Daemon Properties
|
||||
###################################
|
||||
|
|
Loading…
Add table
Reference in a new issue