public class SecurityUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
HADOOP_SECURITY_AUTHENTICATION |
static String |
KERBEROS |
| Constructor and Description |
|---|
SecurityUtil() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.hadoop.security.UserGroupInformation |
getUgiForKerberosUser(org.apache.hadoop.conf.Configuration config,
KerberosUser kerberosUser)
Authenticates a
KerberosUser and acquires a UserGroupInformation instance using UserGroupInformation.getUGIFromSubject(Subject). |
static boolean |
isSecurityEnabled(org.apache.hadoop.conf.Configuration config)
Initializes UserGroupInformation with the given Configuration and returns UserGroupInformation.isSecurityEnabled().
|
static org.apache.hadoop.security.UserGroupInformation |
loginKerberos(org.apache.hadoop.conf.Configuration config,
String principal,
String keyTab)
Initializes UserGroupInformation with the given Configuration and performs the login for the given principal
and keytab.
|
static org.apache.hadoop.security.UserGroupInformation |
loginSimple(org.apache.hadoop.conf.Configuration config)
Initializes UserGroupInformation with the given Configuration and returns UserGroupInformation.getLoginUser().
|
public static final String HADOOP_SECURITY_AUTHENTICATION
public static final String KERBEROS
public static org.apache.hadoop.security.UserGroupInformation loginKerberos(org.apache.hadoop.conf.Configuration config,
String principal,
String keyTab)
throws IOException
UserGroupInformation.loginUserFromKeytab(String, String) to
authenticate the given principal, which sets the static variable loginUser in the
UserGroupInformation instance. Setting loginUser is necessary for
Client.Connection.handleSaslConnectionFailure(int, int, Exception, Random, UserGroupInformation)
to be able to attempt a relogin during a connection failure. The handleSaslConnectionFailure method
calls UserGroupInformation.getLoginUser().reloginFromKeytab() statically, which can return null
if loginUser is not set, resulting in failure of the hadoop operation.
In previous versions of NiFi, UserGroupInformation.loginUserFromKeytabAndReturnUGI(String, String) was
used to authenticate the principal, which does not set loginUser, making it impossible
for a
Client.Connection.handleSaslConnectionFailure(int, int, Exception, Random, UserGroupInformation)
to be able to implicitly relogin the principal.config - the configuration instanceprincipal - the principal to authenticate askeyTab - the keytab to authenticate withIOException - if login failedpublic static org.apache.hadoop.security.UserGroupInformation getUgiForKerberosUser(org.apache.hadoop.conf.Configuration config,
KerberosUser kerberosUser)
throws IOException
KerberosUser and acquires a UserGroupInformation instance using UserGroupInformation.getUGIFromSubject(Subject).
The UserGroupInformation will use the given Configuration.config - The Configuration to apply to the acquired UserGroupInformation instancekerberosUser - The KerberosUser to authenticateIOException - if authentication failspublic static org.apache.hadoop.security.UserGroupInformation loginSimple(org.apache.hadoop.conf.Configuration config)
throws IOException
config - the configuration instanceIOException - if login failedpublic static boolean isSecurityEnabled(org.apache.hadoop.conf.Configuration config)
config - the given configurationCopyright © 2020 Apache NiFi Project. All rights reserved.