/** * @param action the action to be checked * @return whether the action is contained in the permitted actions */ public boolean contains(AclAction action) { return mActions.get(action.ordinal()); }
/** * @return an immutable copy of permitted actions */ public Set<AclAction> getActions() { ImmutableSet.Builder<AclAction> builder = ImmutableSet.builder(); for (int i = mActions.nextSetBit(0); i >= 0; i = mActions.nextSetBit(i + 1)) { builder.add(AclAction.ofOrdinal(i)); } return builder.build(); }
/** * Update the mask to be the union of owning group entry, named user entry and named group entry. * @param groupActions the group entry to be integrated into the mask */ public void updateMask(AclActions groupActions) { AclActions result = new AclActions(groupActions); for (Map.Entry<String, AclActions> kv : mNamedUserActions.entrySet()) { AclActions userAction = kv.getValue(); result.merge(userAction); for (AclAction action : AclAction.values()) { if (result.contains(action) || userAction.contains(action)) { result.add(action); } } } for (Map.Entry<String, AclActions> kv : mNamedGroupActions.entrySet()) { AclActions userAction = kv.getValue(); result.merge(userAction); for (AclAction action : AclAction.values()) { if (result.contains(action) || userAction.contains(action)) { result.add(action); } } } mMaskActions = result; }
/** * Adds a permitted action. * * @param action the permitted action */ public void add(AclAction action) { mActions.set(action.ordinal()); }
/** * Creats a new instance with initial permitted actions. * * @param actions the initial setEntry of permitted actions which is copied from */ public AclActions(Set<AclAction> actions) { mActions = new BitSet(ACTIONS_BITSET_INITIAL_BITS); for (AclAction action : actions) { mActions.set(action.ordinal()); } }