>From c8e0592608852ece1479c7b9e50437edbce22bc9 Mon Sep 17 00:00:00 2001
From: Adam Young <ayoung@redhat.com>
Date: Fri, 18 Nov 2011 13:56:30 -0500
Subject: [PATCH 39/45] typesafety  certserv and cmscore

---
 .../ca/src/com/netscape/ca/CRLIssuingPoint.java    |    1 -
 .../netscape/certsrv/base/MetaAttributeDef.java    |   16 ++++++++--------
 .../com/netscape/certsrv/ca/ICRLIssuingPoint.java  |    5 +++--
 .../netscape/certsrv/ca/ICertificateAuthority.java |    5 +++--
 .../com/netscape/certsrv/dbs/IDBAttrMapper.java    |    2 +-
 .../src/com/netscape/certsrv/dbs/IDBObj.java       |    2 +-
 .../com/netscape/certsrv/dbs/IDBSearchResults.java |    2 +-
 .../com/netscape/certsrv/dbs/ModificationSet.java  |    4 ++--
 .../netscape/certsrv/dbs/keydb/IKeyRecordList.java |    2 +-
 .../netscape/certsrv/request/IRequestRecord.java   |    4 ++--
 .../src/com/netscape/cmscore/dbs/CertRecord.java   |    6 +++---
 .../com/netscape/cmscore/dbs/DBSearchResults.java  |    4 ++--
 .../com/netscape/cmscore/dbs/KeyRepository.java    |   15 ++++++---------
 .../netscape/cmscore/dbs/ObjectStreamMapper.java   |    4 ++--
 .../netscape/cmscore/request/RequestRecord.java    |    3 ++-
 .../cmscore/dbs/RequestRecordDefaultStub.java      |    6 +++---
 16 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java b/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
index ef0e949ab2dde521c32a6178458f844848fb1349..0e675be8c365f3c1438da4043565edd6603f97eb 100644
--- a/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
+++ b/pki/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.math.BigInteger;
 import java.security.NoSuchAlgorithmException;
 import java.security.cert.CRLException;
-import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Hashtable;
diff --git a/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java b/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
index e01d40f88b81cb468be1e3685f10a0ed0913d56e..f11fdbcdf56fd21129299cc76ee61f83f06a1600 100644
--- a/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
+++ b/pki/base/common/src/com/netscape/certsrv/base/MetaAttributeDef.java
@@ -34,9 +34,9 @@ public class MetaAttributeDef {
 
     private String mName;
     private ObjectIdentifier mOid;
-    private Class mValueClass;
-    private static Hashtable mNameToAttrDef = new Hashtable();
-    private static Hashtable mOidToAttrDef = new Hashtable();
+    private Class<?> mValueClass;
+    private static Hashtable<String, MetaAttributeDef> mNameToAttrDef = new Hashtable<String, MetaAttributeDef>();
+    private static Hashtable<ObjectIdentifier, MetaAttributeDef> mOidToAttrDef = new Hashtable<ObjectIdentifier, MetaAttributeDef>();
 
     private MetaAttributeDef() {
     }
@@ -49,7 +49,7 @@ public class MetaAttributeDef {
      * @param valueClass attribute value class
      * @param oid attribute object identifier
      */
-    private MetaAttributeDef(String name, Class valueClass, 
+    private MetaAttributeDef(String name, Class<?> valueClass, 
         ObjectIdentifier oid) {
         mName = name;
         mValueClass = valueClass;
@@ -72,7 +72,7 @@ public class MetaAttributeDef {
      *
      * @return returns Java class for the attribute values
      */
-    public Class getValueClass() { 
+    public Class<?> getValueClass() { 
         return mValueClass; 
     }
 
@@ -98,7 +98,7 @@ public class MetaAttributeDef {
      * @exception IllegalArgumentException if name or valueClass are null, or
      * conflicting attribute definition already exists
      */
-    public static MetaAttributeDef register(String name, Class valueClass, 
+    public static MetaAttributeDef register(String name, Class<?> valueClass, 
         ObjectIdentifier oid) {
         if (name == null) {
             throw new IllegalArgumentException(
@@ -183,7 +183,7 @@ public class MetaAttributeDef {
      *
      * @return returns enumeration of the registered attribute names
      */
-    public static Enumeration getAttributeNames() {
+    public static Enumeration<String> getAttributeNames() {
         return mNameToAttrDef.keys();
     }
 
@@ -193,7 +193,7 @@ public class MetaAttributeDef {
      *
      * @return returns enumeration of the attribute object identifiers
      */
-    public static Enumeration getAttributeNameOids() {
+    public static Enumeration<ObjectIdentifier> getAttributeNameOids() {
         return mOidToAttrDef.keys();
     }
 }
diff --git a/pki/base/common/src/com/netscape/certsrv/ca/ICRLIssuingPoint.java b/pki/base/common/src/com/netscape/certsrv/ca/ICRLIssuingPoint.java
index 82e0961c11485bc472e32845cfe2217946b99d96..dab45fdb1facababa3ced898ec0666fb6a5e3ee7 100644
--- a/pki/base/common/src/com/netscape/certsrv/ca/ICRLIssuingPoint.java
+++ b/pki/base/common/src/com/netscape/certsrv/ca/ICRLIssuingPoint.java
@@ -25,6 +25,7 @@ import java.util.Vector;
 
 import netscape.security.x509.CRLExtensions;
 import netscape.security.x509.RevokedCertImpl;
+import netscape.security.x509.RevokedCertificate;
 import netscape.security.x509.X509CRLImpl;
 
 import com.netscape.certsrv.base.EBaseException;
@@ -295,7 +296,7 @@ public interface ICRLIssuingPoint {
      * @param end next after last requested CRL entry
      * @return set of all the revoked certificates or null if there are none.
      */
-    public Set getRevokedCertificates(int start, int end);
+    public Set<RevokedCertificate> getRevokedCertificates(int start, int end);
 
     /**
      * Returns certificate authority.
@@ -373,7 +374,7 @@ public interface ICRLIssuingPoint {
      *
      * @return split times from CRL generation in milliseconds
      */
-    public Vector getSplitTimes();
+    public Vector<Long> getSplitTimes();
 
     /**
      * Generates CRL now based on cache or local directory if cache
diff --git a/pki/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java b/pki/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
index 6f7a49615e55be791b10633f55494915f16a0325..86abf0451778e5546ee04ab62027bb7d2658b309 100644
--- a/pki/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
+++ b/pki/base/common/src/com/netscape/certsrv/ca/ICertificateAuthority.java
@@ -29,6 +29,7 @@ import netscape.security.x509.X509CertInfo;
 
 import org.mozilla.jss.crypto.SignatureAlgorithm;
 
+import com.netscape.ca.CRLIssuingPoint;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.ISubsystem;
@@ -225,7 +226,7 @@ public interface ICertificateAuthority extends ISubsystem {
      *
      * @return enumeration of all the CRL issuing points
      */
-    public Enumeration getCRLIssuingPoints();
+    public Enumeration<CRLIssuingPoint> getCRLIssuingPoints();
 
     /**
      * Retrieves CRL issuing point with the given identifier.
@@ -280,7 +281,7 @@ public interface ICertificateAuthority extends ISubsystem {
      *
      * @return name enumeration of all request listeners
      */
-    public Enumeration getRequestListenerNames();
+    public Enumeration<String>  getRequestListenerNames();
 
     /**
      * Retrieves the request listener for issued certificates.
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/IDBAttrMapper.java b/pki/base/common/src/com/netscape/certsrv/dbs/IDBAttrMapper.java
index 7d851b7476fb017fc232842fceb6a9761922cc91..173537d6bb99cf52982670d963d3d75e5ae5cc38 100644
--- a/pki/base/common/src/com/netscape/certsrv/dbs/IDBAttrMapper.java
+++ b/pki/base/common/src/com/netscape/certsrv/dbs/IDBAttrMapper.java
@@ -42,7 +42,7 @@ public interface IDBAttrMapper {
      *
      * @return a list of supported attribute names
      */
-    public Enumeration getSupportedLDAPAttributeNames();
+    public Enumeration<String> getSupportedLDAPAttributeNames();
 
     /**
      * Maps object attribute into LDAP attributes.
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/IDBObj.java b/pki/base/common/src/com/netscape/certsrv/dbs/IDBObj.java
index 4be6c340901ac1c3c45114466ae524e1c6a9a053..37f9431e5bcda53c217f693a4aa71df0b3140c01 100644
--- a/pki/base/common/src/com/netscape/certsrv/dbs/IDBObj.java
+++ b/pki/base/common/src/com/netscape/certsrv/dbs/IDBObj.java
@@ -39,5 +39,5 @@ public interface IDBObj extends IAttrSet {
      *
      * @return a list of serializable attribute names
      */
-    public Enumeration getSerializableAttrNames(); 
+    public Enumeration<String> getSerializableAttrNames(); 
 }
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/IDBSearchResults.java b/pki/base/common/src/com/netscape/certsrv/dbs/IDBSearchResults.java
index ab90866b1c3cb5791f15ce2b041029c223615d23..9f15b80825e6b6ee42ece353c63188c3a08d79f5 100644
--- a/pki/base/common/src/com/netscape/certsrv/dbs/IDBSearchResults.java
+++ b/pki/base/common/src/com/netscape/certsrv/dbs/IDBSearchResults.java
@@ -28,7 +28,7 @@ import java.util.Enumeration;
  *
  * @version $Revision$, $Date$ 
  */
-public interface IDBSearchResults extends Enumeration {
+public interface IDBSearchResults extends Enumeration<Object> {
 
     /**
      * Checks if any element is available.
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/ModificationSet.java b/pki/base/common/src/com/netscape/certsrv/dbs/ModificationSet.java
index 4a5592c0b5ce4b0bdde5a687c17036676b323c32..b737f861d7b90a0375cf7f1754b17a1486e2b62f 100644
--- a/pki/base/common/src/com/netscape/certsrv/dbs/ModificationSet.java
+++ b/pki/base/common/src/com/netscape/certsrv/dbs/ModificationSet.java
@@ -33,7 +33,7 @@ public class ModificationSet {
     /**
      * A list of modifications
      */
-    private Vector mods = new Vector();
+    private Vector<Modification> mods = new Vector<Modification>();
 
     /**
      * Constructs modification set.
@@ -57,7 +57,7 @@ public class ModificationSet {
      *
      * @return a list of Modifications
      */
-    public Enumeration getModifications() {
+    public Enumeration<Modification> getModifications() {
         return mods.elements();
     }
 }
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java
index 2bc9f57b979855d7b82b9e1d871561d5b5cb1e06..5da2394520283be80c91ecea13181ebdc9e51ab1 100644
--- a/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java
+++ b/pki/base/common/src/com/netscape/certsrv/dbs/keydb/IKeyRecordList.java
@@ -46,6 +46,6 @@ public interface IKeyRecordList {
      * @return key records
      * @exception EBaseException failed to retrieve key records
      */
-    public Enumeration getKeyRecords(int startidx, int endidx)
+    public Enumeration<IKeyRecord> getKeyRecords(int startidx, int endidx)
         throws EBaseException;
 }
diff --git a/pki/base/common/src/com/netscape/certsrv/request/IRequestRecord.java b/pki/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
index 696dc4e166400042d28b959c9a7fee051c9b6bfe..53a3e37b501a47b09f4fab4d4dcdf40cdf4c3971 100644
--- a/pki/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
+++ b/pki/base/common/src/com/netscape/certsrv/request/IRequestRecord.java
@@ -74,7 +74,7 @@ public interface IRequestRecord
      *
      * @return list of attribute names
      */
-    public Enumeration getAttrNames();
+    public Enumeration<String> getAttrNames();
 
     /**
      * Gets the request attribute value by the name.
@@ -105,7 +105,7 @@ public interface IRequestRecord
      *
      * @return attribute list
      */
-    public Enumeration getElements();
+    public Enumeration<String> getElements();
 
     // IDBObj.getSerializableAttrNames
     //public Enumeration getSerializableAttrNames();
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java
index 321ce618397c23bc477d8e2d5b7bafd4fa7b630b..973ddc4f2efa9da4fb7fb63e4a7a517fcd365244 100644
--- a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java
+++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java
@@ -61,7 +61,7 @@ public class CertRecord implements IDBObj, ICertRecord {
     private String mRevokedBy = null;
     private Date mRevokedOn = null;
 
-    protected static Vector mNames = new Vector();
+    protected static Vector<String> mNames = new Vector<String>();
     static {
         mNames.addElement(ATTR_ID);
         mNames.addElement(ATTR_META_INFO);
@@ -166,11 +166,11 @@ public class CertRecord implements IDBObj, ICertRecord {
         throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_ATTRIBUTE", name));
     }
 
-    public Enumeration getElements() {
+    public Enumeration<String> getElements() {
         return mNames.elements();
     }
 
-    public Enumeration getSerializableAttrNames() {
+    public Enumeration<String> getSerializableAttrNames() {
         return mNames.elements();
     }
 
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java
index c515b3305b4cafe572965f3fc5a973be9e2a2cde..8b5098dc3cca79153b656da8ef1cb77b1fe90c1e 100644
--- a/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java
+++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java
@@ -40,13 +40,13 @@ import com.netscape.certsrv.logging.ILogger;
 public class DBSearchResults implements IDBSearchResults {
 
     private IDBRegistry mRegistry = null;
-    private Enumeration mRes = null;
+    private Enumeration<Object> mRes = null;
     private ILogger mLogger = CMS.getLogger();
 
     /**
      * Constructs search results.
      */
-    public DBSearchResults(IDBRegistry registry, Enumeration res) {
+    public DBSearchResults(IDBRegistry registry, Enumeration<Object> res) {
         mRegistry = registry;
         mRes = res;
     }
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
index 6d4e4688d43874f3c0bcefba2d8165b255d4ec2d..f684718cfd2fae51a7d68c9bbb60ba3c600b9952 100644
--- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
+++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
@@ -22,7 +22,6 @@ import java.math.BigInteger;
 import java.security.PublicKey;
 import java.util.Date;
 import java.util.Enumeration;
-import java.util.Vector;
 
 import netscape.security.x509.X500Name;
 
@@ -178,9 +177,9 @@ public class KeyRepository extends Repository implements IKeyRepository {
         IKeyRecordList list = findKeyRecordsInList(filter,
                     null, "serialno", 10);
         int size = list.getSize();
-        Enumeration e = list.getKeyRecords(0, size - 1);
+        Enumeration<IKeyRecord> e = list.getKeyRecords(0, size - 1);
         while (e.hasMoreElements()) {
-            KeyRecord rec = (KeyRecord) e.nextElement();
+            IKeyRecord rec =  e.nextElement();
             deleteKeyRecord(rec.getSerialNumber());
         }
     }
@@ -353,10 +352,10 @@ CMS.debug("filter= " + filter);
         return result;
     }
 
-    public Enumeration searchKeys(String filter, int maxSize)
+    public Enumeration<Object> searchKeys(String filter, int maxSize)
         throws EBaseException {
         IDBSSession s = mDBService.createSession();
-        Enumeration e = null;
+        Enumeration<Object> e = null;
 
         try {
             e = s.search(getDN(), filter, maxSize);
@@ -367,10 +366,10 @@ CMS.debug("filter= " + filter);
         return e;
     }
 
-    public Enumeration searchKeys(String filter, int maxSize, int timeLimit)
+    public Enumeration<Object> searchKeys(String filter, int maxSize, int timeLimit)
         throws EBaseException {
         IDBSSession s = mDBService.createSession();
-        Enumeration e = null;
+        Enumeration<Object> e = null;
 
         try {
             e = s.search(getDN(), filter, maxSize, timeLimit);
@@ -469,8 +468,6 @@ CMS.debug("filter= " + filter);
           }
           int ltSize = recList.getSizeBeforeJumpTo();
 
-          Vector cList = new Vector(ltSize);
-
           CMS.debug("KeyRepository:getLastSerialNumberInRange: ltSize " + ltSize);
 
           int i;
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java
index cb5e4cb688c23ac57787b702b882526ad952e2de..46979715b709a726a5f23901f7af36a562284c2b 100644
--- a/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java
+++ b/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java
@@ -48,7 +48,7 @@ import com.netscape.certsrv.logging.ILogger;
 public class ObjectStreamMapper implements IDBAttrMapper {
 
     private String mLdapName = null;
-    private Vector v = new Vector();
+    private Vector<String> v = new Vector<String>();
     private ILogger mLogger = CMS.getLogger();
 
     /**
@@ -62,7 +62,7 @@ public class ObjectStreamMapper implements IDBAttrMapper {
     /**
      * Retrieves a list of supported ldap attributes.
      */
-    public Enumeration getSupportedLDAPAttributeNames() {
+    public Enumeration<String> getSupportedLDAPAttributeNames() {
         return v.elements();
     }
 
diff --git a/pki/base/common/src/com/netscape/cmscore/request/RequestRecord.java b/pki/base/common/src/com/netscape/cmscore/request/RequestRecord.java
index 99764b9111bb9463218123a9557ac6fbbcea4945..321e32ec2893c47136cf09e821c4a035ae2f79c0 100644
--- a/pki/base/common/src/com/netscape/cmscore/request/RequestRecord.java
+++ b/pki/base/common/src/com/netscape/cmscore/request/RequestRecord.java
@@ -103,7 +103,8 @@ public class RequestRecord
     }
 
     // IDBObj.set
-    public void set(String name, Object o) {
+    @SuppressWarnings("unchecked")
+	public void set(String name, Object o) {
         if (name.equals(IRequestRecord.ATTR_REQUEST_ID))
             mRequestId = (RequestId) o;
         else if (name.equals(IRequestRecord.ATTR_REQUEST_STATE))
diff --git a/pki/base/common/test/com/netscape/cmscore/dbs/RequestRecordDefaultStub.java b/pki/base/common/test/com/netscape/cmscore/dbs/RequestRecordDefaultStub.java
index 0788a0a388f190fb3a3cf3ec95d5ed2831a2e3ff..1814c90d65d88f424c4d805c2f917ea6e09ef174 100644
--- a/pki/base/common/test/com/netscape/cmscore/dbs/RequestRecordDefaultStub.java
+++ b/pki/base/common/test/com/netscape/cmscore/dbs/RequestRecordDefaultStub.java
@@ -20,7 +20,7 @@ public class RequestRecordDefaultStub implements IRequestRecord, IDBObj {
         return null;
     }
 
-    public Enumeration getAttrNames() {
+    public Enumeration<String> getAttrNames() {
         return null;
     }
 
@@ -34,11 +34,11 @@ public class RequestRecordDefaultStub implements IRequestRecord, IDBObj {
     public void delete(String name) throws EBaseException {
     }
 
-    public Enumeration getElements() {
+    public Enumeration<String> getElements() {
         return null;
     }
 
-    public Enumeration getSerializableAttrNames() {
+    public Enumeration<String> getSerializableAttrNames() {
         return null;
     }
 }
-- 
1.7.7.3

