1 # 2 # Copyright (c) 2007, 2010, 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 6543842 6543440 6939248 8009636 8024302 26 # @summary checking response of timestamp 27 # 28 # @run shell/timeout=600 ts.sh 29 30 # Run for a long time because jarsigner with timestamp needs to create a 31 # 64-bit random number and it might be extremely slow on a machine with 32 # not enough entropy pool 33 34 # set platform-dependent variables 35 OS=`uname -s` 36 case "$OS" in 37 Windows_* ) 38 FS="\\" 39 ;; 40 * ) 41 FS="/" 42 ;; 43 esac 44 45 if [ "${TESTSRC}" = "" ] ; then 46 TESTSRC="." 47 fi 48 if [ "${TESTJAVA}" = "" ] ; then 49 JAVAC_CMD=`which javac` 50 TESTJAVA=`dirname $JAVAC_CMD`/.. 51 fi 52 53 JAR="${TESTJAVA}${FS}bin${FS}jar" 54 JAVA="${TESTJAVA}${FS}bin${FS}java" 55 JAVAC="${TESTJAVA}${FS}bin${FS}javac" 56 KT="${TESTJAVA}${FS}bin${FS}keytool -keystore tsks -storepass changeit -keypass changeit -keyalg rsa -validity 200" 57 58 rm tsks 59 echo Nothing > A 60 rm old.jar 61 $JAR cvf old.jar A 62 63 # ca is CA 64 # old is signer for code 65 # ts is signer for timestamp 66 # tsbad1 has no extendedKeyUsage 67 # tsbad2's extendedKeyUsage is non-critical 68 # tsbad3's extendedKeyUsage has no timestamping 69 70 $KT -alias ca -genkeypair -ext bc -dname CN=CA 71 $KT -alias old -genkeypair -dname CN=old 72 $KT -alias ts -genkeypair -dname CN=ts 73 $KT -alias tsbad1 -genkeypair -dname CN=tsbad1 74 $KT -alias tsbad2 -genkeypair -dname CN=tsbad2 75 $KT -alias tsbad3 -genkeypair -dname CN=tsbad3 76 $KT -alias ts -certreq | \ 77 $KT -alias ca -gencert -ext eku:critical=ts | \ 78 $KT -alias ts -importcert 79 $KT -alias tsbad1 -certreq | \ 80 $KT -alias ca -gencert | \ 81 $KT -alias tsbad1 -importcert 82 $KT -alias tsbad2 -certreq | \ 83 $KT -alias ca -gencert -ext eku=ts | \ 84 $KT -alias tsbad2 -importcert 85 $KT -alias tsbad3 -certreq | \ 86 $KT -alias ca -gencert -ext eku:critical=cs | \ 87 $KT -alias tsbad3 -importcert 88 89 $JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/TimestampCheck.java 90 $JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} TimestampCheck 91