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

allow non-ssl for server when ssl is used for daemon

This commit is contained in:
David McKnight 2006-07-26 17:02:17 +00:00
parent 1226ebf334
commit 41f13fa015
5 changed files with 85 additions and 40 deletions

View file

@ -17,10 +17,10 @@
package org.eclipse.dstore.core.client; package org.eclipse.dstore.core.client;
import org.eclipse.dstore.core.model.ISSLProperties; import org.eclipse.dstore.core.model.ISSLProperties;
public class ClientSSLProperties implements ISSLProperties public class ClientSSLProperties implements ISSLProperties
{ {
private boolean _enableSSL = false; private boolean _enableSSL = false;
private boolean _disableServerSSL = false;
private String _daemonKeyStorePath; private String _daemonKeyStorePath;
private String _daemonKeyStorePassword; private String _daemonKeyStorePassword;
@ -38,6 +38,18 @@ public class ClientSSLProperties implements ISSLProperties
_serverKeyStorePassword = serverPassword; _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) public ClientSSLProperties(boolean enableSSL, String keystore, String password)
{ {
_enableSSL = enableSSL; _enableSSL = enableSSL;
@ -48,10 +60,27 @@ public class ClientSSLProperties implements ISSLProperties
_serverKeyStorePassword = password; _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() public boolean usingSSL()
{ {
return _enableSSL; return _enableSSL;
} }
public boolean usingServerSSL()
{
return !_disableServerSSL;
}
public String getDaemonKeyStorePassword() public String getDaemonKeyStorePassword()

View file

@ -291,16 +291,16 @@ public final class DataStore
_loaders.add(loader); _loaders.add(loader);
} }
public boolean usingSSL() public boolean usingSSL()
{ {
if (_sslProperties != null) if (_sslProperties != null)
{ {
return _sslProperties.usingSSL(); return _sslProperties.usingSSL() && _sslProperties.usingServerSSL();
} }
return false; return false;
} }
/** /**
* Specifies the security properties of this DataStore. * Specifies the security properties of this DataStore.
* These properties indicate whether or not to use ssl, * These properties indicate whether or not to use ssl,

View file

@ -19,6 +19,7 @@ package org.eclipse.dstore.core.model;
public interface ISSLProperties public interface ISSLProperties
{ {
public boolean usingSSL(); public boolean usingSSL();
public boolean usingServerSSL();
public String getDaemonKeyStorePassword(); public String getDaemonKeyStorePassword();
public String getDaemonKeyStorePath(); public String getDaemonKeyStorePath();
public String getServerKeyStorePassword(); public String getServerKeyStorePassword();

View file

@ -21,10 +21,11 @@ import java.util.ResourceBundle;
import org.eclipse.dstore.core.model.ISSLProperties; import org.eclipse.dstore.core.model.ISSLProperties;
public class ServerSSLProperties implements ISSLProperties public class ServerSSLProperties implements ISSLProperties
{ {
private boolean _enableSSL = false; private boolean _enableSSL = false;
private boolean _disableServerSSL = false;
private String _daemonKeyStorePath; private String _daemonKeyStorePath;
private String _daemonKeyStorePassword; private String _daemonKeyStorePassword;
@ -33,6 +34,7 @@ public class ServerSSLProperties implements ISSLProperties
private static final String ENABLE_SSL = "enable_ssl"; 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_FILE = "daemon_keystore_file";
private static final String DAEMON_KEYSTORE_PASSWORD = "daemon_keystore_password"; private static final String DAEMON_KEYSTORE_PASSWORD = "daemon_keystore_password";
@ -46,19 +48,29 @@ public class ServerSSLProperties implements ISSLProperties
try try
{ {
ResourceBundle properties = ResourceBundle.getBundle("ssl"); 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"); try
if (_enableSSL) {
_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 try
{ {
_serverKeyStorePath = properties.getString(SERVER_KEYSTORE_FILE).trim(); _serverKeyStorePath = properties.getString(SERVER_KEYSTORE_FILE).trim();
@ -67,40 +79,36 @@ public class ServerSSLProperties implements ISSLProperties
catch (Exception e) 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:\t"+_serverKeyStorePath+"]");
System.out.println("[server keystore pw:\t"+_serverKeyStorePassword+"]"); System.out.println("[server keystore pw:\t"+_serverKeyStorePassword+"]");
} }
} }
else
{
_enableSSL = false;
}
} }
catch (Exception e) catch (Exception e)
{ {
// no ssl properties...set to disabled e.printStackTrace();
_enableSSL = false;
//e.printStackTrace();
} }
} }
@ -110,6 +118,11 @@ public class ServerSSLProperties implements ISSLProperties
return _enableSSL; return _enableSSL;
} }
public boolean usingServerSSL()
{
return !_disableServerSSL;
}
public String getDaemonKeyStorePath() public String getDaemonKeyStorePath()
{ {
@ -131,5 +144,4 @@ public class ServerSSLProperties implements ISSLProperties
return _serverKeyStorePassword; return _serverKeyStorePassword;
} }
} }

View file

@ -21,6 +21,9 @@
# Specify this property as true to enable SSL # Specify this property as true to enable SSL
enable_ssl=false 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 # Daemon Properties
################################### ###################################