Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* BasicPermission.java -- implements a simple named permission
|
||||
Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -97,7 +98,7 @@ public abstract class BasicPermission extends java.security.Permission
|
||||
// requirement exists in the specification and Sun's runtime
|
||||
// doesn't appear to do it.
|
||||
|
||||
if ("".equals(name))
|
||||
if (name.equals(""))
|
||||
throw new IllegalArgumentException("Empty name");
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ public class KeyStore
|
||||
/**
|
||||
* Returns the default KeyStore type. This method looks up the
|
||||
* type in <JAVA_HOME>/lib/security/java.security with the
|
||||
* property "keystore.type" or if that fails then "jks" .
|
||||
* property "keystore.type" or if that fails then "gkr" .
|
||||
*/
|
||||
public static final String getDefaultType()
|
||||
{
|
||||
@@ -221,7 +221,7 @@ public class KeyStore
|
||||
String tmp = Security.getProperty("keystore.type");
|
||||
|
||||
if (tmp == null)
|
||||
tmp = "jks";
|
||||
tmp = "gkr";
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SecureRandom.java --- Secure Random class implementation
|
||||
Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2001, 2002, 2003, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,11 +38,19 @@ exception statement from your version. */
|
||||
|
||||
package java.security;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.security.Engine;
|
||||
import gnu.java.security.action.GetSecurityPropertyAction;
|
||||
import gnu.java.security.jce.prng.Sha160RandomSpi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* An interface to a cryptographically secure pseudo-random number
|
||||
@@ -71,6 +80,9 @@ public class SecureRandom extends Random
|
||||
int randomBytesUsed = 0;
|
||||
SecureRandomSpi secureRandomSpi = null;
|
||||
byte[] state = null;
|
||||
private String algorithm;
|
||||
|
||||
private boolean isSeeded = false;
|
||||
|
||||
// Constructors.
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -111,6 +123,7 @@ public class SecureRandom extends Random
|
||||
secureRandomSpi = (SecureRandomSpi) Class.
|
||||
forName(classname).newInstance();
|
||||
provider = p[i];
|
||||
algorithm = key.substring(13); // Minus SecureRandom.
|
||||
return;
|
||||
}
|
||||
catch (ThreadDeath death)
|
||||
@@ -128,6 +141,7 @@ public class SecureRandom extends Random
|
||||
|
||||
// Nothing found. Fall back to SHA1PRNG
|
||||
secureRandomSpi = new Sha160RandomSpi();
|
||||
algorithm = "Sha160";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,9 +172,19 @@ public class SecureRandom extends Random
|
||||
@param provider A Provider class
|
||||
*/
|
||||
protected SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider)
|
||||
{
|
||||
this(secureRandomSpi, provider, "unknown");
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor called from the getInstance() method.
|
||||
*/
|
||||
private SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider,
|
||||
String algorithm)
|
||||
{
|
||||
this.secureRandomSpi = secureRandomSpi;
|
||||
this.provider = provider;
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
// Class methods.
|
||||
@@ -243,7 +267,7 @@ public class SecureRandom extends Random
|
||||
{
|
||||
return new SecureRandom((SecureRandomSpi)
|
||||
Engine.getInstance(SECURE_RANDOM, algorithm, provider),
|
||||
provider);
|
||||
provider, algorithm);
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException ite)
|
||||
{
|
||||
@@ -268,6 +292,18 @@ public class SecureRandom extends Random
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the algorithm name used or "unknown" when the algorithm
|
||||
* used couldn't be determined (as when constructed by the protected
|
||||
* 2 argument constructor).
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public String getAlgorithm()
|
||||
{
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
Seeds the SecureRandom. The class is re-seeded for each call and
|
||||
each seed builds on the previous seed so as not to weaken security.
|
||||
@@ -277,6 +313,7 @@ public class SecureRandom extends Random
|
||||
public void setSeed(byte[] seed)
|
||||
{
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
isSeeded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,6 +341,7 @@ public class SecureRandom extends Random
|
||||
(byte) (0xff & seed)
|
||||
};
|
||||
secureRandomSpi.engineSetSeed(tmp);
|
||||
isSeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +353,8 @@ public class SecureRandom extends Random
|
||||
*/
|
||||
public void nextBytes(byte[] bytes)
|
||||
{
|
||||
if (!isSeeded)
|
||||
setSeed(getSeed(32));
|
||||
randomBytesUsed += bytes.length;
|
||||
counter++;
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
@@ -360,10 +400,8 @@ public class SecureRandom extends Random
|
||||
public static byte[] getSeed(int numBytes)
|
||||
{
|
||||
byte[] tmp = new byte[numBytes];
|
||||
|
||||
new Random().nextBytes(tmp);
|
||||
generateSeed(tmp);
|
||||
return tmp;
|
||||
//return secureRandomSpi.engineGenerateSeed( numBytes );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,4 +416,64 @@ public class SecureRandom extends Random
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
}
|
||||
|
||||
// Seed methods.
|
||||
|
||||
private static final String SECURERANDOM_SOURCE = "securerandom.source";
|
||||
private static final String JAVA_SECURITY_EGD = "java.security.egd";
|
||||
private static final Logger logger = Logger.getLogger(SecureRandom.class.getName());
|
||||
|
||||
private static int generateSeed(byte[] buffer)
|
||||
{
|
||||
return generateSeed(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
private static int generateSeed(byte[] buffer, int offset, int length)
|
||||
{
|
||||
URL sourceUrl = null;
|
||||
String urlStr = null;
|
||||
|
||||
GetSecurityPropertyAction action = new GetSecurityPropertyAction(SECURERANDOM_SOURCE);
|
||||
try
|
||||
{
|
||||
urlStr = (String) AccessController.doPrivileged(action);
|
||||
if (urlStr != null)
|
||||
sourceUrl = new URL(urlStr);
|
||||
}
|
||||
catch (MalformedURLException ignored)
|
||||
{
|
||||
logger.log(Level.WARNING, SECURERANDOM_SOURCE + " property is malformed: {0}",
|
||||
urlStr);
|
||||
}
|
||||
|
||||
if (sourceUrl == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
urlStr = SystemProperties.getProperty(JAVA_SECURITY_EGD);
|
||||
if (urlStr != null)
|
||||
sourceUrl = new URL(urlStr);
|
||||
}
|
||||
catch (MalformedURLException mue)
|
||||
{
|
||||
logger.log(Level.WARNING, JAVA_SECURITY_EGD + " property is malformed: {0}",
|
||||
urlStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceUrl != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream in = sourceUrl.openStream();
|
||||
return in.read(buffer, offset, length);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
logger.log(Level.FINE, "error reading random bytes", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we did not get any seed from a property URL.
|
||||
return VMSecureRandom.generateSeed(buffer, offset, length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,12 @@ public final class Security
|
||||
System.err.println
|
||||
(" Falling back to standard GNU security provider");
|
||||
}
|
||||
// Note that this matches our classpath.security file.
|
||||
providers.addElement (new gnu.java.security.provider.Gnu());
|
||||
providers.addElement(new gnu.javax.crypto.jce.GnuCrypto());
|
||||
providers.addElement(new gnu.javax.crypto.jce.GnuSasl());
|
||||
providers.addElement(new gnu.javax.net.ssl.provider.Jessie());
|
||||
providers.addElement(new gnu.javax.security.auth.callback.GnuCallbacks());
|
||||
}
|
||||
}
|
||||
// This class can't be instantiated.
|
||||
|
||||
@@ -38,6 +38,8 @@ exception statement from your version. */
|
||||
|
||||
package java.security.cert;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* The <i>service provider interface</i> (<b>SPI</b>) for the {@link
|
||||
* CertPathValidator} class. Providers implementing certificate path
|
||||
@@ -75,5 +77,5 @@ public abstract class CertPathValidatorSpi
|
||||
public abstract CertPathValidatorResult
|
||||
engineValidate(CertPath certPath, CertPathParameters params)
|
||||
throws CertPathValidatorException,
|
||||
java.security.InvalidAlgorithmParameterException;
|
||||
InvalidAlgorithmParameterException;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ exception statement from your version. */
|
||||
|
||||
package java.security.cert;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -69,7 +70,7 @@ public abstract class CertStoreSpi
|
||||
* parameters are inappropriate for this class.
|
||||
*/
|
||||
public CertStoreSpi(CertStoreParameters params)
|
||||
throws java.security.InvalidAlgorithmParameterException
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ import java.security.SignatureException;
|
||||
*/
|
||||
public abstract class Certificate implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -6751606818319535583L;
|
||||
private static final long serialVersionUID = -3585440601605666277L;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import java.util.Set;
|
||||
*
|
||||
* <p>Concrete subclasses can be passed to the {@link
|
||||
* PKIXParameters#setCertPathCheckers(java.util.List)} and {@link
|
||||
* PKIXParameters#addCertPathChecker(java.security.cert.PKIXCertPathChecker}
|
||||
* PKIXParameters#addCertPathChecker(java.security.cert.PKIXCertPathChecker)}
|
||||
* methods, which are then used to set up PKIX certificate chain
|
||||
* builders or validators. These classes then call the {@link
|
||||
* #check(java.security.cert.Certificate,java.util.Collection)} method
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.Set;
|
||||
* Parameters for verifying certificate paths using the PKIX
|
||||
* (Public-Key Infrastructure (X.509)) algorithm.
|
||||
*
|
||||
* @see CertPathBulider
|
||||
* @see CertPathBuilder
|
||||
*/
|
||||
public class PKIXParameters implements CertPathParameters
|
||||
{
|
||||
|
||||
@@ -367,7 +367,7 @@ public class X509CertSelector implements CertSelector, Cloneable
|
||||
* Sets the authority key identifier criterion, or <code>null</code> to clear
|
||||
* this criterion. Note that the byte array is cloned to prevent modification.
|
||||
*
|
||||
* @param subjectKeyId The subject key identifier.
|
||||
* @param authKeyId The authority key identifier.
|
||||
*/
|
||||
public void setAuthorityKeyIdentifier(byte[] authKeyId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user