SecurityUtil { public static void setAuthenticationMethod( AuthenticationMethod authenticationMethod, Configuration conf) { if (authenticationMethod == null) { authenticationMethod = AuthenticationMethod.SIMPLE; } conf.set(HADOOP_SECURITY_AUTHENTICATION, StringUtils.toLowerCase(authenticationMethod.toString())); }  @InterfaceAudience.Private @VisibleForTesting static void setTokenServiceUseIp(boolean flag); @InterfaceAudience.Public @InterfaceStability.Evolving static String getServerPrincipal(String principalConfig,
      String hostname); @InterfaceAudience.Public @InterfaceStability.Evolving static String getServerPrincipal(String principalConfig,
      InetAddress addr); @InterfaceAudience.Public @InterfaceStability.Evolving static void login(final Configuration conf,
      final String keytabFileKey, final String userNameKey); @InterfaceAudience.Public @InterfaceStability.Evolving static void login(final Configuration conf,
      final String keytabFileKey, final String userNameKey, String hostname); static String buildDTServiceName(URI uri, int defPort); static String getHostFromPrincipal(String principalName); @InterfaceAudience.Private static void setSecurityInfoProviders(SecurityInfo... providers); static KerberosInfo getKerberosInfo(Class<?> protocol, Configuration conf); static TokenInfo getTokenInfo(Class<?> protocol, Configuration conf); static InetSocketAddress getTokenServiceAddr(Token<?> token); static void setTokenService(Token<?> token, InetSocketAddress addr); static Text buildTokenService(InetSocketAddress addr); static Text buildTokenService(URI uri); static T doAsLoginUserOrFatal(PrivilegedAction<T> action); static T doAsLoginUser(PrivilegedExceptionAction<T> action); static T doAsCurrentUser(PrivilegedExceptionAction<T> action); @InterfaceAudience.Private static InetAddress getByName(String hostname); static AuthenticationMethod getAuthenticationMethod(Configuration conf); static void setAuthenticationMethod(
      AuthenticationMethod authenticationMethod, Configuration conf); static boolean isPrivilegedPort(final int port); static final Log LOG; static final String HOSTNAME_PATTERN; static final String FAILED_TO_GET_UGI_MSG_HEADER; }
@Test public void testSetAuthenticationMethod() { Configuration conf = new Configuration(); SecurityUtil.setAuthenticationMethod(null, conf); assertEquals("simple", conf.get(HADOOP_SECURITY_AUTHENTICATION)); SecurityUtil.setAuthenticationMethod(SIMPLE, conf); assertEquals("simple", conf.get(HADOOP_SECURITY_AUTHENTICATION)); SecurityUtil.setAuthenticationMethod(KERBEROS, conf); assertEquals("kerberos", conf.get(HADOOP_SECURITY_AUTHENTICATION)); }