AccessControlList implements Writable { @Override public String toString() { String str = null; if (allAllowed) { str = "All users are allowed"; } else if (users.isEmpty() && groups.isEmpty()) { str = "No users are allowed"; } else { String usersStr = null; String groupsStr = null; if (!users.isEmpty()) { usersStr = users.toString(); } if (!groups.isEmpty()) { groupsStr = groups.toString(); } if (!users.isEmpty() && !groups.isEmpty()) { str = "Users " + usersStr + " and members of the groups " + groupsStr + " are allowed"; } else if (!users.isEmpty()) { str = "Users " + usersStr + " are allowed"; } else { str = "Members of the groups " + groupsStr + " are allowed"; } } return str; } AccessControlList();  AccessControlList(String aclString);  AccessControlList(String users, String groups); boolean isAllAllowed(); void addUser(String user); void addGroup(String group); void removeUser(String user); void removeGroup(String group); Collection<String> getUsers(); Collection<String> getGroups(); final boolean isUserInList(UserGroupInformation ugi); boolean isUserAllowed(UserGroupInformation ugi); @Override String toString(); String getAclString(); @Override void write(DataOutput out); @Override void readFields(DataInput in); static final String WILDCARD_ACL_VALUE; }
@Test public void testAclString() { AccessControlList acl; acl = new AccessControlList("*"); assertThat(acl.toString()).isEqualTo("All users are allowed"); validateGetAclString(acl); acl = new AccessControlList(" "); assertThat(acl.toString()).isEqualTo("No users are allowed"); acl = new AccessControlList("user1,user2"); assertThat(acl.toString()).isEqualTo("Users [user1, user2] are allowed"); validateGetAclString(acl); acl = new AccessControlList("user1,user2 "); assertThat(acl.toString()).isEqualTo("Users [user1, user2] are allowed"); validateGetAclString(acl); acl = new AccessControlList(" group1,group2"); assertThat(acl.toString()).isEqualTo( "Members of the groups [group1, group2] are allowed"); validateGetAclString(acl); acl = new AccessControlList("user1,user2 group1,group2"); assertThat(acl.toString()).isEqualTo( "Users [user1, user2] and " + "members of the groups [group1, group2] are allowed"); validateGetAclString(acl); }