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 echo TESTSRC=${TESTSRC} 57 echo TESTCLASSES=${TESTCLASSES} 58 echo TESTJAVA=${TESTJAVA} 59 echo "" 60 61 # get command from input args - 62 # default to 'solaris basic' 63 64 RECOMPILE="yes" 65 if [ $# = '2' ] ; then 66 RECOMPILE=$1 67 TEST=$2 68 elif [ $# = '1' ] ; then 69 TEST=$1 70 else 71 TEST="basic" 72 fi 73 74 DEBUG=sunpkcs11,pkcs11keystore 75 76 echo RECOMPILE=${RECOMPILE} 77 echo TEST=${TEST} 78 echo DEBUG=${DEBUG} 79 echo "" 80 81 OS=`uname -s` 82 case "$OS" in 83 SunOS ) 84 FS="/" 85 PS=":" 86 SCCS="${FS}usr${FS}ccs${FS}bin${FS}sccs" 87 CP="${FS}bin${FS}cp -f" 88 RM="${FS}bin${FS}rm -rf" 89 MKDIR="${FS}bin${FS}mkdir -p" 90 CHMOD="${FS}bin${FS}chmod" 91 ;; 92 * ) 93 echo "Unsupported System ${OS} - Test only runs on Solaris 10" 94 exit 0; 95 ;; 96 esac 97 98 OS_VERSION=`uname -r` 99 case "$OS_VERSION" in 100 5.1* ) 101 SOFTTOKEN_DIR=${TESTCLASSES} 102 export SOFTTOKEN_DIR 103 ;; 104 * ) 105 echo "Unsupported Version ${OS_VERSION} - Test only runs on Solaris 10" 106 exit 0; 107 ;; 108 esac 109 110 # copy keystore into write-able location 111 112 echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" 113 114 echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 115 ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 116 117 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 118 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 119 120 echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 121 ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 122 123 echo ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 124 ${TESTCLASSES}${FS}pkcs11_softtoken 125 ${CP} ${TESTSRC}${FS}BasicData${FS}pkcs11_softtoken${FS}objstore_info \ 126 ${TESTCLASSES}${FS}pkcs11_softtoken 127 128 echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 129 ${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 130 131 # compile test 132 133 if [ "${RECOMPILE}" = "yes" ] ; then 134 cd ${TESTCLASSES} 135 ${RM} *.class 136 ${TESTJAVA}${FS}bin${FS}javac \ 137 -classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \ 138 -d ${TESTCLASSES} \ 139 ${TESTSRC}${FS}Basic.java 140 fi 141 142 # run test 143 144 cd ${TESTSRC} 145 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 146 -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \ 147 -DDIR=${TESTSRC}${FS}BasicData${FS} \ 148 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-solaris.txt \ 149 -DNO_DEFAULT=true \ 150 -DNO_DEIMOS=true \ 151 -DTOKEN=solaris \ 152 -DTEST=${TEST} \ 153 -Djava.security.manager \ 154 -Djava.security.policy=${TESTSRC}${FS}Basic.policy \ 155 -Djava.security.debug=${DEBUG} \ 156 Basic 157 158 # clean up 159 160 #${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 161 162 # return 163 164 exit $?