jdk/test/sun/security/tools/jarsigner/onlymanifest.sh
author weijun
Fri, 25 Apr 2014 10:57:09 +0800
changeset 24116 9f9b4ba34aad
parent 23010 6dadb192ad81
child 34382 5d11306d6969
permissions -rw-r--r--
8040321: keytool and jarsigner tests doesn't pass though VM tools to tools Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7524
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     1
#
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21342
diff changeset
     2
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
7524
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     4
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     7
# published by the Free Software Foundation.
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     8
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    13
# accompanied this code).
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    14
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    18
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    21
# questions.
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    22
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    23
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    24
# @test
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    25
# @bug 7004035
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    26
# @summary signed jar with only META-INF/* inside is not verifiable
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    27
#
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    28
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    29
if [ "${TESTJAVA}" = "" ] ; then
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    30
  JAVAC_CMD=`which javac`
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    31
  TESTJAVA=`dirname $JAVAC_CMD`/..
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    32
fi
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    33
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    34
# set platform-dependent variables
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    35
OS=`uname -s`
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    36
case "$OS" in
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    37
  Windows_* )
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    38
    FS="\\"
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    39
    ;;
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    40
  * )
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    41
    FS="/"
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    42
    ;;
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    43
esac
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    44
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    45
KS=onlymanifest.jks
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    46
JFILE=onlymanifest.jar
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    47
24116
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    48
KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
21342
7bbb056a1c23 8027026: Change keytool -genkeypair to use -keyalg RSA
weijun
parents: 7524
diff changeset
    49
        -keystore $KS -keyalg rsa"
24116
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    50
JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
9f9b4ba34aad 8040321: keytool and jarsigner tests doesn't pass though VM tools to tools
weijun
parents: 23010
diff changeset
    51
JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
7524
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    52
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    53
rm $KS $JFILE 2> /dev/null
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    54
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    55
# Create an empty jar file with only MANIFEST.MF
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    56
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    57
echo "Key: Value" > manifest
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    58
$JAR cvfm $JFILE manifest
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    59
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    60
$KT -alias a -dname CN=a -genkey -validity 300 || exit 1
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    61
$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 2
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    62
$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE a -debug -strict \
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    63
        > onlymanifest.out || exit 3
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    64
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    65
grep unsigned onlymanifest.out && exit 4
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    66
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    67
exit 0
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents:
diff changeset
    68