Search in sources :

Example 6 with AggregatedPermissionProvider

use of org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfiguration method getPermissionProvider.

@Nonnull
@Override
public PermissionProvider getPermissionProvider(@Nonnull final Root root, @Nonnull final String workspaceName, @Nonnull final Set<Principal> principals) {
    List<AuthorizationConfiguration> configurations = getConfigurations();
    switch(configurations.size()) {
        case 0:
            throw new IllegalStateException();
        case 1:
            return configurations.get(0).getPermissionProvider(root, workspaceName, principals);
        default:
            List<AggregatedPermissionProvider> aggrPermissionProviders = new ArrayList(configurations.size());
            for (AuthorizationConfiguration conf : configurations) {
                PermissionProvider pProvider = conf.getPermissionProvider(root, workspaceName, principals);
                if (pProvider instanceof AggregatedPermissionProvider) {
                    aggrPermissionProviders.add((AggregatedPermissionProvider) pProvider);
                } else {
                    log.debug("Ignoring permission provider of '{}': Not an AggregatedPermissionProvider", conf.getClass().getName());
                }
            }
            PermissionProvider pp;
            switch(aggrPermissionProviders.size()) {
                case 0:
                    pp = EmptyPermissionProvider.getInstance();
                    break;
                case 1:
                    pp = aggrPermissionProviders.get(0);
                    break;
                default:
                    pp = new CompositePermissionProvider(root, aggrPermissionProviders, getContext());
            }
            return pp;
    }
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) ArrayList(java.util.ArrayList) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) AggregatedPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider) Nonnull(javax.annotation.Nonnull)

Aggregations

AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)6 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)5 Tree (org.apache.jackrabbit.oak.api.Tree)4 Nonnull (javax.annotation.Nonnull)2 PrivilegeBits (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)2 ArrayList (java.util.ArrayList)1 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 TreeLocation (org.apache.jackrabbit.oak.plugins.tree.TreeLocation)1 TreeType (org.apache.jackrabbit.oak.plugins.tree.TreeType)1 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)1 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)1 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)1 TreePermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission)1