5462
|
1 |
#
|
|
2 |
# Copyright 2010 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 6890876
|
|
26 |
# @summary jarsigner can add CRL info into signed jar
|
|
27 |
#
|
|
28 |
|
|
29 |
if [ "${TESTJAVA}" = "" ] ; then
|
|
30 |
JAVAC_CMD=`which javac`
|
|
31 |
TESTJAVA=`dirname $JAVAC_CMD`/..
|
|
32 |
fi
|
|
33 |
|
|
34 |
# set platform-dependent variables
|
|
35 |
# PF: platform name, say, solaris-sparc
|
|
36 |
|
|
37 |
PF=""
|
|
38 |
|
|
39 |
OS=`uname -s`
|
|
40 |
case "$OS" in
|
|
41 |
Windows* )
|
|
42 |
FS="\\"
|
|
43 |
;;
|
|
44 |
* )
|
|
45 |
FS="/"
|
|
46 |
;;
|
|
47 |
esac
|
|
48 |
|
|
49 |
KS=crl.jks
|
|
50 |
JFILE=crl.jar
|
|
51 |
|
|
52 |
KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
|
|
53 |
JAR=$TESTJAVA${FS}bin${FS}jar
|
|
54 |
JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
|
|
55 |
|
|
56 |
rm $KS $JFILE
|
|
57 |
|
|
58 |
# Generates some crl files, each containing two entries
|
|
59 |
|
|
60 |
$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
|
|
61 |
$KT -alias a -gencrl -id 1:1 -id 2:2 -file crl1
|
|
62 |
$KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
|
|
63 |
$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
|
|
64 |
$KT -alias b -gencrl -id 5:1 -id 6:2 -file crl3
|
|
65 |
|
|
66 |
$KT -alias c -dname CN=c -keyalg rsa -genkey -validity 300 \
|
|
67 |
-ext crl=uri:file://`pwd`/crl1
|
|
68 |
|
|
69 |
echo A > A
|
|
70 |
|
|
71 |
# Test -crl:auto, cRLDistributionPoints is a local file
|
|
72 |
|
|
73 |
$JAR cvf $JFILE A
|
|
74 |
$JARSIGNER -keystore $KS -storepass changeit $JFILE c \
|
|
75 |
-crl:auto || exit 1
|
|
76 |
$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 6
|
|
77 |
$KT -printcert -jarfile $JFILE | grep CRLs || exit 7
|
|
78 |
|
|
79 |
# Test -crl <file>
|
|
80 |
|
|
81 |
$JAR cvf $JFILE A
|
|
82 |
$JARSIGNER -keystore $KS -storepass changeit $JFILE a \
|
|
83 |
-crl crl1 -crl crl2 || exit 1
|
|
84 |
$JARSIGNER -keystore $KS -storepass changeit $JFILE b \
|
|
85 |
-crl crl3 -crl crl2 || exit 1
|
|
86 |
$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
|
|
87 |
$KT -printcert -jarfile $JFILE | grep CRLs || exit 4
|
|
88 |
CRLCOUNT=`$KT -printcert -jarfile $JFILE | grep SerialNumber | wc -l`
|
|
89 |
if [ $CRLCOUNT != 8 ]; then exit 5; fi
|
|
90 |
|
|
91 |
exit 0
|