SecretKeysBasic.sh revision 6073:cea72c2bf071
1# 2# Copyright (c) 2008, 2012, 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 .. 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 "." 42if [ "${TESTSRC}" = "" ] ; then 43 TESTSRC=`pwd` 44fi 45if [ "${TESTCLASSES}" = "" ] ; then 46 TESTCLASSES=`pwd` 47fi 48if [ "${TESTJAVA}" = "" ] ; then 49 JAVAC_CMD=`which javac` 50 TESTJAVA=`dirname $JAVAC_CMD`/.. 51fi 52echo TESTSRC=${TESTSRC} 53echo TESTCLASSES=${TESTCLASSES} 54echo TESTJAVA=${TESTJAVA} 55echo "" 56 57#DEBUG=sunpkcs11,pkcs11keystore 58 59echo DEBUG=${DEBUG} 60echo "" 61 62OS=`uname -s` 63case "$OS" in 64 SunOS ) 65 FS="/" 66 PS=":" 67 OS_VERSION=`uname -r` 68 case "${OS_VERSION}" in 69 5.1* ) 70 SOFTTOKEN_DIR=${TESTCLASSES} 71 export SOFTTOKEN_DIR 72 TOKENS="nss solaris" 73 ;; 74 * ) 75 # SunPKCS11-Solaris Test only runs on Solaris 5.10 and later 76 TOKENS="nss" 77 ;; 78 esac 79 ;; 80 Windows_* ) 81 FS="\\" 82 PS=";" 83 TOKENS="nss" 84 ;; 85 CYGWIN* ) 86 FS="/" 87 PS=";" 88 TOKENS="nss" 89 ;; 90 * ) 91 FS="/" 92 PS=":" 93 TOKENS="nss" 94 ;; 95esac 96 97CP="cp -f" 98RM="rm -rf" 99MKDIR="mkdir -p" 100CHMOD="chmod" 101 102 103STATUS=0 104for token in ${TOKENS} 105do 106 107if [ ${token} = "nss" ] 108then 109 # make cert/key DBs writable if token is NSS 110 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES} 111 ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db 112 113 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES} 114 ${CHMOD} +w ${TESTCLASSES}${FS}key3.db 115 USED_FILE_LIST="${TESTCLASSES}${FS}cert8.db ${TESTCLASSES}${FS}key3.db" 116elif [ ${token} = "solaris" ] 117then 118 # copy keystore into write-able location 119 if [ -d ${TESTCLASSES}${FS}pkcs11_softtoken ] 120 then 121 echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" 122 123 echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 124 ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 125 fi 126 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 127 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 128 129 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 130 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 131 132 echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 133 ${TESTCLASSES}${FS}pkcs11_softtoken 134 ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 135 ${TESTCLASSES}${FS}pkcs11_softtoken 136 137 echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 138 ${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 139 USED_FILE_LIST="${TESTCLASSES}${FS}pkcs11_softtoken" 140fi 141 142# run test 143cd ${TESTSRC} 144${TESTJAVA}${FS}bin${FS}java \ 145 -DDIR=${TESTSRC}${FS}BasicData${FS} \ 146 -classpath ${TESTCLASSES}${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} \ 153 SecretKeysBasic 154 155# -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${token}.txt \ 156 157# save error status 158if [ $? != 0 ] 159then 160 echo "Test against " ${token} " Failed!" 161 STATUS=1 162fi 163 164# clean up 165${RM} ${USED_FILE_LIST} 166 167done 168 169# return 170exit ${STATUS} 171