summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/util/src/netscape/security/x509/RDN.java33
-rw-r--r--base/util/src/netscape/security/x509/X500Name.java31
2 files changed, 34 insertions, 30 deletions
diff --git a/base/util/src/netscape/security/x509/RDN.java b/base/util/src/netscape/security/x509/RDN.java
index dc26eb214..bf8212305 100644
--- a/base/util/src/netscape/security/x509/RDN.java
+++ b/base/util/src/netscape/security/x509/RDN.java
@@ -18,6 +18,7 @@
package netscape.security.x509;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
@@ -201,25 +202,25 @@ public class RDN {
// other public methods.
- /**
- * Checks if this RDN is the same as another by comparing the AVAs
- * in the RDNs.
- *
- * @param other the other RDN.
- * @return true iff the other RDN is the same.
- */
- public boolean equals(RDN other) {
- int i;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(assertion);
+ return result;
+ }
- if (other == this)
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
return true;
- if (assertion.length != other.assertion.length)
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RDN other = (RDN) obj;
+ if (!Arrays.equals(assertion, other.assertion))
return false;
-
- for (i = 0; i < assertion.length; i++)
- if (!assertion[i].equals(other.assertion[i]))
- return false;
-
return true;
}
diff --git a/base/util/src/netscape/security/x509/X500Name.java b/base/util/src/netscape/security/x509/X500Name.java
index c2886dab2..d0111a27e 100644
--- a/base/util/src/netscape/security/x509/X500Name.java
+++ b/base/util/src/netscape/security/x509/X500Name.java
@@ -19,6 +19,7 @@ package netscape.security.x509;
import java.io.IOException;
import java.security.Principal;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
@@ -285,23 +286,25 @@ public class X500Name implements Principal, GeneralNameInterface {
}
}
- /**
- * Compares this name with another, for equality.
- *
- * @return true iff the names are identical.
- */
- synchronized public boolean equals(X500Name other) {
- int i;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(names);
+ return result;
+ }
- if (this == other)
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
return true;
-
- if (names.length != other.names.length)
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ X500Name other = (X500Name) obj;
+ if (!Arrays.equals(names, other.names))
return false;
- for (i = 0; i < names.length; i++) {
- if (!names[i].equals(other.names[i]))
- return false;
- }
return true;
}