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