Path: blob/master/test/jdk/sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.sh
41153 views
#! /bin/sh12#3# Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425#2627# set a few environment variables so that the shell-script can run stand-alone28# in the source directory29if [ "${TESTSRC}" = "" ] ; then30TESTSRC="."31fi3233if [ "${TESTCLASSES}" = "" ] ; then34TESTCLASSES="."35fi3637if [ "${TESTJAVA}" = "" ] ; then38echo "TESTJAVA not set. Test cannot execute."39echo "FAILED!!!"40exit 141fi4243if [ "${COMPILEJAVA}" = "" ]; then44COMPILEJAVA="${TESTJAVA}"45fi4647# set platform-dependent variables48OS=`uname -s`49case "$OS" in50Linux )51PATHSEP=":"52FILESEP="/"53;;54Windows* )55PATHSEP=";"56FILESEP="\\"57;;58* )59echo "Unrecognized system!"60exit 1;61;;62esac6364# compile the test program65cd ${TESTSRC}${FILESEP}66rm GrantAllPermToExtWhenNoPolicy.class67${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \68-d ${TESTSRC}${FILESEP} ${TESTSRC}${FILESEP}SomeExtensionClass.java69${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \70-d ${TESTSRC}${FILESEP} ${TESTSRC}${FILESEP}GrantAllPermToExtWhenNoPolicy.java7172# create the extension JAR file73cd ${TESTCLASSES}74${COMPILEJAVA}${FILESEP}bin${FILESEP}jar cvf SomeExt.jar SomeExtensionClass*.class75rm SomeExtensionClass.class7677# move the extension JAR file to the extension directory78mv SomeExt.jar ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext7980# remove the system policy file81mv \82${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}java.policy \83${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}tmp_pol8485# run the test program86${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} -Djava.security.manager \87GrantAllPermToExtWhenNoPolicy8889# save error status90status=$?9192# restore system policy and remove extension JAR file93mv ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}tmp_pol \94${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}java.policy95rm ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext${FILESEP}SomeExt.jar9697exit $status9899100