aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/security
diff options
context:
space:
mode:
authorCasey Marshall <csm@gnu.org>2004-08-30 10:25:38 +0000
committerAndreas Tobler <andreast@gcc.gnu.org>2004-08-30 12:25:38 +0200
commit28839b70d0fa8703311d39ca2ce1f8a17b8d20d6 (patch)
treed5939b84cb5fa05f18e3b26411d09f41525bcafd /libjava/java/security
parentce521a9c85bfb120a9904293897a256e83477eca (diff)
downloadgcc-28839b70d0fa8703311d39ca2ce1f8a17b8d20d6.zip
gcc-28839b70d0fa8703311d39ca2ce1f8a17b8d20d6.tar.gz
gcc-28839b70d0fa8703311d39ca2ce1f8a17b8d20d6.tar.bz2
DummyKeyPairGenerator.java (clone): Removed useless instanceof check.
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
Diffstat (limited to 'libjava/java/security')
-rw-r--r--libjava/java/security/DummyKeyPairGenerator.java5
-rw-r--r--libjava/java/security/DummyMessageDigest.java5
-rw-r--r--libjava/java/security/DummySignature.java5
-rw-r--r--libjava/java/security/MessageDigest.java43
-rw-r--r--libjava/java/security/MessageDigestSpi.java13
-rw-r--r--libjava/java/security/Signature.java18
-rw-r--r--libjava/java/security/SignatureSpi.java4
7 files changed, 39 insertions, 54 deletions
diff --git a/libjava/java/security/DummyKeyPairGenerator.java b/libjava/java/security/DummyKeyPairGenerator.java
index 3a88b86..5d3d914 100644
--- a/libjava/java/security/DummyKeyPairGenerator.java
+++ b/libjava/java/security/DummyKeyPairGenerator.java
@@ -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;
}
diff --git a/libjava/java/security/DummyMessageDigest.java b/libjava/java/security/DummyMessageDigest.java
index d7e769d..703884f 100644
--- a/libjava/java/security/DummyMessageDigest.java
+++ b/libjava/java/security/DummyMessageDigest.java
@@ -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;
}
diff --git a/libjava/java/security/DummySignature.java b/libjava/java/security/DummySignature.java
index 850f86d..2f21cd5 100644
--- a/libjava/java/security/DummySignature.java
+++ b/libjava/java/security/DummySignature.java
@@ -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;
}
diff --git a/libjava/java/security/MessageDigest.java b/libjava/java/security/MessageDigest.java
index 47b082a..8e4dfec 100644
--- a/libjava/java/security/MessageDigest.java
+++ b/libjava/java/security/MessageDigest.java
@@ -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();
diff --git a/libjava/java/security/MessageDigestSpi.java b/libjava/java/security/MessageDigestSpi.java
index a50e0a0..509666c 100644
--- a/libjava/java/security/MessageDigestSpi.java
+++ b/libjava/java/security/MessageDigestSpi.java
@@ -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();
}
}
diff --git a/libjava/java/security/Signature.java b/libjava/java/security/Signature.java
index b797979..39c4126 100644
--- a/libjava/java/security/Signature.java
+++ b/libjava/java/security/Signature.java
@@ -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();
}
}
diff --git a/libjava/java/security/SignatureSpi.java b/libjava/java/security/SignatureSpi.java
index bf2382d..0f95e52 100644
--- a/libjava/java/security/SignatureSpi.java
+++ b/libjava/java/security/SignatureSpi.java
@@ -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();
}
}