Extract Kerberos TGT from UGI
What's inside this article
⌄
- Extract kerberos TGT from UGI
- Hadoop UserGroupInformation TGT
- Get Kerberos ticket from UGI
- UGI kerberos credentials extract
If you need to:
- view lifetime of your Kerberos ticket in Hadoop’s
UserGroupInformation - see Kerberos ticket expiration date in
UserGroupInformation(and do other things)
You need to extract Kerberos TGT from UserGroupInformation.
Here is how we can do it:
public KerberosTicket extractTgtFromUGI(UserGroupInformation ugi) {
Method method = null;
try {
method = ugi.getClass().getDeclaredMethod("getTGT");
method.setAccessible(true);
KerberosTicket tgt = (KerberosTicket) method.invoke(ugi);
log.info("Kerberos ticket info. startTime={}, endTime={}, renewTill={}", tgt.getStartTime(), tgt.getEndTime(), tgt.getRenewTill());
return tgt;
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
throw new RuntimeException(ex);
}
}