summaryrefslogtreecommitdiffstats
path: root/base/util
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-06-11 16:21:26 -0400
committerEndi Sukma Dewata <edewata@redhat.com>2012-06-15 17:12:15 -0500
commit10326ad4fe1b3db620f43feb3f47c4fd008f3f33 (patch)
tree4d4a0f719bbbea6d6db53ef3fab5f3717411cfb9 /base/util
parentc53ca291e21761f1de5417ef596afba395a7f5d1 (diff)
downloadpki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.tar.gz
pki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.tar.xz
pki-10326ad4fe1b3db620f43feb3f47c4fd008f3f33.zip
Fixes for Coverity issues of type Stringbuffer, NO_EQUALS_METHOD , REVERSE_INULL,Wrong_Map_Iterators
Diffstat (limited to 'base/util')
-rw-r--r--base/util/src/netscape/security/pkcs/PKCS10Attributes.java26
-rw-r--r--base/util/src/netscape/security/provider/DSAPrivateKey.java26
-rw-r--r--base/util/src/netscape/security/provider/DSAPublicKey.java26
-rw-r--r--base/util/src/netscape/security/provider/RSAPublicKey.java32
-rw-r--r--base/util/src/netscape/security/x509/AlgIdDSA.java42
-rwxr-xr-xbase/util/src/netscape/security/x509/CRLExtensions.java26
-rw-r--r--base/util/src/netscape/security/x509/CertificateExtensions.java26
-rw-r--r--base/util/src/netscape/security/x509/Extensions.java26
8 files changed, 230 insertions, 0 deletions
diff --git a/base/util/src/netscape/security/pkcs/PKCS10Attributes.java b/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
index d9b463b5f..22a0dce21 100644
--- a/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
+++ b/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
@@ -144,4 +144,30 @@ public class PKCS10Attributes extends Vector<PKCS10Attribute> implements DerEnco
public Enumeration<PKCS10Attribute> getElements() {
return map.elements();
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PKCS10Attributes other = (PKCS10Attributes) obj;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/provider/DSAPrivateKey.java b/base/util/src/netscape/security/provider/DSAPrivateKey.java
index 8b64fbf6c..385aa173c 100644
--- a/base/util/src/netscape/security/provider/DSAPrivateKey.java
+++ b/base/util/src/netscape/security/provider/DSAPrivateKey.java
@@ -141,4 +141,30 @@ public final class DSAPrivateKey extends PKCS8Key
throw new InvalidKeyException(e.getMessage());
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((x == null) ? 0 : x.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DSAPrivateKey other = (DSAPrivateKey) obj;
+ if (x == null) {
+ if (other.x != null)
+ return false;
+ } else if (!x.equals(other.x))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/provider/DSAPublicKey.java b/base/util/src/netscape/security/provider/DSAPublicKey.java
index 66c3eb45a..481b9ee7f 100644
--- a/base/util/src/netscape/security/provider/DSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/DSAPublicKey.java
@@ -130,4 +130,30 @@ public final class DSAPublicKey extends X509Key
e.getMessage());
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((y == null) ? 0 : y.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DSAPublicKey other = (DSAPublicKey) obj;
+ if (y == null) {
+ if (other.y != null)
+ return false;
+ } else if (!y.equals(other.y))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java
index a70d1aeee..40f5583ac 100644
--- a/base/util/src/netscape/security/provider/RSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/RSAPublicKey.java
@@ -149,4 +149,36 @@ public final class RSAPublicKey extends X509Key implements Serializable {
}
}
+ @Override
+ public boolean equals(Object object) {
+
+ if (object == null) {
+ return false;
+ }
+ if (object instanceof RSAPublicKey) {
+ RSAPublicKey rhs = (RSAPublicKey) object;
+ if (this == rhs) {
+ return true;
+ }
+ if (!(bigIntEquals(this.modulus, rhs.modulus) && bigIntEquals(this.publicExponent, rhs.publicExponent))) {
+ return false;
+ }
+ return super.equals(rhs);
+ }
+
+ return false;
+ }
+
+ public boolean bigIntEquals(BigInt x, BigInt y) {
+ if (x == null) {
+ if (y != null) {
+ return false;
+ }
+ } else {
+ if (!x.equals(y)) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/base/util/src/netscape/security/x509/AlgIdDSA.java b/base/util/src/netscape/security/x509/AlgIdDSA.java
index a34c5f59f..1f00b0355 100644
--- a/base/util/src/netscape/security/x509/AlgIdDSA.java
+++ b/base/util/src/netscape/security/x509/AlgIdDSA.java
@@ -174,4 +174,46 @@ public final class AlgIdDSA extends AlgorithmId implements DSAParams {
"\n g:\n" + (new BigInt(g)).toString() +
"\n";
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((g == null) ? 0 : g.hashCode());
+ result = prime * result + ((p == null) ? 0 : p.hashCode());
+ result = prime * result + ((q == null) ? 0 : q.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other instanceof AlgIdDSA) {
+ AlgIdDSA rhs = (AlgIdDSA) other;
+ if (this == rhs) {
+ return true;
+ }
+ if (!(bigIntEquals(this.p, rhs.p) && bigIntEquals(this.q, rhs.q) && bigIntEquals(this.g, rhs.g))) {
+ return false;
+ }
+ return super.equals(rhs);
+ }
+ return false;
+ }
+
+ public boolean bigIntEquals(BigInteger x, BigInteger y) {
+ if (x == null) {
+ if (y != null) {
+ return false;
+ }
+ } else {
+ if (!x.equals(y)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/x509/CRLExtensions.java b/base/util/src/netscape/security/x509/CRLExtensions.java
index 60a6532ba..9c844cd3d 100755
--- a/base/util/src/netscape/security/x509/CRLExtensions.java
+++ b/base/util/src/netscape/security/x509/CRLExtensions.java
@@ -226,4 +226,30 @@ public class CRLExtensions extends Vector<Extension> {
public Enumeration<Extension> getElements() {
return (map.elements());
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CRLExtensions other = (CRLExtensions) obj;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/x509/CertificateExtensions.java b/base/util/src/netscape/security/x509/CertificateExtensions.java
index a8ce5ebee..93be196ab 100644
--- a/base/util/src/netscape/security/x509/CertificateExtensions.java
+++ b/base/util/src/netscape/security/x509/CertificateExtensions.java
@@ -273,4 +273,30 @@ public class CertificateExtensions extends Vector<Extension>
public String getName() {
return (NAME);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CertificateExtensions other = (CertificateExtensions) obj;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ return true;
+ }
+
}
diff --git a/base/util/src/netscape/security/x509/Extensions.java b/base/util/src/netscape/security/x509/Extensions.java
index 3feac9599..109f795e9 100644
--- a/base/util/src/netscape/security/x509/Extensions.java
+++ b/base/util/src/netscape/security/x509/Extensions.java
@@ -223,4 +223,30 @@ public class Extensions extends Vector<Extension>
public String getName() {
return (NAME);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((map == null) ? 0 : map.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Extensions other = (Extensions) obj;
+ if (map == null) {
+ if (other.map != null)
+ return false;
+ } else if (!map.equals(other.map))
+ return false;
+ return true;
+ }
+
}