This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java.security.MessageDigest


hello there,

this patch addresses JDK 1.4 compatibility.

cheers;
rsn

in ChangeLog (in libjava), add:

2003-03-03  Raif S. Naffah  <raif at fl dot net dot au>

	* java.security.MessageDigest: formatting.
	(getInstance(String, Provider)): made it public.


cvs -z9 diff -u -wb -B MessageDigest.java (in directory /data/workspace/cvs/gcc/libjava/java/security/)
Index: MessageDigest.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/security/MessageDigest.java,v
retrieving revision 1.8
diff -u -w -b -B -r1.8 MessageDigest.java
--- MessageDigest.java	17 Nov 2002 00:10:24 -0000	1.8
+++ MessageDigest.java	2 Mar 2003 18:21:26 -0000
@@ -37,6 +37,7 @@
 exception statement from your version. */
 
 package java.security;
+import java.lang.IllegalArgumentException;
 
 public abstract class MessageDigest extends MessageDigestSpi
 {
@@ -110,29 +111,50 @@
     return getInstance(algorithm, p);
   }
 
-  private static MessageDigest getInstance(String algorithm, Provider p)
+  /**
+   * Generates a MessageDigest object implementing the specified algorithm, as
+   * supplied from the specified provider, if such an algorithm is available
+   * from the provider. Note: the <code>provider</code> doesn't have to be
+   * registered.
+   *
+   * @param algorithm the name of the algorithm requested. See Appendix A in
+   * the Java Cryptography Architecture API Specification &amp; Reference for
+   * information about standard algorithm names.
+   * @param provider the provider.
+   * @return a Message Digest object implementing the specified algorithm.
+   * @throws NoSuchAlgorithmException if the algorithm is not available in the
+   * package supplied by the requested provider.
+   * @throws IllegalArgumentException if the provider is <code>null</code>.
+   * @since 1.4
+   * @see Provider
+   */
+  public static MessageDigest getInstance(String algorithm, Provider provider)
     throws NoSuchAlgorithmException
   {
+    if (provider == null)
+      throw new IllegalArgumentException();
+
     // try the name as is
-    String className = p.getProperty("MessageDigest." + algorithm);
-    if (className == null) { // try all uppercase
+    String className = provider.getProperty("MessageDigest." + algorithm);
+    if (className == null) // try all uppercase
+      {
       String upper = algorithm.toUpperCase();
-      className = p.getProperty("MessageDigest." + upper);
-      if (className == null) { // try if it's an alias
-        String alias = p.getProperty("Alg.Alias.MessageDigest." +algorithm);
-        if (alias == null) { // try all-uppercase alias name
-          alias = p.getProperty("Alg.Alias.MessageDigest." +upper);
-          if (alias == null) { // spit the dummy
+        className = provider.getProperty("MessageDigest." + upper);
+        if (className == null) // try if it's an alias
+          {
+            String alias = provider.getProperty("Alg.Alias.MessageDigest." +algorithm);
+            if (alias == null) // try all-uppercase alias name
+              {
+                alias = provider.getProperty("Alg.Alias.MessageDigest." +upper);
+                if (alias == null) // spit the dummy
             throw new NoSuchAlgorithmException(algorithm);
           }
-        }
-        className = p.getProperty("MessageDigest." + alias);
-        if (className == null) {
+            className = provider.getProperty("MessageDigest." + alias);
+            if (className == null)
           throw new NoSuchAlgorithmException(algorithm);
         }
       }
-    }
-    return getInstance(className, algorithm, p);
+    return getInstance(className, algorithm, provider);
   }
 
   private static MessageDigest getInstance(String classname,



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]