ClientAuth.sh revision 6383:7da291690aa0
1#
2# Copyright (c) 2003, 2012, 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 4938185 7106773
26# @summary KeyStore support for NSS cert/key databases
27#          512 bits RSA key cannot work with SHA384 and SHA512
28#
29# @run shell ClientAuth.sh
30
31# set a few environment variables so that the shell-script can run stand-alone
32# in the source directory
33
34if [ "${TESTSRC}" = "" ] ; then
35    TESTSRC=`pwd`
36fi
37if [ "${TESTCLASSES}" = "" ] ; then
38    TESTCLASSES=`pwd`
39fi
40if [ "${TESTJAVA}" = "" ] ; then
41    TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc"
42fi
43if [ "${COMPILEJAVA}" = "" ]; then
44  COMPILEJAVA="${TESTJAVA}"
45fi
46echo TESTSRC=${TESTSRC}
47echo TESTCLASSES=${TESTCLASSES}
48echo TESTJAVA=${TESTJAVA}
49echo COMPILEJAVA=${COMPILEJAVA}
50echo ""
51
52OS=`uname -s`
53case "$OS" in
54  SunOS )
55    ARCH=`isainfo`
56    case "$ARCH" in
57      sparc* )
58	FS="/"
59	PS=":"
60	CP="${FS}bin${FS}cp"
61	CHMOD="${FS}bin${FS}chmod"
62	;;
63      i[3-6]86 )
64	FS="/"
65	PS=":"
66	CP="${FS}bin${FS}cp"
67	CHMOD="${FS}bin${FS}chmod"
68	;;
69      amd64* )
70	FS="/"
71	PS=":"
72	CP="${FS}bin${FS}cp"
73	CHMOD="${FS}bin${FS}chmod"
74	;;
75      * )
76#     ?itanium? )
77#     amd64* )
78	echo "Unsupported System: Solaris ${ARCH}"
79	exit 0;
80	;;
81    esac
82    ;;
83  Linux )
84    ARCH=`uname -m`
85    case "$ARCH" in
86      i[3-6]86 )
87	FS="/"
88	PS=":"
89	CP="${FS}bin${FS}cp"
90	CHMOD="${FS}bin${FS}chmod"
91	;;
92      * )
93#     ia64 )
94#     x86_64 )
95	echo "Unsupported System: Linux ${ARCH}"
96	exit 0;
97	;;
98    esac
99    ;;
100  Windows* )
101    FS="\\"
102    PS=";"
103    CP="cp"
104    CHMOD="chmod"
105
106    # 'uname -m' does not give us enough information -
107    #  should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
108    #  but JTREG does not pass this env variable when executing a shell script.
109    #
110    #  execute test program - rely on it to exit if platform unsupported
111
112    ;;
113  * )
114    echo "Unsupported System: ${OS}"
115    exit 0;
116    ;;
117esac
118
119# first make cert/key DBs writable
120
121${CP} ${TESTSRC}${FS}ClientAuthData${FS}cert8.db ${TESTCLASSES}
122${CHMOD} +w ${TESTCLASSES}${FS}cert8.db
123
124${CP} ${TESTSRC}${FS}ClientAuthData${FS}key3.db ${TESTCLASSES}
125${CHMOD} +w ${TESTCLASSES}${FS}key3.db
126
127# compile test
128${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
129	-classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \
130	-d ${TESTCLASSES} \
131	${TESTSRC}${FS}ClientAuth.java
132
133# run test
134echo "Run ClientAuth ..."
135${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
136	-classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \
137	-DDIR=${TESTSRC}${FS}ClientAuthData${FS} \
138	-DCUSTOM_DB_DIR=${TESTCLASSES} \
139	-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}ClientAuthData${FS}p11-nss.txt \
140	-DNO_DEFAULT=true \
141	-DNO_DEIMOS=true \
142	-Dtest.src=${TESTSRC} \
143	-Dtest.classes=${TESTCLASSES} \
144	ClientAuth
145
146# save error status
147status=$?
148
149# return if failed
150if [ "${status}" != "0" ] ; then
151    exit $status
152fi
153
154# run test with specified TLS protocol and cipher suite
155echo "Run ClientAuth TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA"
156${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
157	-classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \
158	-DDIR=${TESTSRC}${FS}ClientAuthData${FS} \
159	-DCUSTOM_DB_DIR=${TESTCLASSES} \
160	-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}ClientAuthData${FS}p11-nss.txt \
161	-DNO_DEFAULT=true \
162	-DNO_DEIMOS=true \
163	-Dtest.src=${TESTSRC} \
164	-Dtest.classes=${TESTCLASSES} \
165	ClientAuth TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
166
167# save error status
168status=$?
169
170# return
171exit $status
172