gcc/libjava/java/security/KeyPairGenerator.java

87 lines
1.9 KiB
Java
Raw Normal View History

AlgorithmParameterGeneratorSpi.java: New file. * java/security/AlgorithmParameterGeneratorSpi.java: New file. * java/security/DigestException.java: New file. * java/security/GeneralSecurityException.java: New file. * java/security/InvalidAlgorithmParameterException.java: New file. * java/security/InvalidKeyException.java: New file. * java/security/InvalidParameterException.java: New file. * java/security/Key.java: New file. * java/security/KeyException.java: New file. * java/security/KeyPair.java: New file. * java/security/KeyPairGenerator.java: New file. * java/security/KeyPairGeneratorSpi.java: New file. * java/security/NoSuchProviderException.java: New file. * java/security/PrivateKey.java: New file. * java/security/Provider.java: New file. * java/security/PublicKey.java: New file. * java/security/SecureRandom.java: New file. * java/security/Security.java: New file. * java/security/Signature.java: New file. * java/security/SignatureException.java: New file. * java/security/interfaces/DSAKey.java: New file. * java/security/interfaces/DSAParams.java: New file. * java/security/interfaces/DSAPrivateKey.java: New file. * java/security/interfaces/DSAPublicKey.java: New file. * java/security/interfaces/RSAPrivateCrtKey.java: New file. * java/security/interfaces/RSAPrivateKey.java: New file. * java/security/interfaces/RSAPublicKey.java: New file. * java/security/spec/AlgorithmParameterSpec.java: New file. * java/security/spec/InvalidKeySpecException.java: New file. * java/security/spec/InvalidParameterSpecException.java: New file. * java/security/spec/KeySpec.java: New file. * java/security/spec/RSAPrivateCrtKeySpec.java: New file. * java/security/spec/RSAPrivateKeySpec.java: New file. * java/security/spec/RSAPublicKeySpec.java: New file. * Makefile.am: Added above java.security files. * Makefile.in: Rebuilt. * java/security/MessageDigest.java: Rewritten. * java/security/SecureClassLoader.java: Added JDK1.2 comment. From-SVN: r32461
2000-03-10 03:43:57 +01:00
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.security;
/**
* @author Warren Levy <warrenl@cygnus.com>
* @date February 10, 2000.
*/
/**
* Written using on-line Java Platform 1.2 API Specification.
* Status: Partially implemented to the 1.1 spec.
* It is known not to comply with the 1.2 spec.
*/
public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
{
protected KeyPairGenerator(String algorithm)
{
name = algorithm;
}
public static KeyPairGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException
{
String name = "KeyPairGenerator." + algorithm;
Provider[] provs = Security.getProviders();
for (int i = 0; i < provs.length; ++i)
{
String val = provs[i].getProperty(name);
if (val != null)
{
try
{
return (KeyPairGenerator) Class.forName(val).newInstance();
}
catch (Throwable _)
{
// We just ignore failures.
}
}
}
throw new NoSuchAlgorithmException(algorithm);
}
public static KeyPairGenerator getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
String name = "KeyPairGenerator." + algorithm;
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException(provider);
String val = p.getProperty(name);
if (val != null)
{
try
{
return (KeyPairGenerator) Class.forName(val).newInstance();
}
catch (Throwable _)
{
// Nothing.
}
}
throw new NoSuchAlgorithmException(algorithm);
}
public String getAlgorithm()
{
return name;
}
public abstract void initialize(int strength, SecureRandom random);
public abstract KeyPair generateKeyPair();
// Algorithm name.
private String name;
}