1 # 2 # Copyright (c) 2003, 2018, 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 4938185 26 # @library /test/lib 27 # @summary KeyStore support for NSS cert/key databases 28 # 29 # @run shell Basic.sh 30 31 # To run by hand: 32 # %sh Basic.sh <recompile> [yes|no] 33 # <token> [activcard|ibutton|nss|sca1000] 34 # <command> [list|basic] 35 # 36 # %sh Basic.sh no ibutton list 37 # 38 # Note: 39 # . 'list' lists the token aliases 40 # . 'basic' does not run with activcard, 41 # and tests different things depending on what is supported by each token 42 43 # set a few environment variables so that the shell-script can run stand-alone 44 # in the source directory 45 46 # if running by hand on windows, change TESTSRC and TESTCLASSES to "." 47 if [ "${TESTSRC}" = "" ] ; then 48 TESTSRC=`pwd` 49 fi 50 if [ "${TESTCLASSES}" = "" ] ; then 51 TESTCLASSES=`pwd` 52 fi 53 54 # if running by hand on windows, change this to appropriate value 55 if [ "${TESTJAVA}" = "" ] ; then 56 TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc" 57 fi 58 if [ "${COMPILEJAVA}" = "" ]; then 59 COMPILEJAVA="${TESTJAVA}" 60 fi 61 echo TESTSRC=${TESTSRC} 62 echo TESTCLASSES=${TESTCLASSES} 63 echo TESTJAVA=${TESTJAVA} 64 echo COMPILEJAVA=${COMPILEJAVA} 65 echo CPAPPEND=${CPAPPEND} 66 echo "" 67 68 # get command from input args - 69 # default to 'nss basic' 70 71 RECOMPILE="yes" 72 if [ $# = '3' ] ; then 73 RECOMPILE=$1 74 TOKEN=$2 75 TEST=$3 76 elif [ $# = '2' ] ; then 77 TOKEN=$1 78 TEST=$2 79 else 80 TOKEN="nss" 81 TEST="basic" 82 fi 83 84 DEBUG=sunpkcs11,pkcs11keystore 85 86 echo RECOMPILE=${RECOMPILE} 87 echo TOKEN=${TOKEN} 88 echo TEST=${TEST} 89 echo DEBUG=${DEBUG} 90 echo "" 91 92 OS=`uname -s` 93 case "$OS" in 94 Linux ) 95 ARCH=`uname -m` 96 case "$ARCH" in 97 i[3-6]86 ) 98 FS="/" 99 PS=":" 100 CP="${FS}bin${FS}cp" 101 CHMOD="${FS}bin${FS}chmod" 102 ;; 103 * ) 104 # ia64 ) 105 # x86_64 ) 106 echo "Unsupported System: Linux ${ARCH}" 107 exit 0; 108 ;; 109 esac 110 ;; 111 Windows* ) 112 FS="\\" 113 PS=";" 114 CP="cp" 115 CHMOD="chmod" 116 117 # 'uname -m' does not give us enough information - 118 # should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk), 119 # but JTREG does not pass this env variable when executing a shell script. 120 # 121 # execute test program - rely on it to exit if platform unsupported 122 123 ;; 124 * ) 125 echo "Unsupported System: ${OS}" 126 exit 0; 127 ;; 128 esac 129 130 # first make cert/key DBs writable if token is NSS 131 132 if [ "${TOKEN}" = "nss" ] ; then 133 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES} 134 ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db 135 136 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES} 137 ${CHMOD} +w ${TESTCLASSES}${FS}key3.db 138 fi 139 140 # compile test 141 142 if [ "${RECOMPILE}" = "yes" ] ; then 143 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ 144 -classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \ 145 -d ${TESTCLASSES} \ 146 ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jdk${FS}test${FS}lib${FS}artifacts${FS}*.java \ 147 ${TESTSRC}${FS}Basic.java \ 148 ${TESTSRC}${FS}..${FS}PKCS11Test.java 149 fi 150 151 # run test 152 153 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 154 -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar${PS}${CPAPPEND} \ 155 -DDIR=${TESTSRC}${FS}BasicData \ 156 -DCUSTOM_DB_DIR=${TESTCLASSES} \ 157 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${TOKEN}.txt \ 158 -DNO_DEFAULT=true \ 159 -DNO_DEIMOS=true \ 160 -DTOKEN=${TOKEN} \ 161 -DTEST=${TEST} \ 162 -Dtest.src=${TESTSRC} \ 163 -Dtest.classes=${TESTCLASSES} \ 164 -Djava.security.debug=${DEBUG} \ 165 Basic sm Basic.policy 166 167 # save error status 168 status=$? 169 170 # return 171 exit $status