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

Diff of /classpath/java/security/AlgorithmParameters.java

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

revision 1.6 by raif, Sun Mar 9 07:12:01 2003 UTC revision 1.7 by cbj, Thu Mar 27 03:32:08 2003 UTC
# Line 1  Line 1 
1  /* AlgorithmParameters.java --- Algorithm Parameters Implementation Class  /* AlgorithmParameters.java --- Algorithm Parameters Implementation Class
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 81  import java.io.IOException; Line 81  import java.io.IOException;
81   */   */
82  public class AlgorithmParameters  public class AlgorithmParameters
83  {  {
84      /** Service name for algorithm parameters. */
85      private static final String ALGORITHM_PARAMETERS = "AlgorithmParameters";
86    
87    private AlgorithmParametersSpi paramSpi;    private AlgorithmParametersSpi paramSpi;
88    private Provider provider;    private Provider provider;
89    private String algorithm;    private String algorithm;
# Line 163  public class AlgorithmParameters Line 166  public class AlgorithmParameters
166    public static AlgorithmParameters getInstance(String algorithm, String provider)    public static AlgorithmParameters getInstance(String algorithm, String provider)
167      throws NoSuchAlgorithmException, NoSuchProviderException      throws NoSuchAlgorithmException, NoSuchProviderException
168    {    {
169        if (provider == null || provider.length() == 0)
170          throw new IllegalArgumentException("Illegal provider");
171        
172      Provider p = Security.getProvider(provider);      Provider p = Security.getProvider(provider);
173      if (p == null)      if (p == null)
174        throw new NoSuchProviderException();        throw new NoSuchProviderException();
# Line 190  public class AlgorithmParameters Line 196  public class AlgorithmParameters
196      throws NoSuchAlgorithmException      throws NoSuchAlgorithmException
197    {    {
198      if (provider == null)      if (provider == null)
199        throw new IllegalArgumentException();        throw new IllegalArgumentException("Illegal provider");
   
     // try the name as is  
     String className = provider.getProperty("AlgorithmParameters." + algorithm);  
     if (className == null) // try all uppercase  
       {  
         String upper = algorithm.toUpperCase();  
         className = provider.getProperty("AlgorithmParameters." + upper);  
         if (className == null) // try if it's an alias  
           {  
             String alias =  
                 provider.getProperty("Alg.Alias.AlgorithmParameters." + algorithm);  
             if (alias == null) // try all-uppercase alias name  
               {  
                 alias = provider.getProperty("Alg.Alias.AlgorithmParameters." + upper);  
                 if (alias == null) // spit the dummy  
                   throw new NoSuchAlgorithmException(algorithm);  
               }  
             className = provider.getProperty("AlgorithmParameters." + alias);  
             if (className == null)  
               throw new NoSuchAlgorithmException(algorithm);  
           }  
       }  
     return getInstance(className, algorithm, provider);  
   }  
200    
   private static AlgorithmParameters getInstance(String classname,  
                                                  String algorithm,  
                                                  Provider provider)  
     throws NoSuchAlgorithmException  
   {  
201      try      try
202        {        {
203          return new AlgorithmParameters(          return new AlgorithmParameters((AlgorithmParametersSpi)
204              (AlgorithmParametersSpi) Class.forName(classname).newInstance(),            Engine.getInstance(ALGORITHM_PARAMETERS, algorithm, provider),
205              provider,            provider, algorithm);
             algorithm);  
       }  
     catch (ClassNotFoundException cnfe)  
       {  
         throw new NoSuchAlgorithmException("Class not found");  
       }  
     catch (InstantiationException ie)  
       {  
         throw new NoSuchAlgorithmException("Class instantiation failed");  
206        }        }
207      catch (IllegalAccessException iae)      catch (ClassCastException cce)
208        {        {
209          throw new NoSuchAlgorithmException("Illegal Access");          throw new NoSuchAlgorithmException(algorithm);
210        }        }
211    }    }
212    

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