use of org.apache.jackrabbit.api.security.authorization.PrivilegeManager in project jackrabbit-oak by apache.
the class JcrAllTest method testAllAggregation.
@Test
public void testAllAggregation() throws Exception {
PrivilegeBits all = bitsProvider.getBits(JCR_ALL);
PrivilegeManager pMgr = getSecurityProvider().getConfiguration(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
Iterable<Privilege> declaredAggr = Arrays.asList(pMgr.getPrivilege(JCR_ALL).getDeclaredAggregatePrivileges());
String[] allAggregates = Iterables.toArray(Iterables.transform(declaredAggr, new Function<Privilege, String>() {
@Override
public String apply(@Nullable Privilege privilege) {
return checkNotNull(privilege).getName();
}
}), String.class);
PrivilegeBits all2 = bitsProvider.getBits(allAggregates);
assertEquals(all, all2);
assertEquals(Collections.singleton(JCR_ALL), bitsProvider.getPrivilegeNames(all2));
PrivilegeBits bits = PrivilegeBits.getInstance();
for (String name : allAggregates) {
bits.add(bitsProvider.getBits(name));
}
assertEquals(all, bits.unmodifiable());
}
use of org.apache.jackrabbit.api.security.authorization.PrivilegeManager in project jackrabbit-oak by apache.
the class PrivilegeConfigurationImplTest method testGetPrivilegeManager.
@Test
public void testGetPrivilegeManager() {
PrivilegeManager pMgr = configuration.getPrivilegeManager(Mockito.mock(Root.class), NamePathMapper.DEFAULT);
assertTrue(pMgr instanceof PrivilegeManagerImpl);
}
use of org.apache.jackrabbit.api.security.authorization.PrivilegeManager in project jackrabbit-oak by apache.
the class PrivilegeBitsProviderTest method getAggregatedNamesWithCustom.
@Test
public void getAggregatedNamesWithCustom() throws Exception {
PrivilegeManager pMgr = getPrivilegeManager(root);
pMgr.registerPrivilege("test1", true, null);
assertEquals(ImmutableSet.of("test1"), ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames("test1")));
Set<String> expected = Sets.newHashSet(NON_AGGREGATE_PRIVILEGES);
expected.add("test1");
assertEquals(expected, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL)));
assertEquals(expected, ImmutableSet.copyOf(bitsProvider.getAggregatedPrivilegeNames(JCR_ALL)));
}
use of org.apache.jackrabbit.api.security.authorization.PrivilegeManager in project jackrabbit-oak by apache.
the class PrivilegeImplTest method before.
@Override
public void before() throws Exception {
super.before();
PrivilegeManager pMgr = getPrivilegeManager(root);
privilege = pMgr.getPrivilege(JCR_READ_ACCESS_CONTROL);
aggrPrivilege = pMgr.getPrivilege(REP_WRITE);
allPrivilege = pMgr.getPrivilege(JCR_ALL);
abstractPrivilege = pMgr.registerPrivilege("abstractPrivilege", true, null);
}
use of org.apache.jackrabbit.api.security.authorization.PrivilegeManager in project jackrabbit-oak by apache.
the class L3_BuiltInPrivilegesTest method testAggregation.
@Test
public void testAggregation() throws RepositoryException {
PrivilegeManager privilegeManager = getPrivilegeManager(root);
// EXERCISE: for all aggregated privileges define the mapping of the privilege name to declaredAggregates
Map<String, Set<Privilege>> expectedResults = ImmutableMap.of();
Iterable<Privilege> aggregated = Iterables.<Privilege>filter(ImmutableList.<Privilege>copyOf(privilegeManager.getRegisteredPrivileges()), new Predicate<Privilege>() {
@Override
public boolean apply(@Nullable Privilege input) {
return input != null && input.isAggregate();
}
});
for (Privilege aggrPrivilege : aggregated) {
Set<Privilege> expected = expectedResults.get(aggrPrivilege.getName());
assertEquals(expected, ImmutableSet.copyOf(aggrPrivilege.getDeclaredAggregatePrivileges()));
}
}
Aggregations