public static String getAclStringWithHiveModification(Configuration tezConf, String propertyName, boolean addHs2User, String user, String hs2User) throws IOException { // Start with initial ACLs ACLConfigurationParser aclConf = new ACLConfigurationParser(tezConf, propertyName); // Always give access to the user aclConf.addAllowedUser(user); // Give access to the process user if the config is set. if (addHs2User && hs2User != null) { aclConf.addAllowedUser(hs2User); } return aclConf.toAclString(); }
@Override public String toString() { if (getAllowedUsers().contains(WILDCARD_ACL_VALUE)) { return WILDCARD_ACL_VALUE; } else { if (allowedUsers.size() == 0 && allowedGroups.size() == 0) { return " "; } String userString = constructCsv(allowedUsers); String groupString = ""; if (allowedGroups.size() > 0) { groupString = " " + constructCsv(allowedGroups); } return userString + groupString; } }
public ACLConfigurationParser(Configuration conf, String confPropertyName) { allowedUsers = Sets.newLinkedHashSet(); allowedGroups = Sets.newLinkedHashSet(); parse(conf, confPropertyName); }
Configuration conf = new Configuration(); conf.set("ACL_ALL_ACCESS", "*"); aclConf = new ACLConfigurationParser(conf, "ACL_ALL_ACCESS"); assertEquals(1, aclConf.getAllowedUsers().size()); assertTrue(aclConf.getAllowedUsers().contains("*")); assertEquals(0, aclConf.getAllowedGroups().size()); assertEquals("*", aclConf.toAclString()); aclConf = new ACLConfigurationParser(conf, "ACL_INVALID1"); assertEquals(0, aclConf.getAllowedUsers().size()); assertEquals(0, aclConf.getAllowedGroups().size()); assertEquals(" ", aclConf.toAclString()); aclConf = new ACLConfigurationParser(conf, "ACL_NONE"); assertEquals(0, aclConf.getAllowedUsers().size()); assertEquals(0, aclConf.getAllowedGroups().size()); assertEquals(" ", aclConf.toAclString()); aclConf = new ACLConfigurationParser(conf, "ACL_VALID1"); assertEquals(2, aclConf.getAllowedUsers().size()); assertTrue(aclConf.getAllowedUsers().contains("user1")); assertTrue(aclConf.getAllowedUsers().contains("user2")); assertEquals(0, aclConf.getAllowedGroups().size()); assertEquals("user1,user2", aclConf.toAclString()); aclConf = new ACLConfigurationParser(conf, "ACL_VALID2"); assertEquals(2, aclConf.getAllowedUsers().size()); assertTrue(aclConf.getAllowedUsers().contains("user1")); assertTrue(aclConf.getAllowedUsers().contains("user2"));
return; if (isWildCard(aclsStr)) { allowedUsers.add(WILDCARD_ACL_VALUE); return;
return; if (isWildCard(aclsStr)) { allowedUsers.add(WILDCARD_ACL_VALUE); return;
public static String getAclStringWithHiveModification(Configuration tezConf, String propertyName, boolean addHs2User, String user, String hs2User) throws IOException { // Start with initial ACLs ACLConfigurationParser aclConf = new ACLConfigurationParser(tezConf, propertyName); // Always give access to the user aclConf.addAllowedUser(user); // Give access to the process user if the config is set. if (addHs2User && hs2User != null) { aclConf.addAllowedUser(hs2User); } return aclConf.toAclString(); } }
@Override public String toString() { if (getAllowedUsers().contains(WILDCARD_ACL_VALUE)) { return WILDCARD_ACL_VALUE; } else { if (allowedUsers.size() == 0 && allowedGroups.size() == 0) { return " "; } String userString = constructCsv(allowedUsers); String groupString = ""; if (allowedGroups.size() > 0) { groupString = " " + constructCsv(allowedGroups); } return userString + groupString; } }
public ACLConfigurationParser(Configuration conf, String confPropertyName) { allowedUsers = Sets.newLinkedHashSet(); allowedGroups = Sets.newLinkedHashSet(); parse(conf, confPropertyName); }