1# 2# Copyright (c) 2004, 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 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 "." 45if [ "${TESTSRC}" = "" ] ; then 46 TESTSRC=`pwd` 47fi 48if [ "${TESTCLASSES}" = "" ] ; then 49 TESTCLASSES=`pwd` 50fi 51 52# if running by hand on windows, change this to appropriate value 53if [ "${TESTJAVA}" = "" ] ; then 54 TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc" 55fi 56if [ "${COMPILEJAVA}" = "" ]; then 57 COMPILEJAVA="${TESTJAVA}" 58fi 59echo TESTSRC=${TESTSRC} 60echo TESTCLASSES=${TESTCLASSES} 61echo TESTJAVA=${TESTJAVA} 62echo COMPILEJAVA=${COMPILEJAVA} 63echo "" 64 65# get command from input args - 66# default to 'solaris basic' 67 68RECOMPILE="yes" 69if [ $# = '2' ] ; then 70 RECOMPILE=$1 71 TEST=$2 72elif [ $# = '1' ] ; then 73 TEST=$1 74else 75 TEST="basic" 76fi 77 78DEBUG=sunpkcs11,pkcs11keystore 79 80echo RECOMPILE=${RECOMPILE} 81echo TEST=${TEST} 82echo DEBUG=${DEBUG} 83echo "" 84 85OS=`uname -s` 86case "$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 ;; 100esac 101 102OS_VERSION=`uname -r` 103case "$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 ;; 112esac 113 114# copy keystore into write-able location 115 116echo "Removing old pkcs11_keystore, creating new pkcs11_keystore" 117 118echo ${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 119${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 120 121echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 122${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}private 123 124echo ${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 125${MKDIR} ${TESTCLASSES}${FS}pkcs11_softtoken${FS}public 126 127echo ${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 132echo ${CHMOD} +w ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 133${CHMOD} 600 ${TESTCLASSES}${FS}pkcs11_softtoken${FS}objstore_info 134 135# compile test 136 137if [ "${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 ${TESTSRC}${FS}..${FS}PKCS11Test.java 145fi 146 147# run test 148 149cd ${TESTSRC} 150${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ 151 -classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \ 152 -DDIR=${TESTSRC}${FS}BasicData${FS} \ 153 -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-solaris.txt \ 154 -DNO_DEFAULT=true \ 155 -DNO_DEIMOS=true \ 156 -DTOKEN=solaris \ 157 -DTEST=${TEST} \ 158 -Djava.security.debug=${DEBUG} \ 159 Basic sm Basic.policy 160 161# clean up 162 163#${RM} ${TESTCLASSES}${FS}pkcs11_softtoken 164 165# return 166 167exit $? 168