Search in sources :

Example 11 with TypedProperties

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;
    }
}
Also used : IOException(java.io.IOException) TypedProperties(org.jumpmind.properties.TypedProperties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 12 with TypedProperties

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();
    }
}
Also used : TypedProperties(org.jumpmind.properties.TypedProperties)

Example 13 with 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()]);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ArrayList(java.util.ArrayList) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) TypedProperties(org.jumpmind.properties.TypedProperties) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ServerConnector(org.eclipse.jetty.server.ServerConnector) ISecurityService(org.jumpmind.security.ISecurityService) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory)

Example 14 with TypedProperties

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);
}
Also used : SqlTemplateSettings(org.jumpmind.db.sql.SqlTemplateSettings) TypedProperties(org.jumpmind.properties.TypedProperties) File(java.io.File) ResettableBasicDataSource(org.jumpmind.db.util.ResettableBasicDataSource) DataSource(javax.sql.DataSource)

Example 15 with TypedProperties

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");
}
Also used : TypedProperties(org.jumpmind.properties.TypedProperties)

Aggregations

TypedProperties (org.jumpmind.properties.TypedProperties)16 File (java.io.File)4 IOException (java.io.IOException)3 ISecurityService (org.jumpmind.security.ISecurityService)2 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)2 IRegistrationService (org.jumpmind.symmetric.service.IRegistrationService)2 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Attributes (java.util.jar.Attributes)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 DataSource (javax.sql.DataSource)1 Connector (org.eclipse.jetty.server.Connector)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)1 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)1