本文整理汇总了Java中sun.security.krb5.Config.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getInstance方法的具体用法?Java Config.getInstance怎么用?Java Config.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.security.krb5.Config
的用法示例。
在下文中一共展示了Config.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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", ".") +"/yesno.conf");
config = Config.getInstance();
check("a", Boolean.TRUE);
check("b", Boolean.FALSE);
check("c", Boolean.TRUE);
check("d", Boolean.FALSE);
check("e", null);
check("f", null);
if (!Arrays.stream(EType.getBuiltInDefaults())
.anyMatch(n -> n < 4)) {
throw new Exception();
}
}
示例2: getInstance
import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
* Returns default checksum type.
*/
public static CksumType getInstance() throws KdcErrException {
// this method provided for Kerberos applications.
int cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
try {
Config c = Config.getInstance();
if ((cksumType = (Config.getType(c.get("libdefaults",
"ap_req_checksum_type")))) == - 1) {
if ((cksumType = Config.getType(c.get("libdefaults",
"checksum_type"))) == -1) {
cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
}
}
} catch (KrbException e) {
}
return getInstance(cksumType);
}
示例3: getDefaults
import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
* Retrieves the default etypes from the configuration file, or
* if that's not available, return the built-in list of default etypes.
* This result is always non-empty. If no etypes are found,
* an exception is thrown.
*/
public static int[] getDefaults(String configName)
throws KrbException {
Config config = null;
try {
config = Config.getInstance();
} catch (KrbException exc) {
if (DEBUG) {
System.out.println("Exception while getting " +
configName + exc.getMessage());
System.out.println("Using default builtin etypes");
}
return getBuiltInDefaults();
}
return config.defaultEtype(configName);
}
示例4: 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 + "]");
};
}
示例5: 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", ".") + "/krb5.conf");
Config config = Config.getInstance();
config.listTable();
String sample = "kdc.example.com kdc2.example.com";
for ( int i = 0; i < 4; i++ ) {
String expected = config.getAll("realms", "EXAMPLE_" + i + ".COM", "kdc");
if (!sample.equals(expected)) {
throw new Exception("krb5.conf: unexpected kdc value \"" +
expected + "\"");
}
}
// JDK-8055045: IOOBE when reading an empty value
config.get("empty1", "NOVAL.COM");
config.get("empty2", "NOVAL.COM");
config.get("quote1", "NOVAL.COM");
config.get("quote2", "NOVAL.COM");
}
示例6: getInstance
import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
* Returns default checksum type.
*/
public static CksumType getInstance() throws KdcErrException {
// this method provided for Kerberos applications.
int cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
try {
Config c = Config.getInstance();
if ((cksumType = (c.getType(c.getDefault("ap_req_checksum_type",
"libdefaults")))) == - 1) {
if ((cksumType = c.getType(c.getDefault("checksum_type",
"libdefaults"))) == -1) {
cksumType = Checksum.CKSUMTYPE_RSA_MD5; // default
}
}
} catch (KrbException e) {
}
return getInstance(cksumType);
}
示例7: getDefaultSkew
import sun.security.krb5.Config; //导入方法依赖的package包/类
public static int getDefaultSkew() {
int tdiff = Krb5.DEFAULT_ALLOWABLE_CLOCKSKEW;
try {
Config c = Config.getInstance();
if ((tdiff = c.getDefaultIntValue("clockskew",
"libdefaults")) == Integer.MIN_VALUE) { //value is not defined
tdiff = Krb5.DEFAULT_ALLOWABLE_CLOCKSKEW;
}
} catch (KrbException e) {
if (DEBUG) {
System.out.println("Exception in getting clockskew from " +
"Configuration " +
"using default value " +
e.getMessage());
}
}
return tdiff;
}
示例8: initStatic
import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void initStatic() {
boolean allowed = false;
try {
Config cfg = Config.getInstance();
String temp = cfg.get("libdefaults", "allow_weak_crypto");
if (temp != null && temp.equals("true")) allowed = true;
} catch (Exception exc) {
if (DEBUG) {
System.out.println ("Exception in getting allow_weak_crypto, " +
"using default value " +
exc.getMessage());
}
}
allowWeakCrypto = allowed;
}
示例9: 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", ".") +"/k1.conf");
Config config = Config.getInstance();
config.listTable();
String s;
// Latter overwrites former for root section
s = config.get("libdefaults", "default_realm");
if (s != null) {
throw new Exception();
}
// Latter overwrites former for strings
s = config.get("libdefaults", "default_tkt_enctypes");
if (!s.equals("aes256-cts")) {
throw new Exception();
}
// Latter overwrites former for sub-section
s = config.get("realms", "R1", "kdc");
if (!s.equals("k2")) {
throw new Exception(s);
}
// Duplicate keys in [realms] are merged
s = config.getAll("realms", "R2", "kdc");
if (!s.equals("k1 k2 k3 k4")) {
throw new Exception(s);
}
// Duplicate keys in [capaths] are merged
s = config.getAll("capaths", "R1", "R2");
if (!s.equals("R3 R4 R5 R6")) {
throw new Exception(s);
}
// We can be very deep now
s = config.get("new", "x", "y", "z", "a", "b", "c");
if (!s.equals("d")) {
throw new Exception(s);
}
}
示例10: main
import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// This config file is generated using Kerberos.app on a Mac
System.setProperty("java.security.krb5.conf",
System.getProperty("test.src", ".") +"/edu.mit.Kerberos");
Config config = Config.getInstance();
System.out.println(config);
if (!config.getDefaultRealm().equals("MAC.LOCAL")) {
throw new Exception("Realm error");
}
if (!config.getKDCList("MAC.LOCAL").equals("kdc.mac.local:88")) {
throw new Exception("KDC error");
}
}
示例11: initStatic
import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void initStatic() {
boolean allowed = false;
try {
Config cfg = Config.getInstance();
allowed = cfg.getBooleanObject("libdefaults", "allow_weak_crypto")
== Boolean.TRUE;
} catch (Exception exc) {
if (DEBUG) {
System.out.println ("Exception in getting allow_weak_crypto, " +
"using default value " +
exc.getMessage());
}
}
allowWeakCrypto = allowed;
}
示例12: 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", ".") +"/k1.conf");
Config config = Config.getInstance();
config.listTable();
String s;
// root section merged
s = config.get("libdefaults", "default_realm");
if (!s.equals("R1")) {
throw new Exception();
}
// Former is preferred to latter for strings and sections
s = config.get("libdefaults", "default_tkt_enctypes");
if (!s.equals("aes128-cts")) {
throw new Exception();
}
s = config.get("realms", "R1", "kdc");
if (!s.equals("k1")) {
throw new Exception(s);
}
// Duplicate keys in [realms] are merged, and sections with the same
// name in between ignored
s = config.getAll("realms", "R2", "kdc");
if (!s.equals("k1 k2 k3 k4")) {
throw new Exception(s);
}
// Duplicate keys in [capaths] are merged
s = config.getAll("capaths", "R1", "R2");
if (!s.equals("R3 R4 R5 R6")) {
throw new Exception(s);
}
// We can be very deep now
s = config.get("new", "x", "y", "z", "a", "b", "c");
if (!s.equals("d")) {
throw new Exception(s);
}
}
示例13: 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");
}
示例14: 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", ".") +"/nothing.conf");
Config config = Config.getInstance();
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 + "]");
};
}
示例15: 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", ".") +"/krb5.conf");
Config config = Config.getInstance();
config.listTable();
String sample = "kdc.example.com kdc2.example.com";
for ( int i = 0; i < 4; i++ ) {
String expected = config.getAll("realms", "EXAMPLE_" + i + ".COM", "kdc");
if (!sample.equals(expected)) {
throw new Exception("krb5.conf: unexpected kdc value \"" +
expected + "\"");
}
}
}