1#
2# Copyright (c) 2009, 2014, 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 6712755
26# @summary jarsigner fails to sign itextasian.jar since 1.5.0_b14, it works with 1.5.0_13
27#
28# @run shell emptymanifest.sh
29#
30
31if [ "${TESTJAVA}" = "" ] ; then
32  JAVAC_CMD=`which javac`
33  TESTJAVA=`dirname $JAVAC_CMD`/..
34fi
35
36# set platform-dependent variables
37OS=`uname -s`
38case "$OS" in
39  Windows_* )
40    FS="\\"
41    ;;
42  * )
43    FS="/"
44    ;;
45esac
46
47KS=emptymanifest.ks
48JFILE=em.jar
49
50KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
51JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
52JAVA="$TESTJAVA${FS}bin${FS}java ${TESTVMOPTS}"
53JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
54JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
55
56rm $KS $JFILE
57echo A > A
58echo B > B
59mkdir META-INF
60cat <<EOF > CrLf.java
61class CrLf {
62  public static void main(String[] args) throws Exception {
63    System.out.write(new byte[] {'\r', '\n'});
64  }
65}
66EOF
67$JAVAC CrLf.java
68$JAVA CrLf > META-INF${FS}MANIFEST.MF
69zip $JFILE META-INF${FS}MANIFEST.MF A B
70
71$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
72
73$JARSIGNER $JFILE a || exit 1
74$JARSIGNER -verify -debug -strict $JFILE || exit 2
75
76exit 0
77