summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-09-20 18:46:20 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-09-20 18:46:20 +0000
commit3baed5090a8b63218fd8a5808cd38caeb79a0f7d (patch)
treee3d5427d27e9ef1ebb9de69a3fd3639084d196d1 /gnu
parentd30cf1c6c0de86bac88773529f7071497ce18916 (diff)
downloadclasspath-3baed5090a8b63218fd8a5808cd38caeb79a0f7d.tar.gz
2005-09-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of generics-branch for 2005/09/07 - 2005/09/20 @ 10:05am GMT.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/CORBA/Connected_objects.java11
-rw-r--r--gnu/CORBA/ExceptionCreator.java6
-rw-r--r--gnu/CORBA/Poa/activeObjectMap.java11
-rw-r--r--gnu/CORBA/Version.java16
-rw-r--r--gnu/CORBA/gnuAny.java28
-rw-r--r--gnu/classpath/ByteArray.java112
-rw-r--r--gnu/classpath/jdwp/event/VmDeathEvent.java85
-rw-r--r--gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ClassTypeCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/EventRequestCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/MethodCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/StackFrameCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/StringReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java3
-rw-r--r--gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java13
-rw-r--r--gnu/java/awt/AWTUtilities.java9
-rw-r--r--gnu/java/awt/EmbeddedWindow.java6
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java2
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java26
-rw-r--r--gnu/java/awt/peer/gtk/GtkDialogPeer.java3
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java3
-rw-r--r--gnu/java/beans/decoder/BooleanHandler.java4
-rw-r--r--gnu/java/nio/channels/FileChannelImpl.java3
-rw-r--r--gnu/java/rmi/dgc/DGCImpl_Stub.java2
-rw-r--r--gnu/java/rmi/server/RMIObjectInputStream.java2
-rw-r--r--gnu/java/security/PolicyFile.java6
-rw-r--r--gnu/java/security/der/DERReader.java2
-rw-r--r--gnu/java/security/provider/Gnu.java10
-rw-r--r--gnu/java/security/x509/ext/BasicConstraints.java2
-rw-r--r--gnu/java/security/x509/ext/Extension.java2
-rw-r--r--gnu/javax/crypto/DiffieHellmanImpl.java170
-rw-r--r--gnu/javax/crypto/GnuDHPrivateKey.java90
-rw-r--r--gnu/javax/crypto/RSACipherImpl.java311
-rw-r--r--gnu/xml/aelfred2/JAXPFactory.java2
-rw-r--r--gnu/xml/dom/DomDocument.java50
-rw-r--r--gnu/xml/libxmlj/dom/GnomeDocument.java48
-rw-r--r--gnu/xml/pipeline/ValidationConsumer.java2
43 files changed, 957 insertions, 119 deletions
diff --git a/gnu/CORBA/Connected_objects.java b/gnu/CORBA/Connected_objects.java
index b7eefb133..ce5761007 100644
--- a/gnu/CORBA/Connected_objects.java
+++ b/gnu/CORBA/Connected_objects.java
@@ -90,17 +90,6 @@ public class Connected_objects
* applicable.
*/
public final java.lang.Object identity;
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof cObject)
- {
- cObject o = (cObject) other;
- return o.object.equals(object) && o.port == port;
- }
- else
- return false;
- }
}
/**
diff --git a/gnu/CORBA/ExceptionCreator.java b/gnu/CORBA/ExceptionCreator.java
index 8b7520505..abe309dc7 100644
--- a/gnu/CORBA/ExceptionCreator.java
+++ b/gnu/CORBA/ExceptionCreator.java
@@ -138,8 +138,8 @@ public class ExceptionCreator
* @param idl the exception idl name.
* @param input the stream to read from.
*
- * @return the loaded exception.
- * @return null if the helper class cannot be found.
+ * @return the loaded exception, or <code>null</code> if the helper class
+ * cannot be found.
*/
public static UserException readUserException(String idl, InputStream input)
{
@@ -187,7 +187,7 @@ public class ExceptionCreator
}
/**
- * Converts teh given IDL name to class name.
+ * Converts the given IDL name to class name.
*
* @param IDL the idl name.
*
diff --git a/gnu/CORBA/Poa/activeObjectMap.java b/gnu/CORBA/Poa/activeObjectMap.java
index 1354ba9c5..c6ba6512f 100644
--- a/gnu/CORBA/Poa/activeObjectMap.java
+++ b/gnu/CORBA/Poa/activeObjectMap.java
@@ -142,17 +142,6 @@ public class activeObjectMap
{
deactivated = state;
}
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof Obj)
- {
- Obj o = (Obj) other;
- return o.object.equals(object);
- }
- else
- return false;
- }
}
/**
diff --git a/gnu/CORBA/Version.java b/gnu/CORBA/Version.java
index 84f40bf4f..5a6eb5c25 100644
--- a/gnu/CORBA/Version.java
+++ b/gnu/CORBA/Version.java
@@ -70,8 +70,8 @@ public class Version
/**
* Create the version with the given version numbers.
*
- * @param major major number (0..255)
- * @param minor minor number (0..255)
+ * @param _major major number (0..255)
+ * @param _minor minor number (0..255)
*/
public Version(int _major, int _minor)
{
@@ -99,6 +99,15 @@ public class Version
Version that = (Version) other;
return same(that);
}
+
+ /**
+ * Get the hashcode, higher 8 bits being the major version and lower 8 bits
+ * the minor version.
+ */
+ public int hashCode()
+ {
+ return major << 8 | minor;
+ }
/**
* Read from the input stream, major number first.
@@ -166,7 +175,7 @@ public class Version
* Returs true if the given version is lower or equal to the
* version, specified by the provided minor and major version
* number. This means, the version, specified by these two numbers,
- * should be supported by teh current version.
+ * should be supported by the current version.
*
* @param a_major a major version number.
* @param a_minor a minor version number.
@@ -203,4 +212,5 @@ public class Version
throw new MARSHAL("IOException while writing message header");
}
}
+
}
diff --git a/gnu/CORBA/gnuAny.java b/gnu/CORBA/gnuAny.java
index 7e5ef3351..80946b046 100644
--- a/gnu/CORBA/gnuAny.java
+++ b/gnu/CORBA/gnuAny.java
@@ -62,19 +62,15 @@ import org.omg.CORBA.StringHolder;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodeHolder;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.ValueBaseHolder;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
-import java.io.IOException;
import java.io.Serializable;
-
import java.lang.reflect.Field;
-
import java.math.BigDecimal;
-
import java.util.Arrays;
+import java.util.zip.Adler32;
/**
* The implementation of {@link Any}.
@@ -207,6 +203,28 @@ public class gnuAny
return Arrays.equals(ba, bb);
}
+
+ /**
+ * Get the content - dependent hashcode.
+ */
+ public int hashCode()
+ {
+ if (has == null)
+ return type().kind().value();
+ else
+ {
+ Adler32 adler = new Adler32();
+
+ cdrBufOutput a = new cdrBufOutput();
+ a.setOrb(orb);
+ write_value(a);
+
+ adler.update(a.buffer.toByteArray());
+ adler.update(type().kind().value());
+
+ return (int) adler.getValue() & Integer.MAX_VALUE;
+ }
+ }
/**
* Delegates functionality to {@link #equal(Any)}.
diff --git a/gnu/classpath/ByteArray.java b/gnu/classpath/ByteArray.java
new file mode 100644
index 000000000..de088772f
--- /dev/null
+++ b/gnu/classpath/ByteArray.java
@@ -0,0 +1,112 @@
+/* ByteArray.java -- wrapper around a byte array, with nice toString output.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License along
+with GNU Classpath; if not, write to the
+
+ Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307
+ USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under terms
+of your choice, provided that you also meet, for each linked independent
+module, the terms and conditions of the license of that module. An
+independent module is a module which is not derived from or based on
+this library. If you modify this library, you may extend this exception
+to your version of the library, but you are not obligated to do so. If
+you do not wish to do so, delete this exception statement from your
+version. */
+
+
+package gnu.classpath;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public final class ByteArray
+{
+ private final byte[] value;
+
+ public ByteArray (final byte[] value)
+ {
+ this.value = value;
+ }
+
+ public byte[] getValue ()
+ {
+ return value;
+ }
+
+ public String toString ()
+ {
+ StringWriter str = new StringWriter ();
+ PrintWriter out = new PrintWriter (str);
+ int i = 0;
+ int len = value.length;
+ while (i < len)
+ {
+ out.print (formatInt (i, 16, 8));
+ out.print (" ");
+ int l = Math.min (16, len - i);
+ String s = toHexString (value, i, l, ' ');
+ out.print (s);
+ for (int j = 56 - (56 - s.length ()); j < 56; j++)
+ out.print (" ");
+ for (int j = 0; j < l; j++)
+ {
+ byte b = value[i+j];
+ if ((b & 0xFF) < 0x20 || (b & 0xFF) > 0x7E)
+ out.print (".");
+ else
+ out.print ((char) (b & 0xFF));
+ }
+ out.println ();
+ i += 16;
+ }
+ return str.toString ();
+ }
+
+ public static String toHexString (byte[] buf, int off, int len, char sep)
+ {
+ StringBuffer str = new StringBuffer();
+ for (int i = 0; i < len; i++)
+ {
+ str.append (Character.forDigit (buf[i+off] >>> 4 & 0x0F, 16));
+ str.append (Character.forDigit (buf[i+off] & 0x0F, 16));
+ if (i < len - 1)
+ str.append(sep);
+ }
+ return str.toString();
+ }
+
+ public static String formatInt (int value, int radix, int len)
+ {
+ String s = Integer.toString (value, radix);
+ StringBuffer buf = new StringBuffer ();
+ for (int j = 0; j < len - s.length(); j++)
+ buf.append ("0");
+ buf.append (s);
+ return buf.toString();
+ }
+}
diff --git a/gnu/classpath/jdwp/event/VmDeathEvent.java b/gnu/classpath/jdwp/event/VmDeathEvent.java
new file mode 100644
index 000000000..b0d9b6565
--- /dev/null
+++ b/gnu/classpath/jdwp/event/VmDeathEvent.java
@@ -0,0 +1,85 @@
+/* VmDeathEvent.java -- An event specifying that the VM has terminated
+ Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Event notifying the debugger that the virtual machine has terminated.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class VmDeathEvent
+ extends Event
+{
+ /**
+ * Constructs a <code>VmDeathEvent</code> object
+ *
+ * @param thread the initial thread
+ */
+ public VmDeathEvent ()
+ {
+ super (JdwpConstants.EventKind.VM_DEATH);
+ }
+
+ /**
+ * Returns a specific filtering parameter for this event.
+ * This event has no valid types.
+ *
+ * @param type the type of parameter desired
+ * @returns the desired parameter or <code>null</code>
+ */
+ public Object getParameter (Class type)
+ {
+ return null;
+ }
+
+ /**
+ * Writes out event-specific data
+ */
+ protected void _writeData (DataOutputStream outStream)
+ throws IOException
+ {
+ // no data (request ID done by VMIdManager)
+ }
+}
diff --git a/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
index 247021662..a9dc6cc81 100644
--- a/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
@@ -88,7 +88,8 @@ public class ArrayReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeLength(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java b/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java
index 8ae1b4508..b77c3a833 100644
--- a/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ArrayTypeCommandSet.java
@@ -82,7 +82,8 @@ public class ArrayTypeCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
public void executeNewInstance(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java
index 4e8e23ede..cc591b17d 100644
--- a/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ClassLoaderReferenceCommandSet.java
@@ -86,7 +86,8 @@ public class ClassLoaderReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
public void executeVisibleClasses(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java
index dcafa6f84..cfec20bc7 100644
--- a/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ClassObjectReferenceCommandSet.java
@@ -79,7 +79,8 @@ public class ClassObjectReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
public void executeReflectedType(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java b/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
index ff6010e59..f60da7b70 100644
--- a/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
@@ -95,7 +95,8 @@ public class ClassTypeCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeSuperclass(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/EventRequestCommandSet.java b/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
index 389b2d349..e4b1b602e 100644
--- a/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
+++ b/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
@@ -102,7 +102,8 @@ public class EventRequestCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeSet(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/MethodCommandSet.java b/gnu/classpath/jdwp/processor/MethodCommandSet.java
index b5db664e4..53308d7c1 100644
--- a/gnu/classpath/jdwp/processor/MethodCommandSet.java
+++ b/gnu/classpath/jdwp/processor/MethodCommandSet.java
@@ -94,7 +94,8 @@ public class MethodCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeLineTable(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
index 23a64c341..ef421ea5b 100644
--- a/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
@@ -106,7 +106,8 @@ public class ObjectReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeReferenceType(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java b/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
index b9944f7d9..7338480fc 100644
--- a/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
@@ -128,7 +128,8 @@ public class ReferenceTypeCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeSignature(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/StackFrameCommandSet.java b/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
index 480f4ca28..7890a8e4b 100644
--- a/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
+++ b/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
@@ -91,7 +91,8 @@ public class StackFrameCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeGetValues(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java b/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java
index 8f5bc685c..13fde0ac7 100644
--- a/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/StringReferenceCommandSet.java
@@ -84,7 +84,8 @@ public class StringReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeValue(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
index 8a11195a7..ba36251f6 100644
--- a/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java
@@ -85,7 +85,8 @@ public class ThreadGroupReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeName(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java b/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
index 73643b6a8..559e405b6 100644
--- a/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
+++ b/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
@@ -118,7 +118,8 @@ public class ThreadReferenceCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return true;
+
+ return false;
}
private void executeName(ByteBuffer bb, DataOutputStream os)
diff --git a/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java b/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
index b83406873..6bdb23681 100644
--- a/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
+++ b/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
@@ -67,7 +67,7 @@ public class VirtualMachineCommandSet
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
throws JdwpException
{
- boolean keepRunning = true;
+ boolean shutdown = false;
try
{
switch (command)
@@ -91,7 +91,7 @@ public class VirtualMachineCommandSet
executeIDsizes(bb, os);
break;
case JdwpConstants.CommandSet.VirtualMachine.DISPOSE:
- keepRunning = false;
+ shutdown = true;
executeDispose(bb, os);
break;
case JdwpConstants.CommandSet.VirtualMachine.SUSPEND:
@@ -101,7 +101,7 @@ public class VirtualMachineCommandSet
executeResume(bb, os);
break;
case JdwpConstants.CommandSet.VirtualMachine.EXIT:
- keepRunning = false;
+ shutdown = true;
executeExit(bb, os);
break;
case JdwpConstants.CommandSet.VirtualMachine.CREATE_STRING:
@@ -145,7 +145,8 @@ public class VirtualMachineCommandSet
// So if we throw an IOException we're in serious trouble
throw new JdwpInternalErrorException(ex);
}
- return keepRunning;
+
+ return shutdown;
}
private void executeVersion(ByteBuffer bb, DataOutputStream os)
@@ -164,8 +165,8 @@ public class VirtualMachineCommandSet
String vmVersion = props.getProperty("java.version");
String vmName = props.getProperty("java.vm.name");
JdwpString.writeString(os, description);
- os.write(jdwpMajor);
- os.write(jdwpMinor);
+ os.writeInt(jdwpMajor);
+ os.writeInt(jdwpMinor);
JdwpString.writeString(os, vmName);
JdwpString.writeString(os, vmVersion);
}
diff --git a/gnu/java/awt/AWTUtilities.java b/gnu/java/awt/AWTUtilities.java
index af1fc13ca..ca7b55118 100644
--- a/gnu/java/awt/AWTUtilities.java
+++ b/gnu/java/awt/AWTUtilities.java
@@ -592,9 +592,12 @@ public class AWTUtilities
if (destination == null)
destination = getRoot(source);
-
- convertPointToScreen(pt, source);
- convertPointFromScreen(pt, destination);
+
+ if (source.isShowing() && destination.isShowing())
+ {
+ convertPointToScreen(pt, source);
+ convertPointFromScreen(pt, destination);
+ }
return pt;
}
diff --git a/gnu/java/awt/EmbeddedWindow.java b/gnu/java/awt/EmbeddedWindow.java
index 08b2140f4..99f90c9f8 100644
--- a/gnu/java/awt/EmbeddedWindow.java
+++ b/gnu/java/awt/EmbeddedWindow.java
@@ -98,13 +98,11 @@ public class EmbeddedWindow extends Frame
}
catch (IllegalAccessException e)
{
- throw new RuntimeException
- ("couldn't set java.awt.Component.peer field");
+ throw new AssertionError (e);
}
catch (NoSuchFieldException e)
{
- throw new RuntimeException
- ("couldn't set java.awt.Component.peer field");
+ throw new AssertionError (e);
}
super.addNotify();
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index 160602b03..7d8531bf1 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -116,6 +116,8 @@ public class GdkGraphics extends Graphics
{
this.component = component;
font = component.awtComponent.getFont ();
+ if (font == null)
+ font = new Font ("Dialog", Font.PLAIN, 12);
color = Color.black;
if (component.isRealized ())
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 6d9aabf77..687c0c109 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -101,7 +101,7 @@ public class GdkGraphics2D extends Graphics2D
static
{
if (! Configuration.GTK_CAIRO_ENABLED)
- throw new Error("Grahics2D not implemented. "
+ throw new Error("Graphics2D not implemented. "
+ "Cairo was not found or disabled at configure time");
if (Configuration.INIT_LOAD_LIBRARY)
@@ -157,8 +157,19 @@ public class GdkGraphics2D extends Graphics2D
return new GdkGraphics2D(width, height);
}
+ private void fail_g2d ()
+ {
+ System.err.println ("Attempted to instantiate GdkGraphics2D"
+ + " but Graphics2D not enabled. Try again with"
+ + " -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D");
+ System.exit (1);
+ }
+
GdkGraphics2D(GdkGraphics2D g)
{
+ if (!GtkToolkit.useGraphics2D ())
+ fail_g2d ();
+
paint = g.paint;
stroke = g.stroke;
setRenderingHints(g.hints);
@@ -200,6 +211,9 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(int width, int height)
{
+ if (!GtkToolkit.useGraphics2D ())
+ fail_g2d ();
+
initState(width, height);
setColor(Color.black);
@@ -215,6 +229,9 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(GtkComponentPeer component)
{
+ if (!GtkToolkit.useGraphics2D ())
+ fail_g2d ();
+
this.component = component;
if (component.isRealized())
@@ -992,8 +1009,11 @@ public class GdkGraphics2D extends Graphics2D
if (clip == null)
{
// Reset clipping.
- Dimension d = component.awtComponent.getSize();
- setClip(0, 0, d.width, d.height);
+ if (component != null)
+ {
+ Dimension d = component.awtComponent.getSize();
+ setClip(0, 0, d.width, d.height);
+ }
}
else
{
diff --git a/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
index c2cbc37dc..cfb54d6e9 100644
--- a/gnu/java/awt/peer/gtk/GtkDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -83,7 +83,8 @@ public class GtkDialogPeer extends GtkWindowPeer
void create ()
{
// Create a decorated dialog window.
- create (GDK_WINDOW_TYPE_HINT_DIALOG, true);
+ create (GDK_WINDOW_TYPE_HINT_DIALOG,
+ !((Dialog) awtComponent).isUndecorated ());
Dialog dialog = (Dialog) awtComponent;
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index 6eb90ffa0..99cca0cff 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -168,7 +168,8 @@ public class GtkFramePeer extends GtkWindowPeer
void create ()
{
// Create a normal decorated window.
- create (GDK_WINDOW_TYPE_HINT_NORMAL, true);
+ create (GDK_WINDOW_TYPE_HINT_NORMAL,
+ !((Frame) awtComponent).isUndecorated ());
Frame frame = (Frame) awtComponent;
diff --git a/gnu/java/beans/decoder/BooleanHandler.java b/gnu/java/beans/decoder/BooleanHandler.java
index a34fe346e..a675e8c90 100644
--- a/gnu/java/beans/decoder/BooleanHandler.java
+++ b/gnu/java/beans/decoder/BooleanHandler.java
@@ -57,10 +57,10 @@ class BooleanHandler extends SimpleHandler
protected Object parse(String number) throws AssemblyException
{
if (number.equals("true"))
- return new Boolean(true);
+ return Boolean.TRUE;
if (number.equals("false"))
- return new Boolean(false);
+ return Boolean.FALSE;
throw new AssemblyException(new IllegalArgumentException("Element contained no valid boolean value."));
}
diff --git a/gnu/java/nio/channels/FileChannelImpl.java b/gnu/java/nio/channels/FileChannelImpl.java
index 0ee5d3fc2..466f3dd55 100644
--- a/gnu/java/nio/channels/FileChannelImpl.java
+++ b/gnu/java/nio/channels/FileChannelImpl.java
@@ -175,7 +175,8 @@ public final class FileChannelImpl extends FileChannel
*/
protected void finalize() throws IOException
{
- this.close();
+ if (fd != -1)
+ close();
}
public int read (ByteBuffer dst) throws IOException
diff --git a/gnu/java/rmi/dgc/DGCImpl_Stub.java b/gnu/java/rmi/dgc/DGCImpl_Stub.java
index b1e086a73..9f18d129e 100644
--- a/gnu/java/rmi/dgc/DGCImpl_Stub.java
+++ b/gnu/java/rmi/dgc/DGCImpl_Stub.java
@@ -81,7 +81,7 @@ public final class DGCImpl_Stub
public void clean(java.rmi.server.ObjID[] $param_0, long $param_1, java.rmi.dgc.VMID $param_2, boolean $param_3) throws java.rmi.RemoteException {
try {
if (useNewInvoke) {
- ref.invoke(this, $method_clean_0, new java.lang.Object[] {$param_0, new java.lang.Long($param_1), $param_2, new java.lang.Boolean($param_3)}, -5803803475088455571L);
+ ref.invoke(this, $method_clean_0, new java.lang.Object[] {$param_0, new java.lang.Long($param_1), $param_2, Boolean.valueOf($param_3)}, -5803803475088455571L);
}
else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject)this, operations, 0, interfaceHash);
diff --git a/gnu/java/rmi/server/RMIObjectInputStream.java b/gnu/java/rmi/server/RMIObjectInputStream.java
index 888b30bf6..587d57fc7 100644
--- a/gnu/java/rmi/server/RMIObjectInputStream.java
+++ b/gnu/java/rmi/server/RMIObjectInputStream.java
@@ -102,7 +102,7 @@ protected Class resolveProxyClass(String intfs[])
protected Object readValue(Class valueClass) throws IOException, ClassNotFoundException {
if(valueClass.isPrimitive()){
if(valueClass == Boolean.TYPE)
- return new Boolean(readBoolean());
+ return Boolean.valueOf(readBoolean());
if(valueClass == Byte.TYPE)
return new Byte(readByte());
if(valueClass == Character.TYPE)
diff --git a/gnu/java/security/PolicyFile.java b/gnu/java/security/PolicyFile.java
index c6a3061ea..3064f041b 100644
--- a/gnu/java/security/PolicyFile.java
+++ b/gnu/java/security/PolicyFile.java
@@ -533,7 +533,7 @@ public final class PolicyFile extends Policy
if (clazz == null)
{
currentPerms.add(new UnresolvedPermission(className,
- null, null, (Certificate[]) currentCerts.toArray(new Certificate[0])));
+ null, null, (Certificate[]) currentCerts.toArray(new Certificate[currentCerts.size()])));
continue;
}
try
@@ -555,7 +555,7 @@ public final class PolicyFile extends Policy
if (clazz == null)
{
currentPerms.add(new UnresolvedPermission(className,
- target, null, (Certificate[]) currentCerts.toArray(new Certificate[0])));
+ target, null, (Certificate[]) currentCerts.toArray(new Certificate[currentCerts.size()])));
continue;
}
try
@@ -598,7 +598,7 @@ public final class PolicyFile extends Policy
if (clazz == null)
{
currentPerms.add(new UnresolvedPermission(className,
- target, action, (Certificate[]) currentCerts.toArray(new Certificate[0])));
+ target, action, (Certificate[]) currentCerts.toArray(new Certificate[currentCerts.size()])));
continue;
}
else
diff --git a/gnu/java/security/der/DERReader.java b/gnu/java/security/der/DERReader.java
index cb07f1432..09ec1e2df 100644
--- a/gnu/java/security/der/DERReader.java
+++ b/gnu/java/security/der/DERReader.java
@@ -389,7 +389,7 @@ public class DERReader implements DER
Integer.parseInt(str.substring( 4, 6)), // day
Integer.parseInt(str.substring( 6, 8)), // hour
Integer.parseInt(str.substring( 8, 10))); // minute
- if (date.length() == 12);
+ if (date.length() == 12)
calendar.set(Calendar.SECOND,
Integer.parseInt(str.substring(10, 12)));
}
diff --git a/gnu/java/security/provider/Gnu.java b/gnu/java/security/provider/Gnu.java
index 849f63c16..47c774538 100644
--- a/gnu/java/security/provider/Gnu.java
+++ b/gnu/java/security/provider/Gnu.java
@@ -46,7 +46,7 @@ public final class Gnu extends Provider
{
public Gnu()
{
- super("GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores");
+ super("GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores, Diffie-Hellman key agreement");
AccessController.doPrivileged (new PrivilegedAction()
{
@@ -161,6 +161,14 @@ public final class Gnu extends Provider
// CertStore
put("CertStore.Collection", CollectionCertStoreImpl.class.getName());
+ // KeyAgreement
+ put("KeyAgreement.DiffieHellman", gnu.javax.crypto.DiffieHellmanImpl.class.getName());
+ put("Alg.Alias.KeyAgreement.DH", "DiffieHellman");
+
+ // Cipher
+ put("Cipher.RSAES-PKCS1-v1_5", gnu.javax.crypto.RSACipherImpl.class.getName());
+ put("Alg.Alias.Cipher.RSA", "RSAES-PKCS1-v1_5");
+
return null;
}
});
diff --git a/gnu/java/security/x509/ext/BasicConstraints.java b/gnu/java/security/x509/ext/BasicConstraints.java
index 00f7a6ed2..d8f5c6158 100644
--- a/gnu/java/security/x509/ext/BasicConstraints.java
+++ b/gnu/java/security/x509/ext/BasicConstraints.java
@@ -112,7 +112,7 @@ public class BasicConstraints extends Extension.Value
if (encoded == null)
{
List bc = new ArrayList (2);
- bc.add (new DERValue (DER.BOOLEAN, new Boolean (ca)));
+ bc.add (new DERValue (DER.BOOLEAN, Boolean.valueOf (ca)));
if (pathLenConstraint >= 0)
bc.add (new DERValue (DER.INTEGER,
BigInteger.valueOf ((long) pathLenConstraint)));
diff --git a/gnu/java/security/x509/ext/Extension.java b/gnu/java/security/x509/ext/Extension.java
index 5ca9ac3a9..ee2aa073a 100644
--- a/gnu/java/security/x509/ext/Extension.java
+++ b/gnu/java/security/x509/ext/Extension.java
@@ -232,7 +232,7 @@ public class Extension
{
List ext = new ArrayList (3);
ext.add (new DERValue (DER.OBJECT_IDENTIFIER, oid));
- ext.add (new DERValue (DER.BOOLEAN, new Boolean (critical)));
+ ext.add (new DERValue (DER.BOOLEAN, Boolean.valueOf (critical)));
ext.add (new DERValue (DER.OCTET_STRING, value.getEncoded()));
return new DERValue (DER.CONSTRUCTED|DER.SEQUENCE, ext);
}
diff --git a/gnu/javax/crypto/DiffieHellmanImpl.java b/gnu/javax/crypto/DiffieHellmanImpl.java
new file mode 100644
index 000000000..9052feb4f
--- /dev/null
+++ b/gnu/javax/crypto/DiffieHellmanImpl.java
@@ -0,0 +1,170 @@
+/* DiffieHellmanImpl.java -- implementation of the Diffie-Hellman key agreement.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto;
+
+import gnu.java.security.provider.GnuDHPublicKey;
+
+import java.math.BigInteger;
+
+import java.security.Key;
+import java.security.InvalidKeyException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+import javax.crypto.KeyAgreementSpi;
+import javax.crypto.SecretKey;
+import javax.crypto.interfaces.DHPrivateKey;
+import javax.crypto.interfaces.DHPublicKey;
+import javax.crypto.spec.DHParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * The Diffie-Hellman key agreement.
+ *
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public final class DiffieHellmanImpl extends KeyAgreementSpi
+{
+
+ /** The private key being used for this agreement. */
+ private DHPrivateKey key;
+
+ /** The random-number generator used to generate secrets. */
+ private SecureRandom random;
+
+ /** The current result. */
+ private BigInteger result;
+
+ /** True if the caller told us we are done. */
+ private boolean last_phase_done;
+
+ /** Trivial default constructor. */
+ public DiffieHellmanImpl ()
+ {
+ key = null;
+ random = null;
+ result = null;
+ last_phase_done = false;
+ }
+
+ // KeyAgreementSpi methods.
+
+ protected Key engineDoPhase (final Key incoming, final boolean lastPhase)
+ throws InvalidKeyException
+ {
+ if (key == null)
+ throw new IllegalStateException ("not initialized");
+ if (last_phase_done)
+ throw new IllegalStateException ("last phase already done");
+
+ if (!(incoming instanceof DHPublicKey))
+ throw new InvalidKeyException ("expecting javax.crypto.interfaces.DHPublicKey");
+ DHPublicKey pub = (DHPublicKey) incoming;
+ DHParameterSpec s1 = key.getParams();
+ DHParameterSpec s2 = key.getParams();
+ if (!s1.getG().equals (s2.getG())
+ || !s1.getP().equals (s2.getP())
+ || s1.getL() != s2.getL())
+ throw new InvalidKeyException ("supplied key is not compatible");
+
+ BigInteger randval = new BigInteger (s1.getL(), random);
+ BigInteger out = s1.getG().modPow (key.getX(), s1.getP());
+ if (result == null)
+ result = s1.getG();
+ result = result.modPow (pub.getY(), s1.getP());
+ if (lastPhase)
+ {
+ last_phase_done = true;
+ return null;
+ }
+ return new GnuDHPublicKey (s1, out, null);
+ }
+
+ protected byte[] engineGenerateSecret ()
+ {
+ if (result == null || !last_phase_done)
+ throw new IllegalStateException ("not finished");
+
+ byte[] buf = result.toByteArray ();
+ if (buf[0] == 0x00)
+ {
+ byte[] buf2 = new byte[buf.length - 1];
+ System.arraycopy (buf, 1, buf2, 0, buf2.length);
+ buf = buf2;
+ }
+ return buf;
+ }
+
+ protected int engineGenerateSecret (final byte[] secret, final int offset)
+ {
+ byte[] s = engineGenerateSecret();
+ System.arraycopy (s, 0, secret, offset, s.length);
+ return s.length;
+ }
+
+ protected SecretKey engineGenerateSecret (final String algorithm)
+ throws InvalidKeyException
+ {
+ byte[] s = engineGenerateSecret();
+ return new SecretKeySpec (s, algorithm);
+ }
+
+ protected void engineInit (final Key key, final SecureRandom random)
+ throws InvalidKeyException
+ {
+ if (!(key instanceof DHPrivateKey))
+ throw new InvalidKeyException ("not a javax.crypto.interfaces.DHPrivateKey");
+ this.key = (DHPrivateKey) key;
+ if (random != null)
+ this.random = random;
+ else if (this.random == null)
+ this.random = new SecureRandom();
+ result = null;
+ last_phase_done = false;
+ }
+
+ protected void engineInit (final Key key, final AlgorithmParameterSpec params,
+ final SecureRandom random)
+ throws InvalidKeyException
+ {
+ engineInit (key, random);
+ }
+}
diff --git a/gnu/javax/crypto/GnuDHPrivateKey.java b/gnu/javax/crypto/GnuDHPrivateKey.java
new file mode 100644
index 000000000..25af3e5a8
--- /dev/null
+++ b/gnu/javax/crypto/GnuDHPrivateKey.java
@@ -0,0 +1,90 @@
+/* GnuDHPrivateKey.java -- a Diffie-Hellman private key.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto;
+
+import java.math.BigInteger;
+
+import javax.crypto.interfaces.DHKey;
+import javax.crypto.interfaces.DHPrivateKey;
+import javax.crypto.spec.DHParameterSpec;
+
+/**
+ * A Diffie-Hellman private key.
+ *
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class GnuDHPrivateKey implements DHPrivateKey
+{
+
+ private final BigInteger x;
+ private final DHParameterSpec params;
+
+ public GnuDHPrivateKey (final BigInteger x, final DHParameterSpec params)
+ {
+ x.getClass ();
+ params.getClass ();
+ this.x = x;
+ this.params = params;
+ }
+
+ public DHParameterSpec getParams()
+ {
+ return params;
+ }
+
+ public String getAlgorithm()
+ {
+ return "DiffieHellman";
+ }
+
+ public String getFormat ()
+ {
+ return "NONE";
+ }
+
+ public byte[] getEncoded ()
+ {
+ return null;
+ }
+
+ public BigInteger getX ()
+ {
+ return x;
+ }
+}
diff --git a/gnu/javax/crypto/RSACipherImpl.java b/gnu/javax/crypto/RSACipherImpl.java
new file mode 100644
index 000000000..a92fa361b
--- /dev/null
+++ b/gnu/javax/crypto/RSACipherImpl.java
@@ -0,0 +1,311 @@
+/* DiffieHellmanImpl.java -- implementation of the Diffie-Hellman key agreement.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.crypto;
+
+import gnu.classpath.ByteArray;
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+
+import java.math.BigInteger;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+import java.security.interfaces.RSAKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPublicKey;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+import java.util.logging.Logger;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherSpi;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.ShortBufferException;
+
+public class RSACipherImpl extends CipherSpi
+{
+ private static final Logger logger = SystemLogger.SYSTEM;
+
+ private static final byte[] EMPTY = new byte[0];
+ private int opmode = -1;
+ private RSAPrivateKey decipherKey = null;
+ private RSAPublicKey blindingKey = null;
+ private RSAPublicKey encipherKey = null;
+ private SecureRandom random = null;
+ private byte[] dataBuffer = null;
+ private int pos = 0;
+
+ protected void engineSetMode (String mode) throws NoSuchAlgorithmException
+ {
+ throw new NoSuchAlgorithmException ("only one mode available");
+ }
+
+ protected void engineSetPadding (String pad) throws NoSuchPaddingException
+ {
+ throw new NoSuchPaddingException ("only one padding available");
+ }
+
+ protected int engineGetBlockSize ()
+ {
+ return 1;
+ }
+
+ protected int engineGetOutputSize (int inputLen)
+ {
+ int outputLen = 0;
+ if (decipherKey != null)
+ {
+ outputLen = (decipherKey.getModulus ().bitLength () + 7) / 8;
+ }
+ else if (encipherKey != null)
+ {
+ outputLen = (encipherKey.getModulus ().bitLength () + 7) / 8;
+ }
+ else
+ throw new IllegalStateException ("not initialized");
+ if (inputLen > outputLen)
+ throw new IllegalArgumentException ("not configured to encode " + inputLen
+ + "bytes; at most " + outputLen);
+ return outputLen;
+ }
+
+ protected int engineGetKeySize (final Key key) throws InvalidKeyException
+ {
+ if (!(key instanceof RSAKey))
+ throw new InvalidKeyException ("not an RSA key");
+ return ((RSAKey) key).getModulus ().bitLength ();
+ }
+
+ protected byte[] engineGetIV ()
+ {
+ return null;
+ }
+
+ protected AlgorithmParameters engineGetParameters()
+ {
+ return null;
+ }
+
+ protected void engineInit (int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException
+ {
+ int outputLen = 0;
+ if (opmode == Cipher.ENCRYPT_MODE)
+ {
+ if (!(key instanceof RSAPublicKey))
+ throw new InvalidKeyException ("expecting a RSAPublicKey");
+ encipherKey = (RSAPublicKey) key;
+ decipherKey = null;
+ blindingKey = null;
+ outputLen = (encipherKey.getModulus ().bitLength () + 7) / 8;
+ }
+ else if (opmode == Cipher.DECRYPT_MODE)
+ {
+ if (key instanceof RSAPrivateKey)
+ {
+ decipherKey = (RSAPrivateKey) key;
+ encipherKey = null;
+ blindingKey = null;
+ outputLen = (decipherKey.getModulus ().bitLength () + 7) / 8;
+ }
+ else if (key instanceof RSAPublicKey)
+ {
+ if (decipherKey == null)
+ throw new IllegalStateException ("must configure decryption key first");
+ if (!decipherKey.getModulus ().equals (((RSAPublicKey) key).getModulus ()))
+ throw new InvalidKeyException ("blinding key is not compatible");
+ blindingKey = (RSAPublicKey) key;
+ return;
+ }
+ else
+ throw new InvalidKeyException ("expecting either an RSAPrivateKey or an RSAPublicKey (for blinding)");
+ }
+ else
+ throw new IllegalArgumentException ("only encryption and decryption supported");
+ this.random = random;
+ this.opmode = opmode;
+ pos = 0;
+ dataBuffer = new byte[outputLen];
+ }
+
+ protected void engineInit (int opmode, Key key, AlgorithmParameterSpec spec, SecureRandom random)
+ throws InvalidKeyException
+ {
+ engineInit (opmode, key, random);
+ }
+
+ protected void engineInit (int opmode, Key key, AlgorithmParameters params, SecureRandom random)
+ throws InvalidKeyException
+ {
+ engineInit (opmode, key, random);
+ }
+
+ protected byte[] engineUpdate (byte[] in, int offset, int length)
+ {
+ if (opmode != Cipher.ENCRYPT_MODE && opmode != Cipher.DECRYPT_MODE)
+ throw new IllegalStateException ("not initialized");
+ System.arraycopy (in, offset, dataBuffer, pos, length);
+ pos += length;
+ return EMPTY;
+ }
+
+ protected int engineUpdate (byte[] in, int offset, int length, byte[] out, int outOffset)
+ {
+ engineUpdate (in, offset, length);
+ return 0;
+ }
+
+ protected byte[] engineDoFinal (byte[] in, int offset, int length)
+ throws IllegalBlockSizeException, BadPaddingException
+ {
+ engineUpdate (in, offset, length);
+ if (opmode == Cipher.DECRYPT_MODE)
+ {
+ if (pos < dataBuffer.length)
+ throw new IllegalBlockSizeException ("expecting exactly " + dataBuffer.length + " bytes");
+ BigInteger enc = new BigInteger (1, dataBuffer);
+ byte[] dec = rsaDecrypt (enc);
+ logger.log (Component.CRYPTO, "RSA: decryption produced\n{0}",
+ new ByteArray (dec));
+ if (dec[0] != 0x02)
+ throw new BadPaddingException ("expected padding type 2");
+ int i;
+ for (i = 1; i < dec.length && dec[i] != 0x00; i++);
+ int len = dec.length - i;
+ byte[] result = new byte[len];
+ System.arraycopy (dec, i, result, 0, len);
+ pos = 0;
+ return result;
+ }
+ else
+ {
+ offset = dataBuffer.length - pos;
+ if (offset < 3)
+ throw new IllegalBlockSizeException ("input is too large to encrypt");
+ byte[] dec = new byte[dataBuffer.length];
+ dec[0] = 0x02;
+ if (random == null)
+ random = new SecureRandom ();
+ byte[] pad = new byte[offset - 2];
+ random.nextBytes (pad);
+ for (int i = 0; i < pad.length; i++)
+ if (pad[i] == 0)
+ pad[i] = 1;
+ System.arraycopy (pad, 0, dec, 1, pad.length);
+ dec[dec.length - pos] = 0x00;
+ System.arraycopy (dataBuffer, 0, dec, offset, pos);
+ logger.log (Component.CRYPTO, "RSA: produced padded plaintext\n{0}",
+ new ByteArray (dec));
+ BigInteger x = new BigInteger (1, dec);
+ BigInteger y = x.modPow (encipherKey.getPublicExponent (),
+ encipherKey.getModulus ());
+ byte[] enc = y.toByteArray ();
+ if (enc[0] == 0x00)
+ {
+ byte[] tmp = new byte[enc.length - 1];
+ System.arraycopy (enc, 1, tmp, 0, tmp.length);
+ enc = tmp;
+ }
+ pos = 0;
+ return enc;
+ }
+ }
+
+ protected int engineDoFinal (byte[] out, int offset)
+ throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
+ {
+ byte[] result = engineDoFinal (EMPTY, 0, 0);
+ if (out.length - offset < result.length)
+ throw new ShortBufferException ("need " + result.length + ", have "
+ + (out.length - offset));
+ System.arraycopy (result, 0, out, offset, result.length);
+ return result.length;
+ }
+
+ protected int engineDoFinal (final byte[] input, final int offset, final int length,
+ final byte[] output, final int outputOffset)
+ throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
+ {
+ byte[] result = engineDoFinal (input, offset, length);
+ if (output.length - outputOffset < result.length)
+ throw new ShortBufferException ("need " + result.length + ", have "
+ + (output.length - outputOffset));
+ System.arraycopy (result, 0, output, outputOffset, result.length);
+ return result.length;
+ }
+
+ /**
+ * Decrypts the ciphertext, employing RSA blinding if possible.
+ */
+ private byte[] rsaDecrypt (BigInteger enc)
+ {
+ if (random == null)
+ random = new SecureRandom ();
+ BigInteger n = decipherKey.getModulus ();
+ BigInteger r = null;
+ BigInteger pubExp = null;
+ if (blindingKey != null)
+ pubExp = blindingKey.getPublicExponent ();
+ if (pubExp != null && (decipherKey instanceof RSAPrivateCrtKey))
+ pubExp = ((RSAPrivateCrtKey) decipherKey).getPublicExponent ();
+ if (pubExp != null)
+ {
+ r = new BigInteger (n.bitLength () - 1, random);
+ enc = r.modPow (pubExp, n).multiply (enc).mod (n);
+ }
+
+ BigInteger dec = enc.modPow (decipherKey.getPrivateExponent (), n);
+
+ if (pubExp != null)
+ {
+ dec = dec.multiply (r.modInverse (n)).mod (n);
+ }
+
+ return dec.toByteArray ();
+ }
+}
diff --git a/gnu/xml/aelfred2/JAXPFactory.java b/gnu/xml/aelfred2/JAXPFactory.java
index 37e8cc9c1..011ca3c6a 100644
--- a/gnu/xml/aelfred2/JAXPFactory.java
+++ b/gnu/xml/aelfred2/JAXPFactory.java
@@ -109,7 +109,7 @@ public final class JAXPFactory
// (flags can't necessarily be set before parsing)
new JaxpParser().getXMLReader().setFeature(name, value);
- flags.put(name, new Boolean(value));
+ flags.put(name, Boolean.valueOf(value));
}
catch (SAXNotRecognizedException e)
{
diff --git a/gnu/xml/dom/DomDocument.java b/gnu/xml/dom/DomDocument.java
index dc476b582..29b8dc72e 100644
--- a/gnu/xml/dom/DomDocument.java
+++ b/gnu/xml/dom/DomDocument.java
@@ -210,13 +210,15 @@ public class DomDocument
*/
public Element getElementById(String id)
{
- DomDoctype doctype = (DomDoctype) getDoctype();
-
- if (doctype == null || !doctype.hasIds()
- || id == null || id.length() == 0)
+ if (id == null || id.length() == 0)
{
return null;
}
+ DomDoctype doctype = (DomDoctype) getDoctype();
+ if (doctype != null && !doctype.hasIds())
+ {
+ doctype = null;
+ }
// yes, this is linear in size of document.
// it'd be easy enough to maintain a hashtable.
@@ -233,25 +235,39 @@ public class DomDocument
if (current.getNodeType() == ELEMENT_NODE)
{
DomElement element = (DomElement) current;
- DTDElementTypeInfo info =
- doctype.getElementTypeInfo(current.getNodeName());
- if (info != null &&
- id.equals(element.getAttribute(info.idAttrName)))
- {
- return element;
- }
- else if (element.userIdAttrs != null)
+ if (doctype != null)
{
- for (Iterator i = element.userIdAttrs.iterator();
- i.hasNext(); )
+ DTDElementTypeInfo info =
+ doctype.getElementTypeInfo(current.getNodeName());
+ if (info != null &&
+ id.equals(element.getAttribute(info.idAttrName)))
{
- Node idAttr = (Node) i.next();
- if (id.equals(idAttr.getNodeValue()))
+ return element;
+ }
+ else if (element.userIdAttrs != null)
+ {
+ for (Iterator i = element.userIdAttrs.iterator();
+ i.hasNext(); )
{
- return element;
+ Node idAttr = (Node) i.next();
+ if (id.equals(idAttr.getNodeValue()))
+ {
+ return element;
+ }
}
}
}
+ // xml:id
+ String xmlId = element.getAttribute("xml:id");
+ if (xmlId == null)
+ {
+ xmlId = element.getAttributeNS(XMLConstants.XML_NS_URI,
+ "id");
+ }
+ if (id.equals(xmlId))
+ {
+ return element;
+ }
}
// descend?
diff --git a/gnu/xml/libxmlj/dom/GnomeDocument.java b/gnu/xml/libxmlj/dom/GnomeDocument.java
index 3706fba84..03420c463 100644
--- a/gnu/xml/libxmlj/dom/GnomeDocument.java
+++ b/gnu/xml/libxmlj/dom/GnomeDocument.java
@@ -376,31 +376,31 @@ public class GnomeDocument
name = name.toLowerCase();
if ("canonical-form".equals(name))
{
- return new Boolean(canonicalForm);
+ return Boolean.valueOf(canonicalForm);
}
else if ("cdata-sections".equals(name))
{
- return new Boolean(cdataSections);
+ return Boolean.valueOf(cdataSections);
}
else if ("check-character-normalization".equals(name))
{
- return new Boolean(checkCharacterNormalization);
+ return Boolean.valueOf(checkCharacterNormalization);
}
else if ("comments".equals(name))
{
- return new Boolean(comments);
+ return Boolean.valueOf(comments);
}
else if ("datatype-normalization".equals(name))
{
- return new Boolean(datatypeNormalization);
+ return Boolean.valueOf(datatypeNormalization);
}
else if ("element-content-whitespace".equals(name))
{
- return new Boolean(elementContentWhitespace);
+ return Boolean.valueOf(elementContentWhitespace);
}
else if ("entities".equals(name))
{
- return new Boolean(entities);
+ return Boolean.valueOf(entities);
}
else if ("error-handler".equals(name))
{
@@ -408,43 +408,43 @@ public class GnomeDocument
}
else if ("infoset".equals(name))
{
- return new Boolean(!validateIfSchema &&
- !entities &&
- !datatypeNormalization &&
- !cdataSections &&
- namespaceDeclarations &&
- wellFormed &&
- elementContentWhitespace &&
- comments &&
- namespaces);
+ return Boolean.valueOf(!validateIfSchema &&
+ !entities &&
+ !datatypeNormalization &&
+ !cdataSections &&
+ namespaceDeclarations &&
+ wellFormed &&
+ elementContentWhitespace &&
+ comments &&
+ namespaces);
}
else if ("namespaces".equals(name))
{
- return new Boolean(namespaces);
+ return Boolean.valueOf(namespaces);
}
else if ("namespace-declarations".equals(name))
{
- return new Boolean(namespaceDeclarations);
+ return Boolean.valueOf(namespaceDeclarations);
}
else if ("normalize-characters".equals(name))
{
- return new Boolean(normalizeCharacters);
+ return Boolean.valueOf(normalizeCharacters);
}
else if ("split-cdata-sections".equals(name))
{
- return new Boolean(splitCdataSections);
+ return Boolean.valueOf(splitCdataSections);
}
else if ("validate".equals(name))
{
- return new Boolean(validate);
+ return Boolean.valueOf(validate);
}
else if ("validate-if-schema".equals(name))
{
- return new Boolean(validateIfSchema);
+ return Boolean.valueOf(validateIfSchema);
}
else if ("well-formed".equals(name))
{
- return new Boolean(wellFormed);
+ return Boolean.valueOf(wellFormed);
}
else
{
@@ -497,7 +497,7 @@ public class GnomeDocument
}
else if (value instanceof String)
{
- return new Boolean ((String) value).booleanValue();
+ return Boolean.valueOf ((String) value).booleanValue();
}
return false;
}
diff --git a/gnu/xml/pipeline/ValidationConsumer.java b/gnu/xml/pipeline/ValidationConsumer.java
index 0fbfa9264..839176749 100644
--- a/gnu/xml/pipeline/ValidationConsumer.java
+++ b/gnu/xml/pipeline/ValidationConsumer.java
@@ -1607,7 +1607,7 @@ public final class ValidationConsumer extends EventFilter
throw new RuntimeException ("patchNext");
}
- if (table != null && (flags | F_LOOPHEAD) != 0)
+ if (table != null && (flags & F_LOOPHEAD) != 0)
table.put (this, this);
}