use of org.infinispan.security.impl.SubjectACL 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);
}
Aggregations