Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-4718] Add Kerberos kdestroy command support #6810

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
}
}