7197071: Makefiles for various security providers aren't including the default manifest
authorwetmore
Tue, 23 Oct 2012 12:36:47 -0700
changeset 14316 f7665c887b97
parent 14203 d74a31d40678
child 14317 1e855efb3783
7197071: Makefiles for various security providers aren't including the default manifest Reviewed-by: valeriep, mullan, katleman
jdk/make/com/oracle/security/ucrypto/Makefile
jdk/make/javax/crypto/Defs-jce.gmk
jdk/make/sun/security/ec/Makefile
jdk/make/sun/security/mscapi/Makefile
jdk/make/sun/security/pkcs11/Makefile
jdk/test/javax/crypto/sanity/CheckManifestForRelease.java
--- a/jdk/make/com/oracle/security/ucrypto/Makefile	Tue Oct 23 11:57:47 2012 +0100
+++ b/jdk/make/com/oracle/security/ucrypto/Makefile	Tue Oct 23 12:36:47 2012 -0700
@@ -198,9 +198,9 @@
   #
   # Build ucrypto.jar.
   #
-  $(UNSIGNED_DIR)/ucrypto.jar: build
+  $(UNSIGNED_DIR)/ucrypto.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/jdk/make/javax/crypto/Defs-jce.gmk	Tue Oct 23 11:57:47 2012 +0100
+++ b/jdk/make/javax/crypto/Defs-jce.gmk	Tue Oct 23 12:36:47 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 JCE_MANIFEST_FILE    = $(TEMPDIR)/manifest.mf
 $(JCE_MANIFEST_FILE): $(MAINMANIFEST)
 	$(prep-target)
-	$(SED) -e "s#@@RELEASE@@#$(RELEASE)#"           \
+	$(SED) -e "s#@@RELEASE@@#$(JDK_VERSION)#"       \
                -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \
                $(MAINMANIFEST) >> $@
 	$(ECHO) "Extension-Name: javax.crypto" >> $@
--- a/jdk/make/sun/security/ec/Makefile	Tue Oct 23 11:57:47 2012 +0100
+++ b/jdk/make/sun/security/ec/Makefile	Tue Oct 23 12:36:47 2012 -0700
@@ -246,9 +246,9 @@
 #
 # Build sunec.jar.
 #
-$(UNSIGNED_DIR)/sunec.jar: build
+$(UNSIGNED_DIR)/sunec.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/jdk/make/sun/security/mscapi/Makefile	Tue Oct 23 11:57:47 2012 +0100
+++ b/jdk/make/sun/security/mscapi/Makefile	Tue Oct 23 12:36:47 2012 -0700
@@ -209,9 +209,9 @@
 #
 # Build sunmscapi.jar.
 #
-$(UNSIGNED_DIR)/sunmscapi.jar: build
+$(UNSIGNED_DIR)/sunmscapi.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- a/jdk/make/sun/security/pkcs11/Makefile	Tue Oct 23 11:57:47 2012 +0100
+++ b/jdk/make/sun/security/pkcs11/Makefile	Tue Oct 23 12:36:47 2012 -0700
@@ -225,9 +225,9 @@
 #
 # Build sunpkcs11.jar.
 #
-$(UNSIGNED_DIR)/sunpkcs11.jar: build
+$(UNSIGNED_DIR)/sunpkcs11.jar: build $(JCE_MANIFEST_FILE)
 	$(prep-target)
-	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
+	$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \
 	    $(BOOT_JAR_JFLAGS)
 	@$(java-vm-cleanup)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/sanity/CheckManifestForRelease.java	Tue Oct 23 12:36:47 2012 -0700
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7197071
+ * @summary Makefiles for various security providers aren't including
+ *          the default manifest.
+ */
+import java.net.*;
+import java.io.*;
+
+/**
+ * When the Java specification version is incremented, all of the providers
+ * must be recompiled with the proper implementation version to match.
+ */
+public class CheckManifestForRelease {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        checkFileManifests();
+    }
+
+    /*
+     * Iterate over the files of interest: JCE framework and providers
+     */
+    static private void checkFileManifests() throws Exception {
+        System.out.println("=============");
+        String libDirName = System.getProperty("java.home", ".") + "/lib";
+        String extDirName = libDirName + "/ext";
+
+        System.out.println("Checking Manifest in directory: \n    " +
+            extDirName);
+
+        /*
+         * Current list of JCE providers, all of which currently live in
+         * the extensions directory.  Add if more are created.
+         */
+        String[] providers = new String[]{
+            "sunjce_provider.jar",
+            "sunec.jar",
+            "sunmscapi.jar",
+            "sunpkcs11.jar",
+            "ucrypto.jar"
+        };
+
+        checkManifest(libDirName, "jce.jar");
+        for (String provider : providers) {
+            checkManifest(extDirName, provider);
+        }
+        System.out.println("Passed.");
+    }
+
+    // Helper method to format the URL properly.
+    static private String formatURL(String dir, String file) {
+        return "jar:file:///" + dir + "/" + file + "!/";
+    }
+
+    static private String specVersion =
+        System.getProperty("java.specification.version");
+
+    /*
+     * Test the root cause, which is that there were no manifest values
+     * for many of the providers, and for those that had them, there was
+     * no test to make sure that the impl version was appropriate for
+     * the spec version.
+     */
+    static private void checkManifest(String dir, String file)
+            throws Exception {
+
+        System.out.println("Checking: " + file);
+
+        String url = formatURL(dir, file);
+        JarURLConnection urlc =
+            (JarURLConnection) (new URL(url).openConnection());
+
+        String implVersion;
+        try {
+            implVersion = urlc.getManifest().getMainAttributes().getValue(
+                "Implementation-Version");
+        } catch (FileNotFoundException e) {
+            /*
+             * If the file doesn't exist (e.g. mscapi on solaris),
+             * skip it. If there are other problems, fail out.
+             */
+            System.out.println("    " + file + " not found, skipping...");
+            return;
+        }
+
+        if (implVersion == null) {
+            throw new Exception(
+                "Implementation-Version not found in Manifest");
+        }
+
+        if (!implVersion.startsWith(specVersion)) {
+            throw new Exception(
+                "Implementation-Version does not match " +
+                "Specification-Version");
+        }
+    }
+}