use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.
the class CacheCreateDestroyEventSecurityContextTest method testNode.
/**
*/
private void testNode(boolean isClient) throws Exception {
operationInitiatorLogin = isClient ? "cli" : "crd";
Ignite ignite = grid(operationInitiatorLogin);
CacheConfiguration<?, ?> ccfg = cacheConfiguration();
checkCacheEvents(() -> ignite.createCache(ccfg), EVT_CACHE_STARTED);
checkCacheEvents(() -> ignite.destroyCache(ccfg.getName()), EVT_CACHE_STOPPED);
checkCacheEvents(() -> ignite.createCaches(singletonList(ccfg)), EVT_CACHE_STARTED);
checkCacheEvents(() -> ignite.destroyCaches(singletonList(ccfg.getName())), EVT_CACHE_STOPPED);
checkCacheEvents(() -> ignite.getOrCreateCache(cacheConfiguration()), EVT_CACHE_STARTED);
checkCacheEvents(() -> ignite.cluster().state(INACTIVE), EVT_CACHE_STOPPED);
checkCacheEvents(() -> ignite.cluster().state(ACTIVE), EVT_CACHE_STARTED);
operationInitiatorLogin = "joining_" + (isClient ? "client_" : "server_") + "node";
checkCacheEvents(() -> startGrid(getConfiguration(operationInitiatorLogin, new TestSecurityPluginProvider(operationInitiatorLogin, "", ALLOW_ALL, false)).setClientMode(isClient).setCacheConfiguration(cacheConfiguration())).close(), EVT_CACHE_STARTED);
}
use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.
the class IgniteNodeValidationFailedEventTest method testNodeValidationFailedEvent.
/**
*/
@Test
public void testNodeValidationFailedEvent() throws Exception {
startGrid(0);
CountDownLatch evtLatch = new CountDownLatch(1);
AtomicReference<Event> listenedEvtRef = new AtomicReference<>();
grid(0).events().localListen(evt -> {
assertTrue(listenedEvtRef.compareAndSet(null, evt));
evtLatch.countDown();
return true;
}, EVT_NODE_VALIDATION_FAILED);
startGrid(1);
String invalidNodeName = getTestIgniteInstanceName(2);
IgniteConfiguration invalidCfg = getConfiguration(invalidNodeName).setPluginProviders(new TestSecurityPluginProvider("login", "", ALLOW_ALL, false));
assertThrowsWithCause(() -> startGrid(optimize(invalidCfg)), IgniteSpiException.class);
evtLatch.await();
Event listenedEvt = listenedEvtRef.get();
assertTrue(listenedEvt instanceof NodeValidationFailedEvent);
NodeValidationFailedEvent validationEvt = (NodeValidationFailedEvent) listenedEvt;
assertEquals(invalidNodeName, validationEvt.eventNode().attribute(ATTR_NODE_CONSISTENT_ID));
IgniteNodeValidationResult validationRes = validationEvt.validationResult();
assertNotNull(validationRes);
String errMsg = validationRes.message();
assertNotNull(errMsg);
assertTrue(errMsg.contains("Local node's grid security processor class is not equal to remote node's grid security processor class"));
}
use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.
the class PlatformStartIgniteUtils method startWithSecurity.
/**
* Starts an Ignite instance with test security plugin provider.
*
* @param name Ignite instance name.
* @throws IgniteException Exception.
*/
public static void startWithSecurity(String name) throws IgniteException {
TestSecurityPluginProvider securityPluginProvider = new TestSecurityPluginProvider("login1", "pass1", ALLOW_ALL, false, new TestSecurityData("CLIENT", "pass1", SecurityPermissionSetBuilder.create().defaultAllowAll(false).appendCachePermissions("DEFAULT_CACHE", CACHE_READ, CACHE_PUT, CACHE_REMOVE).appendCachePermissions("FORBIDDEN_CACHE").build(), new Permissions()));
IgniteConfiguration cfg = new IgniteConfiguration().setPluginProviders(securityPluginProvider).setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(GridAbstractTest.LOCAL_IP_FINDER)).setLocalHost("127.0.0.1").setIgniteInstanceName(name);
Ignition.start(cfg);
}
use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.
the class RestProcessorAuthorizationTest method getPluginProvider.
/**
* {@inheritDoc}
*/
@Override
protected PluginProvider<?> getPluginProvider(String name) {
return new TestSecurityPluginProvider(name, null, ALLOW_ALL, globalAuth, clientData()) {
/**
* {@inheritDoc}
*/
@Override
protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
return new TestSecurityProcessor(ctx, new TestSecurityData(login, pwd, perms, new Permissions()), Arrays.asList(clientData), globalAuth) {
/**
* {@inheritDoc}
*/
@Override
public void authorize(String name, SecurityPermission perm, SecurityContext securityCtx) throws SecurityException {
authorizationCtxList.add(F.t(name, perm, securityCtx));
super.authorize(name, perm, securityCtx);
}
};
}
};
}
use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.
the class AbstractEventSecurityContextTest method startGrid.
/**
* {@inheritDoc}
*/
@Override
protected IgniteEx startGrid(String login, SecurityPermissionSet prmSet, Permissions sandboxPerms, boolean isClient) throws Exception {
IgniteConfiguration cfg = getConfiguration(login, new TestSecurityPluginProvider(login, "", prmSet, sandboxPerms, globalAuth));
cfg.setClientMode(isClient);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(new ConnectorConfiguration().setJettyPath("modules/clients/src/test/resources/jetty/rest-jetty.xml"));
if (!isClient || includeClientNodes()) {
cfg.setIncludeEventTypes(eventTypes());
cfg.setLocalEventListeners(singletonMap(new IgnitePredicate<Event>() {
/**
*/
@IgniteInstanceResource
IgniteEx ignite;
/**
* {@inheritDoc}
*/
@Override
public boolean apply(Event evt) {
LISTENED_EVTS.computeIfAbsent(ignite.localNode(), k -> ConcurrentHashMap.newKeySet()).add(evt);
return true;
}
}, eventTypes()));
}
return startGrid(cfg);
}
Aggregations