public class ShellBasedIdMapping extends Object implements IdMappingServiceProvider
IdMappingServiceProvider
Map id to user name or group name. It does update every 15 minutes. Only a
single instance of this class is expected to be on the server.
The maps are incrementally updated as described below:
1. Initialize the maps as empty.
2. Incrementally update the maps
- When ShellBasedIdMapping is requested for user or group name given
an ID, or for ID given a user or group name, do look up in the map
first, if it doesn't exist, find the corresponding entry with shell
command, and insert the entry to the maps.
- When group ID is requested for a given group name, and if the
group name is numerical, the full group map is loaded. Because we
don't have a good way to find the entry for a numerical group name,
loading the full map helps to get in all entries.
3. Periodically refresh the maps for both user and group, e.g,
do step 1.
Note: for testing purpose, step 1 may initial the maps with full mapping
when using constructor
ShellBasedIdMapping(Configuration, boolean)
.Constructor and Description |
---|
ShellBasedIdMapping(Configuration conf) |
ShellBasedIdMapping(Configuration conf,
boolean constructFullMapAtInit) |
Modifier and Type | Method and Description |
---|---|
void |
clearNameMaps() |
int |
getGid(String group) |
int |
getGidAllowingUnknown(String group) |
com.google.common.collect.BiMap<Integer,String> |
getGidNameMap() |
String |
getGroupName(int gid,
String unknown) |
long |
getTimeout() |
int |
getUid(String user) |
int |
getUidAllowingUnknown(String user) |
com.google.common.collect.BiMap<Integer,String> |
getUidNameMap() |
String |
getUserName(int uid,
String unknown) |
static boolean |
updateMapInternal(com.google.common.collect.BiMap<Integer,String> map,
String mapName,
String command,
String regex,
Map<Integer,Integer> staticMapping)
Get the list of users or groups returned by the specified command,
and save them in the corresponding map.
|
void |
updateMaps() |
public ShellBasedIdMapping(Configuration conf, boolean constructFullMapAtInit) throws IOException
IOException
public ShellBasedIdMapping(Configuration conf) throws IOException
IOException
public long getTimeout()
public void clearNameMaps()
public static boolean updateMapInternal(com.google.common.collect.BiMap<Integer,String> map, String mapName, String command, String regex, Map<Integer,Integer> staticMapping) throws IOException
IOException
public void updateMaps() throws IOException
IOException
public int getUid(String user) throws IOException
getUid
in interface IdMappingServiceProvider
IOException
public int getGid(String group) throws IOException
getGid
in interface IdMappingServiceProvider
IOException
public String getUserName(int uid, String unknown)
getUserName
in interface IdMappingServiceProvider
public String getGroupName(int gid, String unknown)
getGroupName
in interface IdMappingServiceProvider
public int getUidAllowingUnknown(String user)
getUidAllowingUnknown
in interface IdMappingServiceProvider
public int getGidAllowingUnknown(String group)
getGidAllowingUnknown
in interface IdMappingServiceProvider
Copyright © 2017 Apache Software Foundation. All Rights Reserved.