@Override public void grant(final EntityId entity, final String user) { aclsTx.get().executeUnchecked(new TransactionExecutor.Procedure<ACLDataset>() { @Override public void apply(ACLDataset acls) throws Exception { acls.add(entity, user, Action.ALL); } }, acls.get()); }
@Override public void revoke(final EntityId entity, final String user, final Set<Action> actions) { aclsTx.get().executeUnchecked(new TransactionExecutor.Procedure<ACLDataset>() { @Override public void apply(ACLDataset acls) throws Exception { for (Action action : actions) { acls.remove(entity, user, action); } } }, acls.get()); }
@Override public void grant(final EntityId entity, final String user, final Set<Action> actions) { aclsTx.get().executeUnchecked(new TransactionExecutor.Procedure<ACLDataset>() { @Override public void apply(ACLDataset acls) throws Exception { for (Action action : actions) { acls.add(entity, user, action); } } }, acls.get()); }
@Override public void revoke(final EntityId entity, final String user) { aclsTx.get().executeUnchecked(new TransactionExecutor.Procedure<ACLDataset>() { @Override public void apply(ACLDataset acls) throws Exception { acls.remove(entity, user); } }, acls.get()); }
@Override public void revoke(final EntityId entity) { aclsTx.get().executeUnchecked(new TransactionExecutor.Procedure<ACLDataset>() { @Override public void apply(ACLDataset acls) throws Exception { acls.remove(entity); } }, acls.get()); } }
@Override public boolean authorized(final EntityId entity, final String user, final Set<Action> actions) { return aclsTx.get().executeUnchecked(new TransactionExecutor.Function<ACLDataset, Boolean>() { @Override public Boolean apply(ACLDataset acls) throws Exception { Set<Action> unfulfilledActions = new HashSet<>(actions); for (EntityId current : entity.getHierarchy()) { Set<Action> allowedActions = acls.search(current, user); if (allowedActions.contains(Action.ALL)) { return true; } unfulfilledActions.removeAll(allowedActions); if (unfulfilledActions.isEmpty()) { return true; } } return unfulfilledActions.isEmpty(); } }, acls.get()); }