diff options
| author | Brian Jones <cbj@gnu.org> | 2003-03-27 03:32:08 +0000 |
|---|---|---|
| committer | Brian Jones <cbj@gnu.org> | 2003-03-27 03:32:08 +0000 |
| commit | 8e60cd79d0176a6e86aea698100de3550503c000 (patch) | |
| tree | bce574ecece50b2af477f9d71d737532eaf602de /java/security/KeyFactory.java | |
| parent | b2bab933c09836f3f4d71f2b3c1b8ced80083021 (diff) | |
| download | classpath-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/KeyFactory.java')
| -rw-r--r-- | java/security/KeyFactory.java | 61 |
1 files changed, 15 insertions, 46 deletions
diff --git a/java/security/KeyFactory.java b/java/security/KeyFactory.java index bc0a065ca..918bf3d6d 100644 --- a/java/security/KeyFactory.java +++ b/java/security/KeyFactory.java @@ -1,5 +1,5 @@ /* KeyFactory.java --- Key Factory Class - Copyright (C) 1999, 2003, Free Software Foundation, Inc. + Copyright (C) 1999, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -83,6 +83,9 @@ import java.security.NoSuchAlgorithmException; */ public class KeyFactory { + /** The service name for key factories. */ + private static final String KEY_FACTORY = "KeyFactory"; + private KeyFactorySpi keyFacSpi; private Provider provider; private String algorithm; @@ -125,7 +128,7 @@ public class KeyFactory for (int i = 0; i < p.length; i++) try { - getInstance(algorithm, p[i]); + return getInstance(algorithm, p[i]); } catch (NoSuchAlgorithmException ignored) {} @@ -150,6 +153,9 @@ public class KeyFactory public static KeyFactory getInstance(String algorithm, 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(); @@ -178,55 +184,18 @@ public class KeyFactory throws NoSuchAlgorithmException { if (provider == null) - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Illegal provider"); - // try the name as is - String className = provider.getProperty("KeyFactory." + algorithm); - if (className == null) // try all uppercase - { - String upper = algorithm.toUpperCase(); - className = provider.getProperty("KeyFactory." + upper); - if (className == null) // try if it's an alias - { - String alias = - provider.getProperty("Alg.Alias.KeyFactory." + algorithm); - if (alias == null) // try all-uppercase alias name - { - alias = provider.getProperty("Alg.Alias.KeyFactory." + upper); - if (alias == null) // spit the dummy - throw new NoSuchAlgorithmException(algorithm); - } - className = provider.getProperty("KeyFactory." + alias); - if (className == null) - throw new NoSuchAlgorithmException(algorithm); - } - } - return getInstance(className, algorithm, provider); - } - - private static KeyFactory getInstance(String classname, String algorithm, - Provider provider) - throws NoSuchAlgorithmException - { try { - return new KeyFactory( - (KeyFactorySpi) Class.forName(classname).newInstance(), - provider, - algorithm); - } - catch (ClassNotFoundException cnfe) - { - throw new NoSuchAlgorithmException("Class not found"); + return new KeyFactory((KeyFactorySpi) + Engine.getInstance(KEY_FACTORY, algorithm, provider), + provider, algorithm); } - catch (InstantiationException ie) + catch (ClassCastException cce) { - throw new NoSuchAlgorithmException("Class instantiation failed"); - } - catch (IllegalAccessException iae) - { - throw new NoSuchAlgorithmException("Illegal Access"); - } + throw new NoSuchAlgorithmException(algorithm); + } } /** |
