Search in sources :

Example 1 with UserGroupProvider

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;
    }
}
Also used : UserAndGroups(org.apache.nifi.registry.security.authorization.UserAndGroups) Group(org.apache.nifi.registry.security.authorization.Group) ManagedAuthorizer(org.apache.nifi.registry.security.authorization.ManagedAuthorizer) UserGroupProvider(org.apache.nifi.registry.security.authorization.UserGroupProvider)

Aggregations

Group (org.apache.nifi.registry.security.authorization.Group)1 ManagedAuthorizer (org.apache.nifi.registry.security.authorization.ManagedAuthorizer)1 UserAndGroups (org.apache.nifi.registry.security.authorization.UserAndGroups)1 UserGroupProvider (org.apache.nifi.registry.security.authorization.UserGroupProvider)1