/[classpath]/classpath/java/security/AlgorithmParameterGenerator.java
ViewVC logotype

Diff of /classpath/java/security/AlgorithmParameterGenerator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by raif, Sun Mar 9 07:08:32 2003 UTC revision 1.7 by cbj, Thu Mar 27 03:32:08 2003 UTC
# Line 1  Line 1 
1  /* AlgorithmParameterGenerator.java --- Algorithm Parameter Generator  /* AlgorithmParameterGenerator.java --- Algorithm Parameter Generator
2     Copyright (C) 1999, 2003, Free Software Foundation, Inc.     Copyright (C) 1999, 2003 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 80  import java.security.spec.AlgorithmParam Line 80  import java.security.spec.AlgorithmParam
80   */   */
81  public class AlgorithmParameterGenerator  public class AlgorithmParameterGenerator
82  {  {
83      /** Service name for algorithm parameter generators. */
84      private static final String ALGORITHM_PARAMETER_GENERATOR =
85        "AlgorithmParameterGenerator";
86    
87    private AlgorithmParameterGeneratorSpi paramGenSpi;    private AlgorithmParameterGeneratorSpi paramGenSpi;
88    private Provider provider;    private Provider provider;
89    private String algorithm;    private String algorithm;
# Line 132  public class AlgorithmParameterGenerator Line 136  public class AlgorithmParameterGenerator
136      for (int i = 0; i < p.length; i++)      for (int i = 0; i < p.length; i++)
137        try        try
138          {          {
139            getInstance(algorithm, p[i]);            return getInstance(algorithm, p[i]);
140          }          }
141        catch (NoSuchAlgorithmException ignored) {}        catch (NoSuchAlgorithmException ignored) {}
142    
# Line 159  public class AlgorithmParameterGenerator Line 163  public class AlgorithmParameterGenerator
163                                                          String provider)                                                          String provider)
164      throws NoSuchAlgorithmException, NoSuchProviderException      throws NoSuchAlgorithmException, NoSuchProviderException
165    {    {
166        if (provider == null || provider.length() == 0)
167          throw new IllegalArgumentException("Illegal provider");
168    
169      Provider p = Security.getProvider(provider);      Provider p = Security.getProvider(provider);
170      if (p == null)      if (p == null)
171        throw new NoSuchProviderException();        throw new NoSuchProviderException();
# Line 186  public class AlgorithmParameterGenerator Line 193  public class AlgorithmParameterGenerator
193      throws NoSuchAlgorithmException      throws NoSuchAlgorithmException
194    {    {
195      if (provider == null)      if (provider == null)
196        throw new IllegalArgumentException();        throw new IllegalArgumentException("Illegal provider");
   
     // 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  
   {  
197    
198      try      try
199        {        {
200          return new AlgorithmParameterGenerator(          return new AlgorithmParameterGenerator(
201              (AlgorithmParameterGeneratorSpi) Class.forName(classname).newInstance(),            (AlgorithmParameterGeneratorSpi) Engine.getInstance(
202              provider,              ALGORITHM_PARAMETER_GENERATOR, algorithm, provider),
203              algorithm);            provider, algorithm);
204        }          }
205      catch (ClassNotFoundException cnfe)      catch (ClassCastException cce)
       {  
         throw new NoSuchAlgorithmException("Class not found");  
       }  
     catch (InstantiationException ie)  
       {  
         throw new NoSuchAlgorithmException("Class instantiation failed");  
       }  
     catch (IllegalAccessException iae)  
206        {        {
207          throw new NoSuchAlgorithmException("Illegal Access");          throw new NoSuchAlgorithmException(algorithm);
208        }        }
209    }    }
210    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26