summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Wringe <mwringe@redhat.com>2006-07-28 18:48:36 +0000
committerMatt Wringe <mwringe@redhat.com>2006-07-28 18:48:36 +0000
commit1d186ccb8ccb45a1564f834eab117aaea512e6ff (patch)
treea53dd7ae8a9fed98d336bfe8e325508f169cf79d
parentf5f8ea709c1fc30ab976524a93c7dc538f212aaf (diff)
downloadclasspath-1d186ccb8ccb45a1564f834eab117aaea512e6ff.tar.gz
* gnu/java/security/Engine.java
(getInstance): Add case insentivity to algorithm names * java/security/Provider.java (put): Stop using canonical key naming (remove): Likewise (toCanonicalKey): Method removed (get): Method removed, no longer needs to overwrite parent implementation
-rw-r--r--ChangeLog11
-rw-r--r--gnu/java/security/Engine.java47
-rw-r--r--java/security/Provider.java17
3 files changed, 47 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 047f7ecb4..58cef13ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-07-28 Matt Wringe <mwringe@redhat.com>
+
+ * gnu/java/security/Engine.java
+ (getInstance): Add case insentivity to algorithm names
+ * java/security/Provider.java
+ (put): Stop using canonical key naming
+ (remove): Likewise
+ (toCanonicalKey): Method removed
+ (get): Method removed, no longer needs to overwrite
+ parent implementation
+
2006-07-28 Lillian Angel <langel@redhat.com>
* gnu/java/awt/dnd/peer/gtk/GtkDragSourceContextPeer.java
diff --git a/gnu/java/security/Engine.java b/gnu/java/security/Engine.java
index 4b6bd10d9..59a5d0e52 100644
--- a/gnu/java/security/Engine.java
+++ b/gnu/java/security/Engine.java
@@ -42,6 +42,7 @@ import java.lang.reflect.InvocationTargetException;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Enumeration;
/**
* Generic implementation of the getInstance methods in the various
@@ -141,26 +142,46 @@ public final class Engine
|| 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();
diff --git a/java/security/Provider.java b/java/security/Provider.java
index 4ffaa55bc..57affe1dc 100644
--- a/java/security/Provider.java
+++ b/java/security/Provider.java
@@ -146,15 +146,9 @@ public abstract class Provider extends Properties implements Serializable
*/
public Object put(Object key, Object value)
{
- return super.put(toCanonicalKey(key), value);
+ return super.put(key, value);
}
- // overrides same in java.util.Hashtable
- public Object get(Object key)
- {
- return super.get(toCanonicalKey(key));
- }
-
/**
* This method removes the specified key entry (and its associated value)
* from the property mapping list.
@@ -166,7 +160,7 @@ public abstract class Provider extends Properties implements Serializable
*/
public Object remove(Object key)
{
- return super.remove(toCanonicalKey(key));
+ return super.remove(key);
}
/**
@@ -192,11 +186,4 @@ public abstract class Provider extends Properties implements Serializable
version);
}
- private Object toCanonicalKey(Object key)
- {
- if (key.getClass().isAssignableFrom(String.class)) // is it ours?
- return ((String) key).toUpperCase(); // use default locale
- else
- return key;
- }
}