diff options
author | Abhishek Koneru <akoneru@redhat.com> | 2012-06-11 16:21:26 -0400 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-06-15 17:12:15 -0500 |
commit | 10326ad4fe1b3db620f43feb3f47c4fd008f3f33 (patch) | |
tree | 4d4a0f719bbbea6d6db53ef3fab5f3717411cfb9 /base/util/src/netscape/security/provider | |
parent | c53ca291e21761f1de5417ef596afba395a7f5d1 (diff) | |
download | pki-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/src/netscape/security/provider')
3 files changed, 84 insertions, 0 deletions
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; + } } |