From 10326ad4fe1b3db620f43feb3f47c4fd008f3f33 Mon Sep 17 00:00:00 2001 From: Abhishek Koneru Date: Mon, 11 Jun 2012 16:21:26 -0400 Subject: Fixes for Coverity issues of type Stringbuffer, NO_EQUALS_METHOD , REVERSE_INULL,Wrong_Map_Iterators --- base/util/src/netscape/security/x509/AlgIdDSA.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'base/util/src/netscape/security/x509/AlgIdDSA.java') 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; + } + } -- cgit