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

Diff of /classpath/java/security/KeyFactory.java

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

revision 1.6 by raif, Sun Mar 9 07:13:19 2003 UTC revision 1.7 by cbj, Thu Mar 27 03:32:08 2003 UTC
# Line 1  Line 1 
1  /* KeyFactory.java --- Key Factory Class  /* KeyFactory.java --- Key Factory 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 83  import java.security.NoSuchAlgorithmExce Line 83  import java.security.NoSuchAlgorithmExce
83   */   */
84  public class KeyFactory  public class KeyFactory
85  {  {
86      /** The service name for key factories. */
87      private static final String KEY_FACTORY = "KeyFactory";
88    
89    private KeyFactorySpi keyFacSpi;    private KeyFactorySpi keyFacSpi;
90    private Provider provider;    private Provider provider;
91    private String algorithm;    private String algorithm;
# Line 125  public class KeyFactory Line 128  public class KeyFactory
128      for (int i = 0; i < p.length; i++)      for (int i = 0; i < p.length; i++)
129        try        try
130          {          {
131            getInstance(algorithm, p[i]);            return getInstance(algorithm, p[i]);
132          }          }
133        catch (NoSuchAlgorithmException ignored) {}        catch (NoSuchAlgorithmException ignored) {}
134    
# Line 150  public class KeyFactory Line 153  public class KeyFactory
153    public static KeyFactory getInstance(String algorithm, String provider)    public static KeyFactory getInstance(String algorithm, String provider)
154      throws NoSuchAlgorithmException, NoSuchProviderException      throws NoSuchAlgorithmException, NoSuchProviderException
155    {    {
156        if (provider == null || provider.length() == 0)
157          throw new IllegalArgumentException("Illegal provider");
158    
159      Provider p = Security.getProvider(provider);      Provider p = Security.getProvider(provider);
160      if (p == null)      if (p == null)
161        throw new NoSuchProviderException();        throw new NoSuchProviderException();
# Line 178  public class KeyFactory Line 184  public class KeyFactory
184      throws NoSuchAlgorithmException      throws NoSuchAlgorithmException
185    {    {
186      if (provider == null)      if (provider == null)
187        throw new IllegalArgumentException();        throw new IllegalArgumentException("Illegal provider");
188    
     // 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  
   {  
189      try      try
190        {        {
191          return new KeyFactory(          return new KeyFactory((KeyFactorySpi)
192              (KeyFactorySpi) Class.forName(classname).newInstance(),            Engine.getInstance(KEY_FACTORY, algorithm, provider),
193              provider,            provider, algorithm);
             algorithm);  
       }  
     catch (ClassNotFoundException cnfe)  
       {  
         throw new NoSuchAlgorithmException("Class not found");  
194        }        }
195      catch (InstantiationException ie)      catch (ClassCastException cce)
196        {        {
197          throw new NoSuchAlgorithmException("Class instantiation failed");          throw new NoSuchAlgorithmException(algorithm);
198        }        }
     catch (IllegalAccessException iae)  
       {  
         throw new NoSuchAlgorithmException("Illegal Access");  
       }  
199    }    }
200    
201    /**    /**

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