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
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService(package private) static org.apache.hadoop.security.Groupsprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(org.apache.hadoop.security.UserGroupInformation ugi) Wraps an underlyingUserGroupInformationinstance.Return the current user within the current execution contextReturns the userName for the current logged-in user.static org.apache.hadoop.security.Groupsstatic UserProviderinstantiate(org.apache.hadoop.conf.Configuration conf) Instantiate theUserProviderspecified in the configuration and set the passed configuration viasetConf(Configuration)booleanReturn whether or not Kerberos authentication is configured for Hadoop.booleanReturns true if security is enabled, false otherwisevoidLogin with given keytab and principal.voidLog in the current process using the given configuration keys for the credential file and login principal.voidsetConf(org.apache.hadoop.conf.Configuration conf) static voidsetGroups(org.apache.hadoop.security.Groups groups) static voidsetUserProviderForTesting(org.apache.hadoop.conf.Configuration conf, Class<? extends UserProvider> provider) Set theUserProviderin the given configuration that should be instantiatedbooleanIn 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:
setConfin interfaceorg.apache.hadoop.conf.Configurable- Overrides:
setConfin classBaseConfigurable
-
instantiate
Instantiate theUserProviderspecified in the configuration and set the passed configuration viasetConf(Configuration)- Parameters:
conf- to read and set on the createdUserProvider- Returns:
- a
UserProviderready for use.
-
setUserProviderForTesting
public static void setUserProviderForTesting(org.apache.hadoop.conf.Configuration conf, Class<? extends UserProvider> provider) Set theUserProviderin 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 underlyingUserGroupInformationinstance.- 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
-