Skip to content

Instantly share code, notes, and snippets.

@bbhavsar
Created October 30, 2020 22:19
Show Gist options
  • Save bbhavsar/4b11bd8b5ea92bb3bbbdc629fb779806 to your computer and use it in GitHub Desktop.
Save bbhavsar/4b11bd8b5ea92bb3bbbdc629fb779806 to your computer and use it in GitHub Desktop.
Kudu Kerberos Ticket Cache
static KuduClient GetTicketCacheClient() {
Subject subject = SecurityUtil.getSubjectFromTicketCacheOrNull();
if (subject == null) {
System.out.println("Subject not available from ticket cache");
System.exit(1);
}
KuduClient client = null;
try {
client = Subject.doAs(subject, new PrivilegedExceptionAction<KuduClient>() {
public KuduClient run() throws Exception {
return new KuduClientBuilder("bankim-b-1.gce.cloudera.com:7051").build();
}
});
} catch (Exception ex) {
System.out.println("Error in ticket cache: " + ex.getMessage());
}
return client;
}
public static void main(String[] args) {
KuduClient client = GetTicketCacheClient();
ListTables(client);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment