Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/pkcs11/KeyStore/SecretKeysBasic.sh
38855 views
#1# Copyright (c) 2008, 2013, 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# @test24# @bug 659997925# @summary Ensure that re-assigning the alias works26#27# @library ..28# @build SecretKeysBasic29# @run shell SecretKeysBasic.sh30#31# To run by hand:32# %sh SecretKeysBasic.sh33#34# Note:35# . test only runs on solaris at the moment3637# set a few environment variables so that the shell-script can run stand-alone38# in the source directory3940# if running by hand on windows, change TESTSRC and TESTCLASSES to "."41if [ "${TESTSRC}" = "" ] ; then42TESTSRC=`pwd`43fi44if [ "${TESTCLASSES}" = "" ] ; then45TESTCLASSES=`pwd`46fi47if [ "${TESTJAVA}" = "" ] ; then48JAVAC_CMD=`which javac`49TESTJAVA=`dirname $JAVAC_CMD`/..50fi51echo TESTSRC=${TESTSRC}52echo TESTCLASSES=${TESTCLASSES}53echo TESTJAVA=${TESTJAVA}54echo ""5556#DEBUG=sunpkcs11,pkcs11keystore5758echo DEBUG=${DEBUG}59echo ""6061OS=`uname -s`62case "$OS" in63SunOS )64FS="/"65PS=":"66OS_VERSION=`uname -r`67case "${OS_VERSION}" in685.1* )69SOFTTOKEN_DIR=${TESTCLASSES}70export SOFTTOKEN_DIR71TOKENS="nss solaris"72;;73* )74# SunPKCS11-Solaris Test only runs on Solaris 5.10 and later75TOKENS="nss"76;;77esac78;;79Windows_* )80FS="\\"81PS=";"82TOKENS="nss"83;;84CYGWIN* )85FS="/"86PS=";"87TOKENS="nss"88;;89* )90FS="/"91PS=":"92TOKENS="nss"93;;94esac9596CP="cp -f"97RM="rm -rf"98MKDIR="mkdir -p"99CHMOD="chmod"100101102STATUS=0103for token in ${TOKENS}104do105106if [ ${token} = "nss" ]107then108# make cert/key DBs writable if token is NSS109${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES}110${CHMOD} +w ${TESTCLASSES}${FS}cert8.db111112${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES}113${CHMOD} +w ${TESTCLASSES}${FS}key3.db114USED_FILE_LIST="${TESTCLASSES}${FS}cert8.db ${TESTCLASSES}${FS}key3.db"115elif [ ${token} = "solaris" ]116then117# copy keystore into write-able location118if [ -d ${TESTCLASSES}${FS}pkcs11_softtoken ]119then120echo "Removing old pkcs11_keystore, creating new pkcs11_keystore"121122echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken123${RM} ${TESTCLASSES}${FS}pkcs11_softtoken124fi125echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private126${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private127128echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public129${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public130131echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \132${TESTCLASSES}${FS}pkcs11_softtoken133${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \134${TESTCLASSES}${FS}pkcs11_softtoken135136echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info137${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info138USED_FILE_LIST="${TESTCLASSES}${FS}pkcs11_softtoken"139fi140141# run test142cd ${TESTSRC}143${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \144-DDIR=${TESTSRC}${FS}BasicData${FS} \145-classpath \146${TESTCLASSES}${PS}${TESTCLASSES}${FS}..${PS}${TESTSRC}${FS}loader.jar \147-DCUSTOM_DB_DIR=${TESTCLASSES} \148-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \149-DNO_DEFAULT=true \150-DNO_DEIMOS=true \151-DTOKEN=${token} \152-Djava.security.debug=${DEBUG} \153SecretKeysBasic154155# -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \156157# save error status158if [ $? != 0 ]159then160echo "Test against " ${token} " Failed!"161STATUS=1162fi163164# clean up165${RM} ${USED_FILE_LIST}166167done168169# return170exit ${STATUS}171172173