use of org.apache.nifi.registry.security.authorization.UserGroupProvider in project nifi-registry by apache.
the class IdentityAuthenticationProvider method getUserGroups.
private static Set<String> getUserGroups(final Authorizer authorizer, final String userIdentity) {
if (authorizer instanceof ManagedAuthorizer) {
final ManagedAuthorizer managedAuthorizer = (ManagedAuthorizer) authorizer;
final UserGroupProvider userGroupProvider = managedAuthorizer.getAccessPolicyProvider().getUserGroupProvider();
final UserAndGroups userAndGroups = userGroupProvider.getUserAndGroups(userIdentity);
final Set<Group> userGroups = userAndGroups.getGroups();
if (userGroups == null || userGroups.isEmpty()) {
return Collections.emptySet();
} else {
return userAndGroups.getGroups().stream().map(Group::getName).collect(Collectors.toSet());
}
} else {
return null;
}
}
Aggregations