safeprops.js revision 746:79c69831674f
117683Spst/*
217683Spst * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
317683Spst * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
417683Spst *
517683Spst * This code is free software; you can redistribute it and/or modify it
617683Spst * under the terms of the GNU General Public License version 2 only, as
717683Spst * published by the Free Software Foundation.
817683Spst *
917683Spst * This code is distributed in the hope that it will be useful, but WITHOUT
1017683Spst * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1117683Spst * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1217683Spst * version 2 for more details (a copy is included in the LICENSE file that
1317683Spst * accompanied this code).
1417683Spst *
1517683Spst * You should have received a copy of the GNU General Public License version
1617683Spst * 2 along with this work; if not, write to the Free Software Foundation,
1717683Spst * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1817683Spst *
1917683Spst * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2017683Spst * or visit www.oracle.com if you need additional information or have any
2117683Spst * questions.
2217683Spst */
23127664Sbms
24214518Srpaulo/**
2517683Spst * Try to access System properties safe to read for any code.
2617683Spst * No security exception expected.
2775107Sfenner *
2875107Sfenner * @test
2975107Sfenner * @security
3075107Sfenner * @run
31214518Srpaulo * @bug 8033924: Default permissions are not given for eval code
32214518Srpaulo */
33214518Srpaulo
34214518Srpaulovar propNames = [
35214518Srpaulo   "java.version",
36214518Srpaulo   "java.vendor",
37214518Srpaulo   "java.vendor.url",
38214518Srpaulo   "java.class.version",
39214518Srpaulo   "os.name",
40214518Srpaulo   "os.version",
41214518Srpaulo   "os.arch",
4217683Spst   "file.separator",
43214518Srpaulo   "path.separator",
4417683Spst   "line.separator",
4517683Spst   "java.specification.version",
4617683Spst   "java.specification.vendor",
4717683Spst   "java.specification.name",
4817683Spst   "java.vm.specification.version",
4917683Spst   "java.vm.specification.vendor",
5017683Spst   "java.vm.specification.name",
5117683Spst   "java.vm.version",
52190225Srpaulo   "java.vm.vendor",
5317683Spst   "java.vm.name"
5417683Spst];
5517683Spst
5617683Spst// no security exception expected
5717683Spstfor (var p in propNames) {
5817683Spst    java.lang.System.getProperty(propNames[p]);
5917683Spst}
6017683Spst
6117683Spst// no security exception expected
6217683Spstfor (var p in propNames) {
6317683Spst    var name = propNames[p];
6417683Spst    eval('java.lang.System.getProperty(name)');
6517683Spst}
6617683Spst