Skip to content

Commit

Permalink
[HUDI-4718] Add Kerberos kdestroy command support (#6810)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Sep 30, 2022
1 parent 45a699b commit 9bd2a52
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,27 @@ public String performKerberosAuthentication(

return "Kerberos authentication success";
}

@ShellMethod(key = "kerberos kdestroy", value = "Destroy Kerberos authentication")
public String destroyKerberosAuthentication(
@ShellOption(value = "--krb5conf", help = "Path to krb5.conf", defaultValue = "/etc/krb5.conf") String krb5ConfPath) throws IOException {

System.out.println("Destroy Kerberos authentication");
System.out.println("Parameters:");
System.out.println("--krb5conf: " + krb5ConfPath);

System.setProperty("java.security.krb5.conf", krb5ConfPath);
UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
if (loginUser.hasKerberosCredentials()) {
loginUser.logoutUserFromKeytab();
UserGroupInformation.reset();
} else {
System.out.println("Currently, no user login with kerberos, do nothing");
}

System.out.println("Current user: " + UserGroupInformation.getCurrentUser());
System.out.println("Login user: " + UserGroupInformation.getLoginUser());

return "Destroy Kerberos authentication success";
}
}

0 comments on commit 9bd2a52

Please sign in to comment.