From ac1ed908de999523efc36f38e69bca1aadfe0808 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 14 Aug 2006 23:12:35 +0000 Subject: Imported GNU Classpath 0.92 2006-08-14 Mark Wielaard 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 --- .../classpath/gnu/java/security/prng/BasePRNG.java | 39 ++---- .../gnu/java/security/prng/EntropySource.java | 1 - .../classpath/gnu/java/security/prng/IRandom.java | 156 ++++++++++----------- .../java/security/prng/LimitReachedException.java | 18 +-- .../gnu/java/security/prng/MDGenerator.java | 60 +++----- .../gnu/java/security/prng/PRNGFactory.java | 41 ++---- .../gnu/java/security/prng/RandomEvent.java | 11 +- .../java/security/prng/RandomEventListener.java | 8 +- 8 files changed, 127 insertions(+), 207 deletions(-) (limited to 'libjava/classpath/gnu/java/security/prng') diff --git a/libjava/classpath/gnu/java/security/prng/BasePRNG.java b/libjava/classpath/gnu/java/security/prng/BasePRNG.java index fe815d7..3b7c8cf 100644 --- a/libjava/classpath/gnu/java/security/prng/BasePRNG.java +++ b/libjava/classpath/gnu/java/security/prng/BasePRNG.java @@ -41,14 +41,11 @@ package gnu.java.security.prng; import java.util.Map; /** - *

An abstract class to facilitate implementing PRNG algorithms.

+ * 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) - // ------------------------------------------------------------------------- - /** - *

Trivial constructor for use by concrete subclasses.

- * + * 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(); diff --git a/libjava/classpath/gnu/java/security/prng/EntropySource.java b/libjava/classpath/gnu/java/security/prng/EntropySource.java index 260c668..95f68f0 100644 --- a/libjava/classpath/gnu/java/security/prng/EntropySource.java +++ b/libjava/classpath/gnu/java/security/prng/EntropySource.java @@ -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, diff --git a/libjava/classpath/gnu/java/security/prng/IRandom.java b/libjava/classpath/gnu/java/security/prng/IRandom.java index 2c89e7a..66ad6d2 100644 --- a/libjava/classpath/gnu/java/security/prng/IRandom.java +++ b/libjava/classpath/gnu/java/security/prng/IRandom.java @@ -41,140 +41,134 @@ package gnu.java.security.prng; import java.util.Map; /** - *

The basic visible methods of any pseudo-random number generator.

- * - *

The [HAC] defines a PRNG (as implemented in this library) as follows:

- * + * The basic visible methods of any pseudo-random number generator. + *

+ * The [HAC] defines a PRNG (as implemented in this library) as follows: *

- * - *

IMPLEMENTATION NOTE: Although all the concrete classes in this + *

+ * IMPLEMENTATION NOTE: 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, DOES NOT 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 same block size but without any - * knowledge of neither key material nor key size.

- * - *

References:

- * + * the same cipher that operates with the same block size but without + * any knowledge of neither key material nor key size. + *

+ * References: *

    - *
  1. [HAC]: Handbook of - * Applied Cryptography.
    - * CRC Press, Inc. ISBN 0-8493-8523-7, 1997
    - * Menezes, A., van Oorschot, P. and S. Vanstone.
  2. + *
  3. [HAC]: Handbook of + * Applied Cryptography.
    + * CRC Press, Inc. ISBN 0-8493-8523-7, 1997
    + * Menezes, A., van Oorschot, P. and S. Vanstone.
  4. *
*/ -public interface IRandom extends Cloneable +public interface IRandom + extends Cloneable { - - // Constants - // ------------------------------------------------------------------------- - - // Methods - // ------------------------------------------------------------------------- - /** - *

Returns the canonical name of this instance.

- * - * @return the canonical name of this instance. */ + * Returns the canonical name of this instance. + * + * @return the canonical name of this instance. + */ String name(); /** - *

Initialises the pseudo-random number generator scheme with the - * appropriate attributes.

- * + * 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); /** - *

Returns the next 8 bits of random data generated from this instance.

- * + * 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; /** - *

Fills the designated byte array, starting from byte at index - * offset, for a maximum of length bytes with the - * output of this generator instance. - * + * Fills the designated byte array, starting from byte at index + * offset, for a maximum of length bytes with + * the output of this generator instance. + * * @param out the placeholder to contain the generated random bytes. * @param offset the starting index in out to consider. This method - * does nothing if this parameter is not within 0 and - * out.length. - * @param length the maximum number of required random bytes. This method - * does nothing if this parameter is less than 1. + * does nothing if this parameter is not within 0 and + * out.length. + * @param length the maximum number of required random bytes. This method does + * nothing if this parameter is less than 1. * @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; /** - *

Supplement, or possibly replace, the random state of this PRNG with - * a random byte.

- * - *

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}.

- * + * Supplement, or possibly replace, the random state of this PRNG with a + * random byte. + *

+ * 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); /** - *

Supplement, or possibly replace, the random state of this PRNG with - * a sequence of new random bytes.

- * - *

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}.

- * + * Supplement, or possibly replace, the random state of this PRNG with a + * sequence of new random bytes. + *

+ * 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); /** - *

Supplement, or possibly replace, the random state of this PRNG with - * a sequence of new random bytes.

- * - *

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}.

- * + * Supplement, or possibly replace, the random state of this PRNG with a + * sequence of new random bytes. + *

+ * 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 offset, length, - * or offset+length is out of bounds. + * @exception IndexOutOfBoundsException If offset, length, or + * offset+length is out of bounds. */ void addRandomBytes(byte[] in, int offset, int length); /** - *

Returns a clone copy of this instance.

- * + * Returns a clone copy of this instance. + * * @return a clone copy of this instance. */ Object clone() throws CloneNotSupportedException; -} \ No newline at end of file +} diff --git a/libjava/classpath/gnu/java/security/prng/LimitReachedException.java b/libjava/classpath/gnu/java/security/prng/LimitReachedException.java index 2fd8bfa..8d5b30b 100644 --- a/libjava/classpath/gnu/java/security/prng/LimitReachedException.java +++ b/libjava/classpath/gnu/java/security/prng/LimitReachedException.java @@ -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 - // ------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/libjava/classpath/gnu/java/security/prng/MDGenerator.java b/libjava/classpath/gnu/java/security/prng/MDGenerator.java index 073c559..574a2f9 100644 --- a/libjava/classpath/gnu/java/security/prng/MDGenerator.java +++ b/libjava/classpath/gnu/java/security/prng/MDGenerator.java @@ -45,19 +45,17 @@ import gnu.java.security.hash.IMessageDigest; import java.util.Map; /** - *

A simple pseudo-random number generator that relies on a hash algorithm, - * that (a) starts its operation by hashing a seed, 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 seed, 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 - * seed is given, an empty octet sequence is used.

+ * seed 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 - { // ensure we have a reliable implementation of this hash - md = HashFactory.getInstance(underlyingMD); + else // a clone. reset it for reuse + md.reset(); } - + 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(); diff --git a/libjava/classpath/gnu/java/security/prng/PRNGFactory.java b/libjava/classpath/gnu/java/security/prng/PRNGFactory.java index 8b51414..ae15d05 100644 --- a/libjava/classpath/gnu/java/security/prng/PRNGFactory.java +++ b/libjava/classpath/gnu/java/security/prng/PRNGFactory.java @@ -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; /** - *

A Factory to instantiate pseudo random number generators.

+ * 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 Singleton pattern. */ protected PRNGFactory() { } - // Class methods - // ------------------------------------------------------------------------- - /** - *

Returns an instance of a padding algorithm given its name.

- * + * 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; } /** - *

Returns a {@link Set} of names of padding algorithms supported by this - * Factory.

- * + * Returns a {@link Set} of names of padding algorithms supported by this + * Factory. + * * @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 - // ------------------------------------------------------------------------- } diff --git a/libjava/classpath/gnu/java/security/prng/RandomEvent.java b/libjava/classpath/gnu/java/security/prng/RandomEvent.java index c070621..fc4607a 100644 --- a/libjava/classpath/gnu/java/security/prng/RandomEvent.java +++ b/libjava/classpath/gnu/java/security/prng/RandomEvent.java @@ -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; } -} \ No newline at end of file +} diff --git a/libjava/classpath/gnu/java/security/prng/RandomEventListener.java b/libjava/classpath/gnu/java/security/prng/RandomEventListener.java index 1dc1461..beb9087 100644 --- a/libjava/classpath/gnu/java/security/prng/RandomEventListener.java +++ b/libjava/classpath/gnu/java/security/prng/RandomEventListener.java @@ -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); -} \ No newline at end of file +} -- cgit v1.1