Package org.apache.hadoop.security
Class LdapGroupsMapping
java.lang.Object
org.apache.hadoop.security.LdapGroupsMapping
- All Implemented Interfaces:
Configurable,GroupMappingServiceProvider
- Direct Known Subclasses:
RuleBasedLdapGroupsMapping
@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public class LdapGroupsMapping
extends Object
implements GroupMappingServiceProvider, Configurable
An implementation of
GroupMappingServiceProvider which
connects directly to an LDAP server for determining group membership.
This provider should be used only if it is necessary to map users to
groups that reside exclusively in an Active Directory or LDAP installation.
The common case for a Hadoop installation will be that LDAP users and groups
materialized on the Unix servers, and for an installation like that,
ShellBasedUnixGroupsMapping is preferred. However, in cases where
those users and groups aren't materialized in Unix, but need to be used for
access control, this class may be used to communicate directly with the LDAP
server.
It is important to note that resolving group mappings will incur network
traffic, and may cause degraded performance, although user-group mappings
will be cached via the infrastructure provided by Groups.
This implementation does not support configurable search limits. If a filter
is used for searching users or groups which returns more results than are
allowed by the server, an exception will be thrown.
The implementation attempts to resolve group hierarchies,
to a configurable limit.
If the limit is 0, in order to be considered a member of a group,
the user must be an explicit member in LDAP. Otherwise, it will traverse the
group hierarchy n levels up.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn private internal socket factory used to create SSL sockets with custom configuration. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final StringFile path to the location of the SSL truststore to usestatic final StringThe path to a file containing the password for the LDAP SSL truststorestatic final StringThe key of the credential entry containing the password for the LDAP SSL truststorestatic final Stringstatic final Stringstatic final Booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final StringFields 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 booleanfailover(int attemptsMadeWithSameLdap, int maxAttemptsBeforeFailover) Check whether we should fail over to the next LDAP server.getConf()Return the configuration used by this object.Returns list of groups for a user.getGroupsSet(String user) Get all various group memberships of a given user.Get URLs of configured LDAP servers.voidsetConf(Configuration conf) Set the configuration to be used by this object.protected voidSwitch to the next available user to bind to.
-
Field Details
-
LDAP_CONFIG_PREFIX
- See Also:
-
LDAP_URL_KEY
- See Also:
-
LDAP_URL_DEFAULT
- See Also:
-
LDAP_USE_SSL_KEY
- See Also:
-
LDAP_USE_SSL_DEFAULT
-
LDAP_KEYSTORE_KEY
- See Also:
-
LDAP_KEYSTORE_DEFAULT
- See Also:
-
LDAP_KEYSTORE_PASSWORD_KEY
- See Also:
-
LDAP_KEYSTORE_PASSWORD_DEFAULT
- See Also:
-
LDAP_KEYSTORE_PASSWORD_FILE_KEY
- See Also:
-
LDAP_KEYSTORE_PASSWORD_FILE_DEFAULT
- See Also:
-
LDAP_TRUSTSTORE_KEY
File path to the location of the SSL truststore to use- See Also:
-
LDAP_TRUSTSTORE_PASSWORD_KEY
The key of the credential entry containing the password for the LDAP SSL truststore- See Also:
-
LDAP_TRUSTSTORE_PASSWORD_FILE_KEY
The path to a file containing the password for the LDAP SSL truststore- See Also:
-
BIND_USERS_KEY
- See Also:
-
BIND_USER_SUFFIX
- See Also:
-
BIND_USER_KEY
- See Also:
-
BIND_USER_DEFAULT
- See Also:
-
BIND_PASSWORD_SUFFIX
- See Also:
-
BIND_PASSWORD_KEY
- See Also:
-
BIND_PASSWORD_DEFAULT
- See Also:
-
BIND_PASSWORD_FILE_SUFFIX
- See Also:
-
BIND_PASSWORD_FILE_KEY
- See Also:
-
BIND_PASSWORD_FILE_DEFAULT
- See Also:
-
BIND_PASSWORD_ALIAS_SUFFIX
- See Also:
-
BIND_PASSWORD_ALIAS_KEY
- See Also:
-
BIND_PASSWORD_ALIAS_DEFAULT
- See Also:
-
BASE_DN_KEY
- See Also:
-
BASE_DN_DEFAULT
- See Also:
-
USER_BASE_DN_KEY
- See Also:
-
GROUP_BASE_DN_KEY
- See Also:
-
USER_SEARCH_FILTER_KEY
- See Also:
-
USER_SEARCH_FILTER_DEFAULT
- See Also:
-
GROUP_SEARCH_FILTER_KEY
- See Also:
-
GROUP_SEARCH_FILTER_DEFAULT
- See Also:
-
MEMBEROF_ATTR_KEY
- See Also:
-
MEMBEROF_ATTR_DEFAULT
- See Also:
-
GROUP_MEMBERSHIP_ATTR_KEY
- See Also:
-
GROUP_MEMBERSHIP_ATTR_DEFAULT
- See Also:
-
GROUP_NAME_ATTR_KEY
- See Also:
-
GROUP_NAME_ATTR_DEFAULT
- See Also:
-
GROUP_HIERARCHY_LEVELS_KEY
- See Also:
-
GROUP_HIERARCHY_LEVELS_DEFAULT
public static final int GROUP_HIERARCHY_LEVELS_DEFAULT- See Also:
-
POSIX_UID_ATTR_KEY
- See Also:
-
POSIX_UID_ATTR_DEFAULT
- See Also:
-
POSIX_GID_ATTR_KEY
- See Also:
-
POSIX_GID_ATTR_DEFAULT
- See Also:
-
GROUP_SEARCH_FILTER_PATTERN
- See Also:
-
GROUP_SEARCH_FILTER_PATTERN_DEFAULT
- See Also:
-
POSIX_GROUP
- See Also:
-
POSIX_ACCOUNT
- See Also:
-
DIRECTORY_SEARCH_TIMEOUT
- See Also:
-
DIRECTORY_SEARCH_TIMEOUT_DEFAULT
public static final int DIRECTORY_SEARCH_TIMEOUT_DEFAULT- See Also:
-
CONNECTION_TIMEOUT
- See Also:
-
CONNECTION_TIMEOUT_DEFAULT
public static final int CONNECTION_TIMEOUT_DEFAULT- See Also:
-
READ_TIMEOUT
- See Also:
-
READ_TIMEOUT_DEFAULT
public static final int READ_TIMEOUT_DEFAULT- See Also:
-
LDAP_NUM_ATTEMPTS_KEY
- See Also:
-
LDAP_NUM_ATTEMPTS_DEFAULT
public static final int LDAP_NUM_ATTEMPTS_DEFAULT- See Also:
-
LDAP_NUM_ATTEMPTS_BEFORE_FAILOVER_KEY
- See Also:
-
LDAP_NUM_ATTEMPTS_BEFORE_FAILOVER_DEFAULT
public static final int LDAP_NUM_ATTEMPTS_BEFORE_FAILOVER_DEFAULT- See Also:
-
LDAP_CTX_FACTORY_CLASS_KEY
- See Also:
-
LDAP_CTX_FACTORY_CLASS_DEFAULT
- See Also:
-
-
Constructor Details
-
LdapGroupsMapping
public LdapGroupsMapping()
-
-
Method Details
-
getGroups
Returns list of groups for a user. The LdapCtx which underlies the DirContext object is not thread-safe, so we need to block around this whole method. The caching infrastructure will ensure that performance stays in an acceptable range.- Specified by:
getGroupsin interfaceGroupMappingServiceProvider- Parameters:
user- get groups for this user- Returns:
- list of groups for a given user
-
failover
protected boolean failover(int attemptsMadeWithSameLdap, int maxAttemptsBeforeFailover) Check whether we should fail over to the next LDAP server.- Parameters:
attemptsMadeWithSameLdap- current number of attempts made with using same LDAP instancemaxAttemptsBeforeFailover- maximum number of attempts before failing over- Returns:
- true if we should fail over to the next LDAP server
-
switchBindUser
Switch to the next available user to bind to.- Parameters:
e- AuthenticationException encountered when contacting LDAP
-
cacheGroupsRefresh
public void cacheGroupsRefresh()Caches groups, no need to do that for this provider- Specified by:
cacheGroupsRefreshin interfaceGroupMappingServiceProvider
-
cacheGroupsAdd
Adds groups to cache, no need to do that for this provider- Specified by:
cacheGroupsAddin interfaceGroupMappingServiceProvider- Parameters:
groups- unused
-
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:
user- User's name- Returns:
- set of group memberships of user
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- Configuration
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- configuration to be used
-
getLdapUrls
Get URLs of configured LDAP servers.- Returns:
- URLs of LDAP servers being used.
-