exceptionfactory commented on a change in pull request #5277:
URL: https://github.com/apache/nifi/pull/5277#discussion_r691332143
##########
File path:
nifi-nar-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java
##########
@@ -450,6 +476,36 @@ HdfsResources resetHDFSResources(final List<String>
resourceLocations, ProcessCo
return new HdfsResources(config, fs, ugi, kerberosUser);
}
+ private KerberosUser getKerberosUser(final ProcessContext context) throws
IOException {
+ // Check Kerberos User Service first, if present then get the
KerberosUser from the service
+ // The customValidate method ensures that KerberosUserService can't be
set at the same time as the credentials service or explicit properties
+ final KerberosUserService kerberosUserService =
context.getProperty(KERBEROS_USER_SERVICE).asControllerService(KerberosUserService.class);
+ if (kerberosUserService != null) {
+ return kerberosUserService.createKerberosUser();
+ }
+
+ // Kerberos User Service wasn't set, so create KerberosUser based on
credentials service or explicit properties...
+ String principal =
context.getProperty(kerberosProperties.getKerberosPrincipal()).evaluateAttributeExpressions().getValue();
+ String keyTab =
context.getProperty(kerberosProperties.getKerberosKeytab()).evaluateAttributeExpressions().getValue();
+ String password =
context.getProperty(kerberosProperties.getKerberosPassword()).getValue();
+
+ // If the Kerberos Credentials Service is specified, we need to use
its configuration, not the explicit properties for principal/keytab.
+ // The customValidate method ensures that only one can be set, so we
know that the principal & keytab above are null.
+ final KerberosCredentialsService credentialsService =
context.getProperty(KERBEROS_CREDENTIALS_SERVICE).asControllerService(KerberosCredentialsService.class);
+ if (credentialsService != null) {
+ principal = credentialsService.getPrincipal();
+ keyTab = credentialsService.getKeytab();
+ }
+
+ if (keyTab != null) {
+ return new KerberosKeytabUser(principal, keyTab);
+ } else if (password != null) {
+ return new KerberosPasswordUser(principal, password);
+ } else {
+ throw new IOException("Unable to authenticate with Kerberos, no
keytab or password was provided");
Review comment:
Thanks for looking into this behavior. `IllegalStateException` sounds
good given that validation should prevent this from happening.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]