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 6948909 26 # @summary Jarsigner removes MANIFEST.MF info for badly packages jar's 27 # 28 29 if [ "${TESTSRC}" = "" ] ; then 30 TESTSRC="." 31 fi 32 if [ "${TESTCLASSES}" = "" ] ; then 33 TESTCLASSES="." 34 fi 35 if [ "${TESTJAVA}" = "" ] ; then 36 echo "TESTJAVA not set. Test cannot execute." 37 echo "FAILED!!!" 38 exit 1 39 fi 40 41 # set platform-dependent variables 42 OS=`uname -s` 43 case "$OS" in 44 SunOS | Linux ) 45 NULL=/dev/null 46 PS=":" 47 FS="/" 48 CP="${FS}bin${FS}cp -f" 49 TMP=/tmp 50 ;; 51 CYGWIN* ) 52 NULL=/dev/null 53 PS=";" 54 FS="/" 55 CP="cp -f" 56 TMP=/tmp 57 ;; 58 Windows_* ) 59 NULL=NUL 60 PS=";" 61 FS="\\" 62 CP="cp -f" 63 TMP="c:/temp" 64 ;; 65 * ) 66 echo "Unrecognized operating system!" 67 exit 1; 68 ;; 69 esac 70 71 echo 1 > 1 72 mkdir META-INF 73 74 # Create a fake .RSA file so that jarsigner believes it's signed 75 76 touch META-INF/x.RSA 77 78 # A MANIFEST.MF using \n as newlines and no double newlines at the end 79 80 cat > META-INF/MANIFEST.MF <<EOF 81 Manifest-Version: 1.0 82 Created-By: 1.7.0-internal (Sun Microsystems Inc.) 83 Today: Monday 84 EOF 85 86 # With the fake .RSA file, to trigger the if (wasSigned) block 87 88 rm diffend.jar 89 zip diffend.jar META-INF/MANIFEST.MF META-INF/x.RSA 1 90 91 ${TESTJAVA}${FS}bin${FS}jarsigner \ 92 -keystore ${TESTSRC}${FS}JarSigning.keystore \ 93 -storepass bbbbbb \ 94 -digestalg SHA1 \ 95 -signedjar diffend.new.jar \ 96 diffend.jar c 97 98 unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 1 99 100 # Without the fake .RSA file, to trigger the else block 101 102 rm diffend.jar 103 zip diffend.jar META-INF/MANIFEST.MF 1 104 105 ${TESTJAVA}${FS}bin${FS}jarsigner \ 106 -keystore ${TESTSRC}${FS}JarSigning.keystore \ 107 -storepass bbbbbb \ 108 -digestalg SHA1 \ 109 -signedjar diffend.new.jar \ 110 diffend.jar c 111 112 unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 2 113