/[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.5 by raif, Sat Mar 8 14:10:12 2003 UTC revision 1.6 by raif, Sun Mar 9 07:13:19 2003 UTC
# Line 39  package java.security; Line 39  package java.security;
39    
40  import java.security.spec.KeySpec;  import java.security.spec.KeySpec;
41  import java.security.spec.InvalidKeySpecException;  import java.security.spec.InvalidKeySpecException;
42    import java.security.NoSuchAlgorithmException;
43    
44  /**  /**
45   * <p>Key factories are used to convert keys (opaque cryptographic keys of type   * <p>Key factories are used to convert keys (opaque cryptographic keys of type
# Line 122  public class KeyFactory Line 123  public class KeyFactory
123    {    {
124      Provider[] p = Security.getProviders();      Provider[] p = Security.getProviders();
125      for (int i = 0; i < p.length; i++)      for (int i = 0; i < p.length; i++)
126        {        try
127          String classname = p[i].getProperty("KeyFactory." + algorithm);          {
128          if (classname != null)            getInstance(algorithm, p[i]);
129            return getInstance(classname, algorithm, p[i]);          }
130        }        catch (NoSuchAlgorithmException ignored) {}
131    
132      throw new NoSuchAlgorithmException(algorithm);      throw new NoSuchAlgorithmException(algorithm);
133    }    }
# Line 153  public class KeyFactory Line 154  public class KeyFactory
154      if (p == null)      if (p == null)
155        throw new NoSuchProviderException();        throw new NoSuchProviderException();
156    
157      return getInstance(p.getProperty("KeyFactory." + algorithm), algorithm, p);      return getInstance(algorithm, p);
158      }
159    
160      /**
161       * Generates a <code>KeyFactory</code> object for the specified algorithm from
162       * the specified provider. Note: the <code>provider</code> doesn't have to be
163       * registered.
164       *
165       * @param algorithm the name of the requested key algorithm. See Appendix A
166       * in the Java Cryptography Architecture API Specification &amp; Reference for
167       * information about standard algorithm names.
168       * @param provider the provider.
169       * @return a <code>KeyFactory</code> object for the specified algorithm.
170       * @throws NoSuchAlgorithmException if the algorithm is not available from
171       * the specified provider.
172       * @throws IllegalArgumentException if the <code>provider</code> is
173       * <code>null</code>.
174       * @since 1.4
175       * @see Provider
176       */
177      public static KeyFactory getInstance(String algorithm, Provider provider)
178        throws NoSuchAlgorithmException
179      {
180        if (provider == null)
181          throw new IllegalArgumentException();
182    
183        // try the name as is
184        String className = provider.getProperty("KeyFactory." + algorithm);
185        if (className == null) // try all uppercase
186          {
187            String upper = algorithm.toUpperCase();
188            className = provider.getProperty("KeyFactory." + upper);
189            if (className == null) // try if it's an alias
190              {
191                String alias =
192                    provider.getProperty("Alg.Alias.KeyFactory." + algorithm);
193                if (alias == null) // try all-uppercase alias name
194                  {
195                    alias = provider.getProperty("Alg.Alias.KeyFactory." + upper);
196                    if (alias == null) // spit the dummy
197                      throw new NoSuchAlgorithmException(algorithm);
198                  }
199                className = provider.getProperty("KeyFactory." + alias);
200                if (className == null)
201                  throw new NoSuchAlgorithmException(algorithm);
202              }
203          }
204        return getInstance(className, algorithm, provider);
205    }    }
206    
207    private static KeyFactory getInstance(String classname, String algorithm,    private static KeyFactory getInstance(String classname, String algorithm,

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

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