summaryrefslogtreecommitdiff
path: root/java/security/AlgorithmParameterGenerator.java
diff options
context:
space:
mode:
authorBrian Jones <cbj@gnu.org>2003-03-27 03:32:08 +0000
committerBrian Jones <cbj@gnu.org>2003-03-27 03:32:08 +0000
commit8e60cd79d0176a6e86aea698100de3550503c000 (patch)
treebce574ecece50b2af477f9d71d737532eaf602de /java/security/AlgorithmParameterGenerator.java
parentb2bab933c09836f3f4d71f2b3c1b8ced80083021 (diff)
downloadclasspath-8e60cd79d0176a6e86aea698100de3550503c000.tar.gz
2003-03-26 C. Brian Jones <cbj@gnu.org>
* configure.in: VERSION changed to 0.05+cvs * THANKYOU: added Casey Marshall 2003-03-26 Casey Marshall <rsdio@metastatic.org> * java/security/AlgorithmParameterGenerator.java (getInstance (String)): add missing return statement (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code (getInstance (String,String,Provider)): removed * java/security/AlgorithmParameters.java (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code (getInstance (String,String,Provider)): removed * java/security/Engine.java: new file * java/security/KeyFactory.java (getInstance (String)): add missing return statement (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code (getInstance (String,String,Provider)): removed * java/security/KeyPairGenerator.java (getInstance (String,Provider)): reuse common Engine code (getInstance (String,String,Provider)): removed * java/security/KeyStore.java (getInstance (String)): use getInstance(String,Provider) instead (getInstance (String,String)): use getInstance(String,Provider) instead (getInstance (String,Provider): reuse common Engine code * java/security/MessageDigest.java (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code * java/security/SecureRandom.java (getInstance (String): formatting (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code * java/security/Signature.java (getInstance (String,String)): check for improper provider argument (getInstance (String,Provider)): reuse common Engine code (getInstance (String,String,Provider)): removed
Diffstat (limited to 'java/security/AlgorithmParameterGenerator.java')
-rw-r--r--java/security/AlgorithmParameterGenerator.java68
1 files changed, 17 insertions, 51 deletions
diff --git a/java/security/AlgorithmParameterGenerator.java b/java/security/AlgorithmParameterGenerator.java
index bbc3b90a5..b8ad8e27d 100644
--- a/java/security/AlgorithmParameterGenerator.java
+++ b/java/security/AlgorithmParameterGenerator.java
@@ -1,5 +1,5 @@
/* AlgorithmParameterGenerator.java --- Algorithm Parameter Generator
- Copyright (C) 1999, 2003, Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -80,6 +80,10 @@ import java.security.spec.AlgorithmParameterSpec;
*/
public class AlgorithmParameterGenerator
{
+ /** Service name for algorithm parameter generators. */
+ private static final String ALGORITHM_PARAMETER_GENERATOR =
+ "AlgorithmParameterGenerator";
+
private AlgorithmParameterGeneratorSpi paramGenSpi;
private Provider provider;
private String algorithm;
@@ -132,7 +136,7 @@ public class AlgorithmParameterGenerator
for (int i = 0; i < p.length; i++)
try
{
- getInstance(algorithm, p[i]);
+ return getInstance(algorithm, p[i]);
}
catch (NoSuchAlgorithmException ignored) {}
@@ -159,6 +163,9 @@ public class AlgorithmParameterGenerator
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ if (provider == null || provider.length() == 0)
+ throw new IllegalArgumentException("Illegal provider");
+
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException();
@@ -186,59 +193,18 @@ public class AlgorithmParameterGenerator
throws NoSuchAlgorithmException
{
if (provider == null)
- throw new IllegalArgumentException();
-
- // try the name as is
- String className = provider.getProperty(
- "AlgorithmParameterGenerator." + algorithm);
- if (className == null) // try all uppercase
- {
- String upper = algorithm.toUpperCase();
- className = provider.getProperty("AlgorithmParameterGenerator." + upper);
- if (className == null) // try if it's an alias
- {
- String alias = provider.getProperty(
- "Alg.Alias.AlgorithmParameterGenerator." + algorithm);
- if (alias == null) // try all-uppercase alias name
- {
- alias = provider.getProperty(
- "Alg.Alias.AlgorithmParameterGenerator." + upper);
- if (alias == null) // spit the dummy
- throw new NoSuchAlgorithmException(algorithm);
- }
- className = provider.getProperty(
- "AlgorithmParameterGenerator." + alias);
- if (className == null)
- throw new NoSuchAlgorithmException(algorithm);
- }
- }
- return getInstance(className, algorithm, provider);
- }
-
- private static AlgorithmParameterGenerator getInstance(String classname,
- String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
+ throw new IllegalArgumentException("Illegal provider");
try
{
- return new AlgorithmParameterGenerator(
- (AlgorithmParameterGeneratorSpi) Class.forName(classname).newInstance(),
- provider,
- algorithm);
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new NoSuchAlgorithmException("Class not found");
- }
- catch (InstantiationException ie)
- {
- throw new NoSuchAlgorithmException("Class instantiation failed");
- }
- catch (IllegalAccessException iae)
+ return new AlgorithmParameterGenerator(
+ (AlgorithmParameterGeneratorSpi) Engine.getInstance(
+ ALGORITHM_PARAMETER_GENERATOR, algorithm, provider),
+ provider, algorithm);
+ }
+ catch (ClassCastException cce)
{
- throw new NoSuchAlgorithmException("Illegal Access");
+ throw new NoSuchAlgorithmException(algorithm);
}
}