diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/dbs')
8 files changed, 76 insertions, 61 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java b/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java index 9f0797d40..0a3a46f14 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java @@ -23,6 +23,8 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; +import netscape.security.x509.RevokedCertificate; + import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBObj; @@ -51,10 +53,10 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { protected String mFirstUnsaved = null; protected byte mCRL[] = null; protected byte mCACert[] = null; - protected Hashtable mCRLCache = null; - protected Hashtable mRevokedCerts = null; - protected Hashtable mUnrevokedCerts = null; - protected Hashtable mExpiredCerts = null; + protected Hashtable<BigInteger, RevokedCertificate> mCRLCache = null; + protected Hashtable<BigInteger, RevokedCertificate> mRevokedCerts = null; + protected Hashtable<BigInteger, RevokedCertificate> mUnrevokedCerts = null; + protected Hashtable<BigInteger, RevokedCertificate> mExpiredCerts = null; protected byte mDeltaCRL[] = null; protected static Vector<String> mNames = new Vector<String>(); static { @@ -106,7 +108,9 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { */ public CRLIssuingPointRecord(String id, BigInteger crlNumber, Long crlSize, Date thisUpdate, Date nextUpdate, BigInteger deltaCRLNumber, Long deltaCRLSize, - Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) { + Hashtable<BigInteger, RevokedCertificate> revokedCerts, + Hashtable<BigInteger, RevokedCertificate> unrevokedCerts, + Hashtable<BigInteger, RevokedCertificate> expiredCerts) { mId = id; mCRLNumber = crlNumber; mCRLSize = crlSize; @@ -121,6 +125,7 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { mExpiredCerts = expiredCerts; } + @SuppressWarnings({ "unchecked" }) public void set(String name, Object obj) throws EBaseException { if (name.equalsIgnoreCase(ATTR_ID)) { mId = (String) obj; @@ -143,13 +148,13 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { } else if (name.equalsIgnoreCase(ATTR_CA_CERT)) { mCACert = (byte[]) obj; } else if (name.equalsIgnoreCase(ATTR_CRL_CACHE)) { - mCRLCache = (Hashtable) obj; + mCRLCache = (Hashtable<BigInteger, RevokedCertificate>) obj; } else if (name.equalsIgnoreCase(ATTR_REVOKED_CERTS)) { - mRevokedCerts = (Hashtable) obj; + mRevokedCerts = (Hashtable<BigInteger, RevokedCertificate>) obj; } else if (name.equalsIgnoreCase(ATTR_UNREVOKED_CERTS)) { - mUnrevokedCerts = (Hashtable) obj; + mUnrevokedCerts = (Hashtable<BigInteger, RevokedCertificate>) obj; } else if (name.equalsIgnoreCase(ATTR_EXPIRED_CERTS)) { - mExpiredCerts = (Hashtable) obj; + mExpiredCerts = (Hashtable<BigInteger, RevokedCertificate>) obj; } else if (name.equalsIgnoreCase(ATTR_DELTA_CRL)) { mDeltaCRL = (byte[]) obj; } else { @@ -279,47 +284,51 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { return mCACert; } - public Hashtable getCRLCacheNoClone() { + public Hashtable<BigInteger, RevokedCertificate> getCRLCacheNoClone() { if (mCRLCache == null) return null; else - return (Hashtable) mCRLCache; + return mCRLCache; } - public Hashtable getCRLCache() { + @SuppressWarnings("unchecked") + public Hashtable<BigInteger, RevokedCertificate> getCRLCache() { if (mCRLCache == null) return null; else - return (Hashtable) mCRLCache.clone(); + return (Hashtable<BigInteger, RevokedCertificate>) mCRLCache.clone(); } /** * Retrieves cache info of revoked certificates. */ - public Hashtable getRevokedCerts() { + @SuppressWarnings("unchecked") + public Hashtable<BigInteger, RevokedCertificate> getRevokedCerts() { if (mRevokedCerts == null) return null; else - return (Hashtable) mRevokedCerts.clone(); + return (Hashtable<BigInteger, RevokedCertificate>) mRevokedCerts.clone(); } /** * Retrieves cache info of unrevoked certificates. */ - public Hashtable getUnrevokedCerts() { + @SuppressWarnings("unchecked") + public Hashtable<BigInteger, RevokedCertificate> getUnrevokedCerts() { if (mUnrevokedCerts == null) return null; else - return (Hashtable) mUnrevokedCerts.clone(); + return (Hashtable<BigInteger, RevokedCertificate>) mUnrevokedCerts.clone(); } /** * Retrieves cache info of expired certificates. */ - public Hashtable getExpiredCerts() { + @SuppressWarnings("unchecked") + public Hashtable<BigInteger, RevokedCertificate> getExpiredCerts() { if (mExpiredCerts == null) return null; else - return (Hashtable) mExpiredCerts.clone(); + return (Hashtable<BigInteger, RevokedCertificate>) mExpiredCerts.clone(); } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java b/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java index a54ff500f..f9c4369a2 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java @@ -22,6 +22,8 @@ import java.util.Date; import java.util.Hashtable; import java.util.Vector; +import netscape.security.x509.RevokedCertificate; + import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.EDBException; @@ -230,7 +232,9 @@ public class CRLRepository extends Repository implements ICRLRepository { */ public void updateCRLIssuingPointRecord(String id, byte[] newCRL, Date thisUpdate, Date nextUpdate, BigInteger crlNumber, Long crlSize, - Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) + Hashtable<BigInteger, RevokedCertificate> revokedCerts, + Hashtable<BigInteger, RevokedCertificate> unrevokedCerts, + Hashtable<BigInteger, RevokedCertificate> expiredCerts) throws EBaseException { ModificationSet mods = new ModificationSet(); @@ -270,8 +274,9 @@ public class CRLRepository extends Repository implements ICRLRepository { /** * Updates CRL issuing point record with recently revoked certificates info. */ - public void updateRevokedCerts(String id, Hashtable revokedCerts, - Hashtable unrevokedCerts) + public void updateRevokedCerts(String id, + Hashtable<BigInteger, RevokedCertificate> revokedCerts, + Hashtable<BigInteger, RevokedCertificate> unrevokedCerts) throws EBaseException { ModificationSet mods = new ModificationSet(); @@ -287,7 +292,7 @@ public class CRLRepository extends Repository implements ICRLRepository { /** * Updates CRL issuing point record with recently expired certificates info. */ - public void updateExpiredCerts(String id, Hashtable expiredCerts) + public void updateExpiredCerts(String id, Hashtable<BigInteger, RevokedCertificate> expiredCerts) throws EBaseException { ModificationSet mods = new ModificationSet(); @@ -300,9 +305,9 @@ public class CRLRepository extends Repository implements ICRLRepository { * Updates CRL issuing point record with CRL cache info. */ public void updateCRLCache(String id, Long crlSize, - Hashtable revokedCerts, - Hashtable unrevokedCerts, - Hashtable expiredCerts) + Hashtable<BigInteger, RevokedCertificate> revokedCerts, + Hashtable<BigInteger, RevokedCertificate> unrevokedCerts, + Hashtable<BigInteger, RevokedCertificate> expiredCerts) throws EBaseException { ModificationSet mods = new ModificationSet(); diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java index 8b29dec53..6ae379840 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java @@ -45,6 +45,7 @@ import com.netscape.certsrv.ca.ICRLIssuingPoint; import com.netscape.certsrv.dbs.EDBException; import com.netscape.certsrv.dbs.IDBRegistry; import com.netscape.certsrv.dbs.IDBSSession; +import com.netscape.certsrv.dbs.IDBSearchResults; import com.netscape.certsrv.dbs.IDBSubsystem; import com.netscape.certsrv.dbs.IDBVirtualList; import com.netscape.certsrv.dbs.Modification; @@ -450,9 +451,6 @@ public class CertificateRepository extends Repository } } - CertRecord cRec = null; - BigInteger serial = null; - transitCertList(cList, CertRecord.STATUS_EXPIRED); } @@ -622,7 +620,6 @@ public class CertificateRepository extends Repository */ public X509CertImpl getX509Certificate(BigInteger serialNo) throws EBaseException { - X509CertImpl cert = null; ICertRecord cr = readCertificateRecord(serialNo); return (cr.getCertificate()); @@ -767,19 +764,22 @@ public class CertificateRepository extends Repository return e; } - public Enumeration<Object> searchCertificates(String filter, int maxSize, int timeLimit) + public Enumeration<ICertRecord> searchCertificates(String filter, int maxSize, int timeLimit) throws EBaseException { IDBSSession s = mDBService.createSession(); - Enumeration<Object> e = null; + Vector<ICertRecord> v = new Vector<ICertRecord>(); CMS.debug("searchCertificateswith time limit filter " + filter); try { - e = s.search(getDN(), filter, maxSize, timeLimit); + IDBSearchResults sr = s.search(getDN(), filter, maxSize, timeLimit); + while (sr.hasMoreElements()) { + v.add((ICertRecord) sr.nextElement()); + } } finally { if (s != null) s.close(); } - return e; + return v.elements(); } /** @@ -894,7 +894,7 @@ public class CertificateRepository extends Repository CertRecordList list = null; try { - IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, attrs, + IDBVirtualList<ICertRecord> vlist = s.<ICertRecord>createVirtualList(getDN(), filter, attrs, sortKey, pageSize); list = new CertRecordList(vlist); @@ -1212,7 +1212,7 @@ public class CertificateRepository extends Repository String fromVal = "0"; try { if (from != null) { - int fv = Integer.parseInt(from); + Integer.parseInt(from); fromVal = from; } } catch (Exception e1) { @@ -1515,8 +1515,6 @@ public class CertificateRepository extends Repository public ICertRecordList getInvalidCertsByNotBeforeDate(Date date, int pageSize) throws EBaseException { - String now = null; - Date rightNow = CMS.getCurrentDate(); ICertRecordList list = null; @@ -1555,8 +1553,6 @@ public class CertificateRepository extends Repository public ICertRecordList getValidCertsByNotAfterDate(Date date, int pageSize) throws EBaseException { - String now = null; - ICertRecordList list = null; IDBSSession s = mDBService.createSession(); diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java index 34e50c711..941b0552d 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java @@ -34,12 +34,12 @@ import com.netscape.certsrv.dbs.keydb.IKeyRecordList; */ public class KeyRecordList implements IKeyRecordList { - private IDBVirtualList<Object> mVlist = null; + private IDBVirtualList<IKeyRecord> mVlist = null; /** * Constructs a key list. */ - public KeyRecordList(IDBVirtualList<Object> vlist) { + public KeyRecordList(IDBVirtualList<IKeyRecord> vlist) { mVlist = vlist; } @@ -62,7 +62,7 @@ public class KeyRecordList implements IKeyRecordList { } public IKeyRecord getKeyRecord(int i) { - IKeyRecord record = (IKeyRecord) mVlist.getElementAt(i); + IKeyRecord record = mVlist.getElementAt(i); if (record == null) return null; @@ -78,7 +78,7 @@ public class KeyRecordList implements IKeyRecordList { Vector<IKeyRecord> entries = new Vector<IKeyRecord>(); for (int i = startidx; i <= endidx; i++) { - IKeyRecord element = (IKeyRecord) mVlist.getElementAt(i); + IKeyRecord element = mVlist.getElementAt(i); if (element != null) { entries.addElement(element); 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 6219bab0c..3b2186b23 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java @@ -21,6 +21,7 @@ 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; @@ -372,32 +373,38 @@ public class KeyRepository extends Repository implements IKeyRepository { return result; } - public Enumeration<Object> searchKeys(String filter, int maxSize) + public Enumeration<IKeyRecord> searchKeys(String filter, int maxSize) throws EBaseException { IDBSSession s = mDBService.createSession(); - Enumeration<Object> e = null; + Vector<IKeyRecord> v = new Vector<IKeyRecord>(); try { - e = s.search(getDN(), filter, maxSize); + IDBSearchResults sr = s.search(getDN(), filter, maxSize); + while (sr.hasMoreElements()) { + v.add((IKeyRecord) sr.nextElement()); + } } finally { if (s != null) s.close(); } - return e; + return v.elements(); } - public Enumeration<Object> searchKeys(String filter, int maxSize, int timeLimit) + public Enumeration<IKeyRecord> searchKeys(String filter, int maxSize, int timeLimit) throws EBaseException { IDBSSession s = mDBService.createSession(); - Enumeration<Object> e = null; + Vector<IKeyRecord> v = new Vector<IKeyRecord>(); try { - e = s.search(getDN(), filter, maxSize, timeLimit); + IDBSearchResults sr = s.search(getDN(), filter, maxSize, timeLimit); + while (sr.hasMoreElements()) { + v.add((IKeyRecord) sr.nextElement()); + } } finally { if (s != null) s.close(); } - return e; + return v.elements(); } /** @@ -418,7 +425,7 @@ public class KeyRepository extends Repository implements IKeyRepository { try { if (s != null) { list = new KeyRecordList( - s.createVirtualList(getDN(), "(&(objectclass=" + + s.<IKeyRecord>createVirtualList(getDN(), "(&(objectclass=" + KeyRecord.class.getName() + ")" + filter + ")", attrs, sortKey, pageSize)); } @@ -448,7 +455,7 @@ public class KeyRepository extends Repository implements IKeyRepository { try { if (s != null) { list = new KeyRecordList( - s.createVirtualList(getDN(), "(&(objectclass=" + + s.<IKeyRecord>createVirtualList(getDN(), "(&(objectclass=" + KeyRecord.class.getName() + ")" + filter + ")", attrs, jumpToVal, sortKey, pageSize)); } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java b/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java index 74ac7ca96..ff867bf52 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java @@ -34,12 +34,12 @@ import com.netscape.certsrv.dbs.IFilterConverter; */ public class LdapFilterConverter implements IFilterConverter { - private Hashtable mReg = null; + private Hashtable<String, IDBAttrMapper> mReg = null; /** * Constructs filter convertor. */ - public LdapFilterConverter(Hashtable reg) { + public LdapFilterConverter(Hashtable<String, IDBAttrMapper> reg) { mReg = reg; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java index f4d8cabeb..8b66d02ca 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java @@ -44,7 +44,7 @@ import com.netscape.cmscore.cert.CertUtils; public class PublicKeyMapper implements IDBAttrMapper { private String mLdapName = null; - private Vector v = new Vector(); + private Vector<String> v = new Vector<String>(); private ILogger mLogger = CMS.getLogger(); @@ -59,7 +59,7 @@ public class PublicKeyMapper implements IDBAttrMapper { /** * Lists a list of supported ldap attribute names. */ - public Enumeration getSupportedLDAPAttributeNames() { + public Enumeration<String> getSupportedLDAPAttributeNames() { return v.elements(); } @@ -95,7 +95,7 @@ public class PublicKeyMapper implements IDBAttrMapper { int i = value.indexOf("#"); if (i != -1) { - String tag = value.substring(0, i); + //String tag = value.substring(0, i); String val = value.substring(i + 1); try { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java index 856a8c591..18f0c8e3d 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java @@ -31,7 +31,6 @@ import netscape.security.extensions.NSCertTypeExtension; import netscape.security.x509.BasicConstraintsExtension; import netscape.security.x509.Extension; import netscape.security.x509.X509CertImpl; -import netscape.security.x509.X509CertInfo; import netscape.security.x509.X509Key; import com.netscape.certsrv.apps.CMS; @@ -250,7 +249,6 @@ public class X509CertImplMapper implements IDBAttrMapper { // LDAPAttribute attr = attrs.getAttribute( // Schema.LDAP_ATTR_SIGNED_CERT); - X509CertInfo certinfo = new X509CertInfo(); LDAPAttribute attr = attrs.getAttribute( CertDBSchema.LDAP_ATTR_SIGNED_CERT); |