Package org.apache.hadoop.hbase.security
Class UserProvider
java.lang.Object
org.apache.hadoop.hbase.BaseConfigurable
org.apache.hadoop.hbase.security.UserProvider
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
Provide an instance of a user. Allows custom
User
creation.-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService
(package private) static org.apache.hadoop.security.Groups
private static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(org.apache.hadoop.security.UserGroupInformation ugi) Wraps an underlyingUserGroupInformation
instance.Return the current user within the current execution contextReturns the userName for the current logged-in user.static org.apache.hadoop.security.Groups
static UserProvider
instantiate
(org.apache.hadoop.conf.Configuration conf) Instantiate theUserProvider
specified in the configuration and set the passed configuration viasetConf(Configuration)
boolean
Return whether or not Kerberos authentication is configured for Hadoop.boolean
Returns true if security is enabled, false otherwisevoid
Login with given keytab and principal.void
Log in the current process using the given configuration keys for the credential file and login principal.void
setConf
(org.apache.hadoop.conf.Configuration conf) static void
setGroups
(org.apache.hadoop.security.Groups groups) static void
setUserProviderForTesting
(org.apache.hadoop.conf.Configuration conf, Class<? extends UserProvider> provider) Set theUserProvider
in the given configuration that should be instantiatedboolean
In secure environment, if a user specified his keytab and principal, a hbase client will try to login with them.Methods inherited from class org.apache.hadoop.hbase.BaseConfigurable
getConf
-
Field Details
-
USER_PROVIDER_CONF_KEY
- See Also:
-
executor
private static final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService executor -
groupCache
private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<String,String[]> groupCache -
groups
-
-
Constructor Details
-
UserProvider
public UserProvider()
-
-
Method Details
-
getGroups
-
setGroups
-
setConf
- Specified by:
setConf
in interfaceorg.apache.hadoop.conf.Configurable
- Overrides:
setConf
in classBaseConfigurable
-
instantiate
Instantiate theUserProvider
specified in the configuration and set the passed configuration viasetConf(Configuration)
- Parameters:
conf
- to read and set on the createdUserProvider
- Returns:
- a
UserProvider
ready for use.
-
setUserProviderForTesting
public static void setUserProviderForTesting(org.apache.hadoop.conf.Configuration conf, Class<? extends UserProvider> provider) Set theUserProvider
in the given configuration that should be instantiated- Parameters:
conf
- to updateprovider
- class of the provider to set
-
getCurrentUserName
Returns the userName for the current logged-in user.- Throws:
IOException
- if the underlying user cannot be obtained
-
isHBaseSecurityEnabled
Returns true if security is enabled, false otherwise -
isHadoopSecurityEnabled
Return whether or not Kerberos authentication is configured for Hadoop. For non-secure Hadoop, this always returnsfalse
. For secure Hadoop, it will return the value fromUserGroupInformation.isSecurityEnabled()
. -
shouldLoginFromKeytab
In secure environment, if a user specified his keytab and principal, a hbase client will try to login with them. Otherwise, hbase client will try to obtain ticket(through kinit) from system. -
getCurrent
Return the current user within the current execution context- Throws:
IOException
- if the user cannot be loaded
-
create
Wraps an underlyingUserGroupInformation
instance.- Parameters:
ugi
- The base Hadoop user
-
login
Log in the current process using the given configuration keys for the credential file and login principal. It is for SPN(Service Principal Name) login. SPN should be this format, servicename/fully.qualified.domain.name@REALM.This is only applicable when running on secure Hadoop -- see org.apache.hadoop.security.SecurityUtil#login(Configuration,String,String,String). On regular Hadoop (without security features), this will safely be ignored.
- Parameters:
fileConfKey
- Property key used to configure path to the credential fileprincipalConfKey
- Property key used to configure login principallocalhost
- Current hostname to use in any credentials- Throws:
IOException
- underlying exception from SecurityUtil.login() call
-
login
Login with given keytab and principal. This can be used for both SPN(Service Principal Name) and UPN(User Principal Name) which format should be clientname@REALM.- Parameters:
fileConfKey
- config name for client keytabprincipalConfKey
- config name for client principal- Throws:
IOException
- underlying exception from UserGroupInformation.loginUserFromKeytab
-