93
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
|
93
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5506
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
93
|
22 |
*/
|
|
23 |
/*
|
|
24 |
* @test
|
|
25 |
* @bug 6673164
|
1946
|
26 |
* @bug 6552334
|
|
27 |
* @summary fix dns_fallback parse error, and use dns by default
|
93
|
28 |
*/
|
|
29 |
|
|
30 |
import sun.security.krb5.*;
|
|
31 |
import java.io.*;
|
|
32 |
|
|
33 |
public class DnsFallback {
|
|
34 |
public static void main(String[] args) throws Exception {
|
1946
|
35 |
|
|
36 |
// for 6673164
|
93
|
37 |
check("true", "true", true);
|
|
38 |
check("false", "true", false);
|
|
39 |
check("true", "false", true);
|
|
40 |
check("false", "false", false);
|
|
41 |
check("true", null, true);
|
|
42 |
check("false", null, false);
|
|
43 |
check(null, "true", true);
|
|
44 |
check(null, "false", false);
|
1946
|
45 |
|
|
46 |
// for 6552334
|
|
47 |
check(null, null, true);
|
93
|
48 |
}
|
|
49 |
|
|
50 |
static void check(String realm, String fallback, boolean output) throws Exception {
|
|
51 |
FileOutputStream fo = new FileOutputStream("dnsfallback.conf");
|
|
52 |
StringBuffer sb = new StringBuffer();
|
|
53 |
sb.append("[libdefaults]\n");
|
|
54 |
if (realm != null) {
|
|
55 |
sb.append("dns_lookup_realm=" + realm + "\n");
|
|
56 |
}
|
|
57 |
if (fallback != null) {
|
|
58 |
sb.append("dns_fallback=" + fallback + "\n");
|
|
59 |
}
|
|
60 |
fo.write(sb.toString().getBytes());
|
|
61 |
fo.close();
|
|
62 |
System.setProperty("java.security.krb5.conf", "dnsfallback.conf");
|
|
63 |
Config.refresh();
|
|
64 |
System.out.println("Testing " + realm + ", " + fallback + ", " + output);
|
|
65 |
if (Config.getInstance().useDNS_Realm() != output) {
|
|
66 |
throw new Exception("Fail");
|
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|