1 # 2 # Copyright (c) 2004, 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 5038659 26 # @library /test/lib 27 # @summary Enable PKCS#11 KeyStore for SunPKCS11-Solaris 28 # 29 # @run shell Solaris.sh 30 31 # To run by hand: 32 # %sh Solaris.sh <recompile> [yes|no] 33 # <command> [list|basic] 34 # 35 # %sh Solaris.sh no list 36 # 37 # Note: 38 # . test only runs on solaris at the moment 39 # . 'list' lists the token aliases 40 # . 'basic' tests different things 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 COMPILEJAVA=${COMPILEJAVA} 64 echo "" 65 66 # get command from input args - 67 # default to 'solaris basic' 68 69 RECOMPILE="yes" 70 if [ $# = '2' ] ; then 71 RECOMPILE=$1 72 TEST=$2 73 elif [ $# = '1' ] ; then 74 TEST=$1 75 else 76 TEST="basic" 77 fi 78 79 DEBUG=sunpkcs11,pkcs11keystore 80 81 echo RECOMPILE=${RECOMPILE} 82 echo TEST=${TEST} 83 echo DEBUG=${DEBUG} 84 echo "" 85 86 OS=`uname -s` 87 case "$OS" in 88 SunOS ) 89 FS="/" 90 PS=":" 91 SCCS="${FS}usr${FS}ccs${FS}bin${FS}sccs" 92 CP="${FS}bin${FS}cp -f" 93 RM="${FS}bin${FS}rm -rf" 94 MKDIR="${FS}bin${FS}mkdir -p" 95 CHMOD="${FS}bin${FS}chmod" 96 ;; 97 * ) 98 echo "Unsupported System ${OS} - Test only runs on Solaris 10" 99 exit 0; 100 ;; 101 esac 102 103 OS_VERSION=`uname -r` 104 case "$OS_VERSION" in 105 5.1* ) 106 SOFTTOKEN_DIR=${TESTCLASSES} 107 export SOFTTOKEN_DIR 108 ;; 109 * ) 110 echo "Unsupported Version ${OS_VERSION} - Test only runs on Solaris 10" 111 exit 0; 112 ;; 113 esac 114 115 # copy keystore into write-able location 116 117 echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" 118 119 echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 120 ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 121 122 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 123 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 124 125 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 126 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 127 128 echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 129 ${TESTCLASSES}${FS}pkcs11_softtoken 130 ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 131 ${TESTCLASSES}${FS}pkcs11_softtoken 132 133 echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 134 ${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 135 136 # compile test 137 138 if [ "${RECOMPILE}" = "yes" ] ; then 139 cd ${TESTCLASSES} 140 ${RM} *.class 141 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ 142 -classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \ 143 -d ${TESTCLASSES} \ 144 ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jdk${FS}test${FS}lib${FS}artifacts${FS}*.java \ 145 ${TESTSRC}${FS}Basic.java \ 146 ${TESTSRC}${FS}..${FS}PKCS11Test.java 147 fi 148 149 # run test 150 151 cd ${TESTSRC} 152 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 153 -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar${PS}${CPAPPEND} \ 154 -DDIR=${TESTSRC}${FS}BasicData${FS} \ 155 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-solaris.txt \ 156 -DNO_DEFAULT=true \ 157 -DNO_DEIMOS=true \ 158 -DTOKEN=solaris \ 159 -DTEST=${TEST} \ 160 -Djava.security.debug=${DEBUG} \ 161 Basic sm Basic.policy 162 163 # clean up 164 165 #${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 166 167 # return 168 169 exit $?