jdk/test/sun/security/tools/jarsigner/crl.sh
author weijun
Thu, 06 May 2010 13:42:52 +0800
changeset 5462 cb614e59f7f9
child 5506 202f599c92aa
permissions -rw-r--r--
6890876: jarsigner can add CRL info into signed jar Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5462
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     1
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     2
# Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     4
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     7
# published by the Free Software Foundation.
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     8
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    13
# accompanied this code).
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    14
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    18
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    19
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    20
# CA 95054 USA or visit www.sun.com if you need additional information or
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    21
# have any questions.
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    22
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    23
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    24
# @test
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    25
# @bug 6890876
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    26
# @summary jarsigner can add CRL info into signed jar
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    27
#
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    28
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    29
if [ "${TESTJAVA}" = "" ] ; then
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    30
  JAVAC_CMD=`which javac`
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    31
  TESTJAVA=`dirname $JAVAC_CMD`/..
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    32
fi
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    33
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    34
# set platform-dependent variables
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    35
# PF: platform name, say, solaris-sparc
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    36
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    37
PF=""
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    38
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    39
OS=`uname -s`
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    40
case "$OS" in
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    41
  Windows* )
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    42
    FS="\\"
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    43
    ;;
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    44
  * )
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    45
    FS="/"
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    46
    ;;
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    47
esac
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    48
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    49
KS=crl.jks
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    50
JFILE=crl.jar
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    51
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    52
KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    53
JAR=$TESTJAVA${FS}bin${FS}jar
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    54
JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    55
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    56
rm $KS $JFILE
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    57
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    58
# Generates some crl files, each containing two entries
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    59
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    60
$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    61
$KT -alias a -gencrl -id 1:1 -id 2:2 -file crl1
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    62
$KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    63
$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    64
$KT -alias b -gencrl -id 5:1 -id 6:2 -file crl3
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    65
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    66
$KT -alias c -dname CN=c -keyalg rsa -genkey -validity 300 \
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    67
    -ext crl=uri:file://`pwd`/crl1
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    68
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    69
echo A > A
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    70
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    71
# Test -crl:auto, cRLDistributionPoints is a local file
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    72
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    73
$JAR cvf $JFILE A
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    74
$JARSIGNER -keystore $KS -storepass changeit $JFILE c \
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    75
        -crl:auto || exit 1
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    76
$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 6
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    77
$KT -printcert -jarfile $JFILE | grep CRLs || exit 7
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    78
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    79
# Test -crl <file>
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    80
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    81
$JAR cvf $JFILE A
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    82
$JARSIGNER -keystore $KS -storepass changeit $JFILE a \
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    83
        -crl crl1 -crl crl2 || exit 1
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    84
$JARSIGNER -keystore $KS -storepass changeit $JFILE b \
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    85
        -crl crl3 -crl crl2 || exit 1
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    86
$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    87
$KT -printcert -jarfile $JFILE | grep CRLs || exit 4
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    88
CRLCOUNT=`$KT -printcert -jarfile $JFILE | grep SerialNumber | wc -l`
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    89
if [ $CRLCOUNT != 8 ]; then exit 5; fi
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    90
cb614e59f7f9 6890876: jarsigner can add CRL info into signed jar
weijun
parents:
diff changeset
    91
exit 0