@InterfaceAudience.Private public class UserProvider extends BaseConfigurable
User
creation.构造器和说明 |
---|
UserProvider() |
限定符和类型 | 方法和说明 |
---|---|
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
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
在接口中 org.apache.hadoop.conf.Configurable
setConf
在类中 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–2019 The Apache Software Foundation. All rights reserved.