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;
}
}
Aggregations