ExpansionErrorMisleading.java revision 0
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste/*
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste *
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * This code is free software; you can redistribute it and/or modify it
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * under the terms of the GNU General Public License version 2 only, as
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * published by the Free Software Foundation.
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste *
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * This code is distributed in the hope that it will be useful, but WITHOUT
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * version 2 for more details (a copy is included in the LICENSE file that
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * accompanied this code).
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts *
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * You should have received a copy of the GNU General Public License version
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * 2 along with this work; if not, write to the Free Software Foundation,
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts *
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * CA 95054 USA or visit www.sun.com if you need additional information or
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * have any questions.
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts */
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts/*
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * @test
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * @bug 4308389
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * @summary Misleading (non-useful) error message while parsing
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * security policy file if property expansion fails
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * for an undefined property
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts *
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * This test needs to be verified by reading the debug output.
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * It should output that the PolicyParser could not expand
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * the system property, "undefined".
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts *
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts * @run main/othervm/policy=ExpansionErrorMisleading.policy -Djava.security.debug=parser ExpansionErrorMisleading
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts */
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpottspublic class ExpansionErrorMisleading {
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts public static void main(String[] args) {
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts // trigger a security check
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts try {
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts java.io.FileInputStream fis = new java.io.FileInputStream
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts ("/tmp/hello");
7197110fbdb6deb7868581c455516161cbcf7e0fJaco Jooste } catch (java.io.FileNotFoundException fnfe) {
7197110fbdb6deb7868581c455516161cbcf7e0fJaco Jooste // bad
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts System.out.println("Test Failed");
7197110fbdb6deb7868581c455516161cbcf7e0fJaco Jooste throw new SecurityException(fnfe.getMessage());
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts } catch (SecurityException se) {
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts // good
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts System.out.println("Test Succeeded");
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts }
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts }
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts}
ca7a323358dc50374d5f281355842fb7edb3983eJames Phillpotts