This is an automated email from the ASF dual-hosted git repository.

yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 9bd2a5220a [HUDI-4718] Add Kerberos kdestroy command support (#6810)
9bd2a5220a is described below

commit 9bd2a5220a64ba10307150c2a875528f3ff9b03a
Author: Zouxxyy <[email protected]>
AuthorDate: Sat Oct 1 05:53:19 2022 +0800

    [HUDI-4718] Add Kerberos kdestroy command support (#6810)
---
 .../commands/KerberosAuthenticationCommand.java    | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git 
a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/KerberosAuthenticationCommand.java
 
b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/KerberosAuthenticationCommand.java
index d79279a315..125b36a85a 100644
--- 
a/hudi-cli/src/main/java/org/apache/hudi/cli/commands/KerberosAuthenticationCommand.java
+++ 
b/hudi-cli/src/main/java/org/apache/hudi/cli/commands/KerberosAuthenticationCommand.java
@@ -57,4 +57,27 @@ public class KerberosAuthenticationCommand {
 
     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";
+  }
 }

Reply via email to