DnsFallback.java revision 2362
1545N/A/*
4596N/A * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
1545N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1545N/A *
1545N/A * This code is free software; you can redistribute it and/or modify it
1545N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation.
1545N/A *
2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1545N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1545N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1545N/A * version 2 for more details (a copy is included in the LICENSE file that
1545N/A * accompanied this code).
1545N/A *
1545N/A * You should have received a copy of the GNU General Public License version
1545N/A * 2 along with this work; if not, write to the Free Software Foundation,
1545N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1545N/A *
1545N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1545N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A */
2362N/A/*
1545N/A * @test
1545N/A * @bug 6673164
1545N/A * @bug 6552334
1674N/A * @summary fix dns_fallback parse error, and use dns by default
1545N/A */
1545N/A
1545N/Aimport sun.security.krb5.*;
1545N/Aimport java.io.*;
1545N/A
1545N/Apublic class DnsFallback {
1545N/A public static void main(String[] args) throws Exception {
1545N/A
1545N/A // for 6673164
1545N/A check("true", "true", true);
1545N/A check("false", "true", false);
1545N/A check("true", "false", true);
1545N/A check("false", "false", false);
1545N/A check("true", null, true);
1545N/A check("false", null, false);
1545N/A check(null, "true", true);
1545N/A check(null, "false", false);
1545N/A
1545N/A // for 6552334
1545N/A check(null, null, true);
1545N/A }
1545N/A
1545N/A static void check(String realm, String fallback, boolean output) throws Exception {
1545N/A FileOutputStream fo = new FileOutputStream("dnsfallback.conf");
1545N/A StringBuffer sb = new StringBuffer();
1545N/A sb.append("[libdefaults]\n");
1545N/A if (realm != null) {
1545N/A sb.append("dns_lookup_realm=" + realm + "\n");
1545N/A }
1545N/A if (fallback != null) {
1545N/A sb.append("dns_fallback=" + fallback + "\n");
1545N/A }
1545N/A fo.write(sb.toString().getBytes());
1545N/A fo.close();
1545N/A System.setProperty("java.security.krb5.conf", "dnsfallback.conf");
1545N/A Config.refresh();
1545N/A System.out.println("Testing " + realm + ", " + fallback + ", " + output);
1545N/A if (Config.getInstance().useDNS_Realm() != output) {
1545N/A throw new Exception("Fail");
1545N/A }
1545N/A }
1545N/A}
1545N/A
1545N/A