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


Java Config类代码示例

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


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

示例1: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:KrbCredSubKey.java

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

示例3: getDefaultSkew

import sun.security.krb5.Config; //导入依赖的package包/类
public static int getDefaultSkew() {
    int tdiff = Krb5.DEFAULT_ALLOWABLE_CLOCKSKEW;
    try {
        if ((tdiff = Config.getInstance().getIntValue(
                "libdefaults", "clockskew"))
                    == 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:KerberosTime.java

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

示例5: 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:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CksumType.java

示例6: 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:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:EType.java

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

示例8: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:NewSalt.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", ".") +"/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

示例10: main

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

        useDNS_Realm = Config.class.getDeclaredMethod("useDNS_Realm");
        useDNS_Realm.setAccessible(true);
        useDNS_KDC = Config.class.getDeclaredMethod("useDNS_KDC");
        useDNS_KDC.setAccessible(true);


        // for 6673164
        check("true", "true", true, true);
        check("false", "true", false, false);
        check("true", "false", true, true);
        check("false", "false", false, false);
        check("true", null, true, true);
        check("false", null, false, false);
        check(null, "true", true, true);
        check(null, "false", false, false);

        // for 6552334, no longer true
        //check(null, null, true, true);

        // 8077102
        check(null, null, false, true);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DnsFallback.java

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

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

示例13: main

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

        OneKDC kdc = new OneKDC(null);

        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "ticket_lifetime = 10s",
                "renew_lifetime = 11s");
        Config.refresh();

        KerberosTicket ticket = Context
                .fromUserPass(OneKDC.USER, OneKDC.PASS, false).s()
                .getPrivateCredentials(KerberosTicket.class).iterator().next();

        System.out.println(ticket);
        Asserts.assertTrue(ticket.getRenewTill() != null, ticket.toString());

        Thread.sleep(2000);

        ticket.refresh();
        System.out.println(ticket);
        Asserts.assertTrue(ticket.getRenewTill() == null, ticket.toString());

        Thread.sleep(2000);
        ticket.refresh();
        System.out.println(ticket);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:NullRenewUntil.java

示例14: 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(Locale.US),
            OneKDC.PASS, true);
    Context c2 = Context.fromUserPass(OneKDC.USER2.toUpperCase(Locale.US),
            OneKDC.PASS2, true);

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

    Context.handshake(c1, c2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:NewSalt.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", ".") +"/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


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