Search in sources :

Example 1 with NodeSecurity

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);
    }
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) INodeService(org.jumpmind.symmetric.service.INodeService) IParameterService(org.jumpmind.symmetric.service.IParameterService)

Example 2 with NodeSecurity

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;
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) INodeService(org.jumpmind.symmetric.service.INodeService) ArrayList(java.util.ArrayList) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService)

Example 3 with NodeSecurity

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);
}
Also used : MockNodeService(org.jumpmind.symmetric.service.impl.MockNodeService) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) MockParameterService(org.jumpmind.symmetric.service.impl.MockParameterService) Node(org.jumpmind.symmetric.model.Node) Test(org.junit.Test)

Example 4 with NodeSecurity

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;
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) INodeService(org.jumpmind.symmetric.service.INodeService)

Example 5 with NodeSecurity

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;
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) INodeService(org.jumpmind.symmetric.service.INodeService)

Aggregations

NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)31 Node (org.jumpmind.symmetric.model.Node)13 INodeService (org.jumpmind.symmetric.service.INodeService)12 Date (java.util.Date)7 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)7 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 IoException (org.jumpmind.exception.IoException)4 SymmetricException (org.jumpmind.symmetric.SymmetricException)4 IncomingBatch (org.jumpmind.symmetric.model.IncomingBatch)4 NodeHost (org.jumpmind.symmetric.model.NodeHost)4 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 UniqueKeyException (org.jumpmind.db.sql.UniqueKeyException)3 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)2 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)2 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)2 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)2