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


Java Config.refresh方法代码示例

本文整理汇总了Java中sun.security.krb5.Config.refresh方法的典型用法代码示例。如果您正苦于以下问题:Java Config.refresh方法的具体用法?Java Config.refresh怎么用?Java Config.refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.security.krb5.Config的用法示例。


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

示例1: OneKDC

import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
 * Creates the KDC and starts it.
 * @param etype Encryption type, null if not specified
 * @throws java.lang.Exception if there's anything wrong
 */
public OneKDC(String etype) throws Exception {
    super(REALM, KDCHOST, 0, true);
    addPrincipal(USER, PASS);
    addPrincipal(USER2, PASS2);
    addPrincipalRandKey("krbtgt/" + REALM);
    addPrincipalRandKey(SERVER);
    addPrincipalRandKey(BACKEND);

    String extraConfig = "";
    if (etype != null) {
        extraConfig += "default_tkt_enctypes=" + etype
                + "\ndefault_tgs_enctypes=" + etype;
        if (etype.startsWith("des")) {
            extraConfig += "\nallow_weak_crypto = true";
        }
    }
    KDC.saveConfig(KRB5_CONF, this,
            "forwardable = true",
            "default_keytab_name = " + KTAB,
            extraConfig);
    System.setProperty("java.security.krb5.conf", KRB5_CONF);
    // Whatever krb5.conf had been loaded before, we reload ours now.
    Config.refresh();

    writeKtab(KTAB);
    Security.setProperty("auth.login.defaultCallbackHandler",
            "OneKDC$CallbackForClient");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:OneKDC.java

示例2: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Path base = Paths.get("krb5.conf");
    Path include = Paths.get("included.conf");
    String baseConf = "include " + include.toAbsolutePath().toString()
            + "\n[x]\na = b\n";
    String includeConf = "[y]\nc = d\n";
    Files.write(include, includeConf.getBytes());
    Files.write(base, baseConf.getBytes());

    System.setProperty("java.security.krb5.conf", base.toString());
    Config.refresh();

    if (!Objects.equals(Config.getInstance().get("x", "a"), "b")) {
        throw new Exception("Failed");
    }
}
 
开发者ID:frohoff,项目名称:jdk8u-dev-jdk,代码行数:17,代码来源:ExtraLines.java

示例3: checkLogin

import sun.security.krb5.Config; //导入方法依赖的package包/类
static void checkLogin(
        String s1,      // ticket_lifetime in krb5.conf, null if none
        String s2,      // renew_lifetime in krb5.conf, null if none
        int t1, int t2  // expected lifetimes, -1 of unexpected
            ) throws Exception {
    KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
            s1 != null ? ("ticket_lifetime = " + s1) : "",
            s2 != null ? ("renew_lifetime = " + s2) : "");
    Config.refresh();

    Context c;
    c = Context.fromJAAS("client");

    Set<KerberosTicket> tickets =
            c.s().getPrivateCredentials(KerberosTicket.class);
    if (tickets.size() != 1) {
        throw new Exception();
    }
    KerberosTicket ticket = tickets.iterator().next();

    checkRough(ticket.getEndTime(), t1);
    checkRough(ticket.getRenewTill(), t2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:Renewal.java

示例4: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        OneKDC kdc = new OneKDC(null);
        kdc.writeJAASConf();

        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "default_tkt_enctypes=des-cbc-md5",
                "default_tgs_enctypes=des-cbc-md5",
                "permitted_enctypes=des-cbc-md5");
        Config.refresh();

        try {
            Context.fromJAAS("client");
            throw new Exception("What?");
        } catch (LoginException le) {
            // This is OK
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:OnlyDesLogin.java

示例5: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        // We don't care about clock difference
        new FileOutputStream("krb5.conf").write(
                "[libdefaults]\nclockskew=999999999".getBytes());
        System.setProperty("java.security.krb5.conf", "krb5.conf");
        Config.refresh();

        Subject subj = new Subject();
        KerberosPrincipal kp = new KerberosPrincipal(princ);
        KerberosKey kk = new KerberosKey(
                kp, key, EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96, 0);
        subj.getPrincipals().add(kp);
        subj.getPrivateCredentials().add(kk);

        Subject.doAs(subj, new PrivilegedExceptionAction() {
            public Object run() throws Exception {
                GSSManager man = GSSManager.getInstance();
                GSSContext ctxt = man.createContext(man.createCredential(
                        null, GSSCredential.INDEFINITE_LIFETIME,
                        GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY));
                return ctxt.acceptSecContext(token, 0, token.length);
            }
        });
    }
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:KrbCredSubKey.java

示例6: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args)
        throws Exception {

    // Create and start the KDC
    KDC kdc = new OneKDC(null);
    if (System.getProperty("onlyonepreauth") != null) {
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "default_tgs_enctypes=des3-cbc-sha1");
        Config.refresh();
        kdc.setOption(KDC.Option.ONLY_ONE_PREAUTH, true);
    }
    if (System.getProperty("nopreauth") != null) {
        kdc.setOption(KDC.Option.PREAUTH_REQUIRED, false);
    }

    // Use a different case of name. KDC will return correct salt
    Context c1 = Context.fromUserPass(OneKDC.USER.toUpperCase(),
            OneKDC.PASS, true);
    Context c2 = Context.fromUserPass(OneKDC.USER2.toUpperCase(),
            OneKDC.PASS2, true);

    c1.startAsClient(OneKDC.USER2, GSSUtil.GSS_KRB5_MECH_OID);
    c2.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);

    Context.handshake(c1, c2);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:NewSalt.java

示例7: OneKDC

import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
 * Creates the KDC and starts it.
 * @param etype Encryption type, null if not specified
 * @throws java.lang.Exception if there's anything wrong
 */
public OneKDC(String etype) throws Exception {
    super(REALM, KDCHOST, 0, true);
    addPrincipal(USER, PASS);
    addPrincipal(USER2, PASS2);
    addPrincipalRandKey("krbtgt/" + REALM);
    addPrincipalRandKey(SERVER);
    addPrincipalRandKey(BACKEND);
    KDC.saveConfig(KRB5_CONF, this,
            "forwardable = true",
            "default_keytab_name = " + KTAB,
            etype == null ? "" : "default_tkt_enctypes=" + etype + "\ndefault_tgs_enctypes=" + etype);
    System.setProperty("java.security.krb5.conf", KRB5_CONF);
    // Whatever krb5.conf had been loaded before, we reload ours now.
    Config.refresh();

    writeKtab(KTAB);
    new File(KRB5_CONF).deleteOnExit();
    new File(KTAB).deleteOnExit();
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:25,代码来源:OneKDC.java

示例8: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:W83.java

示例9: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args)
        throws Exception {

    System.setProperty("sun.security.krb5.debug", "true");

    OneKDC kdc = new OneKDC(null);
    kdc.writeJAASConf();

    // Two styles of kdc_timeout setting. One global, one realm-specific.
    if (args[0].equals("UDP")) {
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "kdc_timeout = 10s");
    } else {
        kdc.addConf("kdc_timeout = 10s");
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "udp_preference_limit = 1");
    }
    Config.refresh();

    ByteArrayOutputStream bo = new ByteArrayOutputStream();
    PrintStream oldout = System.out;
    System.setOut(new PrintStream(bo));
    Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
    System.setOut(oldout);

    for (String line: new String(bo.toByteArray()).split("\n")) {
        if (line.contains(">>> KDCCommunication")) {
            if (!line.contains(args[0]) || !line.contains("timeout=10000")) {
                throw new Exception("No " + args[0] + " in: " + line);
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:UdpTcp.java

示例10: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        OneKDC kdc = new OneKDC(null);
        kdc.writeJAASConf();

        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "default_keytab_name = " + OneKDC.KTAB,
                "allow_weak_crypto = true");
        Config.refresh();

        // Rewrite to include DES keys
        kdc.writeKtab(OneKDC.KTAB);

        // Different test cases, read KDC.processAsReq for details
        kdc.setOption(KDC.Option.DUP_ETYPE, Integer.parseInt(args[0]));

        Context c, s;
        c = Context.fromJAAS("client");
        s = Context.fromJAAS("server");

        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);

        Context.handshake(c, s);

        Context.transmit("i say high --", c, s);
        Context.transmit("   you say low", s, c);

        s.dispose();
        c.dispose();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DupEtypes.java

示例11: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    File f = new File(
            System.getProperty("test.src", "."), "unreachable.krb5.conf");
    System.setProperty("java.security.krb5.conf", f.getPath());
    Config.refresh();

    // If PortUnreachableException is not received, the login will consume
    // about 3*3*30 seconds and the test will timeout.
    try {
        Context.fromUserPass("name", "pass".toCharArray(), true);
    } catch (LoginException le) {
        // This is OK
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:Unreachable.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", ".") + "/kdc_default_options.conf");
    Config.refresh();
    KDCOptions options = new KDCOptions();
    if (!options.get(KDCOptions.FORWARDABLE) ||
            !options.get(KDCOptions.PROXIABLE) ||
            !options.get(KDCOptions.RENEWABLE_OK)) {
        throw new Exception(options.toString());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:KdcDefaultOptions.java

示例13: check

import sun.security.krb5.Config; //导入方法依赖的package包/类
/**
 * Sets and checks.
 *
 * @param u dns_lookup_XXX value set, none if null
 * @param f dns_fallback value set, none if null
 * @param r expected useDNS_Realm
 * @param k expected useDNS_KDC
 */
static void check(String u, String f, boolean r, boolean k)
        throws Exception {

    try (PrintStream ps =
            new PrintStream(new FileOutputStream("dnsfallback.conf"))) {
        ps.println("[libdefaults]\n");
        if (u != null) {
            ps.println("dns_lookup_realm=" + u);
            ps.println("dns_lookup_kdc=" + u);
        }
        if (f != null) {
            ps.println("dns_fallback=" + f);
        }
    }

    System.setProperty("java.security.krb5.conf", "dnsfallback.conf");
    Config.refresh();
    System.out.println("Testing " + u + ", " + f + ", " + r + ", " + k);

    if (!useDNS_Realm.invoke(Config.getInstance()).equals(r)) {
        throw new Exception("useDNS_Realm Fail");
    }

    if (!useDNS_KDC.invoke(Config.getInstance()).equals(k)) {
        throw new Exception("useDNS_KDC Fail");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:DnsFallback.java

示例14: main

import sun.security.krb5.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        OneKDC kdc = new OneKDC(null).writeJAASConf();

        // A lifetime 2d will make it renewable
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "ticket_lifetime = 2d");
        Config.refresh();

        Context.fromJAAS("client");
    }
 
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:LongLife.java

示例15: 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


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