Search in sources :

Example 1 with ManagedAuthorizer

use of org.apache.nifi.registry.security.authorization.ManagedAuthorizer in project nifi-registry by apache.

the class AuthorizerCapabilityDetection method isConfigurableUserGroupProvider.

public static boolean isConfigurableUserGroupProvider(final Authorizer authorizer) {
    if (!isManagedAuthorizer(authorizer)) {
        return false;
    }
    final ManagedAuthorizer managedAuthorizer = (ManagedAuthorizer) authorizer;
    final AccessPolicyProvider accessPolicyProvider = managedAuthorizer.getAccessPolicyProvider();
    return accessPolicyProvider.getUserGroupProvider() instanceof ConfigurableUserGroupProvider;
}
Also used : ManagedAuthorizer(org.apache.nifi.registry.security.authorization.ManagedAuthorizer) ConfigurableUserGroupProvider(org.apache.nifi.registry.security.authorization.ConfigurableUserGroupProvider) AccessPolicyProvider(org.apache.nifi.registry.security.authorization.AccessPolicyProvider) ConfigurableAccessPolicyProvider(org.apache.nifi.registry.security.authorization.ConfigurableAccessPolicyProvider)

Example 2 with ManagedAuthorizer

use of org.apache.nifi.registry.security.authorization.ManagedAuthorizer in project nifi-registry by apache.

the class AuthorizerCapabilityDetection method isGroupConfigurable.

public static boolean isGroupConfigurable(final Authorizer authorizer, final Group group) {
    if (!isConfigurableUserGroupProvider(authorizer)) {
        return false;
    }
    final ManagedAuthorizer managedAuthorizer = (ManagedAuthorizer) authorizer;
    final ConfigurableUserGroupProvider configurableUserGroupProvider = (ConfigurableUserGroupProvider) managedAuthorizer.getAccessPolicyProvider().getUserGroupProvider();
    return configurableUserGroupProvider.isConfigurable(group);
}
Also used : ManagedAuthorizer(org.apache.nifi.registry.security.authorization.ManagedAuthorizer) ConfigurableUserGroupProvider(org.apache.nifi.registry.security.authorization.ConfigurableUserGroupProvider)

Example 3 with ManagedAuthorizer

use of org.apache.nifi.registry.security.authorization.ManagedAuthorizer in project nifi-registry by apache.

the class AuthorizerCapabilityDetection method isUserConfigurable.

public static boolean isUserConfigurable(final Authorizer authorizer, final User user) {
    if (!isConfigurableUserGroupProvider(authorizer)) {
        return false;
    }
    final ManagedAuthorizer managedAuthorizer = (ManagedAuthorizer) authorizer;
    final ConfigurableUserGroupProvider configurableUserGroupProvider = (ConfigurableUserGroupProvider) managedAuthorizer.getAccessPolicyProvider().getUserGroupProvider();
    return configurableUserGroupProvider.isConfigurable(user);
}
Also used : ManagedAuthorizer(org.apache.nifi.registry.security.authorization.ManagedAuthorizer) ConfigurableUserGroupProvider(org.apache.nifi.registry.security.authorization.ConfigurableUserGroupProvider)

Example 4 with ManagedAuthorizer

use of org.apache.nifi.registry.security.authorization.ManagedAuthorizer in project nifi-registry by apache.

the class AuthorizerCapabilityDetection method isAccessPolicyConfigurable.

public static boolean isAccessPolicyConfigurable(final Authorizer authorizer, final AccessPolicy accessPolicy) {
    if (!isConfigurableAccessPolicyProvider(authorizer)) {
        return false;
    }
    final ManagedAuthorizer managedAuthorizer = (ManagedAuthorizer) authorizer;
    final ConfigurableAccessPolicyProvider configurableAccessPolicyProvider = (ConfigurableAccessPolicyProvider) managedAuthorizer.getAccessPolicyProvider();
    return configurableAccessPolicyProvider.isConfigurable(accessPolicy);
}
Also used : ManagedAuthorizer(org.apache.nifi.registry.security.authorization.ManagedAuthorizer) ConfigurableAccessPolicyProvider(org.apache.nifi.registry.security.authorization.ConfigurableAccessPolicyProvider)

Example 5 with ManagedAuthorizer

use of org.apache.nifi.registry.security.authorization.ManagedAuthorizer 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

ManagedAuthorizer (org.apache.nifi.registry.security.authorization.ManagedAuthorizer)5 ConfigurableUserGroupProvider (org.apache.nifi.registry.security.authorization.ConfigurableUserGroupProvider)3 ConfigurableAccessPolicyProvider (org.apache.nifi.registry.security.authorization.ConfigurableAccessPolicyProvider)2 AccessPolicyProvider (org.apache.nifi.registry.security.authorization.AccessPolicyProvider)1 Group (org.apache.nifi.registry.security.authorization.Group)1 UserAndGroups (org.apache.nifi.registry.security.authorization.UserAndGroups)1 UserGroupProvider (org.apache.nifi.registry.security.authorization.UserGroupProvider)1