@InitSecurityDatabase public EvaluatingResult[] resolveAllPath( RightCriteriumContext ctx, String pid, ObjectPidsPath path, String action, User user) throws RightCriteriumException { Right[] findRights = findRights(path.getPathFromLeafToRoot(), action, user); findRights = SortingRightsUtils.sortRights(findRights, path); EvaluatingResult[] results = new EvaluatingResult[path.getLength()]; for (int i = 0; i < results.length; i++) { String curPid = path.getNodeFromLeafToRoot(i); ObjectPidsPath restPath = path.cutTail(i); EvaluatingResult result = EvaluatingResult.FALSE; for (Right right : findRights) { boolean thisPid = right.getPid().equals(curPid); boolean inTheRestOfPath = restPath.contains(right.getPid()); if (thisPid || inTheRestOfPath) { ctx.setAssociatedPid(right.getPid()); EvaluatingResult iresult = right.evaluate(ctx); ctx.setAssociatedPid(null); if (iresult != EvaluatingResult.NOT_APPLICABLE) { result = iresult; break; } } } results[i] = result; } return results; }
@Override @InitSecurityDatabase public EvaluatingResult resolve( RightCriteriumContext ctx, String uuid, ObjectPidsPath path, String action, User user) throws RightCriteriumException { ObjectPidsPath processPath = path.injectRepository(); // List<String> pids = Arrays.asList(path.injectRepository().getPathFromRootToLeaf()); String[] pids = processPath.getPathFromLeafToRoot(); Right[] findRights = findRights(pids, action, user); findRights = SortingRightsUtils.sortRights(findRights, processPath); for (Right right : findRights) { ctx.setAssociatedPid(right.getPid()); EvaluatingResult result = right.evaluate(ctx); ctx.setAssociatedPid(null); if (result != EvaluatingResult.NOT_APPLICABLE) return result; } // nenasel zadne pravo nebo vsechny vracely NOT_APPLICABLE return EvaluatingResult.FALSE; }