本文整理汇总了Java中sun.security.krb5.Config.getDefaultRealm方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getDefaultRealm方法的具体用法?Java Config.getDefaultRealm怎么用?Java Config.getDefaultRealm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.security.krb5.Config
的用法示例。
在下文中一共展示了Config.getDefaultRealm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf",
System.getProperty("test.src", ".") +"/no-such-file.conf");
Config config = Config.getInstance();
try {
String r = config.getDefaultRealm();
throw new Exception("What? There is a default realm " + r + "?");
} catch (KrbException ke) {
ke.printStackTrace();
if (ke.getCause() != null) {
throw new Exception("There should be no cause. Won't try DNS");
}
}
String kdcs = config.getKDCList("X");
if (!kdcs.equals("a.com.:88 b.com.:99") &&
!kdcs.equals("a.com. b.com.:99")) {
throw new Exception("Strange KDC: [" + kdcs + "]");
};
}
示例2: login
import sun.security.krb5.Config; //导入方法依赖的package包/类
private static synchronized void login(Args args, Configuration conf) throws Exception {
if (args.has(Args.OPTION_DEBUG)) {
System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("sun.security.spnego.debug", "true");
}
System.setProperty("java.security.auth.login.config", createJaasConfigFile(args, "hbase-client.jaas"));
System.setProperty("java.security.krb5.conf", kerberosConfigFile(args));
Config krbConfig = Config.getInstance();
final String realm;
if (args.has(Args.OPTION_REALM)) {
realm = (String) args.valueOf(Args.OPTION_REALM);
System.setProperty("java.security.krb5.realm", realm);
System.setProperty("java.security.krb5.kdc", krbConfig.getKDCList(realm));
Config.refresh();
} else {
realm = krbConfig.getDefaultRealm();
}
updateConf(conf, realm);
if (args.has(Args.OPTION_KEY_TAB)) {
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab(principal(args), (String) args.valueOf(Args.OPTION_KEY_TAB));
} else if (args.has(Args.OPTION_KEY_TAB_SHORT)) {
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab(principal(args), (String) args.valueOf(Args.OPTION_KEY_TAB_SHORT));
} else {
loginWithPassword(args, conf);
}
UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
System.out.println(currentUser + "\n");
}