2
|
1 |
#
|
|
2 |
# Copyright 2003-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
# have any 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 |
echo TESTSRC=${TESTSRC}
|
|
58 |
echo TESTCLASSES=${TESTCLASSES}
|
|
59 |
echo TESTJAVA=${TESTJAVA}
|
|
60 |
echo ""
|
|
61 |
|
|
62 |
# get command from input args -
|
|
63 |
# default to 'nss basic'
|
|
64 |
|
|
65 |
RECOMPILE="yes"
|
|
66 |
if [ $# = '3' ] ; then
|
|
67 |
RECOMPILE=$1
|
|
68 |
TOKEN=$2
|
|
69 |
TEST=$3
|
|
70 |
elif [ $# = '2' ] ; then
|
|
71 |
TOKEN=$1
|
|
72 |
TEST=$2
|
|
73 |
else
|
|
74 |
TOKEN="nss"
|
|
75 |
TEST="basic"
|
|
76 |
fi
|
|
77 |
|
|
78 |
DEBUG=sunpkcs11,pkcs11keystore
|
|
79 |
|
|
80 |
echo RECOMPILE=${RECOMPILE}
|
|
81 |
echo TOKEN=${TOKEN}
|
|
82 |
echo TEST=${TEST}
|
|
83 |
echo DEBUG=${DEBUG}
|
|
84 |
echo ""
|
|
85 |
|
|
86 |
OS=`uname -s`
|
|
87 |
case "$OS" in
|
|
88 |
SunOS )
|
|
89 |
ARCH=`isainfo`
|
|
90 |
case "$ARCH" in
|
|
91 |
sparc* )
|
|
92 |
FS="/"
|
|
93 |
PS=":"
|
|
94 |
CP="${FS}bin${FS}cp"
|
|
95 |
CHMOD="${FS}bin${FS}chmod"
|
|
96 |
;;
|
|
97 |
i[3-6]86 )
|
|
98 |
FS="/"
|
|
99 |
PS=":"
|
|
100 |
CP="${FS}bin${FS}cp"
|
|
101 |
CHMOD="${FS}bin${FS}chmod"
|
|
102 |
;;
|
|
103 |
amd64* )
|
|
104 |
FS="/"
|
|
105 |
PS=":"
|
|
106 |
CP="${FS}bin${FS}cp"
|
|
107 |
CHMOD="${FS}bin${FS}chmod"
|
|
108 |
;;
|
|
109 |
* )
|
|
110 |
# ?itanium? )
|
|
111 |
# amd64* )
|
|
112 |
echo "Unsupported System: Solaris ${ARCH}"
|
|
113 |
exit 0;
|
|
114 |
;;
|
|
115 |
esac
|
|
116 |
;;
|
|
117 |
Linux )
|
|
118 |
ARCH=`uname -m`
|
|
119 |
case "$ARCH" in
|
|
120 |
i[3-6]86 )
|
|
121 |
FS="/"
|
|
122 |
PS=":"
|
|
123 |
CP="${FS}bin${FS}cp"
|
|
124 |
CHMOD="${FS}bin${FS}chmod"
|
|
125 |
;;
|
|
126 |
* )
|
|
127 |
# ia64 )
|
|
128 |
# x86_64 )
|
|
129 |
echo "Unsupported System: Linux ${ARCH}"
|
|
130 |
exit 0;
|
|
131 |
;;
|
|
132 |
esac
|
|
133 |
;;
|
|
134 |
Windows* )
|
|
135 |
FS="\\"
|
|
136 |
PS=";"
|
|
137 |
CP="cp"
|
|
138 |
CHMOD="chmod"
|
|
139 |
|
|
140 |
# 'uname -m' does not give us enough information -
|
|
141 |
# should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
|
|
142 |
# but JTREG does not pass this env variable when executing a shell script.
|
|
143 |
#
|
|
144 |
# execute test program - rely on it to exit if platform unsupported
|
|
145 |
|
|
146 |
;;
|
|
147 |
* )
|
|
148 |
echo "Unsupported System: ${OS}"
|
|
149 |
exit 0;
|
|
150 |
;;
|
|
151 |
esac
|
|
152 |
|
|
153 |
# first make cert/key DBs writable if token is NSS
|
|
154 |
|
|
155 |
if [ "${TOKEN}" = "nss" ] ; then
|
|
156 |
${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES}
|
|
157 |
${CHMOD} +w ${TESTCLASSES}${FS}cert8.db
|
|
158 |
|
|
159 |
${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES}
|
|
160 |
${CHMOD} +w ${TESTCLASSES}${FS}key3.db
|
|
161 |
fi
|
|
162 |
|
|
163 |
# compile test
|
|
164 |
|
|
165 |
if [ "${RECOMPILE}" = "yes" ] ; then
|
|
166 |
${TESTJAVA}${FS}bin${FS}javac \
|
|
167 |
-classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \
|
|
168 |
-d ${TESTCLASSES} \
|
|
169 |
${TESTSRC}${FS}Basic.java
|
|
170 |
fi
|
|
171 |
|
|
172 |
# run test
|
|
173 |
|
|
174 |
${TESTJAVA}${FS}bin${FS}java \
|
|
175 |
-classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \
|
|
176 |
-DDIR=${TESTSRC}${FS}BasicData \
|
|
177 |
-DCUSTOM_DB_DIR=${TESTCLASSES} \
|
|
178 |
-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${TOKEN}.txt \
|
|
179 |
-DNO_DEFAULT=true \
|
|
180 |
-DNO_DEIMOS=true \
|
|
181 |
-DTOKEN=${TOKEN} \
|
|
182 |
-DTEST=${TEST} \
|
|
183 |
-Dtest.src=${TESTSRC} \
|
|
184 |
-Dtest.classes=${TESTCLASSES} \
|
|
185 |
-Djava.security.manager \
|
|
186 |
-Djava.security.policy=${TESTSRC}${FS}Basic.policy \
|
|
187 |
-Djava.security.debug=${DEBUG} \
|
|
188 |
Basic
|
|
189 |
|
|
190 |
# save error status
|
|
191 |
status=$?
|
|
192 |
|
|
193 |
# return
|
|
194 |
exit $status
|