>From d58875fa6a1ceab16821c7ebf310023e8ee404fa Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Mon, 9 Jul 2012 15:12:11 -0400
Subject: [PATCH] NO_HASHCODE_OVERRIDDEN

---
 .../netscape/certsrv/base/MetaAttributeDef.java    |   54 ++++++++++++--------
 .../netscape/certsrv/request/RequestStatus.java    |   26 ++++++++++
 .../src/com/netscape/certsrv/util/StatsEvent.java  |    2 +-
 .../cms/publish/publishers/FileBasedPublisher.java |   50 +++++++++++++-----
 .../netscape/cms/servlet/base/CMSStartServlet.java |    4 +-
 .../src/com/netscape/cmscore/apps/CMSEngine.java   |    7 ++-
 .../netscape/cmscore/profile/ProfileSubsystem.java |    4 +-
 .../com/netscape/cmscore/realm/PKIJNDIRealm.java   |    3 +-
 .../cmscore/request/RequestRepository.java         |    2 +-
 .../com/netscape/cmscore/security/PWsdrCache.java  |   10 ++--
 .../netscape/cmscore/dbs/CertRecordListTest.java   |    2 +-
 .../com/netscape/cmscore/dbs/DBRegistryTest.java   |    2 +-
 .../com/netscape/cmscore/request/RequestTest.java  |    2 +-
 .../src/com/netscape/cmstools/PasswordCache.java   |   12 +++--
 .../cmsutil/radius/UserPasswordAttribute.java      |    2 +-
 .../src/netscape/security/acl/PermissionImpl.java  |    8 +++
 base/util/src/netscape/security/provider/DSA.java  |    9 ++--
 .../netscape/security/provider/RSAPublicKey.java   |   39 +++++++++-----
 base/util/src/netscape/security/util/BigInt.java   |    9 ++++
 .../src/netscape/security/util/DerInputStream.java |    8 +--
 base/util/src/netscape/security/util/DerValue.java |   11 ++++
 base/util/src/netscape/security/x509/AVA.java      |    9 ++++
 .../src/netscape/security/x509/AlgorithmId.java    |   13 +++++
 .../netscape/security/x509/CRLReasonExtension.java |    8 +++
 .../src/netscape/security/x509/GeneralSubtree.java |    2 +-
 .../netscape/security/x509/GeneralSubtrees.java    |    2 +-
 26 files changed, 224 insertions(+), 76 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
index 63480478fc9ec632afb463fdf427419c484c8cfc..087110a0fce54518ec89b2fa8eb33e218a0631cd 100644
--- a/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
+++ b/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
@@ -129,29 +129,41 @@ public class MetaAttributeDef {
         return newDef;
     }
 
-    /**
-     * Compares this attribute definition with another, for equality.
-     * <P>
-     *
-     * @return true iff names, valueClasses and object identifiers
-     *         are identical.
-     */
-    public boolean equals(Object other) {
-        if (other == this)
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((mName == null) ? 0 : mName.hashCode());
+        result = prime * result + ((mOid == null) ? 0 : mOid.hashCode());
+        result = prime * result + ((mValueClass == null) ? 0 : mValueClass.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
             return true;
-
-        if (other instanceof MetaAttributeDef) {
-            MetaAttributeDef otherDef = (MetaAttributeDef) other;
-
-            if ((mOid != null && otherDef.mOid != null &&
-                    !mOid.equals(otherDef.mOid)) ||
-                    (mOid == null && otherDef.mOid != null) ||
-                    !mName.equals(otherDef.mName) ||
-                    !mValueClass.equals(otherDef.mValueClass)) {
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MetaAttributeDef other = (MetaAttributeDef) obj;
+        if (mName == null) {
+            if (other.mName != null)
                 return false;
-            }
-        }
-        return false;
+        } else if (!mName.equals(other.mName))
+            return false;
+        if (mOid == null) {
+            if (other.mOid != null)
+                return false;
+        } else if (!mOid.equals(other.mOid))
+            return false;
+        if (mValueClass == null) {
+            if (other.mValueClass != null)
+                return false;
+        } else if (!mValueClass.equals(other.mValueClass))
+            return false;
+        return true;
     }
 
     /**
diff --git a/base/common/src/com/netscape/certsrv/request/RequestStatus.java b/base/common/src/com/netscape/certsrv/request/RequestStatus.java
index 259fb8e1c9fe39cd9cf3f8abdf86a08a208b5586..988b1658c5a621995845ee24d0314b55f3b215a9 100644
--- a/base/common/src/com/netscape/certsrv/request/RequestStatus.java
+++ b/base/common/src/com/netscape/certsrv/request/RequestStatus.java
@@ -175,4 +175,30 @@ public final class RequestStatus implements Serializable {
             return false;
         return true;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((mString == null) ? 0 : mString.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        RequestStatus other = (RequestStatus) obj;
+        if (mString == null) {
+            if (other.mString != null)
+                return false;
+        } else if (!mString.equals(other.mString))
+            return false;
+        return true;
+    }
+
 }
diff --git a/base/common/src/com/netscape/certsrv/util/StatsEvent.java b/base/common/src/com/netscape/certsrv/util/StatsEvent.java
index 4137aa3b2198cd9bd7d836f9da6fb14a43ca82d8..07bbf9547cca4cb17d494b387dad1ca74d50912a 100644
--- a/base/common/src/com/netscape/certsrv/util/StatsEvent.java
+++ b/base/common/src/com/netscape/certsrv/util/StatsEvent.java
@@ -116,7 +116,7 @@ public class StatsEvent {
             long a = getTimeTakenSqSum();
             long b = (-2 * getAvg() * getTimeTaken());
             long c = getAvg() * getAvg() * getNoOfOperations();
-            return (long) Math.sqrt((a + b + c) / getNoOfOperations());
+            return (long) Math.sqrt(((double) (a + b + c)) / getNoOfOperations());
         }
     }
 
diff --git a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
index 6a1d528aca875d0823699511e9397553b3cca7d6..0cc73981d165bc93adaee3f367141f471cf471bf 100644
--- a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
+++ b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
@@ -254,19 +254,27 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
         if (com.netscape.cmsutil.util.Utils.exec(cmd)) {
             File oldLink = new File(linkName + ".old");
             if (oldLink.exists()) { // remove old link if exists
-                oldLink.delete();
+                if (!oldLink.delete()) {
+                    CMS.debug("FileBasedPublisher : createLink: Could not delete old link.");
+                }
             }
             File link = new File(linkName);
             if (link.exists()) { // current link becomes an old link
-                link.renameTo(new File(linkName + ".old"));
+                if (!link.renameTo(new File(linkName + ".old"))) {
+                    CMS.debug("FileBasedPublisher : createLink: Could not rename current link to old link.");
+                }
             }
             File newLink = new File(linkName + ".new");
             if (newLink.exists()) { // new link becomes current link
-                newLink.renameTo(new File(linkName));
+                if (!newLink.renameTo(new File(linkName))) {
+                    CMS.debug("FileBasedPublisher : createLink: Could not rename new link as current link.");
+                }
             }
             oldLink = new File(linkName + ".old");
             if (oldLink.exists()) { // remove a new old link
-                oldLink.delete();
+                if (oldLink.delete()) {
+                    CMS.debug("FileBasedPublisher : createLink: Could not delete old link.");
+                }
             }
         } else {
             CMS.debug("FileBasedPublisher:  createLink: '" + cmd + "' --- failed");
@@ -366,10 +374,15 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                     destName = baseName + ".der";
                     destFile = new File(destName);
 
-                    if (destFile.exists())
-                        destFile.delete();
+                    if (destFile.exists()) {
+                        if (!destFile.delete()) {
+                            CMS.debug("FileBasedPublisher : publish:mDerAttr=true: Could not delete file :" + destName);
+                        }
+                    }
                     renameFile = new File(tempFile);
-                    renameFile.renameTo(destFile);
+                    if (!renameFile.renameTo(destFile)) {
+                        CMS.debug("FileBasedPublisher : publish:mDerAttr=true: Could not create :" + destName);
+                    }
 
                     if (mLatestCRL) {
                         String linkExt = ".";
@@ -402,10 +415,15 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                     destName = baseName + ".b64";
                     destFile = new File(destName);
 
-                    if (destFile.exists())
-                        destFile.delete();
+                    if (destFile.exists()) {
+                        if (!destFile.delete()) {
+                            CMS.debug("FileBasedPublisher : publish:mB64Attr=true: Could not delete file :" + destName);
+                        }
+                    }
                     renameFile = new File(tempFile);
-                    renameFile.renameTo(destFile);
+                    if (!renameFile.renameTo(destFile)) {
+                        CMS.debug("FileBasedPublisher : publish:mB64Attr=true: Could not create :" + destName);
+                    }
                 }
             }
         } catch (IOException e) {
@@ -447,15 +465,21 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
 
             fileName = name + ".zip";
             File f = new File(fileName);
-            f.delete();
+            if (!f.delete()) {
+                CMS.debug("FileBasedPublisher : unpublish: Could not delete " + fileName);
+            }
         }
         fileName = name + ".der";
         File f = new File(fileName);
-        f.delete();
+        if (!f.delete()) {
+            CMS.debug("FileBasedPublisher : unpublish: Could not delete " + fileName);
+        }
 
         fileName = name + ".b64";
         f = new File(fileName);
-        f.delete();
+        if (!f.delete()) {
+            CMS.debug("FileBasedPublisher : unpublish: Could not delete " + fileName);
+        }
     }
 
     /**
diff --git a/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java b/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
index 6f9f43d3a959fcc120da26d5da17f04c403ffcfc..a8a4008b78cd3ec0e6561db453a5858ef741e906 100644
--- a/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/base/CMSStartServlet.java
@@ -75,7 +75,9 @@ public class CMSStartServlet extends HttpServlet {
                     // Remove the original file if and only if
                     // the backup copy was successful.
                     if (f.exists()) {
-                        f1.delete();
+                        if (!f1.delete()) {
+                            CMS.debug("CMSStartServlet: init: Cannot delete file : " + old_path);
+                        }
 
                         // Make certain that the new file has
                         // the correct permissions.
diff --git a/base/common/src/com/netscape/cmscore/apps/CMSEngine.java b/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
index 13a8bb6bf9fbf7f7aafb2f2a605ca8b114eb88d3..29c065160ded5fa760b01b067d5d2a5bd905da85 100644
--- a/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
+++ b/base/common/src/com/netscape/cmscore/apps/CMSEngine.java
@@ -658,9 +658,12 @@ public class CMSEngine implements ICMSEngine {
             /* if the file is not there, create one */
             File f = new File(path);
             if (!f.exists()) {
-                f.createNewFile();
+                if (!f.createNewFile()) {
+                    CMS.debug("CMSEngine : Cannot create File : " + path);
+                }
             }
-        } catch (Exception e) {
+        } catch (IOException e) {
+            CMS.debug("Cannot create file: " + path + " ." + e.toString());
         }
 
         return new FileConfigStore(path);
diff --git a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
index 45807d6e93d7dccf491f0d6b435255ed9f531341..1ec3c009ae1eb55bd27c887caf5a5aa634c09c47 100644
--- a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
@@ -173,7 +173,9 @@ public class ProfileSubsystem implements IProfileSubsystem {
         mConfig.removeSubStore(id);
         File file1 = new File(configPath);
 
-        file1.delete();
+        if (!file1.delete()) {
+            CMS.debug("ProfileSubsystem: deleteProfile: Cannot delete the configuration file : " + configPath);
+        }
         mProfileIds.removeElement(id);
         mProfiles.remove(id);
         mProfileClassIds.remove(id);
diff --git a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
index 0576bcf5873306482cde0de4a9a92a3e01aab2e2..86debf3dad9ca5859e4597e80d42b5b0e48c4a8b 100644
--- a/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
+++ b/base/common/src/com/netscape/cmscore/realm/PKIJNDIRealm.java
@@ -423,13 +423,12 @@ public class PKIJNDIRealm extends JNDIRealm {
         String right = expBlock[1];
 
         if (left != null) {
-            left.trim();
+            left = left.trim();
         } else {
             return allowed;
         }
         //Massage the right hand side of this expression to be a legal string value.
         if (right != null) {
-            right.trim();
             right = right.replace("\"", "");
             right = right.trim();
         } else {
diff --git a/base/common/src/com/netscape/cmscore/request/RequestRepository.java b/base/common/src/com/netscape/cmscore/request/RequestRepository.java
index ed18c7048d12d6c96aab84e70b75ed8ebb312e8c..31edc31b0c2ca744bf9b3df69971f7c784a24bf8 100644
--- a/base/common/src/com/netscape/cmscore/request/RequestRepository.java
+++ b/base/common/src/com/netscape/cmscore/request/RequestRepository.java
@@ -174,7 +174,7 @@ class RequestRepository
             }
         }
 
-        if (obj != null || (obj instanceof RepositoryRecord)) {
+        if (obj != null && (obj instanceof RepositoryRecord)) {
             record = (RepositoryRecord) obj;
             status = record.getPublishingStatus();
         } else {
diff --git a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
index 810605d4122a426c0e0c662edd24027e18a3face..e9c7af8e51f0a1bc640ca40df4aa34c1b086c6d5 100644
--- a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
+++ b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
@@ -382,7 +382,9 @@ public class PWsdrCache {
 
             if (tmpPWcache.exists()) {
                 // it wasn't removed?
-                tmpPWcache.delete();
+                if (!tmpPWcache.delete()) {
+                    debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+                }
                 tmpPWcache = new File(mPWcachedb + ".tmp");
             }
             outstream = new FileOutputStream(mPWcachedb + ".tmp");
@@ -417,10 +419,12 @@ public class PWsdrCache {
                                         origFile.getCanonicalPath());
                         } catch (IOException e) {
                             CMS.debug("Unable to change file permissions on "
-                                     + origFile.toString());
+                                    + origFile.toString());
                         }
                     }
-                    tmpPWcache.delete();
+                    if (!tmpPWcache.delete()) {
+                        debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+                    }
                     debug("operation completed for " + mPWcachedb);
                 }
             } catch (Exception exx) {
diff --git a/base/common/test/com/netscape/cmscore/dbs/CertRecordListTest.java b/base/common/test/com/netscape/cmscore/dbs/CertRecordListTest.java
index d9c24106c42bd7cb377f9f99a472f6ed6bbd033e..100d632643576f43a45b41cc3e8d7c74a6afc533 100644
--- a/base/common/test/com/netscape/cmscore/dbs/CertRecordListTest.java
+++ b/base/common/test/com/netscape/cmscore/dbs/CertRecordListTest.java
@@ -58,7 +58,7 @@ public class CertRecordListTest extends CMSBaseTestCase {
         assertEquals(7, dbList.lastIndexGetElementAtCalledWith);
     }
 
-    public class DBVirtualListStub<T> extends DBVirtualListDefaultStub<T> {
+    public static class DBVirtualListStub<T> extends DBVirtualListDefaultStub<T> {
         public int size = 0;
         public int getElementAtCallCount = 0;
         public int lastIndexGetElementAtCalledWith = 0;
diff --git a/base/common/test/com/netscape/cmscore/dbs/DBRegistryTest.java b/base/common/test/com/netscape/cmscore/dbs/DBRegistryTest.java
index 4a52bbcef720e8ed0013c8ebceb28388c7bfe1d2..cb61a12d31f435f23f08588b044a74d07f50d8b6 100644
--- a/base/common/test/com/netscape/cmscore/dbs/DBRegistryTest.java
+++ b/base/common/test/com/netscape/cmscore/dbs/DBRegistryTest.java
@@ -110,7 +110,7 @@ public class DBRegistryTest extends CMSBaseTestCase {
         assertTrue(extAttrMapper.mapLDAPAttrsCalled);
     }
 
-    class DBSubsystemStub extends DBSubsystemDefaultStub {
+    static class DBSubsystemStub extends DBSubsystemDefaultStub {
         DBRegistry registry;
 
         public IDBRegistry getRegistry() {
diff --git a/base/common/test/com/netscape/cmscore/request/RequestTest.java b/base/common/test/com/netscape/cmscore/request/RequestTest.java
index b3a8c6ee561ea63dc5003cd828bdd0e8ec35e3cc..4f761f982c7aa36fd9528de6cc8001c4805251f7 100644
--- a/base/common/test/com/netscape/cmscore/request/RequestTest.java
+++ b/base/common/test/com/netscape/cmscore/request/RequestTest.java
@@ -601,7 +601,7 @@ public class RequestTest extends CMSBaseTestCase {
      * getting a value out. It assumes BtoA is always called first, stores
      * the value passed in, and then returns that value for BtoA.
      */
-    class CMSMemoryStub extends CMSEngineDefaultStub {
+    static class CMSMemoryStub extends CMSEngineDefaultStub {
         boolean bToACalled = false;
         byte[] bToACalledWith = null;
 
diff --git a/base/java-tools/src/com/netscape/cmstools/PasswordCache.java b/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
index 89254a2a543229e13d8f9a6c9e22e4176cd567af..d97a21706aa4e486437fded22a3b90dfaab0b3d6 100644
--- a/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
+++ b/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
@@ -609,7 +609,9 @@ class PWsdrCache {
 
             if (tmpPWcache.exists()) {
                 // it wasn't removed?
-                tmpPWcache.delete();
+                if (!tmpPWcache.delete()) {
+                    debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+                }
             }
             outstream = new FileOutputStream(mPWcachedb + ".tmp");
 
@@ -626,7 +628,9 @@ class PWsdrCache {
             try {
                 // Always remove any pre-existing target file
                 if (origFile.exists()) {
-                    origFile.delete();
+                    if (!origFile.delete()) {
+                        debug("Could not delete the existing " + mPWcachedb + "file.");
+                    }
                 }
 
                 if (isNT()) {
@@ -644,7 +648,9 @@ class PWsdrCache {
                 // Remove the temporary file if and only if
                 // the "rename" was successful.
                 if (origFile.exists()) {
-                    tmpPWcache.delete();
+                    if (!tmpPWcache.delete()) {
+                        debug("Could not delete the existing " + mPWcachedb + ".tmp file.");
+                    }
 
                     // Make certain that the final file has
                     // the correct permissions.
diff --git a/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java b/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java
index 31c27cdfdca4cf640f7cd13b2a4b4a518f8b088e..d87811d11daa3a30af882648ec81efec24c9b924 100644
--- a/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java
+++ b/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java
@@ -61,7 +61,7 @@ public class UserPasswordAttribute extends Attribute {
             if (i < up.length) {
                 ret[i] = (byte) (sum[i % 16] ^ up[i]);
             } else {
-                ret[i] = (byte) (sum[i % 16] ^ 0);
+                ret[i] = sum[i % 16];
             }
             md5.update(ret[i]);
             if ((i % 16) == 15) {
diff --git a/base/util/src/netscape/security/acl/PermissionImpl.java b/base/util/src/netscape/security/acl/PermissionImpl.java
index b20570a8160e487146cdc27509c3536db8e4ad0e..80b36e1da4ef6c6d2fef4f8010fbbbd8784302fa 100644
--- a/base/util/src/netscape/security/acl/PermissionImpl.java
+++ b/base/util/src/netscape/security/acl/PermissionImpl.java
@@ -54,6 +54,14 @@ public class PermissionImpl implements Permission {
         }
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((permission == null) ? 0 : permission.hashCode());
+        return result;
+    }
+
     /**
      * Prints a stringified version of the permission.
      *
diff --git a/base/util/src/netscape/security/provider/DSA.java b/base/util/src/netscape/security/provider/DSA.java
index 64575b870b2d9af46863bdd391a7c3cf8c25cbcf..9403475e0b3ab5cf0b19dd34b95731de3f1f1c25 100644
--- a/base/util/src/netscape/security/provider/DSA.java
+++ b/base/util/src/netscape/security/provider/DSA.java
@@ -311,11 +311,12 @@ public final class DSA extends Signature {
      */
     private int compareSeeds(int[] seed1, int[] seed2) {
 
-        if ((seed1 == null && seed1 == null) ||
-                (seed1 == null && seed2 != null) ||
-                (seed1 != null && seed2 == null) ||
-                seed1.length != seed2.length)
+        if (seed1 == null || seed2 == null) {
             return 1;
+        }
+        if (seed1.length != seed2.length) {
+            return 1;
+        }
 
         for (int i = 0; i < seed1.length; i++) {
             if (seed1[i] != seed2[i])
diff --git a/base/util/src/netscape/security/provider/RSAPublicKey.java b/base/util/src/netscape/security/provider/RSAPublicKey.java
index 40f5583acff502933fdb4e815ef228a942de61c9..bd5aa2fe4f028e0b801babe6a4dd5e1a33610f2a 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) {
diff --git a/base/util/src/netscape/security/util/BigInt.java b/base/util/src/netscape/security/util/BigInt.java
index 62a03cef50f240ec849ca1b5a4f6c676626e0263..c930edf80c1e61767b6f4d908000fe3dae4e7379 100644
--- a/base/util/src/netscape/security/util/BigInt.java
+++ b/base/util/src/netscape/security/util/BigInt.java
@@ -19,6 +19,7 @@ package netscape.security.util;
 
 import java.io.Serializable;
 import java.math.BigInteger;
+import java.util.Arrays;
 
 /**
  * A low-overhead arbitrary-precision <em>unsigned</em> integer.
@@ -192,6 +193,14 @@ public final class BigInt implements Serializable {
         return false;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Arrays.hashCode(places);
+        return result;
+    }
+
     /**
      * Returns true iff the parameter is numerically equivalent.
      *
diff --git a/base/util/src/netscape/security/util/DerInputStream.java b/base/util/src/netscape/security/util/DerInputStream.java
index ff1c54ba234e8a2a1bd8607a591f50eb1e9f84f1..40763a6bab971f3c296844febc6f97352383b903 100644
--- a/base/util/src/netscape/security/util/DerInputStream.java
+++ b/base/util/src/netscape/security/util/DerInputStream.java
@@ -453,7 +453,7 @@ public class DerInputStream {
             if (Htmp >= 24 || Mtmp >= 60)
                 throw new IOException("Parse UTCtime, +hhmm");
 
-            utcTime += ((Htmp * 60) + Mtmp) * 60 * 1000;
+            utcTime += ((Htmp * 60) + Mtmp) * 60 * 1000L;
         }
             break;
 
@@ -466,7 +466,7 @@ public class DerInputStream {
             if (Htmp >= 24 || Mtmp >= 60)
                 throw new IOException("Parse UTCtime, -hhmm");
 
-            utcTime -= ((Htmp * 60) + Mtmp) * 60 * 1000;
+            utcTime -= ((Htmp * 60) + Mtmp) * 60 * 1000L;
         }
             break;
 
@@ -560,7 +560,7 @@ public class DerInputStream {
             if (Htmp >= 24 || Mtmp >= 60)
                 throw new IOException("Parse GeneralizedTime, +hhmm");
 
-            utcTime += ((Htmp * 60) + Mtmp) * 60 * 1000;
+            utcTime += ((Htmp * 60) + Mtmp) * 60 * 1000L;
         }
             break;
 
@@ -573,7 +573,7 @@ public class DerInputStream {
             if (Htmp >= 24 || Mtmp >= 60)
                 throw new IOException("Parse GeneralizedTime, -hhmm");
 
-            utcTime -= ((Htmp * 60) + Mtmp) * 60 * 1000;
+            utcTime -= ((Htmp * 60) + Mtmp) * 60 * 1000L;
         }
             break;
 
diff --git a/base/util/src/netscape/security/util/DerValue.java b/base/util/src/netscape/security/util/DerValue.java
index 40215626ab4397f27448af35d6c583db867b83d5..87a0a38a3fab86f81431d2d175235b5081a44451 100644
--- a/base/util/src/netscape/security/util/DerValue.java
+++ b/base/util/src/netscape/security/util/DerValue.java
@@ -610,6 +610,17 @@ public class DerValue {
             return false;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((buffer == null) ? 0 : buffer.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        result = prime * result + length;
+        result = prime * result + tag;
+        return result;
+    }
+
     /**
      * Bitwise equality comparison. DER encoded values have a single
      * encoding, so that bitwise equality of the encoded values is an
diff --git a/base/util/src/netscape/security/x509/AVA.java b/base/util/src/netscape/security/x509/AVA.java
index fc6601223794bad4f5371c3660e2b04398e05e31..534f7c212094bf3423423be7248e11da2229ae84 100644
--- a/base/util/src/netscape/security/x509/AVA.java
+++ b/base/util/src/netscape/security/x509/AVA.java
@@ -203,6 +203,15 @@ public final class AVA implements DerEncoder {
             return false;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((oid == null) ? 0 : oid.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
     /**
      * Encodes the AVA to a Der output stream.
      * AVAs are encoded as a SEQUENCE of two elements.
diff --git a/base/util/src/netscape/security/x509/AlgorithmId.java b/base/util/src/netscape/security/x509/AlgorithmId.java
index 4b108ac4bcdb2fe1c9b6663bfebd528829c52ed3..a027c19cc2cd6192ddfabe267f3dd15604412ba0 100644
--- a/base/util/src/netscape/security/x509/AlgorithmId.java
+++ b/base/util/src/netscape/security/x509/AlgorithmId.java
@@ -498,6 +498,17 @@ public class AlgorithmId implements Serializable, DerEncoder {
             return false;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((algParams == null) ? 0 : algParams.hashCode());
+        result = prime * result + ((algid == null) ? 0 : algid.hashCode());
+        result = prime * result + ((params == null) ? 0 : params.hashCode());
+        result = prime * result + ((paramsString == null) ? 0 : paramsString.hashCode());
+        return result;
+    }
+
     /**
      * Compares two algorithm IDs for equality. Returns true iff
      * they are the same algorithm, ignoring algorithm parameters.
@@ -506,6 +517,8 @@ public class AlgorithmId implements Serializable, DerEncoder {
         return algid.equals(id);
     }
 
+
+
     /*****************************************************************/
 
     /*
diff --git a/base/util/src/netscape/security/x509/CRLReasonExtension.java b/base/util/src/netscape/security/x509/CRLReasonExtension.java
index 6a5fd62953d8579aa76ad3d94f8322a438983d82..77339528e4b640814c7cf0dca8897b5603f049fe 100644
--- a/base/util/src/netscape/security/x509/CRLReasonExtension.java
+++ b/base/util/src/netscape/security/x509/CRLReasonExtension.java
@@ -231,4 +231,12 @@ public final class CRLReasonExtension extends Extension implements CertAttrSet {
             return false;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((mReason == null) ? 0 : mReason.hashCode());
+        return result;
+    }
+
 }
diff --git a/base/util/src/netscape/security/x509/GeneralSubtree.java b/base/util/src/netscape/security/x509/GeneralSubtree.java
index a491098468467470d0cb977034abdbc9932cd819..4c20bb4ba38fbc6f97c61801c563935c4114f0d3 100644
--- a/base/util/src/netscape/security/x509/GeneralSubtree.java
+++ b/base/util/src/netscape/security/x509/GeneralSubtree.java
@@ -52,7 +52,7 @@ public class GeneralSubtree implements Serializable {
     private int minimum = MIN_DEFAULT;
     private int maximum = -1;
 
-    private PrettyPrintFormat pp = new PrettyPrintFormat(":");
+    private transient PrettyPrintFormat pp = new PrettyPrintFormat(":");
 
     /**
      * The default constructor for the class.
diff --git a/base/util/src/netscape/security/x509/GeneralSubtrees.java b/base/util/src/netscape/security/x509/GeneralSubtrees.java
index 9d8c632a353cae2c332d8ccb3c1de74635ed579e..edbab7ee90b768a802c74e5f7b3ffd8639f100db 100644
--- a/base/util/src/netscape/security/x509/GeneralSubtrees.java
+++ b/base/util/src/netscape/security/x509/GeneralSubtrees.java
@@ -38,7 +38,7 @@ public class GeneralSubtrees implements Serializable {
 
     private static final long serialVersionUID = 6308776640697100848L;
     private Vector<GeneralSubtree> trees;
-    private PrettyPrintFormat pp = new PrettyPrintFormat(":");
+    private transient PrettyPrintFormat pp = new PrettyPrintFormat(":");
 
     /**
      * The default constructor for the class.
-- 
1.7.10.2

