equal
deleted
inserted
replaced
38 import java.security.cert.X509Certificate; |
38 import java.security.cert.X509Certificate; |
39 import java.util.Calendar; |
39 import java.util.Calendar; |
40 import java.util.jar.JarEntry; |
40 import java.util.jar.JarEntry; |
41 import java.util.jar.JarFile; |
41 import java.util.jar.JarFile; |
42 |
42 |
43 import sun.misc.IOUtils; |
|
44 import sun.security.pkcs.ContentInfo; |
43 import sun.security.pkcs.ContentInfo; |
45 import sun.security.pkcs.PKCS7; |
44 import sun.security.pkcs.PKCS7; |
46 import sun.security.pkcs.PKCS9Attribute; |
45 import sun.security.pkcs.PKCS9Attribute; |
47 import sun.security.pkcs.SignerInfo; |
46 import sun.security.pkcs.SignerInfo; |
48 import sun.security.timestamp.TimestampToken; |
47 import sun.security.timestamp.TimestampToken; |
341 static void checkTimestamp(String file, String policyId, String digestAlg) |
340 static void checkTimestamp(String file, String policyId, String digestAlg) |
342 throws Exception { |
341 throws Exception { |
343 try (JarFile jf = new JarFile(file)) { |
342 try (JarFile jf = new JarFile(file)) { |
344 JarEntry je = jf.getJarEntry("META-INF/OLD.RSA"); |
343 JarEntry je = jf.getJarEntry("META-INF/OLD.RSA"); |
345 try (InputStream is = jf.getInputStream(je)) { |
344 try (InputStream is = jf.getInputStream(je)) { |
346 byte[] content = IOUtils.readFully(is, -1, true); |
345 byte[] content = is.readAllBytes(); |
347 PKCS7 p7 = new PKCS7(content); |
346 PKCS7 p7 = new PKCS7(content); |
348 SignerInfo[] si = p7.getSignerInfos(); |
347 SignerInfo[] si = p7.getSignerInfos(); |
349 if (si == null || si.length == 0) { |
348 if (si == null || si.length == 0) { |
350 throw new Exception("Not signed"); |
349 throw new Exception("Not signed"); |
351 } |
350 } |