Search in sources :

Example 6 with TestSecurityPluginProvider

use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.

the class IgnitionComponentProxyTest method testStart.

/**
 */
@Test
public void testStart() {
    Supplier<Ignite> s = new Supplier<Ignite>() {

        @Override
        public Ignite get() {
            try {
                Permissions perms = new Permissions();
                perms.add(new AllPermission());
                AccessControlContext acc = AccessController.doPrivileged((PrivilegedAction<AccessControlContext>) () -> new AccessControlContext(AccessController.getContext(), new IgniteDomainCombiner(perms)));
                return AccessController.doPrivileged((PrivilegedExceptionAction<Ignite>) () -> {
                    String login = "node_" + G.allGrids().size();
                    return Ignition.start(optimize(getConfiguration(login, new TestSecurityPluginProvider(login, "", ALLOW_ALL, perms, globalAuth))));
                }, acc);
            } catch (Exception e) {
                throw new IgniteException(e);
            }
        }
    };
    check(s);
}
Also used : AccessControlContext(java.security.AccessControlContext) TestSecurityPluginProvider(org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider) IgniteException(org.apache.ignite.IgniteException) Permissions(java.security.Permissions) AllPermission(java.security.AllPermission) Ignite(org.apache.ignite.Ignite) Supplier(java.util.function.Supplier) IgniteException(org.apache.ignite.IgniteException) Test(org.junit.Test)

Example 7 with TestSecurityPluginProvider

use of org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider in project ignite by apache.

the class ServiceAuthorizationTest method configuration.

/**
 * @return Ignite node configuration.
 */
private IgniteConfiguration configuration(int idx, SecurityPermission... perms) throws Exception {
    String name = getTestIgniteInstanceName(idx);
    IgniteConfiguration cfg = getConfiguration(name, new TestSecurityPluginProvider(name, "", create().defaultAllowAll(false).appendSystemPermissions(JOIN_AS_SERVER).appendCachePermissions(DEFAULT_CACHE_NAME, CACHE_CREATE).appendTaskPermissions("org.apache.ignite.internal.processors.affinity.GridAffinityUtils$AffinityJob", TASK_EXECUTE, TASK_CANCEL).appendServicePermissions(TEST_SERVICE_NAME, perms).build(), null, false)).setClientMode(isClient);
    if (authErrLatch != null) {
        cfg.setFailureHandler(new FailureHandler() {

            @Override
            public boolean onFailure(Ignite ignite, FailureContext failureCtx) {
                assertTrue(failureCtx.error() instanceof SecurityException);
                assertTrue(failureCtx.error().getMessage().startsWith("Authorization failed [perm=SERVICE_DEPLOY, name=test-service-name"));
                authErrLatch.countDown();
                return true;
            }
        });
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TestSecurityPluginProvider(org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider) FailureContext(org.apache.ignite.failure.FailureContext) FailureHandler(org.apache.ignite.failure.FailureHandler) Ignite(org.apache.ignite.Ignite) SecurityException(org.apache.ignite.plugin.security.SecurityException)

Aggregations

TestSecurityPluginProvider (org.apache.ignite.internal.processors.security.impl.TestSecurityPluginProvider)7 Permissions (java.security.Permissions)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Ignite (org.apache.ignite.Ignite)3 IgniteException (org.apache.ignite.IgniteException)2 Event (org.apache.ignite.events.Event)2 TestSecurityData (org.apache.ignite.internal.processors.security.impl.TestSecurityData)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 AccessControlContext (java.security.AccessControlContext)1 AllPermission (java.security.AllPermission)1 Collection (java.util.Collection)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Map (java.util.Map)1