List of usage examples for org.apache.hadoop.security UserGroupInformation getUGIFromTicketCache
@InterfaceAudience.Public @InterfaceStability.Evolving public static UserGroupInformation getUGIFromTicketCache(String ticketCache, String user) throws IOException
From source file:org.apache.phoenix.queryserver.client.SqllineWrapper.java
License:Apache License
static UserGroupInformation loginIfNecessary(Configuration conf) { // Try to avoid HBase dependency too. Sadly, we have to bring in all of hadoop-common for this.. if ("kerberos".equalsIgnoreCase(conf.get(HBASE_AUTHENTICATION_ATTR))) { // sun.security.krb5.principal is the property for setting the principal name, if that // isn't set, fall back to user.name and hope for the best. String principal = System.getProperty("sun.security.krb5.principal", System.getProperty("user.name")); try {//from w w w.j a va2s . co m // We got hadoop-auth via hadoop-common, so might as well use it. return UserGroupInformation.getUGIFromTicketCache(null, principal); } catch (Exception e) { throw new RuntimeException("Kerberos login failed using ticket cache. Did you kinit?", e); } } return null; }