2006-07-09 Casey Marshall <[EMAIL PROTECTED]>
* gnu/java/io/ByteBufferOutputStream.java (write): new method.
(buffer): use flip() and slice() to get the buffer.
(toString): new method.
* gnu/java/security/Engine.java: merge mwringe's case-insensitive
algorithm name patch.
* gnu/javax/crypto/jce/GnuCrypto.java (<init>): qualify
PrivilegedAction.
* gnu/javax/crypto/key/dh/GnuDHPrivateKey.java (toString): new
method.
* gnu/javax/crypto/key/dh/GnuDHPublicKey.java (toString): new
method.
* java/security/Security.java: qualify generic types.
Committed.
Index: gnu/java/io/ByteBufferOutputStream.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/java/io/Attic/ByteBufferOutputStream.java,v
retrieving revision 1.1.2.1
diff -u -B -b -r1.1.2.1 ByteBufferOutputStream.java
--- gnu/java/io/ByteBufferOutputStream.java 28 Jun 2006 23:07:43 -0000
1.1.2.1
+++ gnu/java/io/ByteBufferOutputStream.java 9 Jul 2006 21:44:16 -0000
@@ -81,6 +81,11 @@
buffer.put(b, offset, length);
}
+ public @Override void write(byte[] b)
+ {
+ write(b, 0, b.length);
+ }
+
/**
* Get the current state of the buffer. The returned buffer will have
* its position set to zero, its capacity set to the current limit,
@@ -90,9 +95,12 @@
*/
public ByteBuffer buffer()
{
- ByteBuffer buf = buffer.slice();
- buf.position(0).limit(buf.capacity());
- return buf;
+ return ((ByteBuffer) buffer.duplicate().flip()).slice();
+ }
+
+ public String toString()
+ {
+ return super.toString() + " [ buffer: " + buffer + " ]";
}
private void growBuffer()
Index: gnu/java/security/Engine.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/Engine.java,v
retrieving revision 1.1.2.2
diff -u -B -b -r1.1.2.2 Engine.java
--- gnu/java/security/Engine.java 10 Jan 2006 15:59:39 -0000 1.1.2.2
+++ gnu/java/security/Engine.java 9 Jul 2006 21:44:16 -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)
- {
- // Iterate through aliases, until we find the class name or resolve
- // too many aliases.
- String alias = null;
+
+ Enumeration enumer = provider.propertyNames();
+ String key;
+ String alias;
int count = 0;
- while ((alias = provider.getProperty(
- ALG_ALIAS + service + "." + algorithm)) != null)
+ boolean algorithmFound = false;
+
+ while (enumer.hasMoreElements())
+ {
+ key = (String) enumer.nextElement();
+
+ if (key.equalsIgnoreCase(service + "." + algorithm))
{
- if (algorithm.equals(alias)) // Refers to itself!
+ // remove the service portion from the key
+ algorithm = key.substring(service.length() + 1);
+
+ algorithmFound = true;
break;
+
+ }
+ else if (key.equalsIgnoreCase(ALG_ALIAS + service + "." + algorithm))
+ {
+
+ 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)
+ }
+
+ if (!algorithmFound) {
throw new NoSuchAlgorithmException(algorithm);
}
+
// Find and instantiate the implementation.
Class clazz = null;
ClassLoader loader = provider.getClass().getClassLoader();
Index: gnu/javax/crypto/jce/GnuCrypto.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/jce/GnuCrypto.java,v
retrieving revision 1.4.2.1
diff -u -B -b -r1.4.2.1 GnuCrypto.java
--- gnu/javax/crypto/jce/GnuCrypto.java 2 Mar 2006 09:33:50 -0000 1.4.2.1
+++ gnu/javax/crypto/jce/GnuCrypto.java 9 Jul 2006 21:44:16 -0000
@@ -71,7 +71,7 @@
{
super(Registry.GNU_CRYPTO, 2.1, "GNU Crypto JCE Provider");
- AccessController.doPrivileged(new PrivilegedAction()
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
Index: gnu/javax/crypto/key/dh/GnuDHPrivateKey.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHPrivateKey.java,v
retrieving revision 1.2.2.1
diff -u -B -b -r1.2.2.1 GnuDHPrivateKey.java
--- gnu/javax/crypto/key/dh/GnuDHPrivateKey.java 2 Mar 2006 09:33:51
-0000 1.2.2.1
+++ gnu/javax/crypto/key/dh/GnuDHPrivateKey.java 9 Jul 2006 21:44:16
-0000
@@ -193,4 +193,11 @@
DHPrivateKey that = (DHPrivateKey) obj;
return super.equals(that) && x.equals(that.getX());
}
+
+ public String toString()
+ {
+ return (super.toString() + " [ x: "
+ + (x == null ? "(nil)" : x.toString(16))
+ + "; params: " + getParams() + " ]");
+ }
}
Index: gnu/javax/crypto/key/dh/GnuDHPublicKey.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/javax/crypto/key/dh/GnuDHPublicKey.java,v
retrieving revision 1.2.2.1
diff -u -B -b -r1.2.2.1 GnuDHPublicKey.java
--- gnu/javax/crypto/key/dh/GnuDHPublicKey.java 2 Mar 2006 09:33:51 -0000
1.2.2.1
+++ gnu/javax/crypto/key/dh/GnuDHPublicKey.java 9 Jul 2006 21:44:16 -0000
@@ -191,4 +191,11 @@
DHPublicKey that = (DHPublicKey) obj;
return super.equals(that) && y.equals(that.getY());
}
+
+ public String toString()
+ {
+ return (super.toString() + " [ y: "
+ + (y == null ? "(nil)" : y.toString(16))
+ + "; params: " + getParams() + " ]");
+ }
}
Index: java/security/Security.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/Security.java,v
retrieving revision 1.30.2.10
diff -u -B -b -r1.30.2.10 Security.java
--- java/security/Security.java 1 May 2006 21:45:48 -0000 1.30.2.10
+++ java/security/Security.java 9 Jul 2006 21:44:16 -0000
@@ -68,7 +68,7 @@
{
private static final String ALG_ALIAS = "Alg.Alias.";
- private static Vector providers = new Vector();
+ private static Vector<Provider> providers = new Vector<Provider>();
private static Properties secprops = new Properties();
static
@@ -139,7 +139,7 @@
try
{
ClassLoader sys = ClassLoader.getSystemClassLoader();
- providers.addElement(Class.forName(name, true,
sys).newInstance());
+ providers.addElement((Provider) Class.forName(name, true,
sys).newInstance());
}
catch (ClassNotFoundException x)
{
@@ -153,6 +153,10 @@
{
exception = x;
}
+ catch (ClassCastException cce)
+ {
+ exception = cce;
+ }
if (exception != null)
{
@@ -490,7 +494,7 @@
if (filter == null || filter.length() == 0)
return getProviders();
- HashMap map = new HashMap(1);
+ HashMap<String,String> map = new HashMap<String,String>(1);
int i = filter.indexOf(':');
if (i == -1) // <service>.<algorithm>
map.put(filter, "");
@@ -553,10 +557,10 @@
if (querries == null || querries.isEmpty())
return getProviders();
- LinkedHashSet result = new LinkedHashSet(providers); // assume all
+ LinkedHashSet<Provider> result = new LinkedHashSet<Provider>(providers);
// assume all
int dot, ws;
String querry, service, algorithm, attribute, value;
- LinkedHashSet serviceProviders = new LinkedHashSet(); // preserve
insertion order
+ LinkedHashSet<Provider> serviceProviders = new LinkedHashSet<Provider>();
// preserve insertion order
for (Iterator i = querries.iterator(); i.hasNext(); )
{
querry = (String) i.next();
@@ -622,12 +626,12 @@
if (result.isEmpty())
return null;
- return (Provider[]) result.toArray(new Provider[result.size()]);
+ return result.toArray(new Provider[result.size()]);
}
private static void selectProviders(String svc, String algo, String attr,
String val, LinkedHashSet providerSet,
- LinkedHashSet result)
+ LinkedHashSet<Provider> result)
{
result.clear(); // ensure we start with an empty result set
for (Iterator i = providerSet.iterator(); i.hasNext(); )
PGP.sig
Description: This is a digitally signed message part
