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

Diff of /classpath/java/security/MessageDigest.java

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

revision 1.7 by raif, Sat Mar 8 14:10:12 2003 UTC revision 1.8 by raif, Sun Mar 9 07:14:52 2003 UTC
# Line 165  public abstract class MessageDigest exte Line 165  public abstract class MessageDigest exte
165      return getInstance(algorithm, p);      return getInstance(algorithm, p);
166    }    }
167    
168    private static MessageDigest getInstance(String algorithm, Provider p)    /**
169       * Generates a <code>MessageDigest</code> object implementing the specified
170       * algorithm, as supplied from the specified provider, if such an algorithm
171       * is available from the provider. Note: the provider doesn't have to be
172       * registered.
173       *
174       * @param algorithm the name of the algorithm requested. See Appendix A in
175       * the Java Cryptography Architecture API Specification &amp; Reference for
176       * information about standard algorithm names.
177       * @param provider the provider.
178       * @return a Message Digest object implementing the specified algorithm.
179       * @throws NoSuchAlgorithmException if the <code>algorithm</code> is not
180       * available in the package supplied by the requested <code>provider</code>.
181       * @throws IllegalArgumentException if the <code>provider</code> is
182       * <code>null</code>.
183       * @since 1.4
184       * @see Provider
185       */
186      public static MessageDigest getInstance(String algorithm, Provider provider)
187      throws NoSuchAlgorithmException      throws NoSuchAlgorithmException
188    {    {
189        if (provider == null)
190          throw new IllegalArgumentException();
191    
192      // try the name as is      // try the name as is
193      String className = p.getProperty("MessageDigest." + algorithm);      String className = provider.getProperty("MessageDigest." + algorithm);
194      if (className == null) // try all uppercase      if (className == null) // try all uppercase
195        {        {
196          String upper = algorithm.toUpperCase();          String upper = algorithm.toUpperCase();
197          className = p.getProperty("MessageDigest." + upper);          className = provider.getProperty("MessageDigest." + upper);
198          if (className == null) // try if it's an alias          if (className == null) // try if it's an alias
199            {            {
200              String alias = p.getProperty("Alg.Alias.MessageDigest." +algorithm);              String alias = provider.getProperty(
201                    "Alg.Alias.MessageDigest." +algorithm);
202              if (alias == null) // try all-uppercase alias name              if (alias == null) // try all-uppercase alias name
203                {                {
204                  alias = p.getProperty("Alg.Alias.MessageDigest." +upper);                  alias = provider.getProperty("Alg.Alias.MessageDigest." +upper);
205                  if (alias == null) // spit the dummy                  if (alias == null) // spit the dummy
206                    throw new NoSuchAlgorithmException(algorithm);                    throw new NoSuchAlgorithmException(algorithm);
207                }                }
208              className = p.getProperty("MessageDigest." + alias);              className = provider.getProperty("MessageDigest." + alias);
209              if (className == null)              if (className == null)
210                throw new NoSuchAlgorithmException(algorithm);                throw new NoSuchAlgorithmException(algorithm);
211            }            }
212        }        }
213      return getInstance(className, algorithm, p);      return getInstance(className, algorithm, provider);
214    }    }
215    
216    private static MessageDigest getInstance(String classname,    private static MessageDigest getInstance(String classname,

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

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