use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration 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(), compositionType, getRootProvider());
}
return pp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class MountPermissionProviderRandomTestIT method candidatePermissionProvider.
@Override
protected PermissionProvider candidatePermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) {
SecurityProvider sp = SecurityProviderBuilder.newBuilder().build();
AuthorizationConfiguration acConfig = MountUtils.bindMountInfoProvider(sp, mountInfoProvider);
PermissionProvider composite = acConfig.getPermissionProvider(root, workspaceName, principals);
Assert.assertTrue(composite instanceof MountPermissionProvider);
return composite;
}
use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class MountUtils method bindMountInfoProvider.
static AuthorizationConfiguration bindMountInfoProvider(@Nonnull SecurityProvider securityProvider, @Nonnull MountInfoProvider mountInfoProvider) {
AuthorizationConfiguration acConfig = securityProvider.getConfiguration(AuthorizationConfiguration.class);
Assert.assertTrue(acConfig instanceof CompositeAuthorizationConfiguration);
((AuthorizationConfigurationImpl) ((CompositeAuthorizationConfiguration) acConfig).getDefaultConfig()).bindMountInfoProvider(mountInfoProvider);
return acConfig;
}
use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method createPermissionProviderOR.
CompositePermissionProvider createPermissionProviderOR(Set<Principal> principals) {
String workspaceName = root.getContentSession().getWorkspaceName();
AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class);
return new CompositePermissionProvider(root, getAggregatedProviders(workspaceName, config, principals), config.getContext(), CompositionType.OR, getRootProvider());
}
Aggregations