Search in sources :

Example 1 with Authorizer

use of org.infinispan.security.impl.Authorizer in project infinispan by infinispan.

the class SecurityActions method checkPermission.

static void checkPermission(EmbeddedCacheManager cacheManager, AuthorizationPermission permission) {
    Authorizer authorizer = getGlobalComponentRegistry(cacheManager).getComponent(Authorizer.class);
    authorizer.checkPermission(permission);
}
Also used : Authorizer(org.infinispan.security.impl.Authorizer)

Example 2 with Authorizer

use of org.infinispan.security.impl.Authorizer in project infinispan by infinispan.

the class SecurityActions method checkPermission.

static void checkPermission(EmbeddedCacheManager cacheManager, AuthorizationPermission permission) {
    Authorizer authorizer = getGlobalComponentRegistry(cacheManager).getComponent(Authorizer.class);
    authorizer.checkPermission(cacheManager.getSubject(), permission);
}
Also used : Authorizer(org.infinispan.security.impl.Authorizer)

Example 3 with Authorizer

use of org.infinispan.security.impl.Authorizer in project infinispan by infinispan.

the class SecurityActions method checkPermission.

static void checkPermission(EmbeddedCacheManager cacheManager, AuthorizationPermission permission) {
    Authorizer authorizer = getGlobalComponentRegistry(cacheManager).getComponent(Authorizer.class);
    authorizer.checkPermission(Security.getSubject(), permission);
}
Also used : Authorizer(org.infinispan.security.impl.Authorizer)

Example 4 with Authorizer

use of org.infinispan.security.impl.Authorizer in project infinispan by infinispan.

the class SecurityActions method checkPermission.

static void checkPermission(InvocationHelper invocationHelper, RestRequest request, AuthorizationPermission permission) {
    EmbeddedCacheManager cacheManager = invocationHelper.getRestCacheManager().getInstance();
    Authorizer authorizer = getGlobalComponentRegistry(cacheManager).getComponent(Authorizer.class);
    authorizer.checkPermission(request.getSubject(), permission);
}
Also used : Authorizer(org.infinispan.security.impl.Authorizer) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 5 with Authorizer

use of org.infinispan.security.impl.Authorizer in project infinispan by infinispan.

the class SecurityResource method acl.

private CompletionStage<RestResponse> acl(RestRequest request) {
    Subject subject = request.getSubject();
    RestCacheManager<Object> rcm = invocationHelper.getRestCacheManager();
    Collection<String> cacheNames = rcm.getCacheNames();
    Json acl = Json.object();
    if (subject == null) {
        acl.set("subject", Json.array());
    } else {
        Json jsonSubjects = Json.array();
        subject.getPrincipals().forEach(principal -> {
            jsonSubjects.add(Json.object().set("name", principal.getName()).set("type", principal.getClass().getSimpleName()));
        });
        acl.set("subject", jsonSubjects);
        Authorizer authorizer = rcm.getAuthorizer();
        SubjectACL globalACL = authorizer.getACL(subject);
        acl.set("global", aclToJson(globalACL));
        Json caches = Json.object();
        acl.set("caches", caches);
        for (String cacheName : cacheNames) {
            Configuration cacheConfiguration = SecurityActions.getCacheConfigurationFromManager(rcm.getInstance(), cacheName);
            SubjectACL cacheACL = authorizer.getACL(subject, cacheConfiguration.security().authorization());
            caches.set(cacheName, aclToJson(cacheACL));
        }
    }
    return asJsonResponseFuture(acl);
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) GlobalAuthorizationConfiguration(org.infinispan.configuration.global.GlobalAuthorizationConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) Authorizer(org.infinispan.security.impl.Authorizer) Json(org.infinispan.commons.dataconversion.internal.Json) Subject(javax.security.auth.Subject) SubjectACL(org.infinispan.security.impl.SubjectACL)

Aggregations

Authorizer (org.infinispan.security.impl.Authorizer)13 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 Subject (javax.security.auth.Subject)2 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 ResourceManagerImpl (org.infinispan.rest.framework.impl.ResourceManagerImpl)2 RestDispatcherImpl (org.infinispan.rest.framework.impl.RestDispatcherImpl)2 SimpleRequest (org.infinispan.rest.framework.impl.SimpleRequest)2 SimpleRestResponse (org.infinispan.rest.framework.impl.SimpleRestResponse)2 CustomAuditLoggerTest (org.infinispan.security.CustomAuditLoggerTest)2 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 CompletionStage (java.util.concurrent.CompletionStage)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 Bindings (javax.script.Bindings)1 Compilable (javax.script.Compilable)1