当前位置: 首页>>代码示例>>Java>>正文


Java Config.getInstance方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:YesNo.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:CksumType.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:EType.java

示例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 + "]");
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:DNS.java

示例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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ParseConfig.java

示例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);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:20,代码来源:CksumType.java

示例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;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:19,代码来源:KerberosTime.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:EType.java

示例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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:39,代码来源:Duplicates.java

示例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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:ConfigWithQuotations.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:EType.java

示例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);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:39,代码来源:Duplicates.java

示例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");
}
 
开发者ID:kakao,项目名称:hbase-tools,代码行数:36,代码来源:HBaseClient.java

示例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 + "]");
    };
}
 
开发者ID:frohoff,项目名称:jdk8u-dev-jdk,代码行数:11,代码来源:DNS.java

示例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 + "\"");
        }
    }
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:15,代码来源:ParseConfig.java


注:本文中的sun.security.krb5.Config.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。