提交 46f45e04 编写于 作者: T tbell

Merge

......@@ -2587,9 +2587,9 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
* significantly better space and time performance by caching
* frequently requested values.
*
* This method will always cache values in the range '&#92;u0000'
* to '&#92;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>.
......
......@@ -1978,20 +1978,35 @@ public class JarSigner {
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;
}
}
}
}
if (mfDigest == null) {
// compute digest and add it to list of attributes
} catch (NoSuchAlgorithmException nsae) {
// Ignored. Writing new digest entry.
}
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;
......
/*
* 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 @@ public class AlgorithmId implements Serializable, DerEncoder {
|| 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
......
......@@ -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,8 +33,7 @@ import java.lang.annotation.*;
import java.util.*;
import static java.util.Arrays.*;
@Classes(value={
"java.util.concurrent.FutureTask",
@Classes({"java.util.concurrent.FutureTask",
"java.util.concurrent.ConcurrentHashMap$EntryIterator",
"java.util.concurrent.ConcurrentHashMap$KeyIterator",
"java.util.concurrent.ConcurrentHashMap$ValueIterator",
......@@ -58,28 +55,13 @@ import static java.util.Arrays.*;
"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"
})
"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 @@ public class Probe {
@Retention(RetentionPolicy.RUNTIME)
@interface Classes {
String [] value(); // list of classes to probe
String [] sunClasses(); // list of Sun-production JDK specific classes to probe
}
#
# 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
/*
* 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");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册