From 76bbc4a0da307725c708e185b9d010c73b1a6b5e Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Wed, 22 Feb 2012 01:15:56 -0600
Subject: [PATCH] Fixed IAttrSet.getElements() implementations.

This patch fixes incorrect implementation of getElement() in
some subclasses of IAttrSet. The method is supposed return the
attribute names as an enumeration of strings.

Ticket #42
---
 .../certsrv/authentication/AuthCredentials.java    |   10 +++---
 .../netscape/certsrv/authorization/AuthzToken.java |   10 +++---
 .../src/com/netscape/certsrv/base/IAttrSet.java    |    2 +-
 .../src/com/netscape/cms/ocsp/LDAPStore.java       |    2 +-
 .../cms/servlet/admin/AuthCredentials.java         |    8 ++--
 .../cms/servlet/common/AuthCredentials.java        |    8 ++--
 .../netscape/cmscore/ldap/LdapPredicateParser.java |   36 --------------------
 .../cmscore/notification/EmailResolverKeys.java    |    6 ++--
 .../cmscore/policy/PolicyPredicateParser.java      |   36 --------------------
 pki/base/migrate/60ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/61ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/62ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/63ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/70ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/71ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/72ToTxt/src/Main.java             |    4 +-
 pki/base/migrate/73ToTxt/src/Main.java             |    4 +-
 17 files changed, 39 insertions(+), 111 deletions(-)

diff --git a/pki/base/common/src/com/netscape/certsrv/authentication/AuthCredentials.java b/pki/base/common/src/com/netscape/certsrv/authentication/AuthCredentials.java
index 1475683ebbf1d95f2399dcf79453b7697854537d..5a0cdd3b8c4d8e03e3b9d40aaf8f0fbbaa2ec5d2 100644
--- a/pki/base/common/src/com/netscape/certsrv/authentication/AuthCredentials.java
+++ b/pki/base/common/src/com/netscape/certsrv/authentication/AuthCredentials.java
@@ -61,7 +61,7 @@ public class AuthCredentials implements IAuthCredentials {
      * @return the authentication credential for the given name
      */
     public Object get(String name) {
-        return ((Object) authCreds.get(name));
+        return authCreds.get(name);
     }
 
     /**
@@ -76,14 +76,14 @@ public class AuthCredentials implements IAuthCredentials {
     }
 
     /**
-     * Returns an enumeration of the credentials in this credential
+     * Returns an enumeration of the credential names in this credential
      * set. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      * 
-     * @return an enumeration of the values in this credential set
+     * @return an enumeration of the names in this credential set
      */
-    public Enumeration<Object> getElements() {
-        return (authCreds.elements());
+    public Enumeration<String> getElements() {
+        return authCreds.keys();
     }
 
     /**
diff --git a/pki/base/common/src/com/netscape/certsrv/authorization/AuthzToken.java b/pki/base/common/src/com/netscape/certsrv/authorization/AuthzToken.java
index b6e2d14460cea63d28020bbae2024f76574800d6..262902e62cebb16fffadde2bbbaa15129d28d97a 100644
--- a/pki/base/common/src/com/netscape/certsrv/authorization/AuthzToken.java
+++ b/pki/base/common/src/com/netscape/certsrv/authorization/AuthzToken.java
@@ -129,7 +129,7 @@ public class AuthzToken implements IAttrSet {
      * @return Enumeration of all attribute names in this AuthzToken.
      */
     public Enumeration<String> getElements() {
-        return (mAttrs.keys());
+        return mAttrs.keys();
     }
 
     /**
@@ -138,7 +138,7 @@ public class AuthzToken implements IAttrSet {
      * @return Enumeration of all attribute names in this AuthzToken.
      */
     public Enumeration<Object> getVals() {
-        return (mAttrs.elements());
+        return mAttrs.elements();
     }
 
     /**
@@ -149,7 +149,7 @@ public class AuthzToken implements IAttrSet {
      *         this token.
      */
     public String getAuthzManagerInstName() {
-        return ((String) mAttrs.get(TOKEN_AUTHZMGR_INST_NAME));
+        return (String) mAttrs.get(TOKEN_AUTHZMGR_INST_NAME);
     }
 
     /**
@@ -160,7 +160,7 @@ public class AuthzToken implements IAttrSet {
      *         token.
      */
     public String getAuthzManagerImplName() {
-        return ((String) mAttrs.get(TOKEN_AUTHZMGR_IMPL_NAME));
+        return (String) mAttrs.get(TOKEN_AUTHZMGR_IMPL_NAME);
     }
 
     /**
@@ -169,6 +169,6 @@ public class AuthzToken implements IAttrSet {
      * @return The time of authorization
      */
     public Date getAuthzTime() {
-        return ((Date) mAttrs.get(TOKEN_AUTHZTIME));
+        return (Date) mAttrs.get(TOKEN_AUTHZTIME);
     }
 }
diff --git a/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java b/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java
index f7567292ead2ac324647e5a8fbfffb2e215f595a..e396b072a8539a52a5c16f47d4df19dd02d36cb1 100644
--- a/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java
+++ b/pki/base/common/src/com/netscape/certsrv/base/IAttrSet.java
@@ -66,5 +66,5 @@ public interface IAttrSet extends Serializable {
      * 
      * @return an enumeration of the attribute names.
      */
-    public Enumeration<?> getElements();
+    public Enumeration<String> getElements();
 }
diff --git a/pki/base/common/src/com/netscape/cms/ocsp/LDAPStore.java b/pki/base/common/src/com/netscape/cms/ocsp/LDAPStore.java
index 11e91fdeb40c22a2c542ca9d4344a9d4b2b838e3..ac6534afd2db454a8dcd43ae2297e0cfbdf20dac 100644
--- a/pki/base/common/src/com/netscape/cms/ocsp/LDAPStore.java
+++ b/pki/base/common/src/com/netscape/cms/ocsp/LDAPStore.java
@@ -748,7 +748,7 @@ class TempCRLIssuingPointRecord implements ICRLIssuingPointRecord {
 
     }
 
-    public Enumeration<Object> getElements() {
+    public Enumeration<String> getElements() {
         return null;
     }
 }
diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/AuthCredentials.java b/pki/base/common/src/com/netscape/cms/servlet/admin/AuthCredentials.java
index 9d4c4f00ee5233760be0b51c819ffdb11f2aa268..69cfd9aafbc3537e8f73ee1537b219d3c492f14c 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/admin/AuthCredentials.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/admin/AuthCredentials.java
@@ -83,15 +83,15 @@ public class AuthCredentials implements IAuthCredentials {
     }
 
     /**
-     * returns an enumeration of the credentials in this credential
+     * returns an enumeration of the credential names in this credential
      * set. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      * 
-     * @return an enumeration of the values in this credential set
+     * @return an enumeration of the names in this credential set
      * @see java.util.Enumeration
      */
-    public Enumeration<Object> getElements() {
-        return authCreds.elements();
+    public Enumeration<String> getElements() {
+        return authCreds.keys();
     }
 
     // Inserted by bskim
diff --git a/pki/base/common/src/com/netscape/cms/servlet/common/AuthCredentials.java b/pki/base/common/src/com/netscape/cms/servlet/common/AuthCredentials.java
index a55406068c74f701dea3416f0d5c33ee03d79def..88369ace377c8b101f12fda1e7c096a21fdf13d7 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/common/AuthCredentials.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/common/AuthCredentials.java
@@ -83,15 +83,15 @@ public class AuthCredentials implements IAuthCredentials {
     }
 
     /**
-     * returns an enumeration of the credentials in this credential
+     * returns an enumeration of the credential names in this credential
      * set. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      * 
-     * @return an enumeration of the values in this credential set
+     * @return an enumeration of the names in this credential set
      * @see java.util.Enumeration
      */
-    public Enumeration<Object> getElements() {
-        return authCreds.elements();
+    public Enumeration<String> getElements() {
+        return authCreds.keys();
     }
 
     // Inserted by bskim
diff --git a/pki/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java b/pki/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
index 5af8e533d66531571c95418eb73d1414d22aa656..a752c1e2906b6c6ffd138f860463661d75fe5b28 100644
--- a/pki/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
+++ b/pki/base/common/src/com/netscape/cmscore/ldap/LdapPredicateParser.java
@@ -17,13 +17,9 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cmscore.ldap;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
 import java.util.Vector;
 
 import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.certsrv.base.IAttrSet;
 import com.netscape.certsrv.ldap.ELdapException;
 import com.netscape.certsrv.publish.ILdapExpression;
 import com.netscape.cmscore.util.Debug;
@@ -344,35 +340,3 @@ class PredicateTokenizer {
         }
     }
 }
-
-class AttributeSet implements IAttrSet {
-    /**
-     *
-     */
-    private static final long serialVersionUID = -3155846653754028803L;
-    Hashtable<String, Object> ht = new Hashtable<String, Object>();
-
-    public AttributeSet() {
-    }
-
-    public void delete(String name)
-            throws EBaseException {
-        Object ob = ht.get(name);
-
-        ht.remove(ob);
-    }
-
-    public Object get(String name)
-            throws EBaseException {
-        return ht.get(name);
-    }
-
-    public void set(String name, Object ob)
-            throws EBaseException {
-        ht.put(name, ob);
-    }
-
-    public Enumeration<Object> getElements() {
-        return ht.elements();
-    }
-}
diff --git a/pki/base/common/src/com/netscape/cmscore/notification/EmailResolverKeys.java b/pki/base/common/src/com/netscape/cmscore/notification/EmailResolverKeys.java
index d0dedafa7624d66a41b3e841e8847bcc0caeb34a..cd63841eb212fce7ebdeb2414a1d9b5caa575083 100644
--- a/pki/base/common/src/com/netscape/cmscore/notification/EmailResolverKeys.java
+++ b/pki/base/common/src/com/netscape/cmscore/notification/EmailResolverKeys.java
@@ -80,14 +80,14 @@ public class EmailResolverKeys implements IEmailResolverKeys {
     }
 
     /**
-     * returns an enumeration of the keys in this key
+     * returns an enumeration of the key names in this key
      * set. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      * 
      * @return an enumeration of the values in this key set
      * @see java.util.Enumeration
      */
-    public Enumeration<Object> getElements() {
-        return mKeys.elements();
+    public Enumeration<String> getElements() {
+        return mKeys.keys();
     }
 }
diff --git a/pki/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java b/pki/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
index 2386f6e0fc0cadddcd915de1e02a2d9f6342287d..4046c789f532fe340221ed0dcc28c3907dd8d20f 100644
--- a/pki/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
+++ b/pki/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java
@@ -17,13 +17,9 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cmscore.policy;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
 import java.util.Vector;
 
 import com.netscape.certsrv.apps.CMS;
-import com.netscape.certsrv.base.EBaseException;
-import com.netscape.certsrv.base.IAttrSet;
 import com.netscape.certsrv.policy.EPolicyException;
 import com.netscape.certsrv.policy.IExpression;
 import com.netscape.cmscore.util.Debug;
@@ -344,35 +340,3 @@ class PredicateTokenizer {
         }
     }
 }
-
-class AttributeSet implements IAttrSet {
-    /**
-     *
-     */
-    private static final long serialVersionUID = -3985810281989018413L;
-    Hashtable<String, Object> ht = new Hashtable<String, Object>();
-
-    public AttributeSet() {
-    }
-
-    public void delete(String name)
-            throws EBaseException {
-        Object ob = ht.get(name);
-
-        ht.remove(ob);
-    }
-
-    public Object get(String name)
-            throws EBaseException {
-        return ht.get(name);
-    }
-
-    public void set(String name, Object ob)
-            throws EBaseException {
-        ht.put(name, ob);
-    }
-
-    public Enumeration<Object> getElements() {
-        return ht.elements();
-    }
-}
diff --git a/pki/base/migrate/60ToTxt/src/Main.java b/pki/base/migrate/60ToTxt/src/Main.java
index 380baab99d069c5402fa0d4957f5ae404af6adaf..72de924c4c7b4f942440f17274e5d41275e494ff 100644
--- a/pki/base/migrate/60ToTxt/src/Main.java
+++ b/pki/base/migrate/60ToTxt/src/Main.java
@@ -318,9 +318,9 @@ class CMS60LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/61ToTxt/src/Main.java b/pki/base/migrate/61ToTxt/src/Main.java
index 298ee027d41338fb6d9ed131cb27a9e7ab8c6513..cd235f73f36ea1f270adeda6f15e681536718c3c 100644
--- a/pki/base/migrate/61ToTxt/src/Main.java
+++ b/pki/base/migrate/61ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS61LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/62ToTxt/src/Main.java b/pki/base/migrate/62ToTxt/src/Main.java
index 95f8d56be80c2b505758a31b12b958b7d9ce44e9..10916247510f5d23ecd6b2f7ce9795b756ebe119 100644
--- a/pki/base/migrate/62ToTxt/src/Main.java
+++ b/pki/base/migrate/62ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS62LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/63ToTxt/src/Main.java b/pki/base/migrate/63ToTxt/src/Main.java
index 1a13f833be44ec43ece6b99c3a382763750b54f9..6066801e293145affe24edfc550154e7c8dc5e97 100644
--- a/pki/base/migrate/63ToTxt/src/Main.java
+++ b/pki/base/migrate/63ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS63LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/70ToTxt/src/Main.java b/pki/base/migrate/70ToTxt/src/Main.java
index b406a5765226e71adfb77910208aa233add28615..133671267d5ee154d3401241db04bb186a755ca5 100644
--- a/pki/base/migrate/70ToTxt/src/Main.java
+++ b/pki/base/migrate/70ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS70LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/71ToTxt/src/Main.java b/pki/base/migrate/71ToTxt/src/Main.java
index 3ff4930a400bd2dbc1061c9f404b0aae49550832..f7f3a5b95770951b60ad8503325a4f6520b2ebea 100644
--- a/pki/base/migrate/71ToTxt/src/Main.java
+++ b/pki/base/migrate/71ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS71LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/72ToTxt/src/Main.java b/pki/base/migrate/72ToTxt/src/Main.java
index 3bd1a333a0da0721a2e237aa8c2422fcb5aed2b8..0a0dc812e0e1bfc6efaf375eb091f0d731717b38 100644
--- a/pki/base/migrate/72ToTxt/src/Main.java
+++ b/pki/base/migrate/72ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS72LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
diff --git a/pki/base/migrate/73ToTxt/src/Main.java b/pki/base/migrate/73ToTxt/src/Main.java
index 088ae441faf741865197544291a68c6770939f05..be26e985895a0a765923afca753e34962cce4ffe 100644
--- a/pki/base/migrate/73ToTxt/src/Main.java
+++ b/pki/base/migrate/73ToTxt/src/Main.java
@@ -319,9 +319,9 @@ class CMS73LdifParser
 			//           to "com.netscape.cmscore.dbs.KeyRecord"
 			com.netscape.cmscore.dbs.KeyRecord o =
 			(com.netscape.cmscore.dbs.KeyRecord)obj;
-			Enumeration e = o.getElements();
+			Enumeration<String> e = o.getElements();
 			while (e.hasMoreElements()) {
-				String k = (String)e.nextElement();
+				String k = e.nextElement();
 				Object ob = o.get(k);
 				if (ob != null) {
 				if (ob instanceof java.util.Date) {
-- 
1.7.7.4

