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