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