sun.security.krb5.Config Java Examples

The following examples show how to use sun.security.krb5.Config. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: dragonwell8_jdk   Author: alibaba   File: KerberosTime.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source Project: openjdk-8-source   Author: keerath   File: KerberosTime.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #3
Source Project: dragonwell8_jdk   Author: alibaba   File: EType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: KerberosTime.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source Project: openjdk-8-source   Author: keerath   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source Project: dragonwell8_jdk   Author: alibaba   File: OnlyDesLogin.java    License: GNU General Public License v2.0 6 votes vote down vote up
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
        }
    }
 
Example #7
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #8
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: CksumType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DnsFallback.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #10
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ExtraLines.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #11
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: EType.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source Project: openjdk-8-source   Author: keerath   File: OnlyDesLogin.java    License: GNU General Public License v2.0 6 votes vote down vote up
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
        }
    }
 
Example #13
Source Project: jdk8u-jdk   Author: frohoff   File: KrbCredSubKey.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        });
    }
 
Example #14
Source Project: jdk8u60   Author: chenghanpeng   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: KrbCredSubKey.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        });
    }
 
Example #16
Source Project: jdk8u-dev-jdk   Author: frohoff   File: KerberosTime.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #17
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: KrbCredSubKey.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        });
    }
 
Example #18
Source Project: openjdk-8   Author: bpupadhyaya   File: DnsFallback.java    License: GNU General Public License v2.0 6 votes vote down vote up
static void check(String realm, String fallback, boolean output)
        throws Exception {

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

    System.setProperty("java.security.krb5.conf", "dnsfallback.conf");
    Config.refresh();
    System.out.println("Testing " + realm + ", " + fallback + ", " + output);

    if (!useDNS_Realm.invoke(Config.getInstance()).equals(output)) {
        throw new Exception("Fail");
    }
}
 
Example #19
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: DnsFallback.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #20
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ParseConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #21
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ExtraLines.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: DNS.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 + "]");
    };
}
 
Example #23
Source Project: jdk8u-dev-jdk   Author: frohoff   File: ExtraLines.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #24
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: OnlyDesLogin.java    License: GNU General Public License v2.0 6 votes vote down vote up
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
        }
    }
 
Example #25
Source Project: hottub   Author: dsrg-uoft   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #26
Source Project: openjdk-8   Author: bpupadhyaya   File: OnlyDesLogin.java    License: GNU General Public License v2.0 6 votes vote down vote up
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
        }
    }
 
Example #27
Source Project: openjdk-8   Author: bpupadhyaya   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #28
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: DnsFallback.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #29
Source Project: jdk8u-dev-jdk   Author: frohoff   File: NewSalt.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #30
Source Project: jdk8u60   Author: chenghanpeng   File: KerberosTime.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}