/** * Returns a list of {@link AclEntry} which represent this ACL instance. The mask will only be * included if extended ACL entries exist. * * @return an immutable list of ACL entries */ public List<AclEntry> getEntries() { ImmutableList.Builder<AclEntry> builder = new ImmutableList.Builder<>(); builder.add(new AclEntry.Builder() .setType(AclEntryType.OWNING_USER) .setSubject(mOwningUser) .setActions(getOwningUserActions()) .build()); builder.add(new AclEntry.Builder() .setType(AclEntryType.OWNING_GROUP) .setSubject(mOwningGroup) .setActions(getOwningGroupActions()) .build()); builder.add(new AclEntry.Builder() .setType(AclEntryType.OTHER) .setActions(getOtherActions()) .build()); if (hasExtended()) { builder.addAll(mExtendedEntries.getEntries()); } return builder.build(); }
/** * @param acl the access control list to convert * @return the proto representation of this object */ public static PAcl toProto(AccessControlList acl) { PAcl.Builder pAcl = PAcl.newBuilder(); pAcl.setOwner(acl.getOwningUser()); pAcl.setOwningGroup(acl.getOwningGroup()); pAcl.setMode(acl.getMode()); if (acl.hasExtended()) { for (AclEntry entry : acl.getExtendedEntries().getEntries()) { pAcl.addEntries(toProto(entry)); } } pAcl.setIsDefault(false); return pAcl.build(); }