org.apache.hadoop.security.ShellBasedUnixGroupsMapping Java Examples
The following examples show how to use
org.apache.hadoop.security.ShellBasedUnixGroupsMapping.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestJNIGroupsMapping.java From hadoop with Apache License 2.0 | 6 votes |
private void testForUser(String user) throws Exception { GroupMappingServiceProvider g = new ShellBasedUnixGroupsMapping(); List<String> shellBasedGroups = g.getGroups(user); g = new JniBasedUnixGroupsMapping(); List<String> jniBasedGroups = g.getGroups(user); String[] shellBasedGroupsArray = shellBasedGroups.toArray(new String[0]); Arrays.sort(shellBasedGroupsArray); String[] jniBasedGroupsArray = jniBasedGroups.toArray(new String[0]); Arrays.sort(jniBasedGroupsArray); if (!Arrays.equals(shellBasedGroupsArray, jniBasedGroupsArray)) { fail("Groups returned by " + ShellBasedUnixGroupsMapping.class.getCanonicalName() + " and " + JniBasedUnixGroupsMapping.class.getCanonicalName() + " didn't match for " + user); } }
Example #2
Source File: TestJNIGroupsMapping.java From big-c with Apache License 2.0 | 6 votes |
private void testForUser(String user) throws Exception { GroupMappingServiceProvider g = new ShellBasedUnixGroupsMapping(); List<String> shellBasedGroups = g.getGroups(user); g = new JniBasedUnixGroupsMapping(); List<String> jniBasedGroups = g.getGroups(user); String[] shellBasedGroupsArray = shellBasedGroups.toArray(new String[0]); Arrays.sort(shellBasedGroupsArray); String[] jniBasedGroupsArray = jniBasedGroups.toArray(new String[0]); Arrays.sort(jniBasedGroupsArray); if (!Arrays.equals(shellBasedGroupsArray, jniBasedGroupsArray)) { fail("Groups returned by " + ShellBasedUnixGroupsMapping.class.getCanonicalName() + " and " + JniBasedUnixGroupsMapping.class.getCanonicalName() + " didn't match for " + user); } }
Example #3
Source File: DFSTestUtil.java From hadoop with Apache License 2.0 | 5 votes |
/** * update the configuration with fake class for mapping user to groups * @param conf * @param map - user to groups mapping */ static public void updateConfWithFakeGroupMapping (Configuration conf, Map<String, String []> map) { if(map!=null) { MockUnixGroupsMapping.fakeUser2GroupsMap = map; } // fake mapping user to groups conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, DFSTestUtil.MockUnixGroupsMapping.class, ShellBasedUnixGroupsMapping.class); }
Example #4
Source File: TestGroupsCaching.java From hadoop with Apache License 2.0 | 5 votes |
@Before public void setup() { FakeGroupMapping.resetRequestCount(); ExceptionalGroupMapping.resetRequestCount(); conf = new Configuration(); conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, FakeGroupMapping.class, ShellBasedUnixGroupsMapping.class); }
Example #5
Source File: TestGroupsCaching.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testGroupLookupForStaticUsers() throws Exception { conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, FakeunPrivilegedGroupMapping.class, ShellBasedUnixGroupsMapping.class); conf.set(CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES, "me=;user1=group1;user2=group1,group2"); Groups groups = new Groups(conf); List<String> userGroups = groups.getGroups("me"); assertTrue("non-empty groups for static user", userGroups.isEmpty()); assertFalse("group lookup done for static user", FakeunPrivilegedGroupMapping.invoked); List<String> expected = new ArrayList<String>(); expected.add("group1"); FakeunPrivilegedGroupMapping.invoked = false; userGroups = groups.getGroups("user1"); assertTrue("groups not correct", expected.equals(userGroups)); assertFalse("group lookup done for unprivileged user", FakeunPrivilegedGroupMapping.invoked); expected.add("group2"); FakeunPrivilegedGroupMapping.invoked = false; userGroups = groups.getGroups("user2"); assertTrue("groups not correct", expected.equals(userGroups)); assertFalse("group lookup done for unprivileged user", FakeunPrivilegedGroupMapping.invoked); Configuration newConf = new Configuration(); newConf.set(CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES, "me=;user1=group1;user2=group1,group2;user3=group3"); groups.refresh(newConf); expected.clear(); expected.add("group3"); FakeunPrivilegedGroupMapping.invoked = false; userGroups = groups.getGroups("user3"); assertTrue("groups not correct", expected.equals(userGroups)); assertFalse("group lookup done for unprivileged user", FakeunPrivilegedGroupMapping.invoked); }
Example #6
Source File: DFSTestUtil.java From big-c with Apache License 2.0 | 5 votes |
/** * update the configuration with fake class for mapping user to groups * @param conf * @param map - user to groups mapping */ static public void updateConfWithFakeGroupMapping (Configuration conf, Map<String, String []> map) { if(map!=null) { MockUnixGroupsMapping.fakeUser2GroupsMap = map; } // fake mapping user to groups conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, DFSTestUtil.MockUnixGroupsMapping.class, ShellBasedUnixGroupsMapping.class); }
Example #7
Source File: TestGroupsCaching.java From big-c with Apache License 2.0 | 5 votes |
@Before public void setup() { FakeGroupMapping.resetRequestCount(); ExceptionalGroupMapping.resetRequestCount(); conf = new Configuration(); conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, FakeGroupMapping.class, ShellBasedUnixGroupsMapping.class); }
Example #8
Source File: TestGroupsCaching.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testGroupLookupForStaticUsers() throws Exception { conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, FakeunPrivilegedGroupMapping.class, ShellBasedUnixGroupsMapping.class); conf.set(CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES, "me=;user1=group1;user2=group1,group2"); Groups groups = new Groups(conf); List<String> userGroups = groups.getGroups("me"); assertTrue("non-empty groups for static user", userGroups.isEmpty()); assertFalse("group lookup done for static user", FakeunPrivilegedGroupMapping.invoked); List<String> expected = new ArrayList<String>(); expected.add("group1"); FakeunPrivilegedGroupMapping.invoked = false; userGroups = groups.getGroups("user1"); assertTrue("groups not correct", expected.equals(userGroups)); assertFalse("group lookup done for unprivileged user", FakeunPrivilegedGroupMapping.invoked); expected.add("group2"); FakeunPrivilegedGroupMapping.invoked = false; userGroups = groups.getGroups("user2"); assertTrue("groups not correct", expected.equals(userGroups)); assertFalse("group lookup done for unprivileged user", FakeunPrivilegedGroupMapping.invoked); }