1 # 2 # Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 24 # @test 25 # @bug 6599979 26 # @summary Ensure that re-assigning the alias works 27 # 28 # @library /test/lib .. 29 # @build SecretKeysBasic 30 # @run shell SecretKeysBasic.sh 31 # 32 # To run by hand: 33 # %sh SecretKeysBasic.sh 34 # 35 # Note: 36 # . test only runs on solaris at the moment 37 38 # set a few environment variables so that the shell-script can run stand-alone 39 # in the source directory 40 41 # if running by hand on windows, change TESTSRC and TESTCLASSES to "." 42 if [ "${TESTSRC}" = "" ] ; then 43 TESTSRC=`pwd` 44 fi 45 if [ "${TESTCLASSES}" = "" ] ; then 46 TESTCLASSES=`pwd` 47 fi 48 if [ "${TESTJAVA}" = "" ] ; then 49 JAVAC_CMD=`which javac` 50 TESTJAVA=`dirname $JAVAC_CMD`/.. 51 fi 52 echo TESTSRC=${TESTSRC} 53 echo TESTCLASSES=${TESTCLASSES} 54 echo TESTJAVA=${TESTJAVA} 55 echo CPAPPEND=${CPAPPEND} 56 echo "" 57 58 #DEBUG=sunpkcs11,pkcs11keystore 59 60 echo DEBUG=${DEBUG} 61 echo "" 62 63 OS=`uname -s` 64 case "$OS" in 65 Windows_* ) 66 FS="\\" 67 PS=";" 68 TOKENS="nss" 69 ;; 70 CYGWIN* ) 71 FS="/" 72 PS=";" 73 TOKENS="nss" 74 ;; 75 * ) 76 FS="/" 77 PS=":" 78 TOKENS="nss" 79 ;; 80 esac 81 82 CP="cp -f" 83 RM="rm -rf" 84 MKDIR="mkdir -p" 85 CHMOD="chmod" 86 87 88 STATUS=0 89 for token in ${TOKENS} 90 do 91 92 if [ ${token} = "nss" ] 93 then 94 # make cert/key DBs writable if token is NSS 95 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES} 96 ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db 97 98 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES} 99 ${CHMOD} +w ${TESTCLASSES}${FS}key3.db 100 USED_FILE_LIST="${TESTCLASSES}${FS}cert8.db ${TESTCLASSES}${FS}key3.db" 101 elif [ ${token} = "solaris" ] 102 then 103 # copy keystore into write-able location 104 if [ -d ${TESTCLASSES}${FS}pkcs11_softtoken ] 105 then 106 echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" 107 108 echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 109 ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 110 fi 111 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 112 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 113 114 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 115 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 116 117 echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 118 ${TESTCLASSES}${FS}pkcs11_softtoken 119 ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 120 ${TESTCLASSES}${FS}pkcs11_softtoken 121 122 echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 123 ${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 124 USED_FILE_LIST="${TESTCLASSES}${FS}pkcs11_softtoken" 125 fi 126 127 # run test 128 cd ${TESTSRC} 129 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 130 -DDIR=${TESTSRC}${FS}BasicData${FS} \ 131 -classpath \ 132 ${TESTCLASSES}${PS}${TESTCLASSES}${FS}..${PS}${TESTSRC}${FS}loader.jar${PS}${CPAPPEND} \ 133 -DCUSTOM_DB_DIR=${TESTCLASSES} \ 134 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \ 135 -DNO_DEFAULT=true \ 136 -DNO_DEIMOS=true \ 137 -DTOKEN=${token} \ 138 -Djava.security.debug=${DEBUG} \ 139 SecretKeysBasic 140 141 # -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \ 142 143 # save error status 144 if [ $? != 0 ] 145 then 146 echo "Test against " ${token} " Failed!" 147 STATUS=1 148 fi 149 150 # clean up 151 ${RM} ${USED_FILE_LIST} 152 153 done 154 155 # return 156 exit ${STATUS}