Package org.apache.hadoop.security
Class ShellBasedUnixGroupsMapping
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.security.ShellBasedUnixGroupsMapping
- All Implemented Interfaces:
Configurable,GroupMappingServiceProvider
- Direct Known Subclasses:
ShellBasedUnixGroupsNetgroupMapping
@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public class ShellBasedUnixGroupsMapping
extends Configured
implements GroupMappingServiceProvider
A simple shell-based implementation of
GroupMappingServiceProvider
that exec's the groups shell command to fetch the group
memberships of a given user.-
Field Summary
FieldsFields inherited from interface org.apache.hadoop.security.GroupMappingServiceProvider
GROUP_MAPPING_CONFIG_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheGroupsAdd(List<String> groups) Adds groups to cache, no need to do that for this providervoidCaches groups, no need to do that for this providerprotected Shell.ShellCommandExecutorcreateGroupExecutor(String userName) Create a ShellCommandExecutor object using the user's name.protected Shell.ShellCommandExecutorcreateGroupIDExecutor(String userName) Create a ShellCommandExecutor object for fetch a user's group id list.Returns list of groups for a userprotected String[]getGroupsForUserCommand(String userName) Returns just the shell command to be used to fetch a user's groups list.protected String[]getGroupsIDForUserCommand(String userName) Returns just the shell command to be used to fetch a user's group IDs list.getGroupsSet(String userName) Get all various group memberships of a given user.resolveFullGroupNames(String groupNames) Split group names into a set.voidsetConf(Configuration conf) Set the configuration to be used by this object.Methods inherited from class org.apache.hadoop.conf.Configured
getConf
-
Field Details
-
LOG
@VisibleForTesting protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ShellBasedUnixGroupsMapping
public ShellBasedUnixGroupsMapping()
-
-
Method Details
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Overrides:
setConfin classConfigured- Parameters:
conf- configuration to be used
-
getGroups
Returns list of groups for a user- Specified by:
getGroupsin interfaceGroupMappingServiceProvider- Parameters:
userName- get groups for this user- Returns:
- list of groups for a given user
- Throws:
IOException- raised on errors performing I/O.
-
cacheGroupsRefresh
Caches groups, no need to do that for this provider- Specified by:
cacheGroupsRefreshin interfaceGroupMappingServiceProvider- Throws:
IOException- raised on errors performing I/O.
-
cacheGroupsAdd
Adds groups to cache, no need to do that for this provider- Specified by:
cacheGroupsAddin interfaceGroupMappingServiceProvider- Parameters:
groups- unused- Throws:
IOException- raised on errors performing I/O.
-
getGroupsSet
Description copied from interface:GroupMappingServiceProviderGet all various group memberships of a given user. Returns EMPTY set in case of non-existing user- Specified by:
getGroupsSetin interfaceGroupMappingServiceProvider- Parameters:
userName- User's name- Returns:
- set of group memberships of user
- Throws:
IOException- raised on errors performing I/O.
-
createGroupExecutor
Create a ShellCommandExecutor object using the user's name.- Parameters:
userName- user's name- Returns:
- a ShellCommandExecutor object
-
getGroupsForUserCommand
Returns just the shell command to be used to fetch a user's groups list. This is mainly separate to make some tests easier.- Parameters:
userName- The username that needs to be passed into the command built- Returns:
- An appropriate shell command with arguments
-
createGroupIDExecutor
Create a ShellCommandExecutor object for fetch a user's group id list.- Parameters:
userName- the user's name- Returns:
- a ShellCommandExecutor object
-
getGroupsIDForUserCommand
Returns just the shell command to be used to fetch a user's group IDs list. This is mainly separate to make some tests easier.- Parameters:
userName- The username that needs to be passed into the command built- Returns:
- An appropriate shell command with arguments
-
resolveFullGroupNames
Split group names into a set.- Parameters:
groupNames- a string representing the user's group names- Returns:
- a set of group names
-