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("*"); assertEquals("All users are allowed", acl.toString()); validateGetAclString(acl); acl = new AccessControlList(" "); assertEquals("No users are allowed", acl.toString()); acl = new AccessControlList("user1,user2"); assertEquals("Users [user1, user2] are allowed", acl.toString()); validateGetAclString(acl); acl = new AccessControlList("user1,user2 "); assertEquals("Users [user1, user2] are allowed", acl.toString()); validateGetAclString(acl); acl = new AccessControlList(" group1,group2"); assertTrue(acl.toString().equals( "Members of the groups [group1, group2] are allowed")); validateGetAclString(acl); acl = new AccessControlList("user1,user2 group1,group2"); assertTrue(acl.toString().equals( "Users [user1, user2] and " + "members of the groups [group1, group2] are allowed")); validateGetAclString(acl); }
@Test public void testAclString() { AccessControlList acl; acl = new AccessControlList("*"); assertTrue(acl.toString().equals("All users are allowed")); validateGetAclString(acl); acl = new AccessControlList(" "); assertTrue(acl.toString().equals("No users are allowed")); acl = new AccessControlList("user1,user2"); assertTrue(acl.toString().equals("Users [user1, user2] are allowed")); validateGetAclString(acl); acl = new AccessControlList("user1,user2 "); assertTrue(acl.toString().equals("Users [user1, user2] are allowed")); validateGetAclString(acl); acl = new AccessControlList(" group1,group2"); assertTrue(acl.toString().equals( "Members of the groups [group1, group2] are allowed")); validateGetAclString(acl); acl = new AccessControlList("user1,user2 group1,group2"); assertTrue(acl.toString().equals( "Users [user1, user2] and " + "members of the groups [group1, group2] are allowed")); validateGetAclString(acl); }