Path: blob/master/test/jdk/com/sun/security/auth/login/ConfigFile/PropertyExpansion.java
51749 views
/*1* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 433776926* @summary ConfigFile should support system property expansion27* @run main/othervm/policy=PropertyExpansion.policy -Djava.security.auth.login.config==file:${test.src}/PropertyExpansion.config PropertyExpansion28*/2930import com.sun.security.auth.login.*;31import javax.security.auth.login.*;3233public class PropertyExpansion {3435public static void main(String[] args) {3637try {38ConfigFile config = new ConfigFile();39throw new IllegalStateException("test 1 failed");40} catch (SecurityException se) {41// good42se.printStackTrace();43}4445Configuration config = null;46try {47config = Configuration.getConfiguration();48} catch (SecurityException se) {49System.out.println("test 2 failed");50throw se;51}5253AppConfigurationEntry[] entries =54config.getAppConfigurationEntry("PropertyExpansion");5556// there are 2 entries57if (entries.length != 2)58throw new IllegalStateException("test 2 failed");5960for (int i = 0; i < 2; i++) {61System.out.println("module " + i + " = " +62entries[i].getLoginModuleName());63System.out.println("control flag " + i + " = " +64entries[i].getControlFlag());65java.util.Map map = entries[i].getOptions();66System.out.println("option " + i + " = useFile, " +67"value = " + map.get("useFile"));68System.out.println("option " + i + " = debug, " +69"value = " + map.get("debug"));7071if (i == 0 && map.get("useFile") == null ||72i == 0 && map.get("debug") != null) {73throw new IllegalStateException("test 3 failed");74}75if (i == 1 && map.get("useFile") != null ||76i == 1 && map.get("debug") == null) {77throw new IllegalStateException("test 4 failed");78}79}8081System.out.println("test succeeded");8283}84}858687