Path: blob/master/test/jdk/sun/security/tools/jarsigner/JvIndex.java
41152 views
/*1* Copyright (c) 2013, 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 802276126* @summary regression: SecurityException is NOT thrown while trying27* to pack a wrongly signed Indexed Jar file28* @library /test/lib29*/3031import jdk.test.lib.SecurityTools;32import jdk.test.lib.util.JarUtils;3334import java.nio.file.Files;35import java.nio.file.Path;36import java.util.List;3738public class JvIndex {39public static void main(String[] args) throws Exception {4041Files.write(Path.of("abcde"), List.of("12345"));42JarUtils.createJarFile(Path.of("jvindex.jar"), Path.of("."),43Path.of("abcde"));44SecurityTools.keytool("-storepass changeit -keypass changeit "45+ "-keystore ks -keyalg rsa -alias a -dname CN=a "46+ "-genkey -validity 300")47.shouldHaveExitValue(0);48SecurityTools.jarsigner("-keystore ks -storepass changeit jvindex.jar a")49.shouldHaveExitValue(0);5051SecurityTools.jar("i jvindex.jar");5253// Make sure the $F line has "sm" (signed and in manifest)54SecurityTools.jarsigner("-keystore ks -storepass changeit -verify "55+ "-verbose jvindex.jar")56.shouldHaveExitValue(0)57.shouldMatch("sm.*abcde");58}59}606162