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 SunOS ) 95 ARCH=`isainfo` 96 case "$ARCH" in 97 sparc* ) 98 FS="/" 99 PS=":" 100 CP="${FS}bin${FS}cp" 101 CHMOD="${FS}bin${FS}chmod" 102 ;; 103 i[3-6]86 ) 104 FS="/" 105 PS=":" 106 CP="${FS}bin${FS}cp" 107 CHMOD="${FS}bin${FS}chmod" 108 ;; 109 amd64* ) 110 FS="/" 111 PS=":" 112 CP="${FS}bin${FS}cp" 113 CHMOD="${FS}bin${FS}chmod" 114 ;; 115 * ) 116 # ?itanium? ) 117 # amd64* ) 118 echo "Unsupported System: Solaris ${ARCH}" 119 exit 0; 120 ;; 121 esac 122 ;; 123 Linux ) 124 ARCH=`uname -m` 125 case "$ARCH" in 126 i[3-6]86 ) 127 FS="/" 128 PS=":" 129 CP="${FS}bin${FS}cp" 130 CHMOD="${FS}bin${FS}chmod" 131 ;; 132 * ) 133 # ia64 ) 134 # x86_64 ) 135 echo "Unsupported System: Linux ${ARCH}" 136 exit 0; 137 ;; 138 esac 139 ;; 140 Windows* ) 141 FS="\\" 142 PS=";" 143 CP="cp" 144 CHMOD="chmod" 145 146 # 'uname -m' does not give us enough information - 147 # should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk), 148 # but JTREG does not pass this env variable when executing a shell script. 149 # 150 # execute test program - rely on it to exit if platform unsupported 151 152 ;; 153 * ) 154 echo "Unsupported System: ${OS}" 155 exit 0; 156 ;; 157 esac 158 159 # first make cert/key DBs writable if token is NSS 160 161 if [ "${TOKEN}" = "nss" ] ; then 162 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES} 163 ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db 164 165 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES} 166 ${CHMOD} +w ${TESTCLASSES}${FS}key3.db 167 fi 168 169 # compile test 170 171 if [ "${RECOMPILE}" = "yes" ] ; then 172 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ 173 -classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \ 174 -d ${TESTCLASSES} \ 175 ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jdk${FS}test${FS}lib${FS}artifacts${FS}*.java \ 176 ${TESTSRC}${FS}Basic.java \ 177 ${TESTSRC}${FS}..${FS}PKCS11Test.java 178 fi 179 180 # run test 181 182 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 183 -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar${PS}${CPAPPEND} \ 184 -DDIR=${TESTSRC}${FS}BasicData \ 185 -DCUSTOM_DB_DIR=${TESTCLASSES} \ 186 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${TOKEN}.txt \ 187 -DNO_DEFAULT=true \ 188 -DNO_DEIMOS=true \ 189 -DTOKEN=${TOKEN} \ 190 -DTEST=${TEST} \ 191 -Dtest.src=${TESTSRC} \ 192 -Dtest.classes=${TESTCLASSES} \ 193 -Djava.security.debug=${DEBUG} \ 194 Basic sm Basic.policy 195 196 # save error status 197 status=$? 198 199 # return 200 exit $status