Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.sh
38854 views
#! /bin/sh12#3# Copyright (c) 1999, 2003, 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" in50SunOS )51PATHSEP=":"52FILESEP="/"53;;54Linux )55PATHSEP=":"56FILESEP="/"57;;58Windows* )59PATHSEP=";"60FILESEP="\\"61;;62* )63echo "Unrecognized system!"64exit 1;65;;66esac6768# compile the test program69cd ${TESTSRC}${FILESEP}70rm GrantAllPermToExtWhenNoPolicy.class71${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \72-d ${TESTSRC}${FILESEP} ${TESTSRC}${FILESEP}SomeExtensionClass.java73${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \74-d ${TESTSRC}${FILESEP} ${TESTSRC}${FILESEP}GrantAllPermToExtWhenNoPolicy.java7576# create the extension JAR file77cd ${TESTCLASSES}78${COMPILEJAVA}${FILESEP}bin${FILESEP}jar cvf SomeExt.jar SomeExtensionClass*.class79rm SomeExtensionClass.class8081# move the extension JAR file to the extension directory82mv SomeExt.jar ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext8384# remove the system policy file85mv \86${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}java.policy \87${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}tmp_pol8889# run the test program90${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} -Djava.security.manager \91GrantAllPermToExtWhenNoPolicy9293# save error status94status=$?9596# restore system policy and remove extension JAR file97mv ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}tmp_pol \98${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}security${FILESEP}java.policy99rm ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext${FILESEP}SomeExt.jar100101exit $status102103104