org.apache.hadoop.hbase.security
Class User

java.lang.Object
  extended by org.apache.hadoop.hbase.security.User

public abstract class User
extends Object

Wrapper to abstract out usage of user and group information in HBase.

This class provides a common interface for interacting with user and group information across changing APIs in different versions of Hadoop. It only provides access to the common set of functionality in UserGroupInformation currently needed by HBase, but can be extended as needs change.

Note: this class does not attempt to support any of the Kerberos authentication methods exposed in security-enabled Hadoop (for the moment at least), as they're not yet needed. Properly supporting authentication is left up to implementation in secure HBase.


Field Summary
protected  org.apache.hadoop.security.UserGroupInformation ugi
           
 
Constructor Summary
User()
           
 
Method Summary
static User createUserForTesting(org.apache.hadoop.conf.Configuration conf, String name, String[] groups)
          Generates a new User instance specifically for use in test code.
static User getCurrent()
          Returns the User instance within current execution context.
 String getName()
          Returns the full user name.
abstract  String getShortName()
          Returns the shortened version of the user name -- the portion that maps to an operating system user name.
static void login(org.apache.hadoop.conf.Configuration conf, String fileConfKey, String principalConfKey, String localhost)
          Log in the current process using the given configuration keys for the credential file and login principal.
abstract
<T> T
runAs(PrivilegedAction<T> action)
          Executes the given action within the context of this user.
abstract
<T> T
runAs(PrivilegedExceptionAction<T> action)
          Executes the given action within the context of this user.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ugi

protected org.apache.hadoop.security.UserGroupInformation ugi
Constructor Detail

User

public User()
Method Detail

getName

public String getName()
Returns the full user name. For Kerberos principals this will include the host and realm portions of the principal name.

Returns:
User full name.

getShortName

public abstract String getShortName()
Returns the shortened version of the user name -- the portion that maps to an operating system user name.

Returns:
Short name

runAs

public abstract <T> T runAs(PrivilegedAction<T> action)
Executes the given action within the context of this user.


runAs

public abstract <T> T runAs(PrivilegedExceptionAction<T> action)
                 throws IOException,
                        InterruptedException
Executes the given action within the context of this user.

Throws:
IOException
InterruptedException

toString

public String toString()
Overrides:
toString in class Object

getCurrent

public static User getCurrent()
                       throws IOException
Returns the User instance within current execution context.

Throws:
IOException

createUserForTesting

public static User createUserForTesting(org.apache.hadoop.conf.Configuration conf,
                                        String name,
                                        String[] groups)
Generates a new User instance specifically for use in test code.

Parameters:
name - the full username
groups - the group names to which the test user will belong
Returns:
a new User instance

login

public static void login(org.apache.hadoop.conf.Configuration conf,
                         String fileConfKey,
                         String principalConfKey,
                         String localhost)
                  throws IOException
Log in the current process using the given configuration keys for the credential file and login principal.

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:
conf - The configuration data to use
fileConfKey - Property key used to configure path to the credential file
principalConfKey - Property key used to configure login principal
localhost - Current hostname to use in any credentials
Throws:
IOException - underlying exception from SecurityUtil.login() call


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.