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