use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class ConfigurationChangedDatabaseWriterFilter method batchCommitted.
@Override
public void batchCommitted(DataContext context) {
IParameterService parameterService = engine.getParameterService();
INodeService nodeService = engine.getNodeService();
if (context.getBatch().getBatchId() == Constants.VIRTUAL_BATCH_FOR_REGISTRATION) {
// mark registration as complete
String nodeId = nodeService.findIdentityNodeId();
if (nodeId != null) {
NodeSecurity security = nodeService.findNodeSecurity(nodeId);
if (security != null && (security.isRegistrationEnabled() || security.getRegistrationTime() == null)) {
engine.getRegistrationService().markNodeAsRegistered(nodeId);
}
}
}
if (context.get(CTX_KEY_FLUSH_GROUPLETS_NEEDED) != null) {
log.info("Grouplets flushed because new grouplet config came through the data loader");
engine.getGroupletService().clearCache();
context.remove(CTX_KEY_FLUSH_GROUPLETS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_LOADFILTERS_NEEDED) != null) {
log.info("Load filters flushed because new filter config came through the data loader");
engine.getLoadFilterService().clearCache();
context.remove(CTX_KEY_FLUSH_LOADFILTERS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_CHANNELS_NEEDED) != null) {
log.info("Channels flushed because new channels came through the data loader");
engine.getConfigurationService().clearCache();
context.remove(CTX_KEY_FLUSH_CHANNELS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_CONFLICTS_NEEDED) != null) {
log.info("About to refresh the cache of conflict settings because new configuration came through the data loader");
engine.getDataLoaderService().clearCache();
context.remove(CTX_KEY_FLUSH_CONFLICTS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_PARAMETERS_NEEDED) != null) {
log.info("About to refresh the cache of parameters because new configuration came through the data loader");
parameterService.rereadParameters();
context.remove(CTX_KEY_FLUSH_PARAMETERS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_NODE_SECURITY_NEEDED) != null) {
log.info("About to refresh the cache of node security because new configuration came through the data loader");
nodeService.flushNodeAuthorizedCache();
context.remove(CTX_KEY_FLUSH_NODE_SECURITY_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_NODE_NEEDED) != null) {
log.info("About to refresh the cache of nodes because new configuration came through the data loader");
nodeService.flushNodeCache();
nodeService.flushNodeGroupCache();
context.remove(CTX_KEY_FLUSH_NODE_NEEDED);
}
}
use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class RouterService method findNodesThatAreReadyForInitialLoad.
public List<NodeSecurity> findNodesThatAreReadyForInitialLoad() {
INodeService nodeService = engine.getNodeService();
IConfigurationService configurationService = engine.getConfigurationService();
String me = nodeService.findIdentityNodeId();
List<NodeSecurity> toReturn = new ArrayList<NodeSecurity>();
List<NodeSecurity> securities = nodeService.findNodeSecurityWithLoadEnabled();
for (NodeSecurity nodeSecurity : securities) {
if (((!nodeSecurity.getNodeId().equals(me) && nodeSecurity.isInitialLoadEnabled()) || (!nodeSecurity.getNodeId().equals(me) && configurationService.isMasterToMaster()) || (nodeSecurity.getNodeId().equals(me) && nodeSecurity.isRevInitialLoadEnabled()))) {
toReturn.add(nodeSecurity);
}
}
return toReturn;
}
use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class DefaultNodeIdCreatorTest method testSelectNodeId.
@Test
public void testSelectNodeId() throws Exception {
final String EXPECTED_NODE_ID = "100-2";
DefaultNodeIdCreator generator = new DefaultNodeIdCreator(new MockParameterService(), new MockNodeService() {
@Override
public NodeSecurity findNodeSecurity(String nodeId) {
if (nodeId.equals(EXPECTED_NODE_ID)) {
NodeSecurity security = new NodeSecurity();
security.setNodeId(EXPECTED_NODE_ID);
security.setRegistrationEnabled(true);
return security;
} else {
return null;
}
}
}, SecurityServiceFactory.create());
Node node = new Node();
node.setExternalId("100");
String selectedNodeId = generator.selectNodeId(node, null, null);
assertEquals(EXPECTED_NODE_ID, selectedNodeId);
}
use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class RestService method isRegistered.
private boolean isRegistered(ISymmetricEngine engine) {
boolean registered = true;
INodeService nodeService = engine.getNodeService();
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
if (modelNode == null) {
registered = false;
} else {
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(modelNode.getNodeId());
if (nodeSecurity == null) {
registered = false;
}
}
return registered;
}
use of org.jumpmind.symmetric.model.NodeSecurity in project symmetric-ds by JumpMind.
the class RestService method securityVerified.
protected boolean securityVerified(String nodeId, ISymmetricEngine engine, String securityToken) {
INodeService nodeService = engine.getNodeService();
boolean allowed = false;
org.jumpmind.symmetric.model.Node targetNode = nodeService.findNode(nodeId);
if (targetNode != null) {
NodeSecurity security = nodeService.findNodeSecurity(nodeId);
allowed = security.getNodePassword().equals(securityToken);
}
return allowed;
}
Aggregations