Path: blob/master/test/jdk/sun/security/tools/jarsigner/EmptyManifest.java
41152 views
/*1* Copyright (c) 2009, 2019, 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/*24* @test25* @bug 671275526* @summary jarsigner fails to sign itextasian.jar since 1.5.0_b14,27* it works with 1.5.0_1328* @library /test/lib29*/3031import jdk.test.lib.SecurityTools;3233import java.io.FileOutputStream;34import java.util.zip.ZipEntry;35import java.util.zip.ZipOutputStream;3637public class EmptyManifest {3839public static void main(String[] args) throws Exception {4041try (FileOutputStream fos = new FileOutputStream("em.jar");42ZipOutputStream zos = new ZipOutputStream(fos)) {43zos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));44zos.write(new byte[]{'\r', '\n'});45zos.putNextEntry(new ZipEntry("A"));46zos.write(new byte[10]);47zos.putNextEntry(new ZipEntry("B"));48zos.write(new byte[0]);49}5051SecurityTools.keytool("-keystore ks -storepass changeit "52+ "-keypass changeit -alias a -dname CN=a -keyalg rsa "53+ "-genkey -validity 300");5455SecurityTools.jarsigner("-keystore ks -storepass changeit em.jar a")56.shouldHaveExitValue(0);57SecurityTools.jarsigner("-keystore ks -storepass changeit -verify "58+ "-debug -strict em.jar")59.shouldHaveExitValue(0);60}61}626364