mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-13 18:04:55 +00:00
Add WHZ_KRB5_DIR environmental variable to the search path for gss-jass.conf & krb5.conf files. (#421)
Also remove the unset WH_HOME directory from the search path.
This commit is contained in:
parent
12f2bc9ec5
commit
9e55d80538
@ -1,3 +1,6 @@
|
|||||||
|
# Directory containing kerberos config files
|
||||||
|
WHZ_KRB5_DIR=
|
||||||
|
|
||||||
# Secret Key
|
# Secret Key
|
||||||
WHZ_SECRET=
|
WHZ_SECRET=
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ package metadata.etl.lineage;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.auth.AuthSchemeProvider;
|
import org.apache.http.auth.AuthSchemeProvider;
|
||||||
@ -60,35 +62,14 @@ public class HadoopJobHistoryNodeExtractor {
|
|||||||
this.serverURL = prop.getProperty(Constant.AZ_HADOOP_JOBHISTORY_KEY);
|
this.serverURL = prop.getProperty(Constant.AZ_HADOOP_JOBHISTORY_KEY);
|
||||||
|
|
||||||
String CURRENT_DIR = System.getProperty("user.dir");
|
String CURRENT_DIR = System.getProperty("user.dir");
|
||||||
String WH_HOME = System.getenv("WH_HOME");
|
String WHZ_KRB5_DIR = System.getenv("WHZ_KRB5_DIR");
|
||||||
String APP_HOME = System.getenv("APP_HOME");
|
String APP_HOME = System.getenv("APP_HOME");
|
||||||
String USER_HOME = System.getenv("HOME") + "/.kerberos";
|
String USER_HOME = System.getenv("HOME") + "/.kerberos";
|
||||||
|
|
||||||
String[] allPositions = new String[]{CURRENT_DIR, WH_HOME, APP_HOME, USER_HOME, "/etc"};
|
String[] searchPath = new String[]{CURRENT_DIR, WHZ_KRB5_DIR, APP_HOME, USER_HOME, "/etc"};
|
||||||
|
|
||||||
for (String position : allPositions) {
|
|
||||||
String gssFileName = position + "/gss-jaas.conf";
|
|
||||||
File gssFile = new File(gssFileName);
|
|
||||||
if (gssFile.exists()) {
|
|
||||||
logger.debug("Found gss-jaas.conf file at: {}", gssFile.getAbsolutePath());
|
|
||||||
System.setProperty("java.security.auth.login.config", gssFile.getAbsolutePath());
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
logger.debug("{} doesn't exist.", gssFile.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String position : allPositions) {
|
|
||||||
String krb5FileName = position + "/krb5.conf";
|
|
||||||
File krb5File = new File(krb5FileName);
|
|
||||||
if (krb5File.exists()) {
|
|
||||||
logger.debug("Found krb5.conf file at: {}", krb5File.getAbsolutePath());
|
|
||||||
System.setProperty("java.security.krb5.conf", krb5File.getAbsolutePath());
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
logger.debug("{} does't exist.", krb5File.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
System.setProperty("java.security.auth.login.config", findFileInSearchPath(searchPath, "gss-jaas.conf"));
|
||||||
|
System.setProperty("java.security.auth.krb5.conf", findFileInSearchPath(searchPath, "krb5.conf"));
|
||||||
if (System.getProperty("java.security.auth.login.config") == null
|
if (System.getProperty("java.security.auth.login.config") == null
|
||||||
|| System.getProperty("java.security.krb5.conf") == null) {
|
|| System.getProperty("java.security.krb5.conf") == null) {
|
||||||
logger.warn("Can't find Java security config [krb5.conf, gss-jass.conf] for Kerberos! Trying other authentication methods...");
|
logger.warn("Can't find Java security config [krb5.conf, gss-jass.conf] for Kerberos! Trying other authentication methods...");
|
||||||
@ -144,4 +125,19 @@ public class HadoopJobHistoryNodeExtractor {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
httpClient.close();
|
httpClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String findFileInSearchPath(@Nonnull String[] searchPath, @Nonnull String filename) {
|
||||||
|
for (String path : searchPath) {
|
||||||
|
File file = new File(path, filename);
|
||||||
|
if (file.exists()) {
|
||||||
|
String absolutePath = file.getAbsolutePath();
|
||||||
|
logger.debug("Found {} file at: {}", filename, absolutePath);
|
||||||
|
return absolutePath;
|
||||||
|
} else {
|
||||||
|
logger.debug("{} doesn't exist.", file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user