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 | |
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')
20 files changed, 374 insertions, 80 deletions
diff --git a/base/ca/src/com/netscape/ca/CMSCRLExtensions.java b/base/ca/src/com/netscape/ca/CMSCRLExtensions.java index 507faa8e8..11f810af2 100644 --- a/base/ca/src/com/netscape/ca/CMSCRLExtensions.java +++ b/base/ca/src/com/netscape/ca/CMSCRLExtensions.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.security.cert.CertificateException; import java.util.Enumeration; import java.util.Hashtable; +import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; @@ -581,8 +582,9 @@ public class CMSCRLExtensions implements ICMSCRLExtensions { ip = ca.getCRLIssuingPoint(ipId); } - for (String name : nvp.keySet()) { - String value = nvp.get(name); + for (Map.Entry<String,String> entry : nvp.entrySet()) { + String name = entry.getKey(); + String value = entry.getValue(); if (name.equals(PROP_ENABLE)) { if (!(value.equals(Constants.TRUE) || value.equals(Constants.FALSE))) { @@ -618,8 +620,10 @@ public class CMSCRLExtensions implements ICMSCRLExtensions { boolean crlCACertsOnly = false; boolean issuingDistPointExtEnabled = false; - - CMSCRLExtensions cmsCRLExtensions = (CMSCRLExtensions) ip.getCRLExtensions(); + CMSCRLExtensions cmsCRLExtensions = null; + if (ip != null) { + cmsCRLExtensions = (CMSCRLExtensions) ip.getCRLExtensions(); + } if (cmsCRLExtensions != null) { issuingDistPointExtEnabled = cmsCRLExtensions.isCRLExtensionEnabled(IssuingDistributionPointExtension.NAME); diff --git a/base/ca/src/com/netscape/ca/CRLIssuingPoint.java b/base/ca/src/com/netscape/ca/CRLIssuingPoint.java index 5dd823737..46891fd6b 100644 --- a/base/ca/src/com/netscape/ca/CRLIssuingPoint.java +++ b/base/ca/src/com/netscape/ca/CRLIssuingPoint.java @@ -25,6 +25,7 @@ import java.util.Date; import java.util.Enumeration; import java.util.Hashtable; import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.TimeZone; @@ -930,8 +931,9 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable { boolean noRestart = true; boolean modifiedSchedule = false; - for (String name : params.keySet()) { - String value = params.get(name); + for (Map.Entry<String, String> entry : params.entrySet()) { + String name = entry.getKey(); + String value = entry.getValue(); // -- Update Schema -- if (name.equals(Constants.PR_ENABLE_CRL)) { @@ -2707,7 +2709,7 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable { long totalTime = 0; long crlTime = 0; long deltaTime = 0; - String splitTimes = " ("; + StringBuilder splitTimes = new StringBuilder(" ("); for (int i = 0; i < mSplits.length; i++) { totalTime += mSplits[i]; if (i > 0 && i < 5) { @@ -2716,13 +2718,10 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable { crlTime += mSplits[i]; } if (i > 0) - splitTimes += ","; - splitTimes += Long.toString(mSplits[i]); + splitTimes.append(","); + splitTimes.append(mSplits[i]); } - splitTimes += - "," - + Long.toString(deltaTime) + "," + Long.toString(crlTime) + "," - + Long.toString(totalTime) + ")"; + splitTimes.append(String.format(",%d,%d,%d)",deltaTime,crlTime,totalTime)); mLogger.log(ILogger.EV_AUDIT, ILogger.S_OTHER, AuditFormat.LEVEL, CMS.getLogMessage("CMSCORE_CA_CA_CRL_UPDATED"), @@ -3095,14 +3094,12 @@ class CertRecProcessor implements IElementProcessor { return includeCert; } boolean reasonMatch = false; - if (reason != null) { - if (mOnlySomeReasons != null) { - reasonMatch = mOnlySomeReasons.get(reasonIndex); - if (reasonMatch != true) { - includeCert = false; - } else { - CMS.debug("onlySomeReasons match! reason: " + reason); - } + if (mOnlySomeReasons != null) { + reasonMatch = mOnlySomeReasons.get(reasonIndex); + if (reasonMatch != true) { + includeCert = false; + } else { + CMS.debug("onlySomeReasons match! reason: " + reason); } } @@ -3150,9 +3147,7 @@ class CertRecProcessor implements IElementProcessor { if (includeCert == true) { mCRLCerts.put(serialNumber, newRevokedCert); - if (serialNumber != null) { - CMS.debug("Putting certificate serial: 0x" + serialNumber.toString(16) + " into CRL hashtable"); - } + CMS.debug("Putting certificate serial: 0x" + serialNumber.toString(16) + " into CRL hashtable"); } } catch (EBaseException e) { CMS.debug( diff --git a/base/common/src/com/netscape/certsrv/common/NameValuePairs.java b/base/common/src/com/netscape/certsrv/common/NameValuePairs.java index 0f95ad2e3..30491cdd0 100644 --- a/base/common/src/com/netscape/certsrv/common/NameValuePairs.java +++ b/base/common/src/com/netscape/certsrv/common/NameValuePairs.java @@ -18,6 +18,7 @@ package com.netscape.certsrv.common; import java.util.LinkedHashMap; +import java.util.Map; import java.util.StringTokenizer; /** @@ -43,12 +44,11 @@ public class NameValuePairs extends LinkedHashMap<String, String> { * @return string representation */ public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); - for (String name : keySet()) { - String value = get(name); + for (Map.Entry<String, String> entry : entrySet()) { - buf.append(name + "=" + value); + buf.append(String.format("%s=%s", entry.getKey(), entry.getValue())); buf.append("\n"); } diff --git a/base/common/src/com/netscape/cmscore/base/SimpleProperties.java b/base/common/src/com/netscape/cmscore/base/SimpleProperties.java index 527b4f694..c1ec27a8c 100644 --- a/base/common/src/com/netscape/cmscore/base/SimpleProperties.java +++ b/base/common/src/com/netscape/cmscore/base/SimpleProperties.java @@ -453,4 +453,30 @@ public class SimpleProperties extends Hashtable<String, String> { h.put(key, get(key)); } } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((defaults == null) ? 0 : defaults.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; + SimpleProperties other = (SimpleProperties) obj; + if (defaults == null) { + if (other.defaults != null) + return false; + } else if (!defaults.equals(other.defaults)) + return false; + return true; + } + } diff --git a/base/common/src/com/netscape/cmscore/logging/Auditor.java b/base/common/src/com/netscape/cmscore/logging/Auditor.java index eef4ad14b..f0bcb5bee 100644 --- a/base/common/src/com/netscape/cmscore/logging/Auditor.java +++ b/base/common/src/com/netscape/cmscore/logging/Auditor.java @@ -18,9 +18,7 @@ package com.netscape.cmscore.logging; -import java.util.Collection; import java.util.Enumeration; -import java.util.Iterator; import java.util.Map; import com.netscape.certsrv.apps.CMS; @@ -98,62 +96,62 @@ public class Auditor implements IAuditor { // if no signed audit object exists, bail if (signedAuditLogger == null) return null; - - String parameters = SIGNED_AUDIT_EMPTY_NAME_VALUE_PAIR; + StringBuilder parameters = new StringBuilder(); // always identify the scope of the request if (scope != null) { - parameters = SIGNED_AUDIT_SCOPE + parameters.append(SIGNED_AUDIT_SCOPE + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + scope; + + scope); + } else { + parameters.append(SIGNED_AUDIT_EMPTY_NAME_VALUE_PAIR); } // identify the operation type of the request if (type != null) { - parameters += SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER; + parameters.append(SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER); - parameters += SIGNED_AUDIT_OPERATION + parameters.append(SIGNED_AUDIT_OPERATION + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + type; + + type); } // identify the resource type of the request if (id != null) { - parameters += SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER; + parameters.append(SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER); - parameters += SIGNED_AUDIT_RESOURCE + parameters.append(SIGNED_AUDIT_RESOURCE + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + id; + + id); } - if (params == null) return parameters; + if (params == null) return parameters.toString(); // identify any remaining request parameters - Collection<String> names = params.keySet(); - for (Iterator<String> i = names.iterator(); i.hasNext(); ) { - String name = i.next(); + for (Map.Entry<String,String> entry : params.entrySet() ) { + String name = entry.getKey(); // skip "RULENAME" parameter if (name.equals(SIGNED_AUDIT_RULENAME)) continue; - parameters += SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER; + parameters.append(SIGNED_AUDIT_NAME_VALUE_PAIRS_DELIMITER); - String value = params.get(name); + String value = entry.getValue(); if (value == null) { - parameters += name + parameters.append(name + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + ILogger.SIGNED_AUDIT_EMPTY_VALUE; + + ILogger.SIGNED_AUDIT_EMPTY_VALUE); continue; } value = value.trim(); if (value.equals("")) { - parameters += name + parameters.append(name + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + ILogger.SIGNED_AUDIT_EMPTY_VALUE; + + ILogger.SIGNED_AUDIT_EMPTY_VALUE); continue; } @@ -182,19 +180,19 @@ public class Auditor implements IAuditor { name.equals(Constants.PR_TOKEN_PASSWD)) { // hide password value - parameters += name - + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + SIGNED_AUDIT_PASSWORD_VALUE; + parameters.append(name + + SIGNED_AUDIT_NAME_VALUE_DELIMITER + + SIGNED_AUDIT_PASSWORD_VALUE); } else { // process normally - parameters += name - + SIGNED_AUDIT_NAME_VALUE_DELIMITER - + value; + parameters.append(name + + SIGNED_AUDIT_NAME_VALUE_DELIMITER + + value); } } - return parameters; + return parameters.toString(); } @Override diff --git a/base/common/src/com/netscape/cmscore/realm/ACL.java b/base/common/src/com/netscape/cmscore/realm/ACL.java index 6c06c92c1..13fcdac44 100644 --- a/base/common/src/com/netscape/cmscore/realm/ACL.java +++ b/base/common/src/com/netscape/cmscore/realm/ACL.java @@ -150,15 +150,15 @@ public class ACL { * <resource name>[<ACLEntry1>,<ACLEntry 2>,...<ACLEntry N>] */ public String toString() { - String entries = ""; + StringBuilder entries = new StringBuilder(); Enumeration<ACLEntry> e = entries(); for (; e.hasMoreElements();) { ACLEntry entry = e.nextElement(); - entries += entry.toString(); + entries.append(entry); if (e.hasMoreElements()) - entries += ","; + entries.append(","); } return getName() + "[" + entries + "]"; } diff --git a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java index abd27fddf..0576bcf58 100644 --- a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java +++ b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java @@ -869,9 +869,6 @@ public class PKIJNDIRealm extends JNDIRealm { private synchronized void loadAuthzProperties(Context context) { if (authzProperties == null && context != null) { - ClassLoader loader = this.getClass().getClassLoader(); - if (loader == null) - loader = ClassLoader.getSystemClassLoader(); InputStream inputStream = context.getServletContext().getResourceAsStream(PROP_AUTH_FILE_PATH); diff --git a/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java b/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java index b7bd43793..317b8e56c 100644 --- a/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java +++ b/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java @@ -1,9 +1,7 @@ package com.netscape.cmscore.request; import java.util.Hashtable; -import java.util.Iterator; import java.util.Map; -import java.util.Set; /** * Subclass of Hashtable returned by IRequest.getExtDataInHashtable. Its @@ -56,14 +54,6 @@ public class ExtDataHashtable<V> extends Hashtable<String, V> { return super.put(oKey.toLowerCase(), val); } - public void putAll(Map<? extends String, ? extends V> map) { - Set<? extends String> keys = map.keySet(); - for (Iterator<? extends String> i = keys.iterator(); i.hasNext();) { - Object key = i.next(); - put((String) key, map.get(key)); - } - } - public V remove(Object o) { if (o instanceof String) { String key = (String) o; diff --git a/base/common/test/com/netscape/cmscore/request/RequestTest.java b/base/common/test/com/netscape/cmscore/request/RequestTest.java index 0e98ab084..7a655fd08 100644 --- a/base/common/test/com/netscape/cmscore/request/RequestTest.java +++ b/base/common/test/com/netscape/cmscore/request/RequestTest.java @@ -631,6 +631,36 @@ public class RequestTest extends CMSBaseTestCase { getEncodedCalled = true; return new byte[] {}; } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + getOuterType().hashCode(); + result = prime * result + (getEncodedCalled ? 1231 : 1237); + 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; + X509CertInfoStub other = (X509CertInfoStub) obj; + if (!getOuterType().equals(other.getOuterType())) + return false; + if (getEncodedCalled != other.getEncodedCalled) + return false; + return true; + } + + private RequestTest getOuterType() { + return RequestTest.this; + } + } class RevokedCertImplStub extends RevokedCertImpl { diff --git a/base/java-tools/src/com/netscape/cmstools/CMCResponse.java b/base/java-tools/src/com/netscape/cmstools/CMCResponse.java index eae0b7303..50db485a4 100644 --- a/base/java-tools/src/com/netscape/cmstools/CMCResponse.java +++ b/base/java-tools/src/com/netscape/cmstools/CMCResponse.java @@ -122,10 +122,10 @@ public class CMCResponse { ASN1Util.encode(sts.elementAt(j))); SEQUENCE seq = cst.getBodyList(); - String s = " BodyList: "; + StringBuilder s = new StringBuilder(" BodyList: "); for (int k = 0; k < seq.size(); k++) { INTEGER n = (INTEGER) seq.elementAt(k); - s = s + n.toString() + " "; + s.append(n.toString() + " "); } System.out.println(s); int st = cst.getStatus(); diff --git a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java index 90d1eff9e..100304cfe 100644 --- a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java +++ b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java @@ -86,7 +86,7 @@ public class PrettyPrintCert { X509CertImpl cert = null; Locale aLocale = null; CertPrettyPrint certDetails = null; - String pp = ""; + StringBuilder pp = new StringBuilder(); FileOutputStream outputCert = null; boolean mSimpleInfo = false; String inputfile = null; @@ -194,11 +194,10 @@ public class PrettyPrintCert { X500Name dname = (X500Name) csn.get(CertificateSubjectName.DN_NAME); - pp = ""; RDN[] rdns = dname.getNames(); for (int i = rdns.length - 1; i >= 0; i--) { - pp = pp + rdns[i] + "\n"; + pp.append(rdns[i] + "\n"); } } catch (Exception e) { @@ -213,7 +212,7 @@ public class PrettyPrintCert { certDetails = new CertPrettyPrint(cert); // (9) Convert the CertPrettyPrint() object into a String() object - pp = certDetails.toString(aLocale); + pp.append(certDetails.toString(aLocale)); } // (10) Finally, "pretty print" the actual certificate to the console @@ -230,7 +229,7 @@ public class PrettyPrintCert { } try { - outputCert.write(pp.getBytes()); + outputCert.write(pp.toString().getBytes()); } catch (IOException e) { System.out.println("PrettyPrintCert: Unexpected error " + "encountered while attempting to write() " + diff --git a/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java b/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java index 16f18500c..5cf513417 100644 --- a/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java +++ b/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java @@ -675,4 +675,29 @@ class CMSProperties extends Hashtable<String, String> { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((defaults == null) ? 0 : defaults.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; + CMSProperties other = (CMSProperties) obj; + if (defaults == null) { + if (other.defaults != null) + return false; + } else if (!defaults.equals(other.defaults)) + return false; + return true; + } } 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; + } + } |