Skip to content

Commit

Permalink
KYLIN-4033 Can not access Kerberized Cluster with DebugTomcat
Browse files Browse the repository at this point in the history
  • Loading branch information
TempleZhou authored and nichunen committed Jun 19, 2019
1 parent 807a571 commit c3fd390
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.kylin.rest;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

Expand All @@ -29,6 +30,7 @@
import org.apache.catalina.startup.Tomcat;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.Shell;
import org.apache.kylin.common.KylinConfig;

Expand All @@ -41,6 +43,10 @@ public static void setupDebugEnv() {

// test_case_data/sandbox/ contains HDP 2.2 site xmls which is dev sandbox
KylinConfig.setSandboxEnvIfPossible();
// Must set SandboxEnv before checking the Kerberos status
if (UserGroupInformation.isSecurityEnabled()) {
authKrb5();
}
overrideDevJobJarLocations();

System.setProperty("spring.profiles.active", "testing");
Expand Down Expand Up @@ -100,6 +106,17 @@ private static File findFile(String dir, String ptn) {
return null;
}

public static void authKrb5() {
// The system property "java.security.krb5.conf" should be set
try {
UserGroupInformation.loginUserFromKeytab(
System.getProperty("java.security.krb5.principal"),
System.getProperty("java.security.krb5.keytab"));
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
setupDebugEnv();

Expand Down

0 comments on commit c3fd390

Please sign in to comment.