use of org.infinispan.security.AuthorizationPermission in project infinispan by infinispan.
the class SecurityResource method createRole.
private CompletionStage<RestResponse> createRole(RestRequest request) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder();
if (rolePermissionMapper == null) {
return completedFuture(new NettyRestResponse.Builder().status(CONFLICT).entity(Log.REST.rolePermissionMapperNotMutable()).build());
}
String name = request.variables().get("role");
List<String> perms = request.parameters().get("permission");
if (perms == null) {
return completedFuture(builder.status(HttpResponseStatus.BAD_REQUEST).build());
}
Set<AuthorizationPermission> permissions = perms.stream().map(p -> AuthorizationPermission.valueOf(p.toUpperCase())).collect(Collectors.toSet());
Role role = new CacheRoleImpl(name, true, permissions);
return rolePermissionMapper.addRole(role).thenCompose(ignore -> aclCacheFlush(request));
}
Aggregations