use of org.jumpmind.properties.TypedProperties in project symmetric-ds by JumpMind.
the class AbstractCommandLauncher method initFromServerProperties.
protected static void initFromServerProperties() {
if (!serverPropertiesInitialized) {
File serverPropertiesFile = new File(DEFAULT_SERVER_PROPERTIES);
TypedProperties serverProperties = new TypedProperties();
if (serverPropertiesFile.exists() && serverPropertiesFile.isFile()) {
FileInputStream fis = null;
try {
fis = new FileInputStream(serverPropertiesFile);
serverProperties.load(fis);
/* System properties always override */
serverProperties.merge(System.getProperties());
/*
* Put server properties back into System properties so they
* are available to the parameter service
*/
System.getProperties().putAll(serverProperties);
} catch (IOException ex) {
log.error("Failed to load " + DEFAULT_SERVER_PROPERTIES, ex);
} finally {
IOUtils.closeQuietly(fis);
}
} else if (!serverPropertiesFile.exists()) {
log.warn("Failed to load " + DEFAULT_SERVER_PROPERTIES + ". File does not exist.");
} else if (!serverPropertiesFile.isFile()) {
log.warn("Failed to load " + DEFAULT_SERVER_PROPERTIES + ". Object is not a file.");
}
serverPropertiesInitialized = true;
}
}
use of org.jumpmind.properties.TypedProperties in project symmetric-ds by JumpMind.
the class AbstractParameterService method rereadDatabaseParameters.
protected TypedProperties rereadDatabaseParameters(Properties p) {
if (databaseHasBeenInitialized) {
TypedProperties properties = getDatabaseParameters(ParameterConstants.ALL, ParameterConstants.ALL);
properties.putAll(getDatabaseParameters(ParameterConstants.ALL, p.getProperty(ParameterConstants.NODE_GROUP_ID)));
properties.putAll(getDatabaseParameters(p.getProperty(ParameterConstants.EXTERNAL_ID), p.getProperty(ParameterConstants.NODE_GROUP_ID)));
databaseHasBeenInitialized = true;
return properties;
} else {
return new TypedProperties();
}
}
use of org.jumpmind.properties.TypedProperties in project symmetric-ds by JumpMind.
the class SymmetricWebServer method getConnectors.
protected Connector[] getConnectors(Server server, int port, int securePort, Mode mode) {
ArrayList<Connector> connectors = new ArrayList<Connector>();
HttpConfiguration httpConfig = new HttpConfiguration();
if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(securePort);
}
httpConfig.setOutputBufferSize(32768);
if (mode.equals(Mode.HTTP) || mode.equals(Mode.MIXED)) {
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(port);
http.setHost(host);
http.setIdleTimeout(maxIdleTime);
connectors.add(http);
log.info(String.format("About to start %s web server on host:port %s:%s", name, host == null ? "default" : host, port));
}
if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
ISecurityService securityService = SecurityServiceFactory.create(SecurityServiceType.SERVER, new TypedProperties(System.getProperties()));
securityService.installDefaultSslCert(host);
String keyStorePassword = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD);
keyStorePassword = (keyStorePassword != null) ? keyStorePassword : SecurityConstants.KEYSTORE_PASSWORD;
SslContextFactory sslConnectorFactory = new SslContextFactory();
sslConnectorFactory.setKeyManagerPassword(keyStorePassword);
/* Prevent POODLE attack */
String ignoredProtocols = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_PROTOCOLS);
if (ignoredProtocols != null && ignoredProtocols.length() > 0) {
String[] protocols = ignoredProtocols.split(",");
sslConnectorFactory.addExcludeProtocols(protocols);
} else {
sslConnectorFactory.addExcludeProtocols("SSLv3");
}
String ignoredCiphers = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_CIPHERS);
if (ignoredCiphers != null && ignoredCiphers.length() > 0) {
String[] ciphers = ignoredCiphers.split(",");
sslConnectorFactory.addExcludeCipherSuites(ciphers);
}
sslConnectorFactory.setCertAlias(System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_CERT_ALIAS, SecurityConstants.ALIAS_SYM_PRIVATE_KEY));
sslConnectorFactory.setKeyStore(securityService.getKeyStore());
sslConnectorFactory.setTrustStore(securityService.getTrustStore());
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslConnectorFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
https.setPort(securePort);
https.setIdleTimeout(maxIdleTime);
https.setHost(host);
connectors.add(https);
log.info(String.format("About to start %s web server on secure host:port %s:%s", name, host == null ? "default" : host, securePort));
}
return connectors.toArray(new Connector[connectors.size()]);
}
use of org.jumpmind.properties.TypedProperties in project symmetric-ds by JumpMind.
the class SqlPersistenceManagerTest method createDatabasePlatform.
public static IDatabasePlatform createDatabasePlatform() throws Exception {
final String DB_DIR = "build/dbs";
File dir = new File(DB_DIR);
if (dir.exists()) {
FileUtils.deleteDirectory(new File(DB_DIR));
}
TypedProperties properties = new TypedProperties();
properties.setProperty(BasicDataSourcePropertyConstants.DB_POOL_DRIVER, "org.h2.Driver");
properties.setProperty(BasicDataSourcePropertyConstants.DB_POOL_URL, "jdbc:h2:file:" + DB_DIR + "/testdb");
properties.setProperty(BasicDataSourcePropertyConstants.DB_POOL_USER, "jumpmind");
properties.setProperty(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD, "jumpmind");
DataSource ds = BasicDataSourceFactory.create(properties);
return JdbcDatabasePlatformFactory.createNewPlatformInstance(ds, new SqlTemplateSettings(), false, false);
}
use of org.jumpmind.properties.TypedProperties in project symmetric-ds by JumpMind.
the class SymmetricWebServer method initFromProperties.
protected void initFromProperties() {
try {
Class.forName(AbstractCommandLauncher.class.getName());
} catch (ClassNotFoundException e) {
}
TypedProperties serverProperties = new TypedProperties(System.getProperties());
httpEnabled = serverProperties.is(ServerConstants.HTTP_ENABLE, Boolean.parseBoolean(System.getProperty(ServerConstants.HTTP_ENABLE, "true")));
httpsEnabled = serverProperties.is(ServerConstants.HTTPS_ENABLE, Boolean.parseBoolean(System.getProperty(ServerConstants.HTTPS_ENABLE, "true")));
jmxEnabled = serverProperties.is(ServerConstants.JMX_HTTP_ENABLE, Boolean.parseBoolean(System.getProperty(ServerConstants.JMX_HTTP_ENABLE, "true")));
httpPort = serverProperties.getInt(ServerConstants.HTTP_PORT, Integer.parseInt(System.getProperty(ServerConstants.HTTP_PORT, "" + httpPort)));
httpsPort = serverProperties.getInt(ServerConstants.HTTPS_PORT, Integer.parseInt(System.getProperty(ServerConstants.HTTPS_PORT, "" + httpsPort)));
jmxPort = serverProperties.getInt(ServerConstants.JMX_HTTP_PORT, Integer.parseInt(System.getProperty(ServerConstants.JMX_HTTP_PORT, "" + jmxPort)));
host = serverProperties.get(ServerConstants.HOST_BIND_NAME, System.getProperty(ServerConstants.HOST_BIND_NAME, host));
httpSslVerifiedServerNames = serverProperties.get(ServerConstants.HTTPS_VERIFIED_SERVERS, System.getProperty(ServerConstants.HTTPS_VERIFIED_SERVERS, httpSslVerifiedServerNames));
allowSelfSignedCerts = serverProperties.is(ServerConstants.HTTPS_ALLOW_SELF_SIGNED_CERTS, Boolean.parseBoolean(System.getProperty(ServerConstants.HTTPS_ALLOW_SELF_SIGNED_CERTS, "" + allowSelfSignedCerts)));
allowDirListing = serverProperties.get(ServerConstants.SERVER_ALLOW_DIR_LISTING, "false");
allowedMethods = serverProperties.get(ServerConstants.SERVER_ALLOW_HTTP_METHODS, "");
disallowedMethods = serverProperties.get(ServerConstants.SERVER_DISALLOW_HTTP_METHODS, "OPTIONS");
}
Aggregations