>From ab467c41f999f87f4b8d76d60bcbc0621ab0376c Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Mon, 11 Jun 2012 16:21:26 -0400
Subject: [PATCH] Fixes for Coverity issues of type Stringbuffer,
 NO_EQUALS_METHOD , REVERSE_INULL,Wrong_Map_Iterators

---
 base/ca/src/com/netscape/ca/CMSCRLExtensions.java  |   12 +++--
 base/ca/src/com/netscape/ca/CRLIssuingPoint.java   |   24 ++++-----
 .../netscape/certsrv/common/NameValuePairs.java    |    6 +--
 .../netscape/cmscore/base/SimpleProperties.java    |   22 ++++++++
 .../src/com/netscape/cmscore/logging/Auditor.java  |   56 ++++++++++----------
 .../common/src/com/netscape/cmscore/realm/ACL.java |    8 +--
 .../com/netscape/cmscore/realm/PKIJNDIRealm.java   |    3 --
 .../netscape/cmscore/request/ExtDataHashtable.java |    9 ++--
 .../com/netscape/cmscore/request/RequestTest.java  |   20 +++++++
 .../src/com/netscape/cmstools/CMCResponse.java     |    6 +--
 .../src/com/netscape/cmstools/PrettyPrintCert.java |   11 ++--
 .../netscape/pkisilent/common/CMSProperties.java   |   22 ++++++++
 .../netscape/security/pkcs/PKCS10Attributes.java   |   25 +++++++++
 .../netscape/security/provider/DSAPrivateKey.java  |   27 ++++++++++
 .../netscape/security/provider/DSAPublicKey.java   |   27 ++++++++++
 .../netscape/security/provider/RSAPublicKey.java   |   32 +++++++++++
 base/util/src/netscape/security/x509/AlgIdDSA.java |   33 ++++++++++++
 .../src/netscape/security/x509/CRLExtensions.java  |   25 +++++++++
 .../security/x509/CertificateExtensions.java       |   25 +++++++++
 .../src/netscape/security/x509/Extensions.java     |   25 +++++++++
 20 files changed, 348 insertions(+), 70 deletions(-)

diff --git a/base/ca/src/com/netscape/ca/CMSCRLExtensions.java b/base/ca/src/com/netscape/ca/CMSCRLExtensions.java
index 507faa8e892f8df78b806778e81130556c3431a1..72d6c5a6474cd2e65000248ba59550776db013a2 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 5dd823737ac116bfbc10958ddf7d83a892a0e479..f58e60bd454b78d773c5f6ccec6c736e0c6a9210 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 = "  (";
+                StringBuffer splitTimes = new StringBuffer("  (");
                 for (int i = 0; i < mSplits.length; i++) {
                     totalTime += mSplits[i];
                     if (i > 0 && i < 5) {
@@ -2716,13 +2718,11 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
                         crlTime += mSplits[i];
                     }
                     if (i > 0)
-                        splitTimes += ",";
-                    splitTimes += Long.toString(mSplits[i]);
+                        splitTimes.append(",");
+                    splitTimes.append(Long.toString(mSplits[i]));
                 }
-                splitTimes +=
-                        ","
-                                + Long.toString(deltaTime) + "," + Long.toString(crlTime) + ","
-                                + Long.toString(totalTime) + ")";
+                splitTimes.append("," + Long.toString(deltaTime) + "," + Long.toString(crlTime) + ","
+                        + Long.toString(totalTime) + ")");
                 mLogger.log(ILogger.EV_AUDIT, ILogger.S_OTHER,
                             AuditFormat.LEVEL,
                             CMS.getLogMessage("CMSCORE_CA_CA_CRL_UPDATED"),
@@ -2734,7 +2734,7 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
                                     Long.toString(mCRLSize),
                                     Long.toString(totalTime),
                                     Long.toString(crlTime),
-                                    Long.toString(deltaTime) + splitTimes
+                                    Long.toString(deltaTime) + splitTimes.toString()
                             }
                            );
                 CMS.debug("Finished Logging CRL Update to transaction log");
@@ -3095,7 +3095,6 @@ class CertRecProcessor implements IElementProcessor {
             return includeCert;
         }
         boolean reasonMatch = false;
-        if (reason != null) {
             if (mOnlySomeReasons != null) {
                 reasonMatch = mOnlySomeReasons.get(reasonIndex);
                 if (reasonMatch != true) {
@@ -3104,7 +3103,6 @@ class CertRecProcessor implements IElementProcessor {
                     CMS.debug("onlySomeReasons match! reason: " + reason);
                 }
             }
-        }
 
         return includeCert;
     }
@@ -3150,9 +3148,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");
-                }
             }
         } 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 0f95ad2e3466aa38bbabc76c806881610ca9dba5..2060f953111f49f795a62f0f6d9ee58908a8d11b 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;
 
 /**
@@ -45,10 +46,9 @@ public class NameValuePairs extends LinkedHashMap<String, String> {
     public String toString() {
         StringBuffer buf = new StringBuffer();
 
-        for (String name : keySet()) {
-            String value = get(name);
+        for (Map.Entry<String, String> entry : entrySet()) {
 
-            buf.append(name + "=" + value);
+            buf.append(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 527b4f694aa990a5e968ab0cf233bd1b6de10014..a8385b1e66421671733162d4677c37b9ac199a3c 100644
--- a/base/common/src/com/netscape/cmscore/base/SimpleProperties.java
+++ b/base/common/src/com/netscape/cmscore/base/SimpleProperties.java
@@ -453,4 +453,26 @@ public class SimpleProperties extends Hashtable<String, String> {
             h.put(key, get(key));
         }
     }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof SimpleProperties) {
+            SimpleProperties rhs = (SimpleProperties) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.defaults == null) {
+                if (rhs.defaults != null) {
+                    return false;
+                }
+            } else if (!this.defaults.equals(rhs.defaults)) {
+                return false;
+            }
+            return super.equals(rhs);
+        }
+        return false;
+    }
 }
diff --git a/base/common/src/com/netscape/cmscore/logging/Auditor.java b/base/common/src/com/netscape/cmscore/logging/Auditor.java
index eef4ad14b4e046b99e17ac9aa82af967d22f0688..5109bcc7fae16ec9d3d77984d5c2992eb99befc0 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;
+        StringBuffer parameters;
 
         // always identify the scope of the request
         if (scope != null) {
-            parameters = SIGNED_AUDIT_SCOPE
+            parameters = new StringBuffer(SIGNED_AUDIT_SCOPE
                     + SIGNED_AUDIT_NAME_VALUE_DELIMITER
-                    + scope;
+                    + scope);
+        } else {
+            parameters = new StringBuffer(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 6c06c92c16312a5d23d315ab6bc51be6414fc460..57b9ef6448c05cba0aaff6e307ba7142b483578e 100644
--- a/base/common/src/com/netscape/cmscore/realm/ACL.java
+++ b/base/common/src/com/netscape/cmscore/realm/ACL.java
@@ -150,17 +150,17 @@ public class ACL  {
      *         <resource name>[<ACLEntry1>,<ACLEntry 2>,...<ACLEntry N>]
      */
     public String toString() {
-        String entries = "";
+        StringBuffer entries = new StringBuffer();
         Enumeration<ACLEntry> e = entries();
 
         for (; e.hasMoreElements();) {
             ACLEntry entry = e.nextElement();
 
-            entries += entry.toString();
+            entries.append(entry.toString());
             if (e.hasMoreElements())
-                entries += ",";
+                entries.append(",");
         }
-        return getName() + "[" + entries + "]";
+        return getName() + "[" + entries.toString() + "]";
     }
 
     /**
diff --git a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
index abd27fddfcaad55ef8537885c58a352e30e8220d..0576bcf5873306482cde0de4a9a92a3e01aab2e2 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 b7bd43793d030799729c698d59c7ac484ba1cbf9..3f55b5f67e49d7ad4cfa3ade367653b706d38f94 100644
--- a/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java
+++ b/base/common/src/com/netscape/cmscore/request/ExtDataHashtable.java
@@ -57,10 +57,11 @@ public class ExtDataHashtable<V> extends Hashtable<String, V> {
     }
 
     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));
+        Set<?> keys = map.entrySet();
+        for (Iterator<?> i = keys.iterator(); i.hasNext();) {
+            @SuppressWarnings("unchecked")
+            Map.Entry<? extends String, ? extends V> entry = (Map.Entry<? extends String, ? extends V>) i.next();
+            put(entry.getKey(), entry.getValue());
         }
     }
 
diff --git a/base/common/test/com/netscape/cmscore/request/RequestTest.java b/base/common/test/com/netscape/cmscore/request/RequestTest.java
index 0e98ab084dbb6258a8756f606995074e5ce4198c..ba0f49e3613b0525d023ca04e69b3c54168e32c6 100644
--- a/base/common/test/com/netscape/cmscore/request/RequestTest.java
+++ b/base/common/test/com/netscape/cmscore/request/RequestTest.java
@@ -631,6 +631,26 @@ public class RequestTest extends CMSBaseTestCase {
             getEncodedCalled = true;
             return new byte[] {};
         }
+
+        @Override
+        public boolean equals(Object other) {
+            if (other == null) {
+                return false;
+            }
+
+            if (other instanceof X509CertInfoStub) {
+                X509CertInfoStub rhs = (X509CertInfoStub) other;
+                if (this == rhs) {
+                    return true;
+                }
+                if (this.getEncodedCalled ^ rhs.getEncodedCalled) {
+                    return false;
+                }
+                return super.equals(other);
+            }
+
+            return false;
+        }
     }
 
     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 eae0b730324437627abfa39be3690059eef4c9e9..036afadea3712b61d8d98fd9769cb8a68fbf65a1 100644
--- a/base/java-tools/src/com/netscape/cmstools/CMCResponse.java
+++ b/base/java-tools/src/com/netscape/cmstools/CMCResponse.java
@@ -122,12 +122,12 @@ public class CMCResponse {
                                 ASN1Util.encode(sts.elementAt(j)));
                         SEQUENCE seq = cst.getBodyList();
 
-                        String s = "   BodyList: ";
+                        StringBuffer s = new StringBuffer("   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);
+                        System.out.println(s.toString());
                         int st = cst.getStatus();
                         if (st != CMCStatusInfo.SUCCESS && st != CMCStatusInfo.CONFIRM_REQUIRED) {
                             String stString = cst.getStatusString();
diff --git a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java
index 90d1eff9eefdc5ec2671ade8ca7bf6d2fb297ba4..a8e0723382e5d9b5352dbef999bbec05bd70f0cd 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 = "";
+        StringBuffer pp = new StringBuffer();
         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,13 +212,13 @@ 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
         //      unless an output file has been specified
         if (outputfile == null) {
-            System.out.println(pp);
+            System.out.println(pp.toString());
         } else {
             try {
                 outputCert = new FileOutputStream(outputfile);
@@ -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 16f18500cb15b0e877ce004868a260eecf348f0a..ed3d7e32edd4a9d0a296af3a6a4a4af05598beab 100644
--- a/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java
+++ b/base/silent/src/com/netscape/pkisilent/common/CMSProperties.java
@@ -675,4 +675,26 @@ class CMSProperties extends Hashtable<String, String> {
             '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
             'E', 'F'
     };
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof CMSProperties) {
+            CMSProperties rhs = (CMSProperties) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.defaults == null) {
+                if (rhs.defaults != null) {
+                    return false;
+                }
+            } else if (!this.defaults.equals(rhs.defaults)) {
+                return false;
+            }
+            return super.equals(rhs);
+        }
+        return false;
+    }
 }
diff --git a/base/util/src/netscape/security/pkcs/PKCS10Attributes.java b/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
index d9b463b5fd3ec57d239321add2c9a6caa11b1168..c539be5c66f44bd62ae760e31ba60296ae80f828 100644
--- a/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
+++ b/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
@@ -144,4 +144,29 @@ public class PKCS10Attributes extends Vector<PKCS10Attribute> implements DerEnco
     public Enumeration<PKCS10Attribute> getElements() {
         return map.elements();
     }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof PKCS10Attributes) {
+            PKCS10Attributes rhs = (PKCS10Attributes) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.map == null) {
+                if (rhs.map != null) {
+                    return false;
+                }
+            } else {
+                if (!this.map.equals(rhs.map)) {
+                    return false;
+                }
+            }
+            return super.equals(rhs);
+        }
+
+        return false;
+    }
 }
diff --git a/base/util/src/netscape/security/provider/DSAPrivateKey.java b/base/util/src/netscape/security/provider/DSAPrivateKey.java
index 8b64fbf6c8d125d5299aeb15b9b921f551385c69..bb27412eef7291e0330916b69d6fc6800100c1d3 100644
--- a/base/util/src/netscape/security/provider/DSAPrivateKey.java
+++ b/base/util/src/netscape/security/provider/DSAPrivateKey.java
@@ -141,4 +141,31 @@ public final class DSAPrivateKey extends PKCS8Key
             throw new InvalidKeyException(e.getMessage());
         }
     }
+
+    @Override
+    public boolean equals(Object object) {
+
+        if (object == null) {
+            return false;
+        }
+        if (object instanceof DSAPrivateKey) {
+            DSAPrivateKey rhs = (DSAPrivateKey) object;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.x == null) {
+                if (rhs.x != null) {
+                    return false;
+                }
+            } else {
+                if (!this.x.equals(rhs.x)) {
+                    return false;
+                }
+            }
+            return super.equals(rhs);
+        }
+
+        return false;
+
+    }
 }
diff --git a/base/util/src/netscape/security/provider/DSAPublicKey.java b/base/util/src/netscape/security/provider/DSAPublicKey.java
index 66c3eb45aacce9923e65ebf04f147a13ca97b33e..b52ebbe46d681f1370be778c18861170b35fbb08 100644
--- a/base/util/src/netscape/security/provider/DSAPublicKey.java
+++ b/base/util/src/netscape/security/provider/DSAPublicKey.java
@@ -130,4 +130,31 @@ public final class DSAPublicKey extends X509Key
                       e.getMessage());
         }
     }
+
+   @Override
+    public boolean equals(Object object) {
+
+       if (object == null) {
+           return false;
+       }
+       if (object instanceof DSAPrivateKey) {
+           DSAPublicKey rhs = (DSAPublicKey) object;
+           if (this == rhs) {
+               return true;
+           }
+           if (this.y == null) {
+               if (rhs.y != null) {
+                   return false;
+               }
+           } else {
+               if (!this.y.equals(rhs.y)) {
+                   return false;
+               }
+           }
+           return super.equals(rhs);
+       }
+
+       return false;
+
+   }
 }
diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java
index a70d1aeeec64f90f4d3dfcf800c9687b22234484..40f5583acff502933fdb4e815ef228a942de61c9 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 a34c5f59f42083be3132a915d206598a92538ccf..523a31572f7936732e3a836315c5b49c5389b2d4 100644
--- a/base/util/src/netscape/security/x509/AlgIdDSA.java
+++ b/base/util/src/netscape/security/x509/AlgIdDSA.java
@@ -174,4 +174,37 @@ public final class AlgIdDSA extends AlgorithmId implements DSAParams {
                 "\n    g:\n" + (new BigInt(g)).toString() +
                 "\n";
     }
+
+    @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 60a6532ba7eac88e184556f08fe736cc3ca63d2b..33c383bb7dcb3ee48f5b1e394f17f5b9213d8446 100755
--- a/base/util/src/netscape/security/x509/CRLExtensions.java
+++ b/base/util/src/netscape/security/x509/CRLExtensions.java
@@ -226,4 +226,29 @@ public class CRLExtensions extends Vector<Extension> {
     public Enumeration<Extension> getElements() {
         return (map.elements());
     }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof CRLExtensions) {
+            CRLExtensions rhs = (CRLExtensions) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.map == null) {
+                if (rhs.map != null) {
+                    return false;
+                }
+            } else {
+                if (!this.map.equals(rhs.map)) {
+                    return false;
+                }
+            }
+            return super.equals(rhs);
+        }
+
+        return false;
+    }
 }
diff --git a/base/util/src/netscape/security/x509/CertificateExtensions.java b/base/util/src/netscape/security/x509/CertificateExtensions.java
index a8ce5ebee8d1b9a51e6c4eb06196bcb755b7db8d..a0b90bf27e3eef2c410065da621d481da8e1c074 100644
--- a/base/util/src/netscape/security/x509/CertificateExtensions.java
+++ b/base/util/src/netscape/security/x509/CertificateExtensions.java
@@ -273,4 +273,29 @@ public class CertificateExtensions extends Vector<Extension>
     public String getName() {
         return (NAME);
     }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof CertificateExtensions) {
+            CertificateExtensions rhs = (CertificateExtensions) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.map == null) {
+                if (rhs.map != null) {
+                    return false;
+                }
+            } else {
+                if (!this.map.equals(rhs.map)) {
+                    return false;
+                }
+            }
+            return super.equals(rhs);
+        }
+
+        return false;
+    }
 }
diff --git a/base/util/src/netscape/security/x509/Extensions.java b/base/util/src/netscape/security/x509/Extensions.java
index 3feac9599eb5e88e69fe13c3a702ff6b2e89fada..8dc3b478e17c7bf7f52c632ddd076741325d1013 100644
--- a/base/util/src/netscape/security/x509/Extensions.java
+++ b/base/util/src/netscape/security/x509/Extensions.java
@@ -223,4 +223,29 @@ public class Extensions extends Vector<Extension>
     public String getName() {
         return (NAME);
     }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (o instanceof Extensions) {
+            Extensions rhs = (Extensions) o;
+            if (this == rhs) {
+                return true;
+            }
+            if (this.map == null) {
+                if (rhs.map != null) {
+                    return false;
+                }
+            } else {
+                if (!this.map.equals(rhs.map)) {
+                    return false;
+                }
+            }
+            return super.equals(rhs);
+        }
+
+        return false;
+    }
 }
-- 
1.7.10.2

