@Test public void testLoginAndReturnUgi() throws IOException { String principal = ""; String keytabPath = ""; String krb5confPath = ""; try { KrbUtils.loginAndReturnUgi(principal, keytabPath, krb5confPath); } catch (IllegalArgumentException e) { Assert.assertEquals(e.getMessage(), "Can't get Kerberos realm"); } }
public static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath) throws IOException { LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); System.setProperty(KRB5_CONF_KEY, krb5confPath); try { Config.refresh(); KerberosName.resetDefaultRealm(); } catch (KrbException e) { LOG.warn("resetting default realm failed, current default realm will still be used.", e); } Configuration configuration = new Configuration(); configuration.set(HADOOP_AUTH_KEY , KRB_STR); UserGroupInformation.setConfiguration(configuration); return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); }
KrbUtils { public static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath) throws IOException { LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); System.setProperty(KRB5_CONF_KEY, krb5confPath); try { Config.refresh(); KerberosName.resetDefaultRealm(); } catch (KrbException e) { LOG.warn("resetting default realm failed, current default realm will still be used.", e); } Configuration configuration = new Configuration(); configuration.set(HADOOP_AUTH_KEY , KRB_STR); UserGroupInformation.setConfiguration(configuration); return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); } }
KrbUtils { public static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath) throws IOException { LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); System.setProperty(KRB5_CONF_KEY, krb5confPath); try { Config.refresh(); KerberosName.resetDefaultRealm(); } catch (KrbException e) { LOG.warn("resetting default realm failed, current default realm will still be used.", e); } Configuration configuration = new Configuration(); configuration.set(HADOOP_AUTH_KEY , KRB_STR); UserGroupInformation.setConfiguration(configuration); return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); }  }
KrbUtils { public static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath) throws IOException { LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); System.setProperty(KRB5_CONF_KEY, krb5confPath); try { Config.refresh(); KerberosName.resetDefaultRealm(); } catch (KrbException e) { LOG.warn("resetting default realm failed, current default realm will still be used.", e); } Configuration configuration = new Configuration(); configuration.set(HADOOP_AUTH_KEY , KRB_STR); UserGroupInformation.setConfiguration(configuration); return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); }  static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath); }
KrbUtils { public static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath) throws IOException { LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); System.setProperty(KRB5_CONF_KEY, krb5confPath); try { Config.refresh(); KerberosName.resetDefaultRealm(); } catch (KrbException e) { LOG.warn("resetting default realm failed, current default realm will still be used.", e); } Configuration configuration = new Configuration(); configuration.set(HADOOP_AUTH_KEY , KRB_STR); UserGroupInformation.setConfiguration(configuration); return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); }  static UserGroupInformation loginAndReturnUgi(String principal, String keytabPath, String krb5confPath); static final String KRB5_CONF_KEY; static final String HADOOP_AUTH_KEY; static final String KRB_STR; }