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 File: KerberosTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 File: NewSalt.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 #3
Source File: DnsFallback.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { useDNS_Realm = Config.class.getDeclaredMethod("useDNS_Realm"); useDNS_Realm.setAccessible(true); // for 6673164 check("true", "true", true); check("false", "true", false); check("true", "false", true); check("false", "false", false); check("true", null, true); check("false", null, false); check(null, "true", true); check(null, "false", false); // for 6552334 check(null, null, true); }
Example #4
Source File: KerberosTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 File: CksumType.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 #6
Source File: NewSalt.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: KerberosTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: OnlyDesLogin.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: DnsFallback.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 File: ExtraLines.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 File: KrbCredSubKey.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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 #12
Source File: EType.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 #13
Source File: KrbCredSubKey.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 File: NewSalt.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 File: KrbCredSubKey.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 File: OnlyDesLogin.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #17
Source File: KrbCredSubKey.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 File: KerberosTime.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #19
Source File: DnsFallback.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 #20
Source File: DnsFallback.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 #21
Source File: ParseConfig.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #22
Source File: NewSalt.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 #23
Source File: ExtraLines.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 File: DnsFallback.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #25
Source File: NewSalt.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 File: DNS.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #27
Source File: ExtraLines.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 #28
Source File: OnlyDesLogin.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #29
Source File: OnlyDesLogin.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 #30
Source File: NewSalt.java From hottub with GNU General Public License v2.0 | 6 votes |
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); }