diff --git a/symmetric-assemble/src/docbook/advanced-topics.xml b/symmetric-assemble/src/docbook/advanced-topics.xml index 49efa818b1..ebead1c8e6 100644 --- a/symmetric-assemble/src/docbook/advanced-topics.xml +++ b/symmetric-assemble/src/docbook/advanced-topics.xml @@ -805,7 +805,7 @@ net stop symmetricds web/WEB-INF/lib folders. Then, in the symmetric.properties specify your class name for the security service. - security.service.class.name=org.jumpmind.symmetric.service.impl.SecurityService + security.service.class.name=org.jumpmind.security.SecurityService Remember to specify your properties file when encrypting passwords, so it will use your custom ISecurityService. diff --git a/symmetric-client/src/main/java/org/jumpmind/symmetric/AbstractCommandLauncher.java b/symmetric-client/src/main/java/org/jumpmind/symmetric/AbstractCommandLauncher.java index 6c7a16543f..855d8fbc12 100644 --- a/symmetric-client/src/main/java/org/jumpmind/symmetric/AbstractCommandLauncher.java +++ b/symmetric-client/src/main/java/org/jumpmind/symmetric/AbstractCommandLauncher.java @@ -51,6 +51,7 @@ import org.apache.log4j.xml.DOMConfigurator; import org.jumpmind.db.platform.IDatabasePlatform; import org.jumpmind.properties.TypedProperties; +import org.jumpmind.security.SecurityConstants; import org.jumpmind.symmetric.common.ParameterConstants; import org.jumpmind.symmetric.common.SystemConstants; import org.slf4j.Logger; @@ -287,7 +288,7 @@ public File findSingleEnginesPropertiesFile() { protected void configureCrypto(CommandLine line) throws Exception { if (line.hasOption(OPTION_KEYSTORE_PASSWORD)) { - System.setProperty(SystemConstants.SYSPROP_KEYSTORE_PASSWORD, + System.setProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD, line.getOptionValue(OPTION_KEYSTORE_PASSWORD)); } diff --git a/symmetric-client/src/main/java/org/jumpmind/symmetric/ClientSymmetricEngine.java b/symmetric-client/src/main/java/org/jumpmind/symmetric/ClientSymmetricEngine.java index ff263e12b6..1cefe04f99 100644 --- a/symmetric-client/src/main/java/org/jumpmind/symmetric/ClientSymmetricEngine.java +++ b/symmetric-client/src/main/java/org/jumpmind/symmetric/ClientSymmetricEngine.java @@ -28,12 +28,11 @@ import org.jumpmind.db.platform.JdbcDatabasePlatformFactory; import org.jumpmind.db.sql.JdbcSqlTemplate; import org.jumpmind.db.sql.SqlTemplateSettings; -import org.jumpmind.db.util.ResettableBasicDataSource; +import org.jumpmind.db.util.BasicDataSourceFactory; import org.jumpmind.exception.IoException; import org.jumpmind.properties.TypedProperties; import org.jumpmind.symmetric.DbExport.Format; import org.jumpmind.symmetric.common.ParameterConstants; -import org.jumpmind.symmetric.common.SecurityConstants; import org.jumpmind.symmetric.common.TableConstants; import org.jumpmind.symmetric.db.ISymmetricDialect; import org.jumpmind.symmetric.db.JdbcSymmetricDialectFactory; @@ -44,10 +43,8 @@ import org.jumpmind.symmetric.job.IJobManager; import org.jumpmind.symmetric.job.JobManager; import org.jumpmind.symmetric.model.TriggerHistory; -import org.jumpmind.symmetric.service.ISecurityService; import org.jumpmind.util.AppUtils; import org.jumpmind.util.JarBuilder; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; @@ -187,55 +184,7 @@ public synchronized void stop() { public static BasicDataSource createBasicDataSource(File propsFile) { TypedProperties properties = createTypedPropertiesFactory(propsFile, null).reload(); - return createBasicDataSource(properties, createSecurityService(properties)); - } - - public static BasicDataSource createBasicDataSource(TypedProperties properties, - ISecurityService securityService) { - ResettableBasicDataSource dataSource = new ResettableBasicDataSource(); - dataSource.setDriverClassName(properties.get(ParameterConstants.DB_POOL_DRIVER, null)); - dataSource.setUrl(properties.get(ParameterConstants.DB_POOL_URL, null)); - String user = properties.get(ParameterConstants.DB_POOL_USER, ""); - if (user != null && user.startsWith(SecurityConstants.PREFIX_ENC)) { - user = securityService.decrypt(user.substring(SecurityConstants.PREFIX_ENC.length())); - } - dataSource.setUsername(user); - - String password = properties.get(ParameterConstants.DB_POOL_PASSWORD, ""); - if (password != null && password.startsWith(SecurityConstants.PREFIX_ENC)) { - password = securityService.decrypt(password.substring(SecurityConstants.PREFIX_ENC - .length())); - } - dataSource.setPassword(password); - dataSource.setInitialSize(properties.getInt(ParameterConstants.DB_POOL_INITIAL_SIZE, 5)); - dataSource.setMaxActive(properties.getInt(ParameterConstants.DB_POOL_MAX_ACTIVE, 20)); - dataSource.setMaxWait(properties.getInt(ParameterConstants.DB_POOL_MAX_WAIT, 5000)); - dataSource.setMinEvictableIdleTimeMillis(properties.getInt( - ParameterConstants.DB_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS, 60000)); - dataSource.setTimeBetweenEvictionRunsMillis(120000); - dataSource.setNumTestsPerEvictionRun(10); - dataSource.setValidationQuery(properties.get(ParameterConstants.DB_POOL_VALIDATION_QUERY, - null)); - dataSource.setTestOnBorrow(properties.is(ParameterConstants.DB_POOL_TEST_ON_BORROW, true)); - dataSource.setTestOnReturn(properties.is(ParameterConstants.DB_POOL_TEST_ON_RETURN, false)); - dataSource.setTestWhileIdle(properties - .is(ParameterConstants.DB_POOL_TEST_WHILE_IDLE, false)); - - String connectionProperties = properties.get( - ParameterConstants.DB_POOL_CONNECTION_PROPERTIES, null); - if (StringUtils.isNotBlank(connectionProperties)) { - String[] tokens = connectionProperties.split(";"); - for (String property : tokens) { - String[] keyValue = property.split("="); - if (keyValue != null && keyValue.length > 1) { - LoggerFactory.getLogger(ClientSymmetricEngine.class).info( - "Setting database connection property %s=%s", keyValue[0], keyValue[1]); - dataSource.addConnectionProperty(keyValue[0], keyValue[1]); - } - } - } - return dataSource; - + return BasicDataSourceFactory.create(properties, createSecurityService(properties)); } @Override @@ -252,7 +201,7 @@ protected IDatabasePlatform createDatabasePlatform(TypedProperties properties) { public static IDatabasePlatform createDatabasePlatform(TypedProperties properties, BasicDataSource dataSource, boolean waitOnAvailableDatabase) { if (dataSource == null) { - dataSource = createBasicDataSource(properties, createSecurityService(properties)); + dataSource = BasicDataSourceFactory.create(properties, createSecurityService(properties)); } if (waitOnAvailableDatabase) { waitForAvailableDatabase(dataSource); diff --git a/symmetric-client/src/main/java/org/jumpmind/symmetric/SymmetricAdmin.java b/symmetric-client/src/main/java/org/jumpmind/symmetric/SymmetricAdmin.java index 12df0b6bb8..684c91c743 100644 --- a/symmetric-client/src/main/java/org/jumpmind/symmetric/SymmetricAdmin.java +++ b/symmetric-client/src/main/java/org/jumpmind/symmetric/SymmetricAdmin.java @@ -43,14 +43,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.h2.util.StringUtils; -import org.jumpmind.symmetric.common.SecurityConstants; +import org.jumpmind.security.ISecurityService; +import org.jumpmind.security.SecurityConstants; import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.service.IDataExtractorService; import org.jumpmind.symmetric.service.IDataLoaderService; import org.jumpmind.symmetric.service.IDataService; import org.jumpmind.symmetric.service.IPurgeService; import org.jumpmind.symmetric.service.IRegistrationService; -import org.jumpmind.symmetric.service.ISecurityService; import org.jumpmind.symmetric.service.ITriggerRouterService; import org.jumpmind.util.JarBuilder; diff --git a/symmetric-client/src/main/java/org/jumpmind/symmetric/service/jmx/NodeManagementService.java b/symmetric-client/src/main/java/org/jumpmind/symmetric/service/jmx/NodeManagementService.java index 8f4f3fa826..e1b47a9fb2 100644 --- a/symmetric-client/src/main/java/org/jumpmind/symmetric/service/jmx/NodeManagementService.java +++ b/symmetric-client/src/main/java/org/jumpmind/symmetric/service/jmx/NodeManagementService.java @@ -35,9 +35,9 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.jumpmind.extension.IBuiltInExtensionPoint; +import org.jumpmind.security.SecurityConstants; import org.jumpmind.symmetric.ISymmetricEngine; import org.jumpmind.symmetric.common.ParameterConstants; -import org.jumpmind.symmetric.common.SecurityConstants; import org.jumpmind.symmetric.ext.ISymmetricEngineAware; import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.transport.ConcurrentConnectionManager.NodeConnectionStatistics; diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java index dd563e7811..20799ac9fb 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java @@ -42,6 +42,8 @@ import org.jumpmind.db.sql.SqlScript; import org.jumpmind.db.sql.SqlScriptReader; import org.jumpmind.properties.TypedProperties; +import org.jumpmind.security.ISecurityService; +import org.jumpmind.security.SecurityService; import org.jumpmind.symmetric.common.Constants; import org.jumpmind.symmetric.common.ParameterConstants; import org.jumpmind.symmetric.common.TableConstants; @@ -76,7 +78,6 @@ import org.jumpmind.symmetric.service.IPushService; import org.jumpmind.symmetric.service.IRegistrationService; import org.jumpmind.symmetric.service.IRouterService; -import org.jumpmind.symmetric.service.ISecurityService; import org.jumpmind.symmetric.service.ISequenceService; import org.jumpmind.symmetric.service.IStatisticService; import org.jumpmind.symmetric.service.ITransformService; @@ -100,7 +101,6 @@ import org.jumpmind.symmetric.service.impl.PushService; import org.jumpmind.symmetric.service.impl.RegistrationService; import org.jumpmind.symmetric.service.impl.RouterService; -import org.jumpmind.symmetric.service.impl.SecurityService; import org.jumpmind.symmetric.service.impl.SequenceService; import org.jumpmind.symmetric.service.impl.StatisticService; import org.jumpmind.symmetric.service.impl.TransformService; @@ -635,6 +635,16 @@ public void forceTriggerRebuild() { public NodeStatus getNodeStatus() { return nodeService.getNodeStatus(); } + + public void removeAndCleanupNode(String nodeId) { + log.warn("Removing node {}", nodeId); + nodeService.deleteNode(nodeId); + log.warn("Marking outgoing batch records as Ok for {}", nodeId); + outgoingBatchService.markAllAsSentForNode(nodeId); + log.warn("Marking incoming batch records as Ok for {}", nodeId); + incomingBatchService.markIncomingBatchesOk(nodeId); + log.warn("Done removing node {}", nodeId); + } public RemoteNodeStatuses pull() { MDC.put("engineName", getEngineName()); diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/ISymmetricEngine.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/ISymmetricEngine.java index ef03ff63e1..f07b70666b 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/ISymmetricEngine.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/ISymmetricEngine.java @@ -26,6 +26,7 @@ import org.jumpmind.db.platform.IDatabasePlatform; import org.jumpmind.db.sql.ISqlTemplate; +import org.jumpmind.security.ISecurityService; import org.jumpmind.symmetric.db.ISymmetricDialect; import org.jumpmind.symmetric.ext.IExtensionPointManager; import org.jumpmind.symmetric.io.stage.IStagingManager; @@ -50,7 +51,6 @@ import org.jumpmind.symmetric.service.IPushService; import org.jumpmind.symmetric.service.IRegistrationService; import org.jumpmind.symmetric.service.IRouterService; -import org.jumpmind.symmetric.service.ISecurityService; import org.jumpmind.symmetric.service.ISequenceService; import org.jumpmind.symmetric.service.IStatisticService; import org.jumpmind.symmetric.service.ITransformService; @@ -210,6 +210,8 @@ public interface ISymmetricEngine { * @param force forces this action to be run regardless of the parameter settings */ public void setupDatabase(boolean force); + + public void removeAndCleanupNode(String nodeId); public IConfigurationService getConfigurationService(); diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java index f865cb9ad3..e4d65c06d2 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java @@ -160,20 +160,6 @@ private ParameterConstants() { public final static String CACHE_TIMEOUT_TABLES_IN_MS = "cache.table.time.ms"; public final static String TRIGGER_UPDATE_CAPTURE_CHANGED_DATA_ONLY = "trigger.update.capture.changed.data.only.enabled"; - - public final static String DB_POOL_URL = "db.url"; - public final static String DB_POOL_DRIVER = "db.driver"; - public final static String DB_POOL_USER = "db.user"; - public final static String DB_POOL_PASSWORD = "db.password"; - public final static String DB_POOL_INITIAL_SIZE = "db.pool.initial.size"; - public final static String DB_POOL_MAX_ACTIVE = "db.pool.max.active"; - public final static String DB_POOL_MAX_WAIT = "db.pool.max.wait.millis"; - public final static String DB_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS = "db.pool.min.evictable.idle.millis"; - public final static String DB_POOL_VALIDATION_QUERY = "db.validation.query"; - public final static String DB_POOL_TEST_ON_BORROW = "db.test.on.borrow"; - public final static String DB_POOL_TEST_ON_RETURN = "db.test.on.return"; - public final static String DB_POOL_TEST_WHILE_IDLE = "db.test.while.idle"; - public final static String DB_POOL_CONNECTION_PROPERTIES = "db.connection.properties"; public final static String DB_METADATA_IGNORE_CASE = "db.metadata.ignore.case"; public final static String DB_NATIVE_EXTRACTOR = "db.native.extractor"; diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SystemConstants.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SystemConstants.java index 9fcd1e2eea..4cb5c760d5 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SystemConstants.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SystemConstants.java @@ -33,9 +33,7 @@ public class SystemConstants { public static final String SYSPROP_WEB_DIR = "symmetric.default.web.dir"; public static final String SYSPROP_DEFAULT_HTTP_PORT = "symmetric.default.http.port"; public static final String SYSPROP_DEFAULT_HTTPS_PORT = "symmetric.default.https.port"; - public static final String SYSPROP_KEYSTORE = "sym.keystore.file"; public static final String SYSPROP_KEYSTORE_TYPE = "sym.keystore.type"; - public static final String SYSPROP_KEYSTORE_PASSWORD = "javax.net.ssl.keyStorePassword"; public static final String SYSPROP_KEYSTORE_CERT_ALIAS = "sym.keystore.ssl.cert.alias"; } \ No newline at end of file diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/job/DefaultOfflineServerListener.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/job/DefaultOfflineServerListener.java index a8d4f81768..4fcaa60cc8 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/job/DefaultOfflineServerListener.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/job/DefaultOfflineServerListener.java @@ -59,7 +59,7 @@ public void clientNodeOffline(Node node) { statisticManager.incrementNodesDisabled(1); node.setSyncEnabled(false); nodeService.save(node); - outgoingBatchService.markAllAsSentForNode(node); + outgoingBatchService.markAllAsSentForNode(node.getNodeId()); nodeService.deleteNodeSecurity(node.getNodeId()); } diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/IOutgoingBatchService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/IOutgoingBatchService.java index bd45e9bb08..e9e6e8f6d1 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/IOutgoingBatchService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/IOutgoingBatchService.java @@ -24,7 +24,6 @@ import java.util.List; import org.jumpmind.db.sql.ISqlTransaction; -import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.model.OutgoingBatch; import org.jumpmind.symmetric.model.OutgoingBatchSummary; import org.jumpmind.symmetric.model.OutgoingBatches; @@ -34,13 +33,13 @@ */ public interface IOutgoingBatchService { - public void markAllAsSentForNode(Node node); + public void markAllAsSentForNode(String nodeId); public void updateAbandonedRoutingBatches(); public OutgoingBatch findOutgoingBatch(long batchId, String nodeId); - public OutgoingBatches getOutgoingBatches(Node node, boolean includeDisabledChannels); + public OutgoingBatches getOutgoingBatches(String nodeId, boolean includeDisabledChannels); public OutgoingBatches getOutgoingBatchRange(String startBatchId, String endBatchId); diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java index 2c721b3151..518634f293 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java @@ -298,7 +298,7 @@ public List extract(Node targetNode, IOutgoingTransport targetTra routerService.routeData(true); } - OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(targetNode, false); + OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(targetNode.getNodeId(), false); if (batches.containsBatches()) { diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataService.java index 470983111f..e5af4248e3 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataService.java @@ -137,7 +137,7 @@ public void insertReloadEvents(Node targetNode, boolean reverse) { /* * Outgoing data events are pointless because we are reloading all data */ - engine.getOutgoingBatchService().markAllAsSentForNode(targetNode); + engine.getOutgoingBatchService().markAllAsSentForNode(targetNode.getNodeId()); Node sourceNode = engine.getNodeService().findIdentity(); diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/NodeService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/NodeService.java index 08a6a89b1d..b7e507b611 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/NodeService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/NodeService.java @@ -223,6 +223,7 @@ public void deleteNode(String nodeId) { if (nodeId.equals(findIdentityNodeId())) { sqlTemplate.update(getSql("deleteNodeIdentitySql")); } + deleteNodeSecurity(nodeId); sqlTemplate.update(getSql("deleteNodeHostSql"), new Object[] { nodeId }); sqlTemplate.update(getSql("deleteNodeSql"), new Object[] { nodeId }); } diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/OutgoingBatchService.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/OutgoingBatchService.java index 7523868b95..e0b497af95 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/OutgoingBatchService.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/OutgoingBatchService.java @@ -38,7 +38,6 @@ import org.jumpmind.symmetric.common.TableConstants; import org.jumpmind.symmetric.db.ISymmetricDialect; import org.jumpmind.symmetric.model.Channel; -import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.model.NodeChannel; import org.jumpmind.symmetric.model.NodeGroupChannelWindow; import org.jumpmind.symmetric.model.NodeHost; @@ -81,10 +80,10 @@ public OutgoingBatchService(IParameterService parameterService, createSqlReplacementTokens())); } - public void markAllAsSentForNode(Node node) { + public void markAllAsSentForNode(String nodeId) { OutgoingBatches batches = null; do { - batches = getOutgoingBatches(node, true); + batches = getOutgoingBatches(nodeId, true); for (OutgoingBatch outgoingBatch : batches.getBatches()) { outgoingBatch.setStatus(Status.OK); outgoingBatch.setErrorFlag(false); @@ -247,21 +246,21 @@ protected boolean containsOnlyStatus(OutgoingBatch.Status status, * been created by {@link #buildOutgoingBatches(String)} in channel priority * order. */ - public OutgoingBatches getOutgoingBatches(Node node, boolean includeDisabledChannels) { + public OutgoingBatches getOutgoingBatches(String nodeId, boolean includeDisabledChannels) { long ts = System.currentTimeMillis(); final int maxNumberOfBatchesToSelect = parameterService.getInt( ParameterConstants.OUTGOING_BATCH_MAX_BATCHES_TO_SELECT, 1000); List list = (List) sqlTemplate.query( getSql("selectOutgoingBatchPrefixSql", "selectOutgoingBatchSql"), maxNumberOfBatchesToSelect, new OutgoingBatchMapper(includeDisabledChannels, true), - new Object[] { node.getNodeId(), OutgoingBatch.Status.NE.name(), + new Object[] { nodeId, OutgoingBatch.Status.NE.name(), OutgoingBatch.Status.QY.name(), OutgoingBatch.Status.SE.name(), OutgoingBatch.Status.LD.name(), OutgoingBatch.Status.ER.name(), OutgoingBatch.Status.IG.name() }, null); OutgoingBatches batches = new OutgoingBatches(list); - List channels = configurationService.getNodeChannels(node.getNodeId(), true); + List channels = configurationService.getNodeChannels(nodeId, true); batches.sortChannels(channels); List keepers = new ArrayList(); @@ -270,7 +269,7 @@ maxNumberOfBatchesToSelect, new OutgoingBatchMapper(includeDisabledChannels, tru if (parameterService.is(ParameterConstants.DATA_EXTRACTOR_ENABLED) || channel.getChannelId().equals(Constants.CHANNEL_CONFIG)) { keepers.addAll(getBatchesForChannelWindows(batches, - node, + nodeId, channel, configurationService.getNodeGroupChannelWindows( parameterService.getNodeGroupId(), channel.getChannelId()))); @@ -286,12 +285,12 @@ maxNumberOfBatchesToSelect, new OutgoingBatchMapper(includeDisabledChannels, tru return batches; } - public List getBatchesForChannelWindows(OutgoingBatches batches, Node targetNode, NodeChannel channel, + public List getBatchesForChannelWindows(OutgoingBatches batches, String targetNodeId, NodeChannel channel, List windows) { List keeping = new ArrayList(); List current = batches.getBatches(); if (current != null && current.size() > 0) { - if (inTimeWindow(windows, targetNode)) { + if (inTimeWindow(windows, targetNodeId)) { int maxBatchesToSend = channel.getMaxBatchToSend(); for (OutgoingBatch outgoingBatch : current) { if (channel.getChannelId().equals(outgoingBatch.getChannelId()) && maxBatchesToSend > 0) { @@ -309,11 +308,11 @@ public List getBatchesForChannelWindows(OutgoingBatches batches, * check to see if the time (according to the offset passed in) is within on * of the configured windows. */ - public boolean inTimeWindow(List windows, Node targetNode) { + public boolean inTimeWindow(List windows, String targetNodeId) { if (windows != null && windows.size() > 0) { for (NodeGroupChannelWindow window : windows) { String timezoneOffset = null; - List hosts = nodeService.findNodeHosts(targetNode.getNodeId()); + List hosts = nodeService.findNodeHosts(targetNodeId); if (hosts.size() > 0) { timezoneOffset = hosts.get(0).getTimezoneOffset(); } else { diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/util/DefaultNodeIdCreator.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/util/DefaultNodeIdCreator.java index 9007d7de5d..4a80654369 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/util/DefaultNodeIdCreator.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/util/DefaultNodeIdCreator.java @@ -22,13 +22,13 @@ package org.jumpmind.symmetric.util; import org.apache.commons.lang.StringUtils; +import org.jumpmind.security.SecurityService; import org.jumpmind.symmetric.common.ParameterConstants; import org.jumpmind.symmetric.config.INodeIdCreator; import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.model.NodeSecurity; import org.jumpmind.symmetric.service.INodeService; import org.jumpmind.symmetric.service.IParameterService; -import org.jumpmind.symmetric.service.impl.SecurityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/symmetric-core/src/main/resources/symmetric-default.properties b/symmetric-core/src/main/resources/symmetric-default.properties index 99c581da9e..22a35522ae 100644 --- a/symmetric-core/src/main/resources/symmetric-default.properties +++ b/symmetric-core/src/main/resources/symmetric-default.properties @@ -888,7 +888,7 @@ outgoing.batches.max.to.select=50000 # The class name for the Security Service to use for encrypting and # decrypting database passwords # Tags: database -security.service.class.name=org.jumpmind.symmetric.service.impl.SecurityService +security.service.class.name=org.jumpmind.security.SecurityService # This is a bean shell script that will be used to generate the node id # for a registering node diff --git a/symmetric-core/src/test/java/org/jumpmind/symmetric/service/impl/AbstractRouterServiceTest.java b/symmetric-core/src/test/java/org/jumpmind/symmetric/service/impl/AbstractRouterServiceTest.java index a1bbc02c1c..f19fa88a74 100644 --- a/symmetric-core/src/test/java/org/jumpmind/symmetric/service/impl/AbstractRouterServiceTest.java +++ b/symmetric-core/src/test/java/org/jumpmind/symmetric/service/impl/AbstractRouterServiceTest.java @@ -112,7 +112,7 @@ public void testMultiChannelRoutingToEveryone() { final int EXPECTED_BATCHES = getDbDialect().supportsTransactionId() ? 16 : 17; - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel, otherChannel); Assert.assertEquals(EXPECTED_BATCHES, batches.getBatches().size()); @@ -120,12 +120,12 @@ public void testMultiChannelRoutingToEveryone() { countBatchesForChannel(batches, testChannel)); Assert.assertEquals(15, countBatchesForChannel(batches, otherChannel)); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false); filterForChannels(batches, testChannel, otherChannel); // Node 2 has sync disabled Assert.assertEquals(0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel, otherChannel); Assert.assertEquals(EXPECTED_BATCHES, batches.getBatches().size()); @@ -140,7 +140,7 @@ public void testMultiChannelRoutingToEveryone() { insert(TEST_TABLE_1, 50, false); getRouterService().routeData(true); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel, otherChannel); Assert.assertEquals(getDbDialect().supportsTransactionId() ? 3 : 17, batches.getBatches() .size()); @@ -288,18 +288,18 @@ public void testColumnMatchTransactionalOnlyRoutingToNode1() { final int EXPECTED_BATCHES = getDbDialect().supportsTransactionId() ? 51 : 550; - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(EXPECTED_BATCHES, batches.getBatches().size()); Assert.assertEquals(EXPECTED_BATCHES, countBatchesForChannel(batches, testChannel)); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false); filterForChannels(batches, testChannel); // Node 2 has sync disabled Assert.assertEquals(0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel); // Batch was targeted only at node 1 Assert.assertEquals(0, batches.getBatches().size()); @@ -309,19 +309,19 @@ public void testColumnMatchTransactionalOnlyRoutingToNode1() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); execute("delete from " + TEST_TABLE_1, null); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); Assert.assertEquals( getDbDialect().supportsTransactionId() ? 1 : 705, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -350,18 +350,18 @@ public void testSubSelectNonTransactionalRoutingToNode1() { final int EXPECTED_BATCHES = 100; - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(EXPECTED_BATCHES, batches.getBatches().size()); Assert.assertEquals(EXPECTED_BATCHES, countBatchesForChannel(batches, testChannel)); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false); filterForChannels(batches, testChannel); // Node 2 has sync disabled Assert.assertEquals(0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel); // Batch was targeted only at node 1 Assert.assertEquals(0, batches.getBatches().size()); @@ -391,14 +391,14 @@ public void testSyncIncomingBatch() throws Exception { getRouterService().routeData(true); - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals( "Should have been 0. We did the insert as if the data had come from node 1.", 0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(1, batches.getBatches().size()); @@ -483,7 +483,7 @@ public void testBshTransactionalRoutingOnUpdate() { logger.info("Just routed " + count + " rows in " + TEST_TABLE_1 + " in " + (System.currentTimeMillis() - ts) + "ms"); - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(getDbDialect().supportsTransactionId() ? 1 : 510, batches.getBatches() @@ -491,12 +491,12 @@ public void testBshTransactionalRoutingOnUpdate() { Assert.assertEquals(getDbDialect().supportsTransactionId() ? count : 1, (int) batches .getBatches().get(0).getDataEventCount()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false); filterForChannels(batches, testChannel); // Node 2 has sync disabled Assert.assertEquals(0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(getDbDialect().supportsTransactionId() ? 1 : 510, batches.getBatches() .size()); @@ -526,17 +526,17 @@ public void testBshRoutingDeletesToNode3() { int count = getSqlTemplate().update(String.format("delete from %s", TEST_TABLE_1)); getRouterService().routeData(true); - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals(count / MAX_BATCH_SIZE + (count % MAX_BATCH_SIZE > 0 ? 1 : 0), batches .getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false); // Node 2 has sync disabled Assert.assertEquals(0, batches.getBatches().size()); - batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false); + batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); // Batch was targeted only at node 3 Assert.assertEquals(0, batches.getBatches().size()); @@ -581,7 +581,7 @@ public void testColumnMatchSubtableRoutingToNode1() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); @@ -589,17 +589,17 @@ public void testColumnMatchSubtableRoutingToNode1() { Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false), testChannel)); resetBatches(); @@ -607,7 +607,7 @@ public void testColumnMatchSubtableRoutingToNode1() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); execute("delete from " + TEST_SUBTABLE, null); @@ -615,34 +615,34 @@ public void testColumnMatchSubtableRoutingToNode1() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false), testChannel)); getRouterService().routeData(true); Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_2.getNodeId(), false), testChannel)); Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false), testChannel)); resetBatches(); @@ -667,7 +667,7 @@ public void testColumnMatchOnNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); @@ -675,7 +675,7 @@ public void testColumnMatchOnNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -685,7 +685,7 @@ public void testColumnMatchOnNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); @@ -693,7 +693,7 @@ public void testColumnMatchOnNull() { Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); } @@ -716,7 +716,7 @@ public void testColumnMatchOnNotNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); @@ -724,7 +724,7 @@ public void testColumnMatchOnNotNull() { Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -734,7 +734,7 @@ public void testColumnMatchOnNotNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); getRouterService().routeData(true); @@ -742,7 +742,7 @@ public void testColumnMatchOnNotNull() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); } @@ -767,7 +767,7 @@ public void testSyncOnColumnChange() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); insert(TEST_TABLE_1, 1, true); @@ -776,7 +776,7 @@ public void testSyncOnColumnChange() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -791,7 +791,7 @@ public void testSyncOnColumnChange() { Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -803,7 +803,7 @@ public void testSyncOnColumnChange() { Assert.assertEquals( 0, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); resetBatches(); @@ -815,7 +815,7 @@ public void testSyncOnColumnChange() { Assert.assertEquals( 1, countBatchesForChannel( - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false), + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel)); } @@ -844,7 +844,7 @@ public void testSyncIncomingBatchWhenUnrouted() throws Exception { getRouterService().routeData(true); - OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, + OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false); filterForChannels(batches, testChannel); Assert.assertEquals( @@ -868,14 +868,14 @@ public void testDefaultRouteToTargetNodeGroupOnly() throws Exception { getRouterService().routeData(true); Assert.assertEquals(1, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false).getBatches() + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches() .size()); Node node2 = getNodeService().findNode("00030"); Assert.assertNotNull(node2); - Assert.assertEquals(0, getOutgoingBatchService().getOutgoingBatches(node2, false) + Assert.assertEquals(0, getOutgoingBatchService().getOutgoingBatches(node2.getNodeId(), false) .getBatches().size()); resetBatches(); @@ -909,7 +909,7 @@ public void testGapRouting() throws Exception { getRouterService().routeData(true); Assert.assertEquals(1, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false) + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false) .getBatches().size()); List gaps = getDataService().findDataGaps(); @@ -954,7 +954,7 @@ public void testGapWithGapAtBegining() { routeAndCreateGaps(); Assert.assertEquals(1, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false) + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false) .getBatches().size()); gaps = getDataService().findDataGaps(); @@ -998,7 +998,7 @@ public void testGapWithGapAtEnd() { routeAndCreateGaps(); Assert.assertEquals(1, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false) + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false) .getBatches().size()); List gaps = getDataService().findDataGaps(); @@ -1048,7 +1048,7 @@ public void testLotsOfGaps() { routeAndCreateGaps(); Assert.assertEquals(10, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false) + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false) .getBatches().size()); List gaps = getDataService().findDataGaps(); @@ -1071,7 +1071,7 @@ public void testNoResend() { resetBatches(); Assert.assertEquals(0, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false).getBatches() + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches() .size()); getSqlTemplate().update("delete from sym_data_gap"); @@ -1079,7 +1079,7 @@ public void testNoResend() { routeAndCreateGaps(); Assert.assertEquals(0, - getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1, false).getBatches() + getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches() .size()); } diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/IConnectionCallback.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/IConnectionCallback.java index 1fab06d537..03cc9806dd 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/IConnectionCallback.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/IConnectionCallback.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import java.sql.Connection; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlReadCursor.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlReadCursor.java index 1fc5ed263d..db471bd9b7 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlReadCursor.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlReadCursor.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import java.sql.Connection; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTemplate.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTemplate.java index 7451ec404d..0e57d1f02e 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTemplate.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTemplate.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import java.io.IOException; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTransaction.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTransaction.java index e5294e8012..86d57ab4ae 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTransaction.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcSqlTransaction.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import java.sql.BatchUpdateException; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcUtils.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcUtils.java index 5a3e8eecd6..d43b5509d7 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcUtils.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/JdbcUtils.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import org.slf4j.Logger; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/SymmetricLobHandler.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/SymmetricLobHandler.java index 19448172eb..4532a1dc62 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/SymmetricLobHandler.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/sql/SymmetricLobHandler.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.sql; import java.sql.ResultSet; diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourceFactory.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourceFactory.java new file mode 100644 index 0000000000..b8140322a1 --- /dev/null +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourceFactory.java @@ -0,0 +1,92 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jumpmind.db.util; + +import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.lang.StringUtils; +import org.jumpmind.properties.TypedProperties; +import org.jumpmind.security.ISecurityService; +import org.jumpmind.security.SecurityConstants; +import org.jumpmind.security.SecurityService; +import org.slf4j.LoggerFactory; + +public class BasicDataSourceFactory { + + + public static BasicDataSource create(TypedProperties properties) { + return create(properties, new SecurityService()); + } + + public static BasicDataSource create(TypedProperties properties, + ISecurityService securityService) { + ResettableBasicDataSource dataSource = new ResettableBasicDataSource(); + dataSource.setDriverClassName(properties.get( + BasicDataSourcePropertyConstants.DB_POOL_DRIVER, null)); + dataSource.setUrl(properties.get(BasicDataSourcePropertyConstants.DB_POOL_URL, null)); + String user = properties.get(BasicDataSourcePropertyConstants.DB_POOL_USER, ""); + if (user != null && user.startsWith(SecurityConstants.PREFIX_ENC)) { + user = securityService.decrypt(user.substring(SecurityConstants.PREFIX_ENC.length())); + } + dataSource.setUsername(user); + + String password = properties.get(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD, ""); + if (password != null && password.startsWith(SecurityConstants.PREFIX_ENC)) { + password = securityService.decrypt(password.substring(SecurityConstants.PREFIX_ENC + .length())); + } + dataSource.setPassword(password); + dataSource.setInitialSize(properties.getInt( + BasicDataSourcePropertyConstants.DB_POOL_INITIAL_SIZE, 5)); + dataSource.setMaxActive(properties.getInt( + BasicDataSourcePropertyConstants.DB_POOL_MAX_ACTIVE, 20)); + dataSource.setMaxWait(properties.getInt(BasicDataSourcePropertyConstants.DB_POOL_MAX_WAIT, + 5000)); + dataSource.setMinEvictableIdleTimeMillis(properties.getInt( + BasicDataSourcePropertyConstants.DB_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS, 60000)); + dataSource.setTimeBetweenEvictionRunsMillis(120000); + dataSource.setNumTestsPerEvictionRun(10); + dataSource.setValidationQuery(properties.get( + BasicDataSourcePropertyConstants.DB_POOL_VALIDATION_QUERY, null)); + dataSource.setTestOnBorrow(properties.is( + BasicDataSourcePropertyConstants.DB_POOL_TEST_ON_BORROW, true)); + dataSource.setTestOnReturn(properties.is( + BasicDataSourcePropertyConstants.DB_POOL_TEST_ON_RETURN, false)); + dataSource.setTestWhileIdle(properties.is( + BasicDataSourcePropertyConstants.DB_POOL_TEST_WHILE_IDLE, false)); + + String connectionProperties = properties.get( + BasicDataSourcePropertyConstants.DB_POOL_CONNECTION_PROPERTIES, null); + if (StringUtils.isNotBlank(connectionProperties)) { + String[] tokens = connectionProperties.split(";"); + for (String property : tokens) { + String[] keyValue = property.split("="); + if (keyValue != null && keyValue.length > 1) { + LoggerFactory.getLogger(BasicDataSourceFactory.class).info( + "Setting database connection property %s=%s", keyValue[0], keyValue[1]); + dataSource.addConnectionProperty(keyValue[0], keyValue[1]); + } + } + } + return dataSource; + + } + +} diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourcePropertyConstants.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourcePropertyConstants.java new file mode 100644 index 0000000000..08857be48a --- /dev/null +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/BasicDataSourcePropertyConstants.java @@ -0,0 +1,48 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jumpmind.db.util; + +/** + * Constants that represent parameters that can be retrieved or saved via the + * {@link IParameterService} + */ +final public class BasicDataSourcePropertyConstants { + + public static final String ALL = "ALL"; + + private BasicDataSourcePropertyConstants() { + } + + public final static String DB_POOL_URL = "db.url"; + public final static String DB_POOL_DRIVER = "db.driver"; + public final static String DB_POOL_USER = "db.user"; + public final static String DB_POOL_PASSWORD = "db.password"; + public final static String DB_POOL_INITIAL_SIZE = "db.pool.initial.size"; + public final static String DB_POOL_MAX_ACTIVE = "db.pool.max.active"; + public final static String DB_POOL_MAX_WAIT = "db.pool.max.wait.millis"; + public final static String DB_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS = "db.pool.min.evictable.idle.millis"; + public final static String DB_POOL_VALIDATION_QUERY = "db.validation.query"; + public final static String DB_POOL_TEST_ON_BORROW = "db.test.on.borrow"; + public final static String DB_POOL_TEST_ON_RETURN = "db.test.on.return"; + public final static String DB_POOL_TEST_WHILE_IDLE = "db.test.while.idle"; + public final static String DB_POOL_CONNECTION_PROPERTIES = "db.connection.properties"; + +} \ No newline at end of file diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/DataSourceProperties.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/DataSourceProperties.java deleted file mode 100644 index c77f1261f0..0000000000 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/DataSourceProperties.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.jumpmind.db.util; - -import java.net.URL; - -import javax.sql.DataSource; - -import org.apache.commons.dbcp.BasicDataSource; -import org.jumpmind.properties.EnvironmentSpecificProperties; - -public class DataSourceProperties extends EnvironmentSpecificProperties { - - public final static String DB_DRIVER = "db.driver"; - public final static String DB_URL = "db.url"; - public final static String DB_USERNAME = "db.user"; - public final static String DB_PASSWORD = "db.password"; - - private static final long serialVersionUID = 1L; - - private BasicDataSource dataSource; - - public DataSourceProperties(String systemPropertyName, URL fileUrl, String... propertiesForEnv) { - super(fileUrl, systemPropertyName, propertiesForEnv); - } - - public DataSource getDataSource() { - if (dataSource == null) { - dataSource = new BasicDataSource(); - dataSource.setDriverClassName(getProperty(DB_DRIVER)); - dataSource.setUrl(getProperty(DB_URL)); - dataSource.setUsername(getProperty(DB_USERNAME)); - dataSource.setPassword(getProperty(DB_PASSWORD)); - } - return dataSource; - } - -} diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/ResettableBasicDataSource.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/ResettableBasicDataSource.java index b20ed71676..d213d75343 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/util/ResettableBasicDataSource.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/util/ResettableBasicDataSource.java @@ -1,3 +1,23 @@ +/* + * Licensed to JumpMind Inc under one or more contributor + * license agreements. See the NOTICE file distributed + * with this work for additional information regarding + * copyright ownership. JumpMind Inc licenses this file + * to you under the GNU Lesser General Public License (the + * "License"); you may not use this file except in compliance + * with the License. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jumpmind.db.util; import java.sql.SQLException; diff --git a/symmetric-jdbc/src/test/java/org/jumpmind/db/DbTestUtils.java b/symmetric-jdbc/src/test/java/org/jumpmind/db/DbTestUtils.java index ab55dd055a..a24734bb43 100644 --- a/symmetric-jdbc/src/test/java/org/jumpmind/db/DbTestUtils.java +++ b/symmetric-jdbc/src/test/java/org/jumpmind/db/DbTestUtils.java @@ -6,25 +6,30 @@ import org.jumpmind.db.platform.IDatabasePlatform; import org.jumpmind.db.platform.JdbcDatabasePlatformFactory; import org.jumpmind.db.sql.SqlTemplateSettings; -import org.jumpmind.db.util.DataSourceProperties; +import org.jumpmind.db.util.BasicDataSourceFactory; +import org.jumpmind.properties.EnvironmentSpecificProperties; +import org.jumpmind.security.SecurityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; abstract public class DbTestUtils { - + Logger logger = LoggerFactory.getLogger(getClass()); - + public final static String DB_TEST_PROPERTIES = "/db-test.properties"; public static final String ROOT = "root"; public static final String CLIENT = "client"; - public static IDatabasePlatform createDatabasePlatform(String name) throws Exception { + public static IDatabasePlatform createDatabasePlatform(String name) throws Exception { File f = new File(String.format("target/%sdbs", name)); FileUtils.deleteDirectory(f); f.mkdir(); - DataSourceProperties properties = new DataSourceProperties(String.format("test.%s", name), - DatabasePlatformTest.class.getResource(DB_TEST_PROPERTIES), name); - return JdbcDatabasePlatformFactory.createNewPlatformInstance(properties.getDataSource(), new SqlTemplateSettings(), true); + EnvironmentSpecificProperties properties = new EnvironmentSpecificProperties( + DatabasePlatformTest.class.getResource(DB_TEST_PROPERTIES), String.format( + "test.%s", name), name); + return JdbcDatabasePlatformFactory.createNewPlatformInstance( + BasicDataSourceFactory.create(properties, new SecurityService()), + new SqlTemplateSettings(), true); } } diff --git a/symmetric-server/src/main/java/org/jumpmind/symmetric/SymmetricWebServer.java b/symmetric-server/src/main/java/org/jumpmind/symmetric/SymmetricWebServer.java index 6024f2520c..f27ca13bd4 100644 --- a/symmetric-server/src/main/java/org/jumpmind/symmetric/SymmetricWebServer.java +++ b/symmetric-server/src/main/java/org/jumpmind/symmetric/SymmetricWebServer.java @@ -47,7 +47,7 @@ import org.eclipse.jetty.util.security.Password; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; -import org.jumpmind.symmetric.common.SecurityConstants; +import org.jumpmind.security.SecurityConstants; import org.jumpmind.symmetric.common.SystemConstants; import org.jumpmind.symmetric.web.ServletUtils; import org.jumpmind.symmetric.web.SymmetricEngineHolder; @@ -286,7 +286,7 @@ protected void setupBasicAuthIfNeeded(Server server) { protected Connector[] getConnectors(int port, int securePort, Mode mode) { ArrayList connectors = new ArrayList(); - String keyStoreFile = System.getProperty(SystemConstants.SYSPROP_KEYSTORE); + String keyStoreFile = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE); String keyStoreType = System.getProperty(SystemConstants.SYSPROP_KEYSTORE_TYPE, SecurityConstants.KEYSTORE_TYPE); if (mode.equals(Mode.HTTP) || mode.equals(Mode.MIXED)) { @@ -307,7 +307,7 @@ protected Connector[] getConnectors(int port, int securePort, Mode mode) { if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) { Connector connector = new SslSocketConnector(); String keyStorePassword = System - .getProperty(SystemConstants.SYSPROP_KEYSTORE_PASSWORD); + .getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD); keyStorePassword = (keyStorePassword != null) ? keyStorePassword : SecurityConstants.KEYSTORE_PASSWORD; SslContextFactory sslConnectorFactory = ((SslSocketConnector) connector).getSslContextFactory(); diff --git a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/SymmetricEngineHolder.java b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/SymmetricEngineHolder.java index 08c276fef2..b15833b97e 100644 --- a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/SymmetricEngineHolder.java +++ b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/SymmetricEngineHolder.java @@ -34,15 +34,16 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; +import org.jumpmind.db.util.BasicDataSourcePropertyConstants; import org.jumpmind.properties.TypedProperties; +import org.jumpmind.security.ISecurityService; +import org.jumpmind.security.SecurityConstants; import org.jumpmind.symmetric.AbstractCommandLauncher; import org.jumpmind.symmetric.AbstractSymmetricEngine; import org.jumpmind.symmetric.ISymmetricEngine; import org.jumpmind.symmetric.common.ParameterConstants; -import org.jumpmind.symmetric.common.SecurityConstants; import org.jumpmind.symmetric.model.Node; import org.jumpmind.symmetric.service.IRegistrationService; -import org.jumpmind.symmetric.service.ISecurityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,12 +161,12 @@ protected ISymmetricEngine create(String propertiesFile) { public ISymmetricEngine install(Properties passedInProperties) throws Exception { TypedProperties properties = new TypedProperties(passedInProperties); - String password = properties.getProperty(ParameterConstants.DB_POOL_PASSWORD); + String password = properties.getProperty(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD); if (StringUtils.isNotBlank(password) && !password.startsWith(SecurityConstants.PREFIX_ENC)) { try { ISecurityService service = AbstractSymmetricEngine .createSecurityService(properties); - properties.setProperty(ParameterConstants.DB_POOL_PASSWORD, + properties.setProperty(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD, SecurityConstants.PREFIX_ENC + service.encrypt(password)); } catch (Exception ex) { log.warn("Could not encrypt password", ex); @@ -281,18 +282,18 @@ public String validateRequiredProperties(Properties properties) { if (StringUtils.isBlank(properties.getProperty(ParameterConstants.SYNC_URL))) { throw new IllegalStateException("Missing property " + ParameterConstants.SYNC_URL); } - if (StringUtils.isBlank(properties.getProperty(ParameterConstants.DB_POOL_DRIVER))) { - throw new IllegalStateException("Missing property " + ParameterConstants.DB_POOL_DRIVER); + if (StringUtils.isBlank(properties.getProperty(BasicDataSourcePropertyConstants.DB_POOL_DRIVER))) { + throw new IllegalStateException("Missing property " + BasicDataSourcePropertyConstants.DB_POOL_DRIVER); } - if (StringUtils.isBlank(properties.getProperty(ParameterConstants.DB_POOL_URL))) { - throw new IllegalStateException("Missing property " + ParameterConstants.DB_POOL_URL); + if (StringUtils.isBlank(properties.getProperty(BasicDataSourcePropertyConstants.DB_POOL_URL))) { + throw new IllegalStateException("Missing property " + BasicDataSourcePropertyConstants.DB_POOL_URL); } - if (!properties.containsKey(ParameterConstants.DB_POOL_USER)) { - throw new IllegalStateException("Missing property " + ParameterConstants.DB_POOL_USER); + if (!properties.containsKey(BasicDataSourcePropertyConstants.DB_POOL_USER)) { + throw new IllegalStateException("Missing property " + BasicDataSourcePropertyConstants.DB_POOL_USER); } - if (!properties.containsKey(ParameterConstants.DB_POOL_PASSWORD)) { + if (!properties.containsKey(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD)) { throw new IllegalStateException("Missing property " - + ParameterConstants.DB_POOL_PASSWORD); + + BasicDataSourcePropertyConstants.DB_POOL_PASSWORD); } if (!properties.containsKey(ParameterConstants.REGISTRATION_URL)) { properties.setProperty(ParameterConstants.REGISTRATION_URL, ""); diff --git a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java index 72f55b2fd5..9a1dd868ef 100644 --- a/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java +++ b/symmetric-server/src/main/java/org/jumpmind/symmetric/web/rest/RestService.java @@ -552,7 +552,7 @@ public final Set getChannelStatusByEngine( @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public final void postRemoveNode(@RequestParam(value = "nodeId") String nodeId) { - removeNodeImpl(getSymmetricEngine(), nodeId); + postRemoveNodeByEngine(nodeId, getSymmetricEngine().getEngineName()); } /** @@ -563,7 +563,7 @@ public final void postRemoveNode(@RequestParam(value = "nodeId") String nodeId) @ResponseBody public final void postRemoveNodeByEngine(@RequestParam(value = "nodeId") String nodeId, @PathVariable("engine") String engineName) { - removeNodeImpl(getSymmetricEngine(engineName), nodeId); + getSymmetricEngine(engineName).removeAndCleanupNode(nodeId); } @ExceptionHandler(Exception.class) @@ -586,28 +586,6 @@ private void startImpl(ISymmetricEngine engine) { private void stopImpl(ISymmetricEngine engine) { engine.stop(); } - - private void removeNodeImpl(ISymmetricEngine engine, String nodeName) { - - INodeService nodeService = engine.getNodeService(); - org.jumpmind.symmetric.model.Node node = nodeService.findNode(nodeName); - if (node != null) { - log.warn("Removing node " + node.getNodeId()); - log.warn("Deleting node security record for " - + node.getNodeId()); - nodeService.deleteNodeSecurity(node.getNodeId()); - log.warn("Deleting node record for " + node.getNodeId()); - nodeService.deleteNode(node.getNodeId()); - log.warn("Marking outgoing batch records as Ok for " - + node.getNodeId()); - engine.getOutgoingBatchService().markAllAsSentForNode(node); - log.warn("Marking incoming batch records as Ok for " - + node.getNodeId()); - engine.getIncomingBatchService().markIncomingBatchesOk( - node.getNodeId()); - log.warn("Done removing node " + node.getNodeId()); - } - } private void syncTriggersImpl(ISymmetricEngine engine, boolean force) { diff --git a/symmetric-server/src/test/java/org/jumpmind/symmetric/test/AbstractIntegrationTest.java b/symmetric-server/src/test/java/org/jumpmind/symmetric/test/AbstractIntegrationTest.java index 339069604a..2221fc4451 100644 --- a/symmetric-server/src/test/java/org/jumpmind/symmetric/test/AbstractIntegrationTest.java +++ b/symmetric-server/src/test/java/org/jumpmind/symmetric/test/AbstractIntegrationTest.java @@ -194,14 +194,14 @@ protected int getIncomingBatchNotOkCountForClient() { protected void assertNoPendingBatchesOnServer() { IOutgoingBatchService outgoingBatchService = getServer().getOutgoingBatchService(); OutgoingBatches batches = outgoingBatchService.getOutgoingBatches( - TestConstants.TEST_CLIENT_NODE, false); + TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); } protected void assertNoPendingBatchesOnClient() { IOutgoingBatchService outgoingBatchService = getClient().getOutgoingBatchService(); OutgoingBatches batches = outgoingBatchService.getOutgoingBatches( - TestConstants.TEST_ROOT_NODE, false); + TestConstants.TEST_ROOT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); } diff --git a/symmetric-server/src/test/java/org/jumpmind/symmetric/test/SimpleIntegrationTest.java b/symmetric-server/src/test/java/org/jumpmind/symmetric/test/SimpleIntegrationTest.java index 97aa44efc0..1a2913a3b0 100644 --- a/symmetric-server/src/test/java/org/jumpmind/symmetric/test/SimpleIntegrationTest.java +++ b/symmetric-server/src/test/java/org/jumpmind/symmetric/test/SimpleIntegrationTest.java @@ -338,7 +338,7 @@ public void testSuspendIgnorePushRemoteBatches() throws Exception { clientPush(); OutgoingBatches batches = clientOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_ROOT_NODE, false); + TestConstants.TEST_ROOT_NODE.getNodeId(), false); Assert.assertEquals("There should be one outgoing batches.", 1, batches.getBatches().size()); @@ -353,7 +353,7 @@ public void testSuspendIgnorePushRemoteBatches() throws Exception { clientPush(); batches = clientOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_ROOT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); @@ -404,7 +404,7 @@ public void testSuspendIgnorePushLocalBatches() throws Exception { clientPush(); OutgoingBatches batches = clientOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_ROOT_NODE, false); + TestConstants.TEST_ROOT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size()); @@ -418,7 +418,7 @@ public void testSuspendIgnorePushLocalBatches() throws Exception { clientPush(); batches = clientOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_ROOT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size()); @@ -450,7 +450,7 @@ public void testSuspendIgnorePullRemoteBatches() throws Exception { IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService(); OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_CLIENT_NODE, false); + TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertNotNull(clientTestService.getOrder(order.getOrderId())); @@ -471,7 +471,7 @@ public void testSuspendIgnorePullRemoteBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals("There should be 1 outgoing batch", 1, batches.getBatches().size()); @@ -486,7 +486,7 @@ public void testSuspendIgnorePullRemoteBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertNull(clientTestService.getOrder(order.getOrderId())); @@ -502,7 +502,7 @@ public void testSuspendIgnorePullRemoteBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); @@ -526,7 +526,7 @@ public void testSuspendIgnorePullRemoteLocalComboBatches() throws Exception { IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService(); OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_CLIENT_NODE, false); + TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertNotNull(clientTestService.getOrder(order.getOrderId())); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); @@ -553,7 +553,7 @@ public void testSuspendIgnorePullRemoteLocalComboBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); Assert.assertNull(clientTestService.getOrder(order.getOrderId())); @@ -577,7 +577,7 @@ public void testSuspendIgnorePullRemoteLocalComboBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); Assert.assertNull(clientTestService.getOrder(order.getOrderId())); @@ -629,7 +629,7 @@ public void testSuspendIgnorePullLocalBatches() throws Exception { IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService(); OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_CLIENT_NODE, false); + TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertNotNull(clientTestService.getOrder(order.getOrderId())); Assert.assertEquals("There should be no outgoing batches", 0, batches.getBatches().size()); @@ -647,7 +647,7 @@ public void testSuspendIgnorePullLocalBatches() throws Exception { clientPull(); batches = rootOutgoingBatchService - .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE, false); + .getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertNull(clientTestService.getOrder(order.getOrderId())); Assert.assertEquals("There should be 1 outgoing batches", 1, batches.getBatches().size()); @@ -988,7 +988,7 @@ public void testSyncShellCommand() throws Exception { rootDataService.sendScript(TestConstants.TEST_CLIENT_EXTERNAL_ID, scriptData, false); clientPull(); OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches( - TestConstants.TEST_CLIENT_NODE, false); + TestConstants.TEST_CLIENT_NODE.getNodeId(), false); Assert.assertEquals(0, batches.countBatches(true)); Assert.assertTrue("Expected the testFlag static variable to have been set to true", testFlag); } diff --git a/symmetric-util/pom.xml b/symmetric-util/pom.xml index 18dec3d2a1..65b2bb20d1 100644 --- a/symmetric-util/pom.xml +++ b/symmetric-util/pom.xml @@ -22,6 +22,10 @@ commons-lang commons-lang + + commons-codec + commons-codec + com.google.code.gson gson diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/ISecurityService.java b/symmetric-util/src/main/java/org/jumpmind/security/ISecurityService.java similarity index 96% rename from symmetric-core/src/main/java/org/jumpmind/symmetric/service/ISecurityService.java rename to symmetric-util/src/main/java/org/jumpmind/security/ISecurityService.java index 06b921921f..f776d1007c 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/ISecurityService.java +++ b/symmetric-util/src/main/java/org/jumpmind/security/ISecurityService.java @@ -19,7 +19,7 @@ * under the License. */ -package org.jumpmind.symmetric.service; +package org.jumpmind.security; /** diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SecurityConstants.java b/symmetric-util/src/main/java/org/jumpmind/security/SecurityConstants.java similarity index 88% rename from symmetric-core/src/main/java/org/jumpmind/symmetric/common/SecurityConstants.java rename to symmetric-util/src/main/java/org/jumpmind/security/SecurityConstants.java index 8ec776ec80..c74cf44745 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/SecurityConstants.java +++ b/symmetric-util/src/main/java/org/jumpmind/security/SecurityConstants.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jumpmind.symmetric.common; +package org.jumpmind.security; public class SecurityConstants { @@ -41,6 +41,10 @@ public class SecurityConstants { public static final String ALIAS_SYM_SECRET_KEY = "sym.secret"; - public static final String EMBEDDED_WEBSERVER_DEFAULT_ROLE="symmetric"; + public static final String EMBEDDED_WEBSERVER_DEFAULT_ROLE="symmetric"; + + public static final String SYSPROP_KEYSTORE = "sym.keystore.file"; + + public static final String SYSPROP_KEYSTORE_PASSWORD = "javax.net.ssl.keyStorePassword"; } \ No newline at end of file diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/SecurityService.java b/symmetric-util/src/main/java/org/jumpmind/security/SecurityService.java similarity index 93% rename from symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/SecurityService.java rename to symmetric-util/src/main/java/org/jumpmind/security/SecurityService.java index 9045a52015..6667144669 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/SecurityService.java +++ b/symmetric-util/src/main/java/org/jumpmind/security/SecurityService.java @@ -19,7 +19,7 @@ * under the License. */ -package org.jumpmind.symmetric.service.impl; +package org.jumpmind.security; import java.io.File; import java.io.FileInputStream; @@ -40,9 +40,6 @@ import org.apache.commons.codec.binary.Base64; import org.jumpmind.exception.IoException; -import org.jumpmind.symmetric.common.SecurityConstants; -import org.jumpmind.symmetric.common.SystemConstants; -import org.jumpmind.symmetric.service.ISecurityService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,7 +58,7 @@ public void init() { } protected void checkThatKeystoreFileExists() { - String keyStoreLocation = System.getProperty(SystemConstants.SYSPROP_KEYSTORE); + String keyStoreLocation = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE); if (!new File(keyStoreLocation).exists()) { throw new IoException( "Could not find the keystore file. We expected it to exist here: " @@ -123,7 +120,7 @@ protected void initializeCipher(Cipher cipher, int mode) throws Exception { } protected SecretKey getSecretKey() throws Exception { - String password = System.getProperty(SystemConstants.SYSPROP_KEYSTORE_PASSWORD); + String password = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD); password = (password != null) ? password : SecurityConstants.KEYSTORE_PASSWORD; KeyStore.ProtectionParameter param = new KeyStore.PasswordProtection(password.toCharArray()); KeyStore ks = getKeyStore(password); @@ -190,7 +187,7 @@ protected SecretKey getDefaultSecretKey() throws Exception { protected KeyStore getKeyStore(String password) throws Exception { KeyStore ks = KeyStore.getInstance(SecurityConstants.KEYSTORE_TYPE); FileInputStream is = new FileInputStream( - System.getProperty(SystemConstants.SYSPROP_KEYSTORE)); + System.getProperty(SecurityConstants.SYSPROP_KEYSTORE)); ks.load(is, password.toCharArray()); is.close(); return ks; @@ -198,7 +195,7 @@ protected KeyStore getKeyStore(String password) throws Exception { protected void saveKeyStore(KeyStore ks, String password) throws Exception { FileOutputStream os = new FileOutputStream( - System.getProperty(SystemConstants.SYSPROP_KEYSTORE)); + System.getProperty(SecurityConstants.SYSPROP_KEYSTORE)); ks.store(os, password.toCharArray()); os.close(); }