1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   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  *
  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.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8029995
  27  * @summary accept yes/no for boolean krb5.conf settings
  28  * @modules java.security.jgss/sun.security.krb5
  29  *          java.security.jgss/sun.security.krb5.internal.crypto
  30  * @compile -XDignore.symbol.file YesNo.java
  31  * @run main/othervm YesNo
  32  */
  33 import sun.security.krb5.Config;
  34 import sun.security.krb5.internal.crypto.EType;
  35 
  36 import java.util.Arrays;
  37 
  38 public class YesNo {
  39     static Config config = null;
  40     public static void main(String[] args) throws Exception {
  41         System.setProperty("java.security.krb5.conf",
  42                 System.getProperty("test.src", ".") +"/yesno.conf");
  43         config = Config.getInstance();
  44         check("a", Boolean.TRUE);
  45         check("b", Boolean.FALSE);
  46         check("c", Boolean.TRUE);
  47         check("d", Boolean.FALSE);
  48         check("e", null);
  49         check("f", null);
  50 
  51         if (!Arrays.stream(EType.getBuiltInDefaults())
  52                 .anyMatch(n -> n < 4)) {
  53             throw new Exception();
  54         }
  55     }
  56 
  57     static void check(String k, Boolean expected) throws Exception {
  58         Boolean result = config.getBooleanObject("libdefaults", k);
  59         if (expected != result) {
  60             throw new Exception("value for " + k + " is " + result);
  61         }
  62     }
  63 }