1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 * @test |
25 * @test |
26 * @bug 8048357 |
26 * @bug 8048357 |
27 * @summary Read signed data in one or more PKCS7 objects from individual files, |
27 * @summary Read signed data in one or more PKCS7 objects from individual files, |
28 * verify SignerInfos and certificate chain. |
28 * verify SignerInfos and certificate chain. |
29 * @modules java.base/sun.security.pkcs |
29 * @modules java.base/sun.security.pkcs |
30 * @run main PKCS7VerifyTest PKCS7TEST.DSA.base64 |
30 * @run main/othervm PKCS7VerifyTest PKCS7TEST.DSA.base64 |
31 * @run main PKCS7VerifyTest PKCS7TEST.DSA.base64 PKCS7TEST.SF |
31 * @run main/othervm PKCS7VerifyTest PKCS7TEST.DSA.base64 PKCS7TEST.SF |
32 */ |
32 */ |
33 import java.io.ByteArrayInputStream; |
33 import java.io.ByteArrayInputStream; |
34 import java.io.File; |
34 import java.io.File; |
35 import java.io.FileInputStream; |
35 import java.io.FileInputStream; |
36 import java.nio.file.Files; |
36 import java.nio.file.Files; |
37 import java.nio.file.Path; |
37 import java.nio.file.Path; |
38 import java.nio.file.Paths; |
38 import java.nio.file.Paths; |
|
39 import java.security.Security; |
39 import java.security.cert.X509Certificate; |
40 import java.security.cert.X509Certificate; |
40 import java.util.Base64; |
41 import java.util.Base64; |
41 import java.util.HashMap; |
42 import java.util.HashMap; |
42 import java.util.Map; |
43 import java.util.Map; |
43 import sun.security.pkcs.PKCS7; |
44 import sun.security.pkcs.PKCS7; |
52 |
53 |
53 public static void main(String[] args) throws Exception { |
54 public static void main(String[] args) throws Exception { |
54 if (args.length == 0) { |
55 if (args.length == 0) { |
55 throw new RuntimeException("usage: java JarVerify <file1> <file2>"); |
56 throw new RuntimeException("usage: java JarVerify <file1> <file2>"); |
56 } |
57 } |
|
58 |
|
59 Security.setProperty("jdk.jar.disabledAlgorithms", ""); |
57 |
60 |
58 // The command " java PKCS7VerifyTest file1 [file2] " |
61 // The command " java PKCS7VerifyTest file1 [file2] " |
59 // treats file1 as containing the DER encoding of a PKCS7 signed data |
62 // treats file1 as containing the DER encoding of a PKCS7 signed data |
60 // object. If file2 is absent, the program verifies that some signature |
63 // object. If file2 is absent, the program verifies that some signature |
61 // (SignerInfo) file1 correctly signs the data contained in the |
64 // (SignerInfo) file1 correctly signs the data contained in the |