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:
@@ -49,15 +49,11 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* <p>A base abstract class to facilitate implementations of concrete
|
||||
* Signatures.</p>
|
||||
* A base abstract class to facilitate implementations of concrete Signatures.
|
||||
*/
|
||||
public abstract class BaseSignature implements ISignature
|
||||
public abstract class BaseSignature
|
||||
implements ISignature
|
||||
{
|
||||
|
||||
// Constants and variables
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** The canonical name of this signature scheme. */
|
||||
protected String schemeName;
|
||||
|
||||
@@ -79,9 +75,6 @@ public abstract class BaseSignature implements ISignature
|
||||
/** Our default source of randomness. */
|
||||
private PRNG prng = null;
|
||||
|
||||
// Constructor(s)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Trivial constructor.
|
||||
*
|
||||
@@ -101,14 +94,6 @@ public abstract class BaseSignature implements ISignature
|
||||
this.md = md;
|
||||
}
|
||||
|
||||
// Class methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Instance methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// gnu.crypto.sig.ISignature interface implementation ----------------------
|
||||
|
||||
public String name()
|
||||
{
|
||||
return schemeName + "-" + md.name();
|
||||
@@ -117,51 +102,41 @@ public abstract class BaseSignature implements ISignature
|
||||
public void setupVerify(Map attributes) throws IllegalArgumentException
|
||||
{
|
||||
setup(attributes);
|
||||
|
||||
// do we have a public key?
|
||||
PublicKey key = (PublicKey) attributes.get(VERIFIER_KEY);
|
||||
if (key != null)
|
||||
{
|
||||
setupForVerification(key);
|
||||
}
|
||||
setupForVerification(key);
|
||||
}
|
||||
|
||||
public void setupSign(Map attributes) throws IllegalArgumentException
|
||||
{
|
||||
setup(attributes);
|
||||
|
||||
// do we have a private key?
|
||||
PrivateKey key = (PrivateKey) attributes.get(SIGNER_KEY);
|
||||
if (key != null)
|
||||
{
|
||||
setupForSigning(key);
|
||||
}
|
||||
setupForSigning(key);
|
||||
}
|
||||
|
||||
public void update(byte b)
|
||||
{
|
||||
if (md == null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
||||
md.update(b);
|
||||
}
|
||||
|
||||
public void update(byte[] b, int off, int len)
|
||||
{
|
||||
if (md == null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
||||
md.update(b, off, len);
|
||||
}
|
||||
|
||||
public Object sign()
|
||||
{
|
||||
if (md == null || privateKey == null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
||||
return generateSignature();
|
||||
}
|
||||
@@ -169,15 +144,11 @@ public abstract class BaseSignature implements ISignature
|
||||
public boolean verify(Object sig)
|
||||
{
|
||||
if (md == null || publicKey == null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
|
||||
return verifySignature(sig);
|
||||
}
|
||||
|
||||
// abstract methods to be implemented by concrete subclasses ---------------
|
||||
|
||||
public abstract Object clone();
|
||||
|
||||
protected abstract void setupForVerification(PublicKey key)
|
||||
@@ -191,8 +162,6 @@ public abstract class BaseSignature implements ISignature
|
||||
protected abstract boolean verifySignature(Object signature)
|
||||
throws IllegalStateException;
|
||||
|
||||
// Other instance methods --------------------------------------------------
|
||||
|
||||
/** Initialises the internal fields of this instance. */
|
||||
protected void init()
|
||||
{
|
||||
@@ -204,33 +173,27 @@ public abstract class BaseSignature implements ISignature
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Fills the designated byte array with random data.</p>
|
||||
*
|
||||
* Fills the designated byte array with random data.
|
||||
*
|
||||
* @param buffer the byte array to fill with random data.
|
||||
*/
|
||||
protected void nextRandomBytes(byte[] buffer)
|
||||
{
|
||||
if (rnd != null)
|
||||
{
|
||||
rnd.nextBytes(buffer);
|
||||
}
|
||||
rnd.nextBytes(buffer);
|
||||
else if (irnd != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
irnd.nextBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
catch (IllegalStateException x)
|
||||
{
|
||||
throw new RuntimeException("nextRandomBytes(): "
|
||||
+ String.valueOf(x));
|
||||
}
|
||||
catch (LimitReachedException x)
|
||||
{
|
||||
throw new RuntimeException("nextRandomBytes(): "
|
||||
+ String.valueOf(x));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
irnd.nextBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
catch (IllegalStateException x)
|
||||
{
|
||||
throw new RuntimeException("nextRandomBytes(): " + x);
|
||||
}
|
||||
catch (LimitReachedException x)
|
||||
{
|
||||
throw new RuntimeException("nextRandomBytes(): " + x);
|
||||
}
|
||||
else
|
||||
getDefaultPRNG().nextBytes(buffer);
|
||||
}
|
||||
@@ -238,17 +201,12 @@ public abstract class BaseSignature implements ISignature
|
||||
private void setup(Map attributes)
|
||||
{
|
||||
init();
|
||||
|
||||
// do we have a Random or SecureRandom, or should we use our own?
|
||||
Object obj = attributes.get(SOURCE_OF_RANDOMNESS);
|
||||
if (obj instanceof Random)
|
||||
{
|
||||
rnd = (Random) obj;
|
||||
}
|
||||
rnd = (Random) obj;
|
||||
else if (obj instanceof IRandom)
|
||||
{
|
||||
irnd = (IRandom) obj;
|
||||
}
|
||||
irnd = (IRandom) obj;
|
||||
}
|
||||
|
||||
private PRNG getDefaultPRNG()
|
||||
|
||||
Reference in New Issue
Block a user