Hi,
The attached patch is in relation to PR28192 : Algorithm Names should be
case insensitive (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28192).
When applied, algorithm names will be case insensitive.
Please review and let me know if any changes are in order.
Thanks,
Matt Wringe
Changelog:
2006-06-28 Matt Wringe <[EMAIL PROTECTED]>
* gnu/java/security/Engine.java (getInstance): Algorithm names now case
insensitive
Index: Engine.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/security/Engine.java,v
retrieving revision 1.3
diff -u -r1.3 Engine.java
--- Engine.java 1 Jan 2006 14:03:45 -0000 1.3
+++ Engine.java 28 Jun 2006 15:19:13 -0000
@@ -42,6 +42,11 @@
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
/**
* Generic implementation of the getInstance methods in the various
@@ -141,26 +146,45 @@
|| provider == null || initArgs == null)
throw new IllegalArgumentException();
- // If there is no property "service.algorithm"
- if (provider.getProperty(service + "." + algorithm) == null)
+
+ Enumeration enumer = provider.propertyNames();
+ String key;
+ String alias;
+ int count = 0;
+ boolean algorithmFound = false;
+
+ while (enumer.hasMoreElements())
{
- // Iterate through aliases, until we find the class name or resolve
- // too many aliases.
- String alias = null;
- int count = 0;
- while ((alias = provider.getProperty(
- ALG_ALIAS + service + "." + algorithm)) != null)
+ key = (String) enumer.nextElement();
+
+ if (key.equalsIgnoreCase(service + "." + algorithm))
+ {
+ // remove the service portion from the key
+ algorithm = key.substring(service.length() + 1);
+
+ algorithmFound = true;
+ break;
+
+ }
+ else if (key.equalsIgnoreCase(ALG_ALIAS + service + "." + algorithm))
{
- if (algorithm.equals(alias)) // Refers to itself!
- break;
+
+ alias = (String) provider.getProperty(key);
algorithm = alias;
if (count++ > MAX_ALIASES)
throw new NoSuchAlgorithmException("too many aliases");
+
+ // need to reset enumeration to now look for the alias
+ enumer = provider.propertyNames();
+
}
- if (provider.getProperty(service + "." + algorithm) == null)
- throw new NoSuchAlgorithmException(algorithm);
}
-
+
+ if (!algorithmFound) {
+ throw new NoSuchAlgorithmException(algorithm);
+ }
+
+
// Find and instantiate the implementation.
Class clazz = null;
ClassLoader loader = provider.getClass().getClassLoader();