本文整理汇总了Java中org.apache.hadoop.security.authentication.util.KerberosUtil.getDefaultRealm方法的典型用法代码示例。如果您正苦于以下问题:Java KerberosUtil.getDefaultRealm方法的具体用法?Java KerberosUtil.getDefaultRealm怎么用?Java KerberosUtil.getDefaultRealm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.security.authentication.util.KerberosUtil
的用法示例。
在下文中一共展示了KerberosUtil.getDefaultRealm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConfiguration
import org.apache.hadoop.security.authentication.util.KerberosUtil; //导入方法依赖的package包/类
/**
* Set the static configuration to get the rules.
* <p/>
* IMPORTANT: This method does a NOP if the rules have been set already.
* If there is a need to reset the rules, the {@link KerberosName#setRules(String)}
* method should be invoked directly.
*
* @param conf the new configuration
* @throws IOException
*/
public static void setConfiguration(Configuration conf) throws IOException {
final String defaultRule;
switch (SecurityUtil.getAuthenticationMethod(conf)) {
case KERBEROS:
case KERBEROS_SSL:
try {
KerberosUtil.getDefaultRealm();
} catch (Exception ke) {
throw new IllegalArgumentException("Can't get Kerberos realm", ke);
}
defaultRule = "DEFAULT";
break;
default:
// just extract the simple user name
defaultRule = "RULE:[1:$1] RULE:[2:$1]";
break;
}
String ruleString = conf.get(HADOOP_SECURITY_AUTH_TO_LOCAL, defaultRule);
setRules(ruleString);
}
示例2: testDefaultRealmValid
import org.apache.hadoop.security.authentication.util.KerberosUtil; //导入方法依赖的package包/类
@Test
public void testDefaultRealmValid() throws Throwable {
String defaultRealm = KerberosUtil.getDefaultRealm();
assertNotEmpty("No default Kerberos Realm",
defaultRealm);
LOG.info("Default Realm '{}'", defaultRealm);
}