Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/tools/jarsigner/diffend.sh
38853 views
#1# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 694890925# @summary Jarsigner removes MANIFEST.MF info for badly packages jar's26#2728if [ "${TESTSRC}" = "" ] ; then29TESTSRC="."30fi31if [ "${TESTCLASSES}" = "" ] ; then32TESTCLASSES="."33fi34if [ "${TESTJAVA}" = "" ] ; then35echo "TESTJAVA not set. Test cannot execute."36echo "FAILED!!!"37exit 138fi3940# set platform-dependent variables41OS=`uname -s`42case "$OS" in43SunOS | Linux | Darwin | AIX )44NULL=/dev/null45PS=":"46FS="/"47CP="${FS}bin${FS}cp -f"48;;49CYGWIN* )50NULL=/dev/null51PS=";"52FS="/"53CP="cp -f"54;;55Windows_* )56NULL=NUL57PS=";"58FS="\\"59CP="cp -f"60;;61* )62echo "Unrecognized operating system!"63exit 1;64;;65esac6667echo 1 > 168mkdir META-INF6970# Create a fake .RSA file so that jarsigner believes it's signed7172touch META-INF/x.RSA7374# A MANIFEST.MF using \n as newlines and no double newlines at the end7576cat > META-INF/MANIFEST.MF <<EOF77Manifest-Version: 1.078Created-By: 1.7.0-internal (Sun Microsystems Inc.)79Today: Monday80EOF8182# With the fake .RSA file, to trigger the if (wasSigned) block8384rm diffend.jar85zip diffend.jar META-INF/MANIFEST.MF META-INF/x.RSA 18687${TESTJAVA}${FS}bin${FS}jarsigner \88-keystore ${TESTSRC}${FS}JarSigning.keystore \89-storepass bbbbbb \90-digestalg SHA1 \91-signedjar diffend.new.jar \92diffend.jar c9394unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 19596# Without the fake .RSA file, to trigger the else block9798rm diffend.jar99zip diffend.jar META-INF/MANIFEST.MF 1100101${TESTJAVA}${FS}bin${FS}jarsigner \102-keystore ${TESTSRC}${FS}JarSigning.keystore \103-storepass bbbbbb \104-digestalg SHA1 \105-signedjar diffend.new.jar \106diffend.jar c107108unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 2109110111112