/** * Constructor function for ACLs. * * @see #entry(String, String, boolean) * @see #entries(String, org.opencastproject.util.data.Tuple[]) */ public static AccessControlList acl(Either<AccessControlEntry, List<AccessControlEntry>>... entries) { // sequence entries final List<AccessControlEntry> seq = mlist(entries) .foldl(new ArrayList<AccessControlEntry>(), new Function2<List<AccessControlEntry>, Either<AccessControlEntry, List<AccessControlEntry>>, List<AccessControlEntry>>() { @Override public List<AccessControlEntry> apply(List<AccessControlEntry> sum, Either<AccessControlEntry, List<AccessControlEntry>> current) { if (current.isLeft()) sum.add(current.left().value()); else sum.addAll(current.right().value()); return sum; } }); return new AccessControlList(seq); }
/** * Reduces an access control list by an access control entry * * @param acl * the access control list to reduce * @param role * the role of the access control entry to remove * @param action * the action of the access control entry to remove * @return the reduced access control list or the same if already contained */ public static AccessControlList reduceAcl(AccessControlList acl, String role, String action) { AccessControlList newAcl = new AccessControlList(); for (AccessControlEntry ace : acl.getEntries()) { if (!ace.getAction().equalsIgnoreCase(action) || !ace.getRole().equalsIgnoreCase(role)) { newAcl.getEntries().add(ace); } } return newAcl; }
Object jsonAceObj = jsonAcl.get(ACE); AccessControlList acl = new AccessControlList(); if (jsonAceObj == null) return acl;
AccessControlList newAcl = new AccessControlList(); boolean foundAce = false; for (AccessControlEntry ace : acl.getEntries()) {