/** * @see JackrabbitSession#hasPermission(String, String...) */ @Override public boolean hasPermission(String absPath, String... actions) throws RepositoryException { return hasPermission(absPath, Text.implode(actions, ",")); }
/** * @see JackrabbitSession#hasPermission(String, String...) */ @Override public boolean hasPermission(String absPath, String... actions) throws RepositoryException { return hasPermission(absPath, Text.implode(actions, ",")); }
@Override public boolean hasPermission(String absPath, String... actions) throws RepositoryException { return hasPermission(absPath, Text.implode(actions, ",")); }
@Override public boolean hasPermission(String absPath, String... actions) throws RepositoryException { return hasPermission(absPath, Text.implode(actions, ",")); }
@Override public boolean hasPermission(String absPath, String... actions) throws RepositoryException { return hasPermission(absPath, Text.implode(actions, ",")); }
private static String normalize(String path) { if (path.indexOf('.') == -1) { return path; } String[] elems = Text.explode(path, '/', false); LinkedList<String> queue = new LinkedList<String>(); String last = ".."; for (String segm : elems) { if ("..".equals(segm) && !"..".equals(last)) { queue.removeLast(); if (queue.isEmpty()) { last = ".."; } else { last = queue.getLast(); } } else if (!".".equals(segm)) { last = segm; queue.add(last); } } return "/" + Text.implode(queue.toArray(new String[queue.size()]), "/"); }
@NotNull static String getActionString(@NotNull String... actions) { return Text.implode(actions, ","); }
public static void assertIfEquals(String message, String[] expected, Iterable<ExternalIdentityRef> result) { List<String> dns = new LinkedList<String>(); for (ExternalIdentityRef ref: result) { dns.add(ref.getId()); } Collections.sort(dns); Arrays.sort(expected); String exp = Text.implode(expected, ",\n"); String res = Text.implode(dns.toArray(new String[dns.size()]), ",\n"); assertEquals(message, exp, res); }
public static void assertIfEquals(String message, String[] expected, Iterable<ExternalIdentityRef> result) { List<String> dns = new LinkedList<String>(); for (ExternalIdentityRef ref: result) { dns.add(ref.getId()); } Collections.sort(dns); Arrays.sort(expected); String exp = Text.implode(expected, ",\n"); String res = Text.implode(dns.toArray(new String[dns.size()]), ",\n"); assertEquals(message, exp, res); }
private void checkDeclaredMembers(Group grp, String ... ids) throws RepositoryException { TreeSet<String> members = new TreeSet<String>(); Iterator<Authorizable> iter = grp.getMembers(); while (iter.hasNext()) { members.add(iter.next().getID()); } Arrays.sort(ids); assertEquals( "Group members", Text.implode(ids, ","), Text.implode(members.toArray(new String[members.size()]), ",")); }
private void checkDeclaredMemberOf(Authorizable auth, String ... ids) throws RepositoryException { TreeSet<String> members = new TreeSet<String>(); Iterator<Group> iter = auth.declaredMemberOf(); while (iter.hasNext()) { members.add(iter.next().getID()); } Arrays.sort(ids); assertEquals( "Group memberships", Text.implode(ids, ","), Text.implode(members.toArray(new String[members.size()]), ",")); }
@Test public void testIsGrantedActions() { assertTrue(openProvider.isGranted("/", Text.implode(new String[]{Session.ACTION_READ, Session.ACTION_ADD_NODE, Session.ACTION_REMOVE, Session.ACTION_SET_PROPERTY}, ","))); } }
@Test public void testGetPermissionsFromPermissionNameActions() { TreeLocation tl = TreeLocation.create(existingTree); long permissions = Permissions.NODE_TYPE_MANAGEMENT|Permissions.LOCK_MANAGEMENT|Permissions.VERSION_MANAGEMENT; Set<String> names = Permissions.getNames(permissions); String jcrActions = Text.implode(names.toArray(new String[0]), ","); assertEquals(permissions, Permissions.getPermissions(jcrActions, tl, false)); }
assertTrue(pp.isGranted(PathUtils.concat(treePath, prop.getName()), Session.ACTION_READ)); String deniedActions = Text.implode(new String[] {Session.ACTION_ADD_NODE, Session.ACTION_SET_PROPERTY, Session.ACTION_REMOVE, JackrabbitSession.ACTION_READ_ACCESS_CONTROL}, ","); assertFalse(pp.isGranted(t.getPath(), deniedActions));
String deniedActions = Text.implode(new String[] {JackrabbitSession.ACTION_MODIFY_ACCESS_CONTROL, JackrabbitSession.ACTION_READ_ACCESS_CONTROL, JackrabbitSession.ACTION_USER_MANAGEMENT}, ","); assertFalse(pp.isGranted(t.getPath(), deniedActions));
@Test public void testAdministrativeAccess() { for (String path : getTreePaths()) { Tree t = root.getTree(path); assertFalse(t.exists()); } PermissionProvider pp = getPermissionProvider(adminSession.getAuthInfo().getPrincipals()); for (Tree t : trees) { pp.getPrivileges(t).contains(PrivilegeConstants.JCR_ALL); assertTrue(pp.isGranted(t, null, Permissions.ALL)); assertTrue(pp.isGranted(t, prop, Permissions.ALL)); String treePath = t.getPath(); String allActions = Text.implode(ACTION_NAMES, ","); assertTrue(pp.isGranted(treePath, allActions)); assertTrue(pp.isGranted(PathUtils.concat(treePath, prop.getName()), allActions)); } }