You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by le...@apache.org on 2007/10/18 05:20:36 UTC
svn commit: r585817 - in
/harmony/enhanced/classlib/trunk/modules/security/src:
main/java/common/java/security/ main/java/common/org/apache/harmony/security/
main/java/common/org/apache/harmony/security/fortress/
main/java/common/org/apache/harmony/sec...
Author: leoli
Date: Wed Oct 17 20:20:36 2007
New Revision: 585817
URL: http://svn.apache.org/viewvc?rev=585817&view=rev
Log:
Apply patch for HARMONY-4916([classlib][security]Harmony fails to get "MD5withRSA" signature under Turkish locale).
Added:
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Engine.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/PolicyUtils.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Services.java
harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/utils/AlgNameMapper.java
harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java Wed Oct 17 20:20:36 2007
@@ -38,6 +38,7 @@
import java.util.Set;
import org.apache.harmony.luni.util.TwoKeyHashMap;
+import org.apache.harmony.security.Util;
import org.apache.harmony.security.fortress.Services;
import org.apache.harmony.security.internal.nls.Messages;
@@ -313,13 +314,13 @@
String attributeValue = getPropertyIgnoreCase(servAlg + ' ' + attribute);
if (attributeValue != null) {
- if (attribute.equalsIgnoreCase("KeySize")) { //$NON-NLS-1$
+ if (Util.equalsIgnoreCase(attribute,"KeySize")) { //$NON-NLS-1$
if (Integer.valueOf(attributeValue).compareTo(
Integer.valueOf(val)) >= 0) {
return true;
}
} else { // other attributes
- if (attributeValue.equalsIgnoreCase(val)) {
+ if (Util.equalsIgnoreCase(attributeValue, val)) {
return true;
}
}
@@ -375,11 +376,11 @@
}
if (type.equals(lastServiceName)
- && algorithm.equalsIgnoreCase(lastAlgorithm)) {
+ && Util.equalsIgnoreCase(algorithm, lastAlgorithm)) {
return returnedService;
}
- String alg = algorithm.toUpperCase();
+ String alg = Util.toUpperCase(algorithm);
Object o = null;
if (serviceTable != null) {
o = serviceTable.get(type, alg);
@@ -439,13 +440,13 @@
if (serviceTable == null) {
serviceTable = new TwoKeyHashMap<String, String, Service>(128);
}
- serviceTable.put(s.type, s.algorithm.toUpperCase(), s);
+ serviceTable.put(s.type, Util.toUpperCase(s.algorithm), s);
if (s.aliases != null) {
if (aliasTable == null) {
aliasTable = new TwoKeyHashMap<String, String, Service>(256);
}
for (Iterator<String> it = s.getAliases(); it.hasNext();) {
- aliasTable.put(s.type, (it.next()).toUpperCase(), s);
+ aliasTable.put(s.type, Util.toUpperCase(it.next()), s);
}
}
serviceInfoToProperties(s);
@@ -461,11 +462,11 @@
}
servicesChanged();
if (serviceTable != null) {
- serviceTable.remove(s.type, s.algorithm.toUpperCase());
+ serviceTable.remove(s.type, Util.toUpperCase(s.algorithm));
}
if (aliasTable != null && s.aliases != null) {
for (Iterator<String> it = s.getAliases(); it.hasNext();) {
- aliasTable.remove(s.type, (it.next()).toUpperCase());
+ aliasTable.remove(s.type, Util.toUpperCase(it.next()));
}
}
serviceInfoFromProperties(s);
@@ -533,7 +534,7 @@
serviceName = service_alias.substring(0, i);
aliasName = service_alias.substring(i + 1);
if (propertyAliasTable != null) {
- propertyAliasTable.remove(serviceName, aliasName.toUpperCase());
+ propertyAliasTable.remove(serviceName, Util.toUpperCase(aliasName));
}
if (propertyServiceTable != null) {
for (Iterator<Service> it = propertyServiceTable.values().iterator(); it
@@ -557,12 +558,12 @@
serviceName = k.substring(0, j);
algorithm = k.substring(j + 1);
if (propertyServiceTable != null) {
- Provider.Service ser = propertyServiceTable.remove(serviceName, algorithm.toUpperCase());
+ Provider.Service ser = propertyServiceTable.remove(serviceName, Util.toUpperCase(algorithm));
if (ser != null && propertyAliasTable != null
&& ser.aliases != null) {
for (Iterator<String> it = ser.aliases.iterator(); it.hasNext();) {
- propertyAliasTable.remove(serviceName, (it
- .next()).toUpperCase());
+ propertyAliasTable.remove(serviceName, Util.toUpperCase(it
+ .next()));
}
}
}
@@ -572,8 +573,7 @@
serviceName = k.substring(0, j);
algorithm = k.substring(j + 1, i);
if (propertyServiceTable != null) {
- Object o = propertyServiceTable.get(serviceName, algorithm
- .toUpperCase());
+ Object o = propertyServiceTable.get(serviceName, Util.toUpperCase(algorithm));
if (o != null) {
s = (Provider.Service) o;
s.attributes.remove(attribute);
@@ -614,7 +614,7 @@
serviceName = service_alias.substring(0, i);
aliasName = service_alias.substring(i + 1);
algorithm = value;
- String algUp = algorithm.toUpperCase();
+ String algUp = Util.toUpperCase(algorithm);
Object o = null;
if (propertyServiceTable == null) {
propertyServiceTable = new TwoKeyHashMap<String, String, Service>(128);
@@ -628,7 +628,7 @@
propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256);
}
propertyAliasTable.put(serviceName,
- aliasName.toUpperCase(), s);
+ Util.toUpperCase(aliasName), s);
} else {
String className = (String) changedProperties
.get(serviceName + "." + algorithm); //$NON-NLS-1$
@@ -641,8 +641,8 @@
if (propertyAliasTable == null) {
propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256);
}
- propertyAliasTable.put(serviceName, aliasName
- .toUpperCase(), s);
+ propertyAliasTable.put(serviceName, Util.toUpperCase(aliasName
+ ), s);
}
}
continue;
@@ -655,7 +655,7 @@
if (i == -1) { // <crypto_service>.<algorithm_or_type>=<className>
serviceName = key.substring(0, j);
algorithm = key.substring(j + 1);
- String alg = algorithm.toUpperCase();
+ String alg = Util.toUpperCase(algorithm);
Object o = null;
if (propertyServiceTable != null) {
o = propertyServiceTable.get(serviceName, alg);
@@ -677,7 +677,7 @@
serviceName = key.substring(0, j);
algorithm = key.substring(j + 1, i);
String attribute = key.substring(i + 1);
- String alg = algorithm.toUpperCase();
+ String alg = Util.toUpperCase(algorithm);
Object o = null;
if (propertyServiceTable != null) {
o = propertyServiceTable.get(serviceName, alg);
@@ -733,7 +733,7 @@
}
for (Enumeration<?> e = propertyNames(); e.hasMoreElements();) {
String pname = (String) e.nextElement();
- if (key.equalsIgnoreCase(pname)) {
+ if (Util.equalsIgnoreCase(key, pname)) {
return getProperty(pname);
}
}
@@ -855,7 +855,7 @@
Class[] parameterTypes = new Class[1];
Object[] initargs = { constructorParameter };
try {
- if (type.equalsIgnoreCase("CertStore")) { //$NON-NLS-1$
+ if (Util.equalsIgnoreCase(type,"CertStore")) { //$NON-NLS-1$
parameterTypes[0] = Class
.forName("java.security.cert.CertStoreParameters"); //$NON-NLS-1$
} else {
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Security.java Wed Oct 17 20:20:36 2007
@@ -36,6 +36,7 @@
import java.util.Properties;
import java.util.Set;
+import org.apache.harmony.security.Util;
import org.apache.harmony.security.fortress.Engine;
import org.apache.harmony.security.fortress.PolicyUtils;
import org.apache.harmony.security.fortress.SecurityAccess;
@@ -74,7 +75,7 @@
}
}
- if ("true".equalsIgnoreCase(secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (Util.equalsIgnoreCase("true", secprops.getProperty("security.allowCustomPropertiesFile", "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String securityFile = System.getProperty("java.security.properties"); //$NON-NLS-1$
if (securityFile != null) {
if (securityFile.startsWith("=")) { // overwrite //$NON-NLS-1$
@@ -149,7 +150,7 @@
for (Enumeration e = providers[i].propertyNames(); e
.hasMoreElements();) {
String pname = (String) e.nextElement();
- if (prop.equalsIgnoreCase(pname)) {
+ if (Util.equalsIgnoreCase(prop, pname)) {
return providers[i].getProperty(pname);
}
}
@@ -394,7 +395,7 @@
for (int i = 0; i < p.length; i++) {
for (Iterator it = p[i].getServices().iterator(); it.hasNext();) {
Provider.Service s = (Provider.Service) it.next();
- if (s.getType().equalsIgnoreCase(serviceName)) {
+ if (Util.equalsIgnoreCase(s.getType(),serviceName)) {
result.add(s.getAlgorithm());
}
}
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/DefaultPolicyScanner.java Wed Oct 17 20:20:36 2007
@@ -127,9 +127,9 @@
break parsing;
case StreamTokenizer.TT_WORD:
- if ("keystore".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ if (Util.equalsIgnoreCase("keystore", st.sval)) { //$NON-NLS-1$
keystoreEntries.add(readKeystoreEntry(st));
- } else if ("grant".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ } else if (Util.equalsIgnoreCase("grant", st.sval)) { //$NON-NLS-1$
grantEntries.add(readGrantEntry(st));
} else {
handleUnexpectedToken(st, Messages.getString("security.89")); //$NON-NLS-1$
@@ -208,19 +208,19 @@
switch (st.nextToken()) {
case StreamTokenizer.TT_WORD:
- if ("signedby".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ if (Util.equalsIgnoreCase("signedby", st.sval)) { //$NON-NLS-1$
if (st.nextToken() == '"') {
ge.signers = st.sval;
} else {
handleUnexpectedToken(st, Messages.getString("security.8B")); //$NON-NLS-1$
}
- } else if ("codebase".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ } else if (Util.equalsIgnoreCase("codebase", st.sval)) { //$NON-NLS-1$
if (st.nextToken() == '"') {
ge.codebase = st.sval;
} else {
handleUnexpectedToken(st, Messages.getString("security.8C")); //$NON-NLS-1$
}
- } else if ("principal".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ } else if (Util.equalsIgnoreCase("principal", st.sval)) { //$NON-NLS-1$
ge.addPrincipal(readPrincipalEntry(st));
} else {
handleUnexpectedToken(st);
@@ -308,7 +308,7 @@
switch (st.nextToken()) {
case StreamTokenizer.TT_WORD:
- if ("permission".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ if (Util.equalsIgnoreCase("permission", st.sval)) { //$NON-NLS-1$
PermissionEntry pe = new PermissionEntry();
if (st.nextToken() == StreamTokenizer.TT_WORD) {
pe.klass = st.sval;
@@ -326,7 +326,7 @@
}
}
if (st.ttype == StreamTokenizer.TT_WORD
- && "signedby".equalsIgnoreCase(st.sval)) { //$NON-NLS-1$
+ && Util.equalsIgnoreCase("signedby", st.sval)) { //$NON-NLS-1$
if (st.nextToken() == '"') {
pe.signers = st.sval;
} else {
Added: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java?rev=585817&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java (added)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java Wed Oct 17 20:20:36 2007
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.security;
+
+public class Util {
+
+ public static String toUpperCase(String s) {
+ return org.apache.harmony.luni.util.Util.toASCIIUpperCase(s);
+ }
+
+ public static boolean equalsIgnoreCase(String s1, String s2) {
+ s1 = org.apache.harmony.luni.util.Util.toASCIIUpperCase(s1);
+ s2 = org.apache.harmony.luni.util.Util.toASCIIUpperCase(s2);
+ return s1.equals(s2);
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Engine.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Engine.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Engine.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Engine.java Wed Oct 17 20:20:36 2007
@@ -25,6 +25,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import org.apache.harmony.security.Util;
import org.apache.harmony.security.internal.nls.Messages;
@@ -89,7 +90,7 @@
}
Services.refresh();
if (returnedService != null
- && algorithm.equalsIgnoreCase(lastAlgorithm)
+ && Util.equalsIgnoreCase(algorithm, lastAlgorithm)
&& refreshNumber == Services.refreshNumber) {
serv = returnedService;
} else {
@@ -99,7 +100,7 @@
}
serv = Services.getService(new StringBuffer(128)
.append(serviceName).append(".").append( //$NON-NLS-1$
- algorithm.toUpperCase()).toString());
+ Util.toUpperCase(algorithm)).toString());
if (serv == null) {
throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$
serviceName, algorithm));
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/PolicyUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/PolicyUtils.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/PolicyUtils.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/PolicyUtils.java Wed Oct 17 20:20:36 2007
@@ -39,6 +39,7 @@
import java.util.List;
import java.util.Properties;
+import org.apache.harmony.security.Util;
import org.apache.harmony.security.internal.nls.Messages;
/**
@@ -371,7 +372,7 @@
* @see #expand(String, Properties)
*/
public static boolean canExpandProperties() {
- return !FALSE.equalsIgnoreCase(AccessController
+ return !Util.equalsIgnoreCase(FALSE,AccessController
.doPrivileged(new SecurityPropertyAccessor(POLICY_EXPAND)));
}
@@ -417,7 +418,7 @@
URL dynamicURL = null;
//first check if policy is set via system properties
- if (!FALSE.equalsIgnoreCase(AccessController
+ if (!Util.equalsIgnoreCase(FALSE, AccessController
.doPrivileged(security.key(POLICY_ALLOW_DYNAMIC)))) {
String location = system.getProperty(systemUrlKey);
if (location != null) {
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Services.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Services.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Services.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/fortress/Services.java Wed Oct 17 20:20:36 2007
@@ -33,6 +33,8 @@
import java.util.Map;
import java.util.Set;
+import org.apache.harmony.security.Util;
+
/**
* This class contains information about all registered providers and preferred
@@ -171,14 +173,14 @@
type = serv.getType();
sb.delete(0, sb.length());
key = sb.append(type).append(".").append( //$NON-NLS-1$
- serv.getAlgorithm().toUpperCase()).toString();
+ Util.toUpperCase(serv.getAlgorithm())).toString();
if (!services.containsKey(key)) {
services.put(key, serv);
}
for (Iterator<String> it2 = Engine.door.getAliases(serv); it2.hasNext();) {
alias = it2.next();
sb.delete(0, sb.length());
- key = sb.append(type).append(".").append(alias.toUpperCase()) //$NON-NLS-1$
+ key = sb.append(type).append(".").append(Util.toUpperCase(alias)) //$NON-NLS-1$
.toString();
if (!services.containsKey(key)) {
services.put(key, serv);
Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/utils/AlgNameMapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/utils/AlgNameMapper.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/utils/AlgNameMapper.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/utils/AlgNameMapper.java Wed Oct 17 20:20:36 2007
@@ -29,6 +29,7 @@
import java.util.Set;
import java.util.Map.Entry;
+import org.apache.harmony.security.Util;
import org.apache.harmony.security.asn1.ObjectIdentifier;
/**
@@ -80,7 +81,7 @@
static {
for (String[] element : knownAlgMappings) {
- String algUC = element[1].toUpperCase();
+ String algUC = Util.toUpperCase(element[1]);
alg2OidMap.put(algUC, element[0]);
oid2AlgMap.put(element[0], algUC);
// map upper case alg name to its original name
@@ -110,7 +111,7 @@
*/
public static String map2OID(String algName) {
// alg2OidMap map contains upper case keys
- return alg2OidMap.get(algName.toUpperCase());
+ return alg2OidMap.get(Util.toUpperCase(algName));
}
/**
@@ -133,7 +134,7 @@
* @return algorithm name
*/
public static String getStandardName(String algName) {
- return algAliasesMap.get(algName.toUpperCase());
+ return algAliasesMap.get(Util.toUpperCase(algName));
}
// Searches given provider for mappings like
@@ -150,7 +151,7 @@
if (key.startsWith(keyPrfix2find)) {
String alias = key.substring(keyPrfix2find.length());
String alg = (String)me.getValue();
- String algUC = alg.toUpperCase();
+ String algUC = Util.toUpperCase(alg);
if (isOID(alias)) {
if (alias.startsWith("OID.")) { //$NON-NLS-1$
alias = alias.substring(4);
@@ -169,8 +170,8 @@
algAliasesMap.put(algUC, alg);
}
// Do not override known standard names
- } else if (!algAliasesMap.containsKey(alias.toUpperCase())) {
- algAliasesMap.put(alias.toUpperCase(), alg);
+ } else if (!algAliasesMap.containsKey(Util.toUpperCase(alias))) {
+ algAliasesMap.put(Util.toUpperCase(alias), alg);
}
}
}
Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java?rev=585817&r1=585816&r2=585817&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Signature2Test.java Wed Oct 17 20:20:36 2007
@@ -25,6 +25,7 @@
import java.security.Security;
import java.security.Signature;
import java.security.spec.DSAParameterSpec;
+import java.util.Locale;
public class Signature2Test extends junit.framework.TestCase {
@@ -226,4 +227,23 @@
sig.update(MESSAGE.getBytes());
assertTrue("Sign/Verify does not pass", sig.verify(signature));
}
+
+ //Regression Test for HARMONY-4916
+ public void test_getInstance_withI18n() throws Exception {
+ // Enfore that providers information has been loaded.
+ Signature.getInstance("DSA");
+ Locale defaultLocale = Locale.getDefault();
+ try {
+ /**
+ * In locale("tr"), char 'i' will be transferred to an upper case
+ * other char than 'I'. Thus in security architecture, all
+ * manipulation to the string representing an algorithm name or
+ * standard property shall be treated as locale neutral
+ */
+ Locale.setDefault(new Locale("tr"));
+ Signature.getInstance("MD5withRSA");
+ } finally {
+ Locale.setDefault(defaultLocale);
+ }
+ }
}