From 3d3c93fe6fdc2b53262c4d50054a989a14f453be Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Tue, 10 Jan 2012 16:39:57 -0600
Subject: [PATCH] Replaced TreeSet with LinkedHashSet.

The TreeSet has been replaced by LinkedHashSet because it is used to store
non-Comparable objects according to the insertion order. This fixes a
ClassCastException that happens while viewing Certificate Revocation List.
---
 .../ca/src/com/netscape/ca/CRLIssuingPoint.java    |    4 ++--
 .../netscape/security/x509/RevokedCertImpl.java    |    6 +++---
 .../src/netscape/security/x509/X509CRLImpl.java    |    8 ++++----
 .../src/netscape/security/x509/X509CertImpl.java   |    6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java b/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
index 0e675be8c365f3c1438da4043565edd6603f97eb..d85550ee0841033b43c162294bf32d88d4b2dfca 100644
--- a/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
+++ b/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
@@ -25,10 +25,10 @@ import java.security.cert.CRLException;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.TimeZone;
-import java.util.TreeSet;
 import java.util.Vector;
 
 import netscape.security.util.BitArray;
@@ -1382,7 +1382,7 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
         if (mCRLCacheIsCleared || mCRLCerts == null || mCRLCerts.isEmpty()) {
             return null;
         } else {
-            Set<RevokedCertificate> certSet = new TreeSet<RevokedCertificate>(mCRLCerts.values());
+            Set<RevokedCertificate> certSet = new LinkedHashSet<RevokedCertificate>(mCRLCerts.values());
             return certSet;
         }
     }
diff --git a/pki/base/util/src/netscape/security/x509/RevokedCertImpl.java b/pki/base/util/src/netscape/security/x509/RevokedCertImpl.java
index ed78be9b8b3db00a1446107fb420a20932dc33bd..d18324290e628f597dc90505c037a4ea7b087952 100755
--- a/pki/base/util/src/netscape/security/x509/RevokedCertImpl.java
+++ b/pki/base/util/src/netscape/security/x509/RevokedCertImpl.java
@@ -26,8 +26,8 @@ import java.math.BigInteger;
 import java.security.cert.CRLException;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.LinkedHashSet;
 import java.util.Set;
-import java.util.TreeSet;
 
 import netscape.security.util.BigInt;
 import netscape.security.util.DerInputStream;
@@ -294,7 +294,7 @@ public class RevokedCertImpl extends RevokedCertificate
     public Set<String> getCriticalExtensionOIDs() {
         if (extensions == null)
             return null;
-        Set<String> extSet = new TreeSet<String>();
+        Set<String> extSet = new LinkedHashSet<String>();
         Extension ex;
             for (Enumeration<Extension> e = extensions.getElements();
                                           e.hasMoreElements();) {
@@ -315,7 +315,7 @@ public class RevokedCertImpl extends RevokedCertificate
     public Set<String> getNonCriticalExtensionOIDs() {
         if (extensions == null)
             return null;
-        Set<String> extSet = new TreeSet<String>();
+        Set<String> extSet = new LinkedHashSet<String>();
         Extension ex;
             for (Enumeration<Extension> e = extensions.getElements();
                                           e.hasMoreElements();) {
diff --git a/pki/base/util/src/netscape/security/x509/X509CRLImpl.java b/pki/base/util/src/netscape/security/x509/X509CRLImpl.java
index 14cf3c016848c12f70c4941229da638ec5be836e..a722216a21d4673271856d7a02d4ca4bcaed0811 100755
--- a/pki/base/util/src/netscape/security/x509/X509CRLImpl.java
+++ b/pki/base/util/src/netscape/security/x509/X509CRLImpl.java
@@ -37,8 +37,8 @@ import java.security.cert.X509Certificate;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.LinkedHashSet;
 import java.util.Set;
-import java.util.TreeSet;
 
 import netscape.security.util.BigInt;
 import netscape.security.util.DerInputStream;
@@ -668,7 +668,7 @@ public class X509CRLImpl extends X509CRL {
         if (revokedCerts == null || revokedCerts.isEmpty())
             return null;
         else {
-            Set<RevokedCertificate> certSet = new TreeSet<RevokedCertificate>(revokedCerts.values());
+            Set<RevokedCertificate> certSet = new LinkedHashSet<RevokedCertificate>(revokedCerts.values());
             return certSet;
         }
     }
@@ -802,7 +802,7 @@ public class X509CRLImpl extends X509CRL {
     public Set<String> getCriticalExtensionOIDs() {
         if (extensions == null)
             return null;
-        Set<String> extSet = new TreeSet<String>();
+        Set<String> extSet = new LinkedHashSet<String>();
         Extension ex;
         for (Enumeration<Extension> e = extensions.getElements();
                                              e.hasMoreElements();) {
@@ -824,7 +824,7 @@ public class X509CRLImpl extends X509CRL {
     public Set<String> getNonCriticalExtensionOIDs() {
         if (extensions == null)
             return null;
-        Set<String> extSet = new TreeSet<String>();
+        Set<String> extSet = new LinkedHashSet<String>();
         Extension ex;
             for (Enumeration<Extension> e = extensions.getElements();
                                              e.hasMoreElements();) {
diff --git a/pki/base/util/src/netscape/security/x509/X509CertImpl.java b/pki/base/util/src/netscape/security/x509/X509CertImpl.java
index c916a5d7630352df4dd544a447dd63cfac58d2d2..10aab98ec065c840b43ddc6ad9392216dc6eac19 100755
--- a/pki/base/util/src/netscape/security/x509/X509CertImpl.java
+++ b/pki/base/util/src/netscape/security/x509/X509CertImpl.java
@@ -41,8 +41,8 @@ import java.security.cert.CertificateParsingException;
 import java.security.cert.X509Certificate;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.LinkedHashSet;
 import java.util.Set;
-import java.util.TreeSet;
 import java.util.Vector;
 
 import netscape.security.util.BigInt;
@@ -913,7 +913,7 @@ implements Serializable, DerEncoder {
                                              CertificateExtensions.NAME);
                 if (exts == null)
                 return null;
-            Set<String> extSet = new TreeSet<String>();
+            Set<String> extSet = new LinkedHashSet<String>();
             Extension ex;
                 for (Enumeration e = exts.getElements(); e.hasMoreElements(); ) {
                 ex = (Extension)e.nextElement();
@@ -942,7 +942,7 @@ implements Serializable, DerEncoder {
                 if (exts == null)
                 return null;
 
-            Set<String> extSet = new TreeSet<String>();
+            Set<String> extSet = new LinkedHashSet<String>();
             Extension ex;
                 for (Enumeration e = exts.getElements(); e.hasMoreElements(); ) {
                 ex = (Extension)e.nextElement();
-- 
1.7.7.4

