1 #
   2 # Copyright (c) 2004, 2016, 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 4850423
  26 # @summary login facilities for hardware tokens
  27 #
  28 # @run shell Login.sh
  29 
  30 # set a few environment variables so that the shell-script can run stand-alone
  31 # in the source directory
  32 
  33 # if running by hand on windows, change TESTSRC and TESTCLASSES to "."
  34 if [ "${TESTSRC}" = "" ] ; then
  35     TESTSRC=`pwd`
  36 fi
  37 if [ "${TESTCLASSES}" = "" ] ; then
  38     TESTCLASSES=`pwd`
  39 fi
  40 
  41 # if running by hand on windows, change this to appropriate value
  42 if [ "${TESTJAVA}" = "" ] ; then
  43     TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc"
  44 fi
  45 if [ "${COMPILEJAVA}" = "" ]; then
  46     COMPILEJAVA="${TESTJAVA}"
  47 fi
  48 echo TESTSRC=${TESTSRC}
  49 echo TESTCLASSES=${TESTCLASSES}
  50 echo TESTJAVA=${TESTJAVA}
  51 echo COMPILEJAVA=${COMPILEJAVA}
  52 echo CPAPPEND=${CPAPPEND}
  53 echo ""
  54 
  55 # let java test exit if platform unsupported
  56 
  57 OS=`uname -s`
  58 case "$OS" in
  59   SunOS )
  60     FS="/"
  61     PS=":"
  62     CP="${FS}bin${FS}cp"
  63     CHMOD="${FS}bin${FS}chmod"
  64     ;;
  65   Linux )
  66     FS="/"
  67     PS=":"
  68     CP="${FS}bin${FS}cp"
  69     CHMOD="${FS}bin${FS}chmod"
  70     ;;
  71   Darwin )
  72     FS="/"
  73     PS=":"
  74     CP="${FS}bin${FS}cp"
  75     CHMOD="${FS}bin${FS}chmod"
  76     ;;
  77   AIX )
  78     FS="/"
  79     PS=":"
  80     CP="${FS}bin${FS}cp"
  81     CHMOD="${FS}bin${FS}chmod"
  82     ;;
  83   Windows* )
  84     FS="\\"
  85     PS=";"
  86     CP="cp"
  87     CHMOD="chmod"
  88     ;;
  89   CYGWIN* )
  90     FS="/"
  91     PS=";"
  92     CP="cp"
  93     CHMOD="chmod"
  94     #
  95     # javac does not like /cygdrive produced by `pwd`
  96     #
  97     TESTSRC=`cygpath -d ${TESTSRC}`
  98     ;;
  99   * )
 100     echo "Unrecognized system!"
 101     exit 1;
 102     ;;
 103 esac
 104 
 105 # first make cert/key DBs writable
 106 
 107 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES}
 108 ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db
 109 
 110 ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES}
 111 ${CHMOD} +w ${TESTCLASSES}${FS}key3.db
 112 
 113 # compile test
 114 
 115 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
 116         -classpath ${TESTSRC}${FS}.. \
 117         -d ${TESTCLASSES} \
 118         ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jdk${FS}test${FS}lib${FS}artifacts${FS}*.java \
 119         ${TESTSRC}${FS}Login.java \
 120         ${TESTSRC}${FS}..${FS}PKCS11Test.java
 121 
 122 # run test
 123 
 124 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
 125         -classpath ${TESTCLASSES}${PS}${CPAPPEND} \
 126         -DCUSTOM_DB_DIR=${TESTCLASSES} \
 127         -DCUSTOM_P11_CONFIG=${TESTSRC}${FS}Login-nss.txt \
 128         -DNO_DEFAULT=true \
 129         -DNO_DEIMOS=true \
 130         -Dtest.src=${TESTSRC} \
 131         -Dtest.classes=${TESTCLASSES} \
 132         -Djava.security.debug=${DEBUG} \
 133         Login sm Login.policy
 134 
 135 # save error status
 136 status=$?
 137 
 138 # return
 139 exit $status