Merge
authorasaha
Sat, 05 Sep 2009 07:55:05 -0700
changeset 4200 7761313b9b16
parent 4199 151e13fd2df1 (current diff)
parent 3719 b00a1e55ec44 (diff)
child 4201 b3906ffdbcd6
Merge
--- a/jdk/src/share/classes/java/lang/Character.java	Thu Sep 03 19:42:27 2009 +0400
+++ b/jdk/src/share/classes/java/lang/Character.java	Sat Sep 05 07:55:05 2009 -0700
@@ -2587,9 +2587,9 @@
      * significantly better space and time performance by caching
      * frequently requested values.
      *
-     * This method will always cache values in the range '\u0000'
-     * to '\u007f'", inclusive, and may cache other values outside
-     * of this range.
+     * This method will always cache values in the range {@code
+     * '\u005Cu0000'} to {@code '\u005Cu007f'}, inclusive, and may
+     * cache other values outside of this range.
      *
      * @param  c a char value.
      * @return a <tt>Character</tt> instance representing <tt>c</tt>.
--- a/jdk/src/share/classes/sun/security/tools/JarSigner.java	Thu Sep 03 19:42:27 2009 +0400
+++ b/jdk/src/share/classes/sun/security/tools/JarSigner.java	Sat Sep 05 07:55:05 2009 -0700
@@ -1978,20 +1978,35 @@
         String[] base64Digests = getDigests(ze, zf, digests, encoder);
 
         for (int i=0; i<digests.length; i++) {
-            String name = digests[i].getAlgorithm()+"-Digest";
-            String mfDigest = attrs.getValue(name);
-            if (mfDigest == null
-                && digests[i].getAlgorithm().equalsIgnoreCase("SHA")) {
-                // treat "SHA" and "SHA1" the same
-                mfDigest = attrs.getValue("SHA-Digest");
+            // The entry name to be written into attrs
+            String name = null;
+            try {
+                // Find if the digest already exists
+                AlgorithmId aid = AlgorithmId.get(digests[i].getAlgorithm());
+                for (Object key: attrs.keySet()) {
+                    if (key instanceof Attributes.Name) {
+                        String n = ((Attributes.Name)key).toString();
+                        if (n.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) {
+                            String tmp = n.substring(0, n.length() - 7);
+                            if (AlgorithmId.get(tmp).equals(aid)) {
+                                name = n;
+                                break;
+                            }
+                        }
+                    }
+                }
+            } catch (NoSuchAlgorithmException nsae) {
+                // Ignored. Writing new digest entry.
             }
-            if (mfDigest == null) {
-                // compute digest and add it to list of attributes
+
+            if (name == null) {
+                name = digests[i].getAlgorithm()+"-Digest";
                 attrs.putValue(name, base64Digests[i]);
                 update=true;
             } else {
                 // compare digests, and replace the one in the manifest
                 // if they are different
+                String mfDigest = attrs.getValue(name);
                 if (!mfDigest.equalsIgnoreCase(base64Digests[i])) {
                     attrs.putValue(name, base64Digests[i]);
                     update=true;
--- a/jdk/src/share/classes/sun/security/x509/AlgorithmId.java	Thu Sep 03 19:42:27 2009 +0400
+++ b/jdk/src/share/classes/sun/security/x509/AlgorithmId.java	Sat Sep 05 07:55:05 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc.  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
@@ -531,6 +531,18 @@
                 || name.equalsIgnoreCase("ECDSA")) {
             return AlgorithmId.sha1WithECDSA_oid;
         }
+        if (name.equalsIgnoreCase("SHA224withECDSA")) {
+            return AlgorithmId.sha224WithECDSA_oid;
+        }
+        if (name.equalsIgnoreCase("SHA256withECDSA")) {
+            return AlgorithmId.sha256WithECDSA_oid;
+        }
+        if (name.equalsIgnoreCase("SHA384withECDSA")) {
+            return AlgorithmId.sha384WithECDSA_oid;
+        }
+        if (name.equalsIgnoreCase("SHA512withECDSA")) {
+            return AlgorithmId.sha512WithECDSA_oid;
+        }
 
         // See if any of the installed providers supply a mapping from
         // the given algorithm name to an OID string
--- a/jdk/test/java/lang/reflect/Generics/Probe.java	Thu Sep 03 19:42:27 2009 +0400
+++ b/jdk/test/java/lang/reflect/Generics/Probe.java	Sat Sep 05 07:55:05 2009 -0700
@@ -23,11 +23,9 @@
 
 /*
  * @test
- * @bug 5003916 6704655
+ * @bug 5003916 6704655 6873951
  * @summary Testing parsing of signatures attributes of nested classes
  * @author Joseph D. Darcy
- * @compile -source 1.5 Probe.java
- * @run main Probe
  */
 
 import java.lang.reflect.*;
@@ -35,51 +33,35 @@
 import java.util.*;
 import static java.util.Arrays.*;
 
-@Classes(value={
-        "java.util.concurrent.FutureTask",
-        "java.util.concurrent.ConcurrentHashMap$EntryIterator",
-        "java.util.concurrent.ConcurrentHashMap$KeyIterator",
-        "java.util.concurrent.ConcurrentHashMap$ValueIterator",
-        "java.util.AbstractList$ListItr",
-        "java.util.EnumMap$EntryIterator",
-        "java.util.EnumMap$KeyIterator",
-        "java.util.EnumMap$ValueIterator",
-        "java.util.IdentityHashMap$EntryIterator",
-        "java.util.IdentityHashMap$KeyIterator",
-        "java.util.IdentityHashMap$ValueIterator",
-        "java.util.WeakHashMap$EntryIterator",
-        "java.util.WeakHashMap$KeyIterator",
-        "java.util.WeakHashMap$ValueIterator",
-        "java.util.TreeMap$EntryIterator",
-        "java.util.TreeMap$KeyIterator",
-        "java.util.TreeMap$ValueIterator",
-        "java.util.HashMap$EntryIterator",
-        "java.util.HashMap$KeyIterator",
-        "java.util.HashMap$ValueIterator",
-        "java.util.LinkedHashMap$EntryIterator",
-        "java.util.LinkedHashMap$KeyIterator",
-        "java.util.LinkedHashMap$ValueIterator"
-        },
-        sunClasses={
-        "javax.crypto.SunJCE_c",
-        "javax.crypto.SunJCE_e",
-        "javax.crypto.SunJCE_f",
-        "javax.crypto.SunJCE_j",
-        "javax.crypto.SunJCE_k",
-        "javax.crypto.SunJCE_l"
-        })
+@Classes({"java.util.concurrent.FutureTask",
+          "java.util.concurrent.ConcurrentHashMap$EntryIterator",
+          "java.util.concurrent.ConcurrentHashMap$KeyIterator",
+          "java.util.concurrent.ConcurrentHashMap$ValueIterator",
+          "java.util.AbstractList$ListItr",
+          "java.util.EnumMap$EntryIterator",
+          "java.util.EnumMap$KeyIterator",
+          "java.util.EnumMap$ValueIterator",
+          "java.util.IdentityHashMap$EntryIterator",
+          "java.util.IdentityHashMap$KeyIterator",
+          "java.util.IdentityHashMap$ValueIterator",
+          "java.util.WeakHashMap$EntryIterator",
+          "java.util.WeakHashMap$KeyIterator",
+          "java.util.WeakHashMap$ValueIterator",
+          "java.util.TreeMap$EntryIterator",
+          "java.util.TreeMap$KeyIterator",
+          "java.util.TreeMap$ValueIterator",
+          "java.util.HashMap$EntryIterator",
+          "java.util.HashMap$KeyIterator",
+          "java.util.HashMap$ValueIterator",
+          "java.util.LinkedHashMap$EntryIterator",
+          "java.util.LinkedHashMap$KeyIterator",
+          "java.util.LinkedHashMap$ValueIterator"})
 public class Probe {
-    public static void main (String[] args) throws Throwable {
+    public static void main (String... args) throws Throwable {
         Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
         List<String> names =
             new ArrayList<String>(asList(classesAnnotation.value()));
 
-        if (System.getProperty("java.runtime.name").startsWith("Java(TM)")) {
-            // Sun production JDK; test crypto classes too
-            for(String name: classesAnnotation.sunClasses())
-                names.add(name);
-        }
-
         int errs = 0;
         for(String name: names) {
             System.out.println("\nCLASS " + name);
@@ -152,5 +134,4 @@
 @Retention(RetentionPolicy.RUNTIME)
 @interface Classes {
     String [] value(); // list of classes to probe
-    String [] sunClasses(); // list of Sun-production JDK specific classes to probe
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/nameclash.sh	Sat Sep 05 07:55:05 2009 -0700
@@ -0,0 +1,66 @@
+#
+# Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+# @test
+# @bug 6876328
+# @summary different names for the same digest algorithms breaks jarsigner
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+  JAVAC_CMD=`which javac`
+  TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  Windows_* )
+    FS="\\"
+    ;;
+  * )
+    FS="/"
+    ;;
+esac
+
+KS=nc.jks
+JFILE=nc.jar
+
+KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
+JAR=$TESTJAVA${FS}bin${FS}jar
+JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+
+rm $KS $JFILE
+
+$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
+$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
+
+echo A > A
+$JAR cvf $JFILE A
+
+$JARSIGNER -keystore $KS -storepass changeit $JFILE a -digestalg SHA1 || exit 1
+$JARSIGNER -keystore $KS -storepass changeit $JFILE b -digestalg SHA-1 || exit 2
+
+$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
+
+exit 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/x509/AlgorithmId/SHA256withECDSA.java	Sat Sep 05 07:55:05 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6871847
+ * @summary AlgorithmId.get("SHA256withECDSA") not available
+ */
+
+import sun.security.x509.*;
+
+public class SHA256withECDSA {
+    public static void main(String[] args) throws Exception {
+        AlgorithmId.get("SHA224withECDSA");
+        AlgorithmId.get("SHA256withECDSA");
+        AlgorithmId.get("SHA384withECDSA");
+        AlgorithmId.get("SHA512withECDSA");
+    }
+}