@InterfaceAudience.Private public class UserProvider extends BaseConfigurable
User
creation.Modifier and Type | Field and Description |
---|---|
private static org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService |
executor |
private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<String,String[]> |
groupCache |
(package private) static org.apache.hadoop.security.Groups |
groups |
private static String |
USER_PROVIDER_CONF_KEY |
Constructor and Description |
---|
UserProvider() |
Modifier and Type | Method and Description |
---|---|
User |
create(org.apache.hadoop.security.UserGroupInformation ugi)
Wraps an underlying
UserGroupInformation instance. |
User |
getCurrent() |
String |
getCurrentUserName() |
static org.apache.hadoop.security.Groups |
getGroups() |
static UserProvider |
instantiate(org.apache.hadoop.conf.Configuration conf)
Instantiate the
UserProvider specified in the configuration and set the passed
configuration via setConf(Configuration) |
boolean |
isHadoopSecurityEnabled() |
boolean |
isHBaseSecurityEnabled() |
void |
login(String fileConfKey,
String principalConfKey)
Login with given keytab and principal.
|
void |
login(String fileConfKey,
String principalConfKey,
String localhost)
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 the
UserProvider in the given configuration that should be instantiated |
boolean |
shouldLoginFromKeytab()
In secure environment, if a user specified his keytab and principal,
a hbase client will try to login with them.
|
getConf
private static final String USER_PROVIDER_CONF_KEY
private static final org.apache.hbase.thirdparty.com.google.common.util.concurrent.ListeningExecutorService executor
private org.apache.hbase.thirdparty.com.google.common.cache.LoadingCache<String,String[]> groupCache
static org.apache.hadoop.security.Groups groups
public UserProvider()
public static org.apache.hadoop.security.Groups getGroups()
public static void setGroups(org.apache.hadoop.security.Groups groups)
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
setConf
in class BaseConfigurable
public static UserProvider instantiate(org.apache.hadoop.conf.Configuration conf)
UserProvider
specified in the configuration and set the passed
configuration via setConf(Configuration)
conf
- to read and set on the created UserProvider
UserProvider
ready for use.public static void setUserProviderForTesting(org.apache.hadoop.conf.Configuration conf, Class<? extends UserProvider> provider)
UserProvider
in the given configuration that should be instantiatedconf
- to updateprovider
- class of the provider to setpublic String getCurrentUserName() throws IOException
IOException
- if the underlying user cannot be obtainedpublic boolean isHBaseSecurityEnabled()
public boolean isHadoopSecurityEnabled()
false
. For secure Hadoop, it will return the value
from UserGroupInformation.isSecurityEnabled()
.public boolean shouldLoginFromKeytab()
public User getCurrent() throws IOException
IOException
- if the user cannot be loadedpublic User create(org.apache.hadoop.security.UserGroupInformation ugi)
UserGroupInformation
instance.ugi
- The base Hadoop userpublic void login(String fileConfKey, String principalConfKey, String localhost) throws IOException
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.
fileConfKey
- Property key used to configure path to the credential fileprincipalConfKey
- Property key used to configure login principallocalhost
- Current hostname to use in any credentialsIOException
- underlying exception from SecurityUtil.login() callpublic void login(String fileConfKey, String principalConfKey) throws IOException
fileConfKey
- config name for client keytabprincipalConfKey
- config name for client principalIOException
- underlying exception from UserGroupInformation.loginUserFromKeytabCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.