use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class CugEvaluationTest method testIsGrantedTestGroupEveryone.
@Test
public void testIsGrantedTestGroupEveryone() throws Exception {
// testGroup + everyone
PermissionProvider pp = createPermissionProvider(testGroupPrincipal, EveryonePrincipal.getInstance());
assertTrue(pp.isGranted(content, null, Permissions.READ));
assertTrue(pp.isGranted(a, null, Permissions.READ));
assertTrue(pp.isGranted(c, null, Permissions.READ));
assertTrue(pp.isGranted(content, null, Permissions.READ_ACCESS_CONTROL));
assertTrue(pp.isGranted(a, null, Permissions.READ_ACCESS_CONTROL));
assertTrue(pp.isGranted(c, null, Permissions.READ_ACCESS_CONTROL));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class CugEvaluationTest method testGetPrivilegesTestUserEveryone.
@Test
public void testGetPrivilegesTestUserEveryone() throws Exception {
// testUser + everyone
PermissionProvider pp = createPermissionProvider(getTestUser().getPrincipal(), EveryonePrincipal.getInstance());
Set<String> r = ImmutableSet.of(PrivilegeConstants.JCR_READ);
assertEquals(r, pp.getPrivileges(content));
assertEquals(r, pp.getPrivileges(c));
assertTrue(pp.getPrivileges(a).isEmpty());
assertTrue(pp.getPrivileges(content2).isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class CugEvaluationTest method testGetPrivilegesEveryone.
@Test
public void testGetPrivilegesEveryone() throws Exception {
// everyone
PermissionProvider pp = createPermissionProvider(EveryonePrincipal.getInstance());
assertTrue(pp.getPrivileges(content).isEmpty());
assertTrue(pp.getPrivileges(content2).isEmpty());
assertTrue(pp.getPrivileges(a).isEmpty());
assertTrue(pp.getPrivileges(c).isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider 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;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class CompositePermissionProvider method refresh.
//-------------------------------------------------< PermissionProvider >---
@Override
public void refresh() {
immutableRoot = RootFactory.createReadOnlyRoot(root);
privilegeBitsProvider = new PrivilegeBitsProvider(immutableRoot);
for (PermissionProvider pp : pps) {
pp.refresh();
}
}
Aggregations