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


Java SCDynamicStoreConfig类代码示例

本文整理汇总了Java中sun.security.krb5.SCDynamicStoreConfig的典型用法代码示例。如果您正苦于以下问题:Java SCDynamicStoreConfig类的具体用法?Java SCDynamicStoreConfig怎么用?Java SCDynamicStoreConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SCDynamicStoreConfig类属于sun.security.krb5包,在下文中一共展示了SCDynamicStoreConfig类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import sun.security.krb5.SCDynamicStoreConfig; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Reconstruct a typical SCDynamicConfig.getKerberosConfig() output
    Hashtable<String, Object> conf = new Hashtable<>();

    Hashtable<String, Object> libdefaults = new Hashtable<>();
    libdefaults.put("default_realm", "REALM.COM");
    conf.put("libdefaults", libdefaults);

    Hashtable<String, Object> realms = new Hashtable<>();
    Hashtable<String, Object> thisRealm = new Hashtable<>();
    realms.put("REALM.COM", thisRealm);
    thisRealm.put("kpasswd", hosts());
    thisRealm.put("kadmin", hosts());
    thisRealm.put("kdc", hosts());
    conf.put("realms", realms);

    Hashtable<String, Object> domain_realm = new Hashtable<>();
    domain_realm.put(".realm.com", "REALM.COM");
    domain_realm.put("realm.com", "REALM.COM");
    conf.put("domain_realm", domain_realm);

    System.out.println("SCDynamicConfig:\n");
    System.out.println(conf);

    // Simulate SCDynamicConfig.getConfig() output
    Method m = SCDynamicStoreConfig.class.getDeclaredMethod(
            "convertNativeConfig", Hashtable.class);
    m.setAccessible(true);
    conf = (Hashtable)m.invoke(null, conf);

    System.out.println("\nkrb5.conf:\n");
    System.out.println(conf);

    // Feed it into a Config object
    System.setProperty("java.security.krb5.conf", "not-a-file");
    Config cf = Config.getInstance();
    Field f = Config.class.getDeclaredField("stanzaTable");
    f.setAccessible(true);
    f.set(cf, conf);

    System.out.println("\nConfig:\n");
    System.out.println(cf);

    if (!cf.getDefaultRealm().equals("REALM.COM")) {
        throw new Exception();
    }
    if (!cf.getKDCList("REALM.COM").equals("127.0.0.1 127.0.0.2")) {
        throw new Exception();
    }
    if (!cf.get("domain_realm", ".realm.com").equals("REALM.COM")) {
        throw new Exception();
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:54,代码来源:SCDynamicConfigTest.java


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