Imported GNU Classpath 0.92

2006-08-14  Mark Wielaard  <mark@klomp.org>

       Imported GNU Classpath 0.92
       * HACKING: Add more importing hints. Update automake version
       requirement.

       * configure.ac (gconf-peer): New enable AC argument.
       Add --disable-gconf-peer and --enable-default-preferences-peer
       to classpath configure when gconf is disabled.
       * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
       gnu/java/awt/dnd/peer/gtk to bc. Classify
       gnu/java/security/Configuration.java as generated source file.

       * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
       gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
       gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
       gnu/java/lang/management/VMThreadMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryMXBeanImpl.java,
       gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
       classes.
       * java/lang/management/VMManagementFactory.java: Likewise.
       * java/net/VMURLConnection.java: Likewise.
       * gnu/java/nio/VMChannel.java: Likewise.

       * java/lang/Thread.java (getState): Add stub implementation.
       * java/lang/Class.java (isEnum): Likewise.
       * java/lang/Class.h (isEnum): Likewise.

       * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.

       * javax/naming/spi/NamingManager.java: New override for StackWalker
       functionality.

       * configure, sources.am, Makefile.in, gcj/Makefile.in,
       include/Makefile.in, testsuite/Makefile.in: Regenerated.

From-SVN: r116139
This commit is contained in:
Mark Wielaard
2006-08-14 23:12:35 +00:00
parent abab460491
commit ac1ed908de
1294 changed files with 99479 additions and 35933 deletions
@@ -41,14 +41,11 @@ package gnu.java.security.prng;
import java.util.Map;
/**
* <p>An abstract class to facilitate implementing PRNG algorithms.</p>
* An abstract class to facilitate implementing PRNG algorithms.
*/
public abstract class BasePRNG implements IRandom
public abstract class BasePRNG
implements IRandom
{
// Constants and variables
// -------------------------------------------------------------------------
/** The canonical name prefix of the PRNG algorithm. */
protected String name;
@@ -61,12 +58,9 @@ public abstract class BasePRNG implements IRandom
/** The index into buffer of where the next byte will come from. */
protected int ndx;
// Constructor(s)
// -------------------------------------------------------------------------
/**
* <p>Trivial constructor for use by concrete subclasses.</p>
*
* Trivial constructor for use by concrete subclasses.
*
* @param name the canonical name of this instance.
*/
protected BasePRNG(String name)
@@ -78,14 +72,6 @@ public abstract class BasePRNG implements IRandom
buffer = new byte[0];
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
// IRandom interface implementation ----------------------------------------
public String name()
{
return name;
@@ -101,10 +87,9 @@ public abstract class BasePRNG implements IRandom
public byte nextByte() throws IllegalStateException, LimitReachedException
{
if (!initialised)
{
throw new IllegalStateException();
}
if (! initialised)
throw new IllegalStateException();
return nextByteInternal();
}
@@ -117,7 +102,7 @@ public abstract class BasePRNG implements IRandom
public void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException, LimitReachedException
{
if (!initialised)
if (! initialised)
throw new IllegalStateException("not initialized");
if (length == 0)
@@ -127,7 +112,6 @@ public abstract class BasePRNG implements IRandom
throw new ArrayIndexOutOfBoundsException("offset=" + offset + " length="
+ length + " limit="
+ out.length);
if (ndx >= buffer.length)
{
fillBlock();
@@ -163,9 +147,6 @@ public abstract class BasePRNG implements IRandom
throw new UnsupportedOperationException("random state is non-modifiable");
}
// Instance methods
// -------------------------------------------------------------------------
public boolean isInitialised()
{
return initialised;
@@ -182,8 +163,6 @@ public abstract class BasePRNG implements IRandom
return buffer[ndx++];
}
// abstract methods to implement by subclasses -----------------------------
public Object clone() throws CloneNotSupportedException
{
BasePRNG result = (BasePRNG) super.clone();
@@ -43,7 +43,6 @@ package gnu.java.security.prng;
*/
public interface EntropySource
{
/**
* Returns the estimated quality of this source. This value should be
* between 0 and 100 (the running quality is computed as a percentage,
@@ -41,140 +41,134 @@ package gnu.java.security.prng;
import java.util.Map;
/**
* <p>The basic visible methods of any pseudo-random number generator.</p>
*
* <p>The [HAC] defines a PRNG (as implemented in this library) as follows:</p>
*
* The basic visible methods of any pseudo-random number generator.
* <p>
* The [HAC] defines a PRNG (as implemented in this library) as follows:
* <ul>
* <li>"5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass
* the <em>next-bit test</em> if there is no polynomial-time algorithm which,
* on input of the first <code>L</code> bits of an output sequence <code>S</code>,
* can predict the <code>(L+1)</code>st bit of <code>S</code> with a
* probability significantly grater than <code>1/2</code>."</li>
*
* <li>"5.8 Definition: A PRBG that passes the <em>next-bit test</em>
* (possibly under some plausible but unproved mathematical assumption such
* as the intractability of factoring integers) is called a
* <em>cryptographically secure pseudorandom bit generator</em> (CSPRBG)."</li>
* <li>"5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass the
* <em>next-bit test</em> if there is no polynomial-time algorithm which, on
* input of the first <code>L</code> bits of an output sequence <code>S</code>,
* can predict the <code>(L+1)</code><sup>st</sup> bit of <code>S</code> with a
* probability significantly greater than <code>1/2</code>."</li>
* <li>"5.8 Definition: A PRBG that passes the <em>next-bit test</em>
* (possibly under some plausible but unproved mathematical assumption such as
* the intractability of factoring integers) is called a <em>cryptographically
* secure pseudorandom bit generator</em> (CSPRBG)."</li>
* </ul>
*
* <p><b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
* <p>
* <b>IMPLEMENTATION NOTE</b>: Although all the concrete classes in this
* package implement the {@link Cloneable} interface, it is important to note
* here that such an operation, for those algorithms that use an underlting
* here that such an operation, for those algorithms that use an underlying
* symmetric key block cipher, <b>DOES NOT</b> clone any session key material
* that may have been used in initialising the source PRNG (the instance to be
* cloned). Instead a clone of an already initialised PRNG, that uses and
* cloned). Instead a clone of an already initialised PRNG, that uses an
* underlying symmetric key block cipher, is another instance with a clone of
* the same cipher that operates with the <b>same block size</b> but without any
* knowledge of neither key material nor key size.</p>
*
* <p>References:</p>
*
* the same cipher that operates with the <b>same block size</b> but without
* any knowledge of neither key material nor key size.
* <p>
* References:
* <ol>
* <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
* Applied Cryptography.<br>
* CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
* Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* <li><a href="http://www.cacr.math.uwaterloo.ca/hac">[HAC]</a>: Handbook of
* Applied Cryptography.<br>
* CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
* Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
*/
public interface IRandom extends Cloneable
public interface IRandom
extends Cloneable
{
// Constants
// -------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------
/**
* <p>Returns the canonical name of this instance.</p>
*
* @return the canonical name of this instance. */
* Returns the canonical name of this instance.
*
* @return the canonical name of this instance.
*/
String name();
/**
* <p>Initialises the pseudo-random number generator scheme with the
* appropriate attributes.</p>
*
* Initialises the pseudo-random number generator scheme with the appropriate
* attributes.
*
* @param attributes a set of name-value pairs that describe the desired
* future instance behaviour.
* future instance behaviour.
* @exception IllegalArgumentException if at least one of the defined name/
* value pairs contains invalid data.
* value pairs contains invalid data.
*/
void init(Map attributes);
/**
* <p>Returns the next 8 bits of random data generated from this instance.</p>
*
* Returns the next 8 bits of random data generated from this instance.
*
* @return the next 8 bits of random data generated from this instance.
* @exception IllegalStateException if the instance is not yet initialised.
* @exception LimitReachedException if this instance has reached its
* theoretical limit for generating non-repetitive pseudo-random data.
* theoretical limit for generating non-repetitive pseudo-random
* data.
*/
byte nextByte() throws IllegalStateException, LimitReachedException;
/**
* <p>Fills the designated byte array, starting from byte at index
* <code>offset</code>, for a maximum of <code>length</code> bytes with the
* output of this generator instance.
*
* Fills the designated byte array, starting from byte at index
* <code>offset</code>, for a maximum of <code>length</code> bytes with
* the output of this generator instance.
*
* @param out the placeholder to contain the generated random bytes.
* @param offset the starting index in <i>out</i> to consider. This method
* does nothing if this parameter is not within <code>0</code> and
* <code>out.length</code>.
* @param length the maximum number of required random bytes. This method
* does nothing if this parameter is less than <code>1</code>.
* does nothing if this parameter is not within <code>0</code> and
* <code>out.length</code>.
* @param length the maximum number of required random bytes. This method does
* nothing if this parameter is less than <code>1</code>.
* @exception IllegalStateException if the instance is not yet initialised.
* @exception LimitReachedException if this instance has reached its
* theoretical limit for generating non-repetitive pseudo-random data.
* theoretical limit for generating non-repetitive pseudo-random
* data.
*/
void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException, LimitReachedException;
/**
* <p>Supplement, or possibly replace, the random state of this PRNG with
* a random byte.</p>
*
* <p>Implementations are not required to implement this method in any
* meaningful way; this may be a no-operation, and implementations may
* throw an {@link UnsupportedOperationException}.</p>
*
* Supplement, or possibly replace, the random state of this PRNG with a
* random byte.
* <p>
* Implementations are not required to implement this method in any meaningful
* way; this may be a no-operation, and implementations may throw an
* {@link UnsupportedOperationException}.
*
* @param b The byte to add.
*/
void addRandomByte(byte b);
/**
* <p>Supplement, or possibly replace, the random state of this PRNG with
* a sequence of new random bytes.</p>
*
* <p>Implementations are not required to implement this method in any
* meaningful way; this may be a no-operation, and implementations may
* throw an {@link UnsupportedOperationException}.</p>
*
* Supplement, or possibly replace, the random state of this PRNG with a
* sequence of new random bytes.
* <p>
* Implementations are not required to implement this method in any meaningful
* way; this may be a no-operation, and implementations may throw an
* {@link UnsupportedOperationException}.
*
* @param in The buffer of new random bytes to add.
*/
void addRandomBytes(byte[] in);
/**
* <p>Supplement, or possibly replace, the random state of this PRNG with
* a sequence of new random bytes.</p>
*
* <p>Implementations are not required to implement this method in any
* meaningful way; this may be a no-operation, and implementations may
* throw an {@link UnsupportedOperationException}.</p>
*
* Supplement, or possibly replace, the random state of this PRNG with a
* sequence of new random bytes.
* <p>
* Implementations are not required to implement this method in any meaningful
* way; this may be a no-operation, and implementations may throw an
* {@link UnsupportedOperationException}.
*
* @param in The buffer of new random bytes to add.
* @param offset The offset from whence to begin reading random bytes.
* @param length The number of random bytes to add.
* @exception IndexOutOfBoundsException If <i>offset</i>, <i>length</i>,
* or <i>offset</i>+<i>length</i> is out of bounds.
* @exception IndexOutOfBoundsException If <i>offset</i>, <i>length</i>, or
* <i>offset</i>+<i>length</i> is out of bounds.
*/
void addRandomBytes(byte[] in, int offset, int length);
/**
* <p>Returns a clone copy of this instance.</p>
*
* Returns a clone copy of this instance.
*
* @return a clone copy of this instance.
*/
Object clone() throws CloneNotSupportedException;
}
}
@@ -42,15 +42,9 @@ package gnu.java.security.prng;
* A checked exception that indicates that a pseudo random number generated has
* reached its theoretical limit in generating random bytes.
*/
public class LimitReachedException extends Exception
public class LimitReachedException
extends Exception
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public LimitReachedException()
{
super();
@@ -60,10 +54,4 @@ public class LimitReachedException extends Exception
{
super(msg);
}
// Class methods
// -------------------------------------------------------------------------
// Instant methods
// -------------------------------------------------------------------------
}
}
@@ -45,19 +45,17 @@ import gnu.java.security.hash.IMessageDigest;
import java.util.Map;
/**
* <p>A simple pseudo-random number generator that relies on a hash algorithm,
* that (a) starts its operation by hashing a <code>seed</code>, and then (b)
* continuously re-hashing its output. If no hash algorithm name is specified
* in the {@link Map} of attributes used to initialise the instance then the
* A simple pseudo-random number generator that relies on a hash algorithm, that
* (a) starts its operation by hashing a <code>seed</code>, and then (b)
* continuously re-hashing its output. If no hash algorithm name is specified in
* the {@link Map} of attributes used to initialise the instance then the
* SHA-160 algorithm is used as the underlying hash function. Also, if no
* <code>seed</code> is given, an empty octet sequence is used.</p>
* <code>seed</code> is given, an empty octet sequence is used.
*/
public class MDGenerator extends BasePRNG implements Cloneable
public class MDGenerator
extends BasePRNG
implements Cloneable
{
// Constants and variables
// -------------------------------------------------------------------------
/** Property name of underlying hash algorithm for this generator. */
public static final String MD_NAME = "gnu.crypto.prng.md.hash.name";
@@ -67,23 +65,12 @@ public class MDGenerator extends BasePRNG implements Cloneable
/** The underlying hash instance. */
private IMessageDigest md;
// Constructor(s)
// -------------------------------------------------------------------------
/** Trivial 0-arguments constructor. */
public MDGenerator()
{
super(Registry.MD_PRNG);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
// Implementation of abstract methods in BaseRandom ------------------------
public void setup(Map attributes)
{
// find out which hash to use
@@ -95,22 +82,15 @@ public class MDGenerator extends BasePRNG implements Cloneable
// ensure we have a reliable implementation of this hash
md = HashFactory.getInstance(Registry.SHA160_HASH);
}
else
{ // a clone. reset it for reuse
md.reset();
}
else // a clone. reset it for reuse
md.reset();
}
else
{ // ensure we have a reliable implementation of this hash
md = HashFactory.getInstance(underlyingMD);
}
else // ensure we have a reliable implementation of this hash
md = HashFactory.getInstance(underlyingMD);
// get the seeed
byte[] seed = (byte[]) attributes.get(SEEED);
if (seed == null)
{
seed = new byte[0];
}
seed = new byte[0];
md.update(seed, 0, seed.length);
}
@@ -122,22 +102,20 @@ public class MDGenerator extends BasePRNG implements Cloneable
md.update(buffer, 0, buffer.length);
}
public void addRandomByte (final byte b)
public void addRandomByte(final byte b)
{
if (md == null)
throw new IllegalStateException ("not initialized");
md.update (b);
throw new IllegalStateException("not initialized");
md.update(b);
}
public void addRandomBytes (final byte[] buf, final int off, final int len)
public void addRandomBytes(final byte[] buf, final int off, final int len)
{
if (md == null)
throw new IllegalStateException ("not initialized");
md.update (buf, off, len);
throw new IllegalStateException("not initialized");
md.update(buf, off, len);
}
// Cloneable interface implementation ---------------------------------------
public Object clone() throws CloneNotSupportedException
{
MDGenerator result = (MDGenerator) super.clone();
@@ -42,60 +42,46 @@ import gnu.java.security.Registry;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* <p>A Factory to instantiate pseudo random number generators.</p>
* A Factory to instantiate pseudo random number generators.
*/
public class PRNGFactory implements Registry
public class PRNGFactory
implements Registry
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
/** Trivial constructor to enforce <i>Singleton</i> pattern. */
protected PRNGFactory()
{
}
// Class methods
// -------------------------------------------------------------------------
/**
* <p>Returns an instance of a padding algorithm given its name.</p>
*
* Returns an instance of a padding algorithm given its name.
*
* @param prng the case-insensitive name of the PRNG.
* @return an instance of the pseudo-random number generator.
* @exception InternalError if the implementation does not pass its self-
* test.
* test.
*/
public static final IRandom getInstance(String prng)
{
if (prng == null)
{
return null;
}
return null;
prng = prng.trim();
IRandom result = null;
if (prng.equalsIgnoreCase(MD_PRNG))
{
result = new MDGenerator();
}
result = new MDGenerator();
return result;
}
/**
* <p>Returns a {@link Set} of names of padding algorithms supported by this
* <i>Factory</i>.</p>
*
* Returns a {@link Set} of names of padding algorithms supported by this
* <i>Factory</i>.
*
* @return a {@link Set} of pseudo-random number generator algorithm names
* (Strings).
* (Strings).
*/
public static final Set getNames()
{
@@ -103,7 +89,4 @@ public class PRNGFactory implements Registry
hs.add(MD_PRNG);
return Collections.unmodifiableSet(hs);
}
// Instance methods
// -------------------------------------------------------------------------
}
@@ -41,12 +41,11 @@ package gnu.java.security.prng;
import java.util.EventObject;
/**
* An interface for entropy accumulators that will be notified of random
* events.
* A type for entropy accumulators that will be notified of random events.
*/
public class RandomEvent extends EventObject
public class RandomEvent
extends EventObject
{
private final byte sourceNumber;
private final byte poolNumber;
@@ -61,7 +60,7 @@ public class RandomEvent extends EventObject
this.poolNumber = poolNumber;
if (data.length == 0 || data.length > 32)
throw new IllegalArgumentException(
"random events take between 1 and 32 bytes of data");
"random events take between 1 and 32 bytes of data");
this.data = (byte[]) data.clone();
}
@@ -79,4 +78,4 @@ public class RandomEvent extends EventObject
{
return data;
}
}
}
@@ -41,10 +41,10 @@ package gnu.java.security.prng;
import java.util.EventListener;
/**
* An interface for entropy accumulators that will be notified of random
* events.
* An interface for entropy accumulators that will be notified of random events.
*/
public interface RandomEventListener extends EventListener
public interface RandomEventListener
extends EventListener
{
void addRandomEvent(RandomEvent event);
}
}