private int getAllowed(AccessControl ac, Set<String> users) {
   switch (ac.get_type()) {
     case OTHER:
       return ac.get_access();
     case USER:
       if (users.contains(ac.get_name())) {
         return ac.get_access();
       }
       return 0;
     default:
       return 0;
   }
 }
 private void fixACLsForUser(List<AccessControl> acls, String user, int mask) {
   boolean foundUserACL = false;
   for (AccessControl control : acls) {
     if (control.get_type() == AccessControlType.USER && control.get_name().equals(user)) {
       int currentAccess = control.get_access();
       if ((currentAccess & mask) != mask) {
         control.set_access(currentAccess | mask);
       }
       foundUserACL = true;
       break;
     }
   }
   if (!foundUserACL) {
     AccessControl userACL = new AccessControl();
     userACL.set_type(AccessControlType.USER);
     userACL.set_name(user);
     userACL.set_access(mask);
     acls.add(userACL);
   }
 }
 public static void validateSettableACLs(String key, List<AccessControl> acls)
     throws AuthorizationException {
   Set<String> aclUsers = new HashSet<>();
   List<String> duplicateUsers = new ArrayList<>();
   for (AccessControl acl : acls) {
     String aclUser = acl.get_name();
     if (!StringUtils.isEmpty(aclUser) && !aclUsers.add(aclUser)) {
       LOG.error("'{}' user can't appear more than once in the ACLs", aclUser);
       duplicateUsers.add(aclUser);
     }
   }
   if (duplicateUsers.size() > 0) {
     String errorMessage =
         "user "
             + Arrays.toString(duplicateUsers.toArray())
             + " can't appear more than once in the ACLs for key ["
             + key
             + "].";
     throw new AuthorizationException(errorMessage);
   }
 }
 public static String accessControlToString(AccessControl ac) {
   StringBuilder ret = new StringBuilder();
   switch (ac.get_type()) {
     case OTHER:
       ret.append("o");
       break;
     case USER:
       ret.append("u");
       break;
     default:
       throw new IllegalArgumentException(
           "Don't know what a type of " + ac.get_type() + " means ");
   }
   ret.append(":");
   if (ac.is_set_name()) {
     ret.append(ac.get_name());
   }
   ret.append(":");
   ret.append(accessToString(ac.get_access()));
   return ret.toString();
 }