summaryrefslogtreecommitdiffstats
path: root/base/util/src/netscape/security/provider/RSAPublicKey.java
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-07-09 15:12:11 -0400
committerAde Lee <alee@redhat.com>2012-07-12 16:42:18 -0400
commit15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd (patch)
treef3bd2a816e816ad565f13ce90816a7fd7fb32454 /base/util/src/netscape/security/provider/RSAPublicKey.java
parent9e4e40b80de0ba47702392b9ad6ccecf67496db7 (diff)
downloadpki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.tar.gz
pki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.tar.xz
pki-15ac6d2b8e83a73ac1f62ab0da0d6a85717f28fd.zip
NO_HASHCODE_OVERRIDDEN
Diffstat (limited to 'base/util/src/netscape/security/provider/RSAPublicKey.java')
-rw-r--r--base/util/src/netscape/security/provider/RSAPublicKey.java39
1 files changed, 25 insertions, 14 deletions
diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java
index 40f5583ac..bd5aa2fe4 100644
--- a/base/util/src/netscape/security/provider/RSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/RSAPublicKey.java
@@ -150,23 +150,34 @@ public final class RSAPublicKey extends X509Key implements Serializable {
}
@Override
- public boolean equals(Object object) {
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((modulus == null) ? 0 : modulus.hashCode());
+ result = prime * result + ((publicExponent == null) ? 0 : publicExponent.hashCode());
+ return result;
+ }
- if (object == null) {
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
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))) {
+ if (getClass() != obj.getClass())
+ return false;
+ RSAPublicKey other = (RSAPublicKey) obj;
+ if (modulus == null) {
+ if (other.modulus != null)
return false;
- }
- return super.equals(rhs);
- }
-
- return false;
+ } else if (!modulus.equals(other.modulus))
+ return false;
+ if (publicExponent == null) {
+ if (other.publicExponent != null)
+ return false;
+ } else if (!publicExponent.equals(other.publicExponent))
+ return false;
+ return true;
}
public boolean bigIntEquals(BigInt x, BigInt y) {