use of org.apache.jackrabbit.oak.plugins.tree.TreeLocation in project jackrabbit-oak by apache.
the class PermissionProviderImpl method isGranted.
@Override
public boolean isGranted(@Nonnull String oakPath, @Nonnull String jcrActions) {
TreeLocation location = TreeLocation.create(immutableRoot, oakPath);
boolean isAcContent = ctx.definesLocation(location);
long permissions = Permissions.getPermissions(jcrActions, location, isAcContent);
return isGranted(location, oakPath, permissions);
}
use of org.apache.jackrabbit.oak.plugins.tree.TreeLocation in project jackrabbit-oak by apache.
the class CompositeProviderFullScopeTest method testIsGrantedAction.
@Test
public void testIsGrantedAction() throws Exception {
for (String p : defActionsGranted.keySet()) {
String[] actions = defActionsGranted.get(p);
if (ImmutableList.copyOf(actions).contains(Session.ACTION_READ)) {
TreeLocation tl = TreeLocation.create(readOnlyRoot, p);
assertEquals(p, tl.getTree() != null, cppTestUser.isGranted(p, Session.ACTION_READ));
} else {
assertFalse(p, cppTestUser.isGranted(p, Session.ACTION_READ));
}
if (actions.length > 1) {
assertFalse(p, cppTestUser.isGranted(p, getActionString(actions)));
}
}
}
use of org.apache.jackrabbit.oak.plugins.tree.TreeLocation in project jackrabbit-oak by apache.
the class PermissionProviderImplTest method testIsGrantedNonExistingVersionStoreLocation.
@Test
public void testIsGrantedNonExistingVersionStoreLocation() {
TreeLocation location = TreeLocation.create(root, VersionConstants.VERSION_STORE_PATH + "/non/existing/tree");
PermissionProvider pp = createPermissionProvider(adminSession);
assertTrue(pp instanceof PermissionProviderImpl);
assertFalse(((PermissionProviderImpl) pp).isGranted(location, Permissions.ALL));
}
use of org.apache.jackrabbit.oak.plugins.tree.TreeLocation in project jackrabbit-oak by apache.
the class UserContextTest method testPropertyDefinesLocation.
@Test
public void testPropertyDefinesLocation() {
Map<String, Collection<String>> m = ImmutableMap.of(NT_REP_GROUP, GROUP_PROPERTY_NAMES, NT_REP_USER, USER_PROPERTY_NAMES, NT_REP_PASSWORD, PWD_PROPERTY_NAMES, NT_REP_MEMBER_REFERENCES, ImmutableList.of(REP_MEMBERS));
for (String ntName : m.keySet()) {
Tree t = mockTree("anyName", ntName);
TreeLocation location = Mockito.mock(TreeLocation.class);
when(location.getTree()).thenReturn(t);
when(location.exists()).thenReturn(true);
for (String propName : m.get(ntName)) {
PropertyState property = PropertyStates.createProperty(propName, "value");
when(location.getProperty()).thenReturn(property);
assertTrue(ctx.definesLocation(location));
}
PropertyState property = PropertyStates.createProperty("anyName", "value");
when(location.getProperty()).thenReturn(property);
assertFalse(ctx.definesLocation(location));
}
}
use of org.apache.jackrabbit.oak.plugins.tree.TreeLocation in project jackrabbit-oak by apache.
the class PermissionsTest method testGetPermissionsOnAccessControlledNode.
@Test
public void testGetPermissionsOnAccessControlledNode() {
TreeLocation tl = createNonExistingTreeLocation(PathUtils.ROOT_PATH + AccessControlConstants.REP_POLICY);
Map<String, Long> map = new HashMap<String, Long>();
// read -> mapped to read-access-control
map.put(Session.ACTION_READ, Permissions.READ_ACCESS_CONTROL);
// all regular write -> mapped to modify-access-control (compatible and in
// accordance to the previous behavior, where specifying an explicit
// modify_access_control action was not possible.
map.put(Session.ACTION_ADD_NODE, Permissions.MODIFY_ACCESS_CONTROL);
map.put(Session.ACTION_REMOVE, Permissions.MODIFY_ACCESS_CONTROL);
map.put(Session.ACTION_SET_PROPERTY, Permissions.MODIFY_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_ADD_PROPERTY, Permissions.MODIFY_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_MODIFY_PROPERTY, Permissions.MODIFY_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_REMOVE_PROPERTY, Permissions.MODIFY_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_REMOVE_NODE, Permissions.MODIFY_ACCESS_CONTROL);
// all other actions are mapped to the corresponding permission without
// testing for item being ac-content
map.put(JackrabbitSession.ACTION_READ_ACCESS_CONTROL, Permissions.READ_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_MODIFY_ACCESS_CONTROL, Permissions.MODIFY_ACCESS_CONTROL);
map.put(JackrabbitSession.ACTION_LOCKING, Permissions.LOCK_MANAGEMENT);
map.put(JackrabbitSession.ACTION_VERSIONING, Permissions.VERSION_MANAGEMENT);
map.put(JackrabbitSession.ACTION_USER_MANAGEMENT, Permissions.USER_MANAGEMENT);
for (Map.Entry<String, Long> entry : map.entrySet()) {
assertEquals(entry.getKey(), entry.getValue().longValue(), Permissions.getPermissions(entry.getKey(), tl, true));
}
}
Aggregations