use of com.hortonworks.streamline.streams.security.catalog.AclEntry.SidType.ROLE in project streamline by hortonworks.
the class SecurityCatalogResource method filter.
private Collection<AclEntry> filter(Collection<AclEntry> aclEntries, SecurityContext securityContext) {
User currentUser = getCurrentUser(securityContext);
Set<Role> currentUserRoles = catalogService.getAllUserRoles(currentUser);
boolean isSecurityAdmin = SecurityUtil.hasRole(authorizer, securityContext, ROLE_SECURITY_ADMIN);
return aclEntries.stream().filter(aclEntry -> isSecurityAdmin || matches(aclEntry, currentUser, currentUserRoles)).collect(Collectors.toSet());
}
use of com.hortonworks.streamline.streams.security.catalog.AclEntry.SidType.ROLE in project streamline by hortonworks.
the class SecurityCatalogResource method getRoleUsers.
private Response getRoleUsers(Long roleId) {
Role role = catalogService.getRole(roleId);
Set<Role> rolesToQuery = new HashSet<>();
if (role != null) {
rolesToQuery.add(role);
rolesToQuery.addAll(catalogService.getChildRoles(roleId));
Set<User> res = rolesToQuery.stream().flatMap(r -> catalogService.listUsers(r).stream()).collect(Collectors.toSet());
return WSUtils.respondEntities(res, OK);
}
throw EntityNotFoundException.byId(roleId.toString());
}
Aggregations