DummyKeyPairGenerator.java (clone): Removed useless instanceof check.
authorCasey Marshall <csm@gnu.org>
Mon, 30 Aug 2004 10:25:38 +0000 (10:25 +0000)
committerAndreas Tobler <andreast@gcc.gnu.org>
Mon, 30 Aug 2004 10:25:38 +0000 (12:25 +0200)
2004-08-30  Casey Marshall  <csm@gnu.org>

        * java/security/DummyKeyPairGenerator.java (clone): Removed
        useless instanceof check.
        * java/security/DummyMessageDigest.java (clone): Likewise.
        * java/security/DummySignature.java (clone): Likewise.
        * java/security/MessageDigest.java (clone): Remove useless
        instanceof check.
        * java/security/MessageDigestSpi.java (clone): Likewise.
        * java/security/Signature.java (clone): Provide meaningful
        implementation.
        * java/security/SignatureSpi.java (clone): Likewise.

From-SVN: r86755

libjava/ChangeLog
libjava/java/security/DummyKeyPairGenerator.java
libjava/java/security/DummyMessageDigest.java
libjava/java/security/DummySignature.java
libjava/java/security/MessageDigest.java
libjava/java/security/MessageDigestSpi.java
libjava/java/security/Signature.java
libjava/java/security/SignatureSpi.java

index 33a66474af3ebb70380de0e4c4cb0413a98cace5..cee3e61aef395d957c766beda094725bbc0999a8 100644 (file)
@@ -1,3 +1,16 @@
+2004-08-30  Casey Marshall  <csm@gnu.org>
+
+       * java/security/DummyKeyPairGenerator.java (clone): Removed
+       useless instanceof check.
+       * java/security/DummyMessageDigest.java (clone): Likewise.
+       * java/security/DummySignature.java (clone): Likewise.
+       * java/security/MessageDigest.java (clone): Remove useless
+       instanceof check.
+       * java/security/MessageDigestSpi.java (clone): Likewise.
+       * java/security/Signature.java (clone): Provide meaningful
+       implementation.
+       * java/security/SignatureSpi.java (clone): Likewise.
+
 2004-08-29  Mark Wielaard  <mark@klomp.org>
 
        * java/util/Arrays.java
index 3a88b86e01ba8a5899305f21bff6749283f1b516..5d3d914cdcd2db2f0558676ca0a62684b320a48a 100644 (file)
@@ -51,11 +51,8 @@ final class DummyKeyPairGenerator extends KeyPairGenerator
 
   public Object clone() throws CloneNotSupportedException
   {
-    if (!(kpgSpi instanceof Cloneable))
-      throw new CloneNotSupportedException();
-
     KeyPairGenerator result = new DummyKeyPairGenerator
-           ((KeyPairGeneratorSpi) kpgSpi.clone(), this.getAlgorithm());
+            ((KeyPairGeneratorSpi) kpgSpi.clone(), this.getAlgorithm());
     result.provider = this.getProvider();
     return result;
   }
index d7e769d328e60ba7aff7b580c39c387b4f3f5a00..703884f4b5555a78663ffefda0415915f78a30aa 100644 (file)
@@ -49,11 +49,8 @@ final class DummyMessageDigest extends MessageDigest
 
   public Object clone() throws CloneNotSupportedException
   {
-    if (!(mdSpi instanceof Cloneable))
-      throw new CloneNotSupportedException();
-
     MessageDigest result = new DummyMessageDigest
-       ((MessageDigestSpi) mdSpi.clone(), this.getAlgorithm());
+        ((MessageDigestSpi) mdSpi.clone(), this.getAlgorithm());
     result.provider = this.getProvider();
     return result;
   }
index 850f86d9dbcfd797bd85d4b83d3f4f98fe03941e..2f21cd5897fde824ab9853cc74ef7421058df008 100644 (file)
@@ -49,11 +49,8 @@ final class DummySignature extends Signature
 
   public Object clone() throws CloneNotSupportedException
   {
-    if (!(sigSpi instanceof Cloneable))
-      throw new CloneNotSupportedException();
-
     Signature result = new DummySignature
-           ((SignatureSpi) sigSpi.clone(), this.getAlgorithm());
+            ((SignatureSpi) sigSpi.clone(), this.getAlgorithm());
     result.provider = this.getProvider();
     return result;
   }
index 47b082a19f401a03e28dab2a408678412729ecb4..8e4dfecb5eb9ada51999bb893d12959ff8db21ce 100644 (file)
@@ -102,9 +102,9 @@ public abstract class MessageDigest extends MessageDigestSpi
   /**
    * Creates a message digest with the specified algorithm name.
    *
-   * @param algorithm the standard name of the digest algorithm. 
-   * See Appendix A in the Java Cryptography Architecture API 
-   * Specification &amp; Reference for information about standard 
+   * @param algorithm the standard name of the digest algorithm.
+   * See Appendix A in the Java Cryptography Architecture API
+   * Specification &amp; Reference for information about standard
    * algorithm names.
    */
   protected MessageDigest(String algorithm)
@@ -134,11 +134,11 @@ public abstract class MessageDigest extends MessageDigestSpi
     Provider[] p = Security.getProviders();
     for (int i = 0; i < p.length; i++)
       {
-       try
-         {
-           return getInstance(algorithm, p[i]);
-         }
-       catch (NoSuchAlgorithmException ignored) {}
+        try
+          {
+            return getInstance(algorithm, p[i]);
+          }
+        catch (NoSuchAlgorithmException ignored) {}
       }
 
     throw new NoSuchAlgorithmException(algorithm);
@@ -206,17 +206,17 @@ public abstract class MessageDigest extends MessageDigestSpi
       }
     catch (java.lang.reflect.InvocationTargetException ite)
       {
-       throw new NoSuchAlgorithmException(algorithm);
+        throw new NoSuchAlgorithmException(algorithm);
       }
-     
+
     if (o instanceof MessageDigestSpi)
       {
-       result = new DummyMessageDigest((MessageDigestSpi) o, algorithm);
+        result = new DummyMessageDigest((MessageDigestSpi) o, algorithm);
       }
     else if (o instanceof MessageDigest)
       {
-       result = (MessageDigest) o;
-       result.algorithm = algorithm;
+        result = (MessageDigest) o;
+        result.algorithm = algorithm;
       }
     else
       {
@@ -335,7 +335,7 @@ public abstract class MessageDigest extends MessageDigestSpi
 
     for (int i = digesta.length - 1; i >= 0; --i)
       if (digesta[i] != digestb[i])
-       return false;
+        return false;
 
     return true;
   }
@@ -383,10 +383,7 @@ public abstract class MessageDigest extends MessageDigestSpi
    */
   public Object clone() throws CloneNotSupportedException
   {
-    if (this instanceof Cloneable)
-      return super.clone();
-    else
-      throw new CloneNotSupportedException();
+    return super.clone();
   }
 
   private String digestToString()
@@ -400,12 +397,12 @@ public abstract class MessageDigest extends MessageDigestSpi
     int len = digest.length;
     for (int i = 0; i < len; ++i)
       {
-       byte b = digest[i];
-       byte high = (byte) ((b & 0xff) >>> 4);
-       byte low = (byte) (b & 0xf);
+        byte b = digest[i];
+        byte high = (byte) ((b & 0xff) >>> 4);
+        byte low = (byte) (b & 0xf);
 
-       buf.append(high > 9 ? ('a' - 10) + high : '0' + high);
-       buf.append(low > 9 ? ('a' - 10) + low : '0' + low);
+        buf.append(high > 9 ? ('a' - 10) + high : '0' + high);
+        buf.append(low > 9 ? ('a' - 10) + low : '0' + low);
       }
 
     return buf.toString();
index a50e0a085ca78e0f35f7b3d1ee637c9aa1c7d9f3..509666c6cfdbd1e96e19de03736e33e4d4764147 100644 (file)
@@ -40,15 +40,15 @@ package java.security;
 /**
    This is the Service Provider Interface (SPI) for MessageDigest
    class in java.security. It provides the back end functionality
-   for the MessageDigest class so that it can compute message 
+   for the MessageDigest class so that it can compute message
    hashes. The default hashes are SHA-1 and MD5. A message hash
    takes data of arbitrary length and produces a unique number
-   representing it. 
+   representing it.
 
    Cryptography service providers who want to implement their
    own message digest hashes need only to subclass this class.
 
-   The implementation of a Cloneable interface is left to up to 
+   The implementation of a Cloneable interface is left to up to
    the programmer of a subclass.
 
    @version 0.0
@@ -135,7 +135,7 @@ public abstract class MessageDigestSpi
   }
 
   /**
-     Resets the digest engine. Reinitializes internal variables 
+     Resets the digest engine. Reinitializes internal variables
      and clears sensitive data.
    */
   protected abstract void engineReset();
@@ -150,9 +150,6 @@ public abstract class MessageDigestSpi
    */
   public Object clone() throws CloneNotSupportedException
   {
-    if (this instanceof Cloneable)
-      return super.clone();
-    else
-      throw new CloneNotSupportedException();
+    return super.clone();
   }
 }
index b7979791042f8cdcb43a4c981462bb3f3b97c006..39c41263888541ce63b82a520bace00e6e4462f3 100644 (file)
@@ -206,7 +206,7 @@ public abstract class Signature extends SignatureSpi
   {
     if (provider == null || provider.length() == 0)
       throw new IllegalArgumentException("Illegal provider");
-    
+
     Provider p = Security.getProvider(provider);
     if (p == null)
       throw new NoSuchProviderException(provider);
@@ -251,16 +251,16 @@ public abstract class Signature extends SignatureSpi
 
     if (o instanceof SignatureSpi)
       {
-       result = new DummySignature((SignatureSpi) o, algorithm);
+        result = new DummySignature((SignatureSpi) o, algorithm);
       }
     else if (o instanceof Signature)
       {
-       result = (Signature) o;
-       result.algorithm = algorithm;
+        result = (Signature) o;
+        result.algorithm = algorithm;
       }
     else
       {
-       throw new NoSuchAlgorithmException(algorithm);
+        throw new NoSuchAlgorithmException(algorithm);
       }
     result.provider = provider;
     return result;
@@ -313,9 +313,9 @@ public abstract class Signature extends SignatureSpi
     if (certificate.getType().equals("X509"))
       {
         X509Certificate cert = (X509Certificate) certificate;
-       boolean[]array = cert.getKeyUsage();
-       if (array != null && array[0] == false)
-         throw new InvalidKeyException(
+        boolean[]array = cert.getKeyUsage();
+        if (array != null && array[0] == false)
+          throw new InvalidKeyException(
               "KeyUsage of this Certificate indicates it cannot be used for digital signing");
       }
     this.initVerify(certificate.getPublicKey());
@@ -627,6 +627,6 @@ public abstract class Signature extends SignatureSpi
    */
   public Object clone() throws CloneNotSupportedException
   {
-    throw new CloneNotSupportedException();
+    return super.clone();
   }
 }
index bf2382d8e407151d939fbc75bcf24d25b90a474e..0f95e526e4fb77ffb33986e118422c69164cf088 100644 (file)
@@ -263,7 +263,7 @@ public abstract class SignatureSpi
    */
   protected AlgorithmParameters engineGetParameters()
   {
-    throw new UnsupportedOperationException();    
+    throw new UnsupportedOperationException();
   }
 
   /**
@@ -297,6 +297,6 @@ public abstract class SignatureSpi
    */
   public Object clone() throws CloneNotSupportedException
   {
-    throw new CloneNotSupportedException();
+    return super.clone();
   }
 }